KeKsBoTer/web-splat

Aspect ratio is not maintained if display window is resized

Closed this issue · 6 comments

Running on Ubuntu 23.04, on a custom dataset, the aspect ratio of the physical object (square) is not maintained on window resize.

But if the window's aspect ratio is set to exactly to that in cameras.json (width and height), the physical object looks fine. This can be seen in the attached dataset when the aspect ratio is drastically changed.

Looking at the code, I do see that the CameraUniforms/projection matrix is changed on a window resize. Not sure why the aspect ratio is not maintained though. Please let me know if I need to do any special initialization.

Thanks for the bug report. I pushed a fix

The fix did not help, I still see distortion. My original images are in portrait mode and the reconstruction and display is fine even if the viewer window has an aspect ratio similar to the landscape mode since this manipulates the fovx (I guess). But the distortion is still there like before and as I mentioned goes away only if the viewer aspect ratio matches that in cameras.json.

I am looking to add functionality equivalent to the css 'object-fit: cover' (or atleast css object-fit: contain) that avoids the distortion.
It can be easily done if the image/texture size and the container size are known by using modifying the shader:
https://stackoverflow.com/questions/62821286/aspect-fit-and-aspect-fill-content-mode-with-opengl-es-2-0
https://discourse.threejs.org/t/solved-fitting-an-object-to-cover-the-whole-canvas-a-la-css-object-fit-cover/53882/8

In this case however, the texture passed to display.wgsl is already the same size as the viewer window side, I think. @KeKsBoTer Please let me know if you have any pointers. Thanks!

Could you share the scene with me? (ply & cameras.json) then I can take a look. Or a link to a dataset with portrait-mode images. then I can take a look.

The google drive link for the cameras.json, *.ply and *.npz. Also the entire image corpus as a .tgz and a representative image is at: https://drive.google.com/drive/folders/1zv8UQNd_FLuYXyeFOIrkuT6jntMBgGCo?usp=sharing

I expressly made a small scene so it is easy to transfer. You could see that the tags (which are square) are distorted when the websplat viewer is resized.

Thank you! I took a look at the scene and updated the camera resize logic so that the fov change is more pleasant.

Super nice!!