hyperlogic / splatapult

A 3d gaussian splatting renderer in C++ and OpenGL
MIT License
89 stars 12 forks source link

pre sort by depth sould be "float depth = p.z / p.w"? #4

Closed yuyaolong closed 6 months ago

yuyaolong commented 7 months ago

https://github.com/hyperlogic/splatapult/blob/818ba0f2a743ee41f6a4f6c382a77570d27f1361/shader/presort_compute.glsl#L41

hyperlogic commented 6 months ago

Admittedly, this could work, but I was concerned about the loss of precision due to the perspective divide. I did not want to have z-fighting like issues for splats that are far from the camera, that is why I elected to just use the "z" value of the splat (in camera space) as the sort key.

yuyaolong commented 6 months ago

Firstly thank you for your reply. I still wonder why it's not "float depth = p.z;" from here: https://www.songho.ca/opengl/gl_projectionmatrix.html p.w will be a fixed number like -Ze

Maybe I miss some info here.

Thanks again

hyperlogic commented 6 months ago

-Z_e is not fixed, it's the z coordinate of the splat position in camera space. (aka eye space)