hyperlogic / splatapult

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

Qestion about quantizedZs value in presort_compute.glsl #15

Closed yuyaolong closed 4 months ago

yuyaolong commented 4 months ago

looks depth is -Zeye here, rang is [near, far] so is the correspond fixedPointZ here rang [uint32_max, 0]? https://github.com/hyperlogic/splatapult/blob/d985c9f569e5e4cefafd3762017f6c3c2790cd06/shader/presort_compute.glsl#L53

which means closer object with higher fixedPointZ value?

hyperlogic commented 4 months ago

For rendering, we want to order each splat from back to front. i.e. "painters algorithm". The existing radix sort compute shader orders elements from low to high. So we flip the order of the splats here before the radix sort. So the resulting interval is (uint32_max, 0]

yuyaolong commented 3 months ago

Again, Thanks for answering. My follow-up question is why we need to range splat from back to front? is it because of color correction of the alpha blending needs to be rendered from the back splats? In the beginning, I thought we can save computation if we range spalts from front to back with depth enabled. But it looks not the case for now.

hyperlogic commented 3 months ago

To get a correct looking image the transparencies must be correct. It might be possible in software to evaluate the volume equation directly, but that would be much too slow for real-time rendering. The typical approach for hardware rendering is to layer transparencies into the color buffer by rendering them in back to front order.

I thought we can save computation if we range spalts from front to back with depth enabled Most of the area for each splat is transparent, so using the depth buffer would block many splats that contribute to the final color for each pixel.