scier / MetalSplatter

Render Gaussian Splats using Metal on Apple platforms (iOS/iPhone/iPad, macOS, and visionOS)
MIT License
272 stars 35 forks source link

correctly use projectedCenter.z to discard splats #28

Closed Yang-Xijie closed 3 months ago

Yang-Xijie commented 3 months ago

correctly use projectedCenter.z to discard splats out outside the view frustum

At

https://github.com/scier/MetalSplatter/blob/9e0fae2e7a0895fd4b21ab82e1ccfb03a0f0aa8c/SampleApp/Scene/MetalKitSceneRenderer.swift#L65-L69

, you set nearZ to 0.1 and farZ to 100.0.

According to

https://github.com/scier/MetalSplatter/blob/9e0fae2e7a0895fd4b21ab82e1ccfb03a0f0aa8c/SampleApp/Util/MatrixMathUtil.swift#L24-L32

and

https://github.com/scier/MetalSplatter/blob/9e0fae2e7a0895fd4b21ab82e1ccfb03a0f0aa8c/MetalSplatter/Resources/Shaders.metal#L139

So if you want to discard splats out of the given range, you should use projectedCenter.z < 0.0 || projectedCenter.z > projectedCenter.w instead of projectedCenter.z < -projectedCenter.w.

https://github.com/scier/MetalSplatter/blob/9e0fae2e7a0895fd4b21ab82e1ccfb03a0f0aa8c/MetalSplatter/Resources/Shaders.metal#L142-L149