Is it possible to adapt to webgl perspective matrix?
yelouafi opened this issue · comments
Is it possible to adapt the code to use a webgl perspective matrix instead?
Folowing this answer https://math.stackexchange.com/questions/4716499/pinhole-camera-projection-of-3d-multivariate-gaussian
Not sure what the intrinsic matrix for the webgl camera is? Also since the code in this repo uses a different convention I guess the Jacobian would be different, perhaps the signs must be inversed
I think I got it working; to compute the focal lengths from the webgl camera
const t_b = 2 * threeCamera.near / threeCamera.projectionMatrix.elements[0];
const r_l = t_b * threeCamera.aspect;
fx = threeCamera.near * canvas.width * downsample/ r_l
fy = threeCamera.near * canvas.height * downsample/ t_b
Intersestingly though changing the signs of the Jacobian doesn't seem to have an effect. I thought it was required since the scaling factor for z has the opposite sign