Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the splats' depth info for current frame #328

Open
lucylucy27 opened this issue Sep 11, 2024 · 3 comments
Open

How to get the splats' depth info for current frame #328

lucylucy27 opened this issue Sep 11, 2024 · 3 comments

Comments

@lucylucy27
Copy link

Hi Mkkellogg,

I want to get the splats' depth info when rendering. But it seems difficult for me.
Can you give some hint of how to achive the depth texture by CPU side?

Thanks for your great work~

@lucylucy27
Copy link
Author

        vertexShaderSource += `
            vec4 viewCenter = transformModelViewMatrix * vec4(splatCenter, 1.0);
            **vPosition.z = viewCenter.z;**
           ...
        `;

Is this value viewCenter.z the depth of splats?

@mkkellogg
Copy link
Owner

Not quite. The actual depth value for a splat is calculated at this line:

vec3 ndcCenter = clipCenter.xyz / clipCenter.w;

And ndcCenter.z is the actual depth that would be rendered to the depth buffer if the depth buffer weren't disabled. It's a little tricky though, because the depth of a splat is really only valid for the splat's center, in a mathematical sense. All of the splat will be render with that depth value, but don't expect the result to be clean, coherent surfaces like you would get with a mesh.

@lucylucy27
Copy link
Author

Thanks for your kind reply :)
I test this value and found it is between (0.8, 1.0) in my scene.
Does this mean we need some clamp operation for the depth value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants