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

Depth calculation #1125

Open
sellendk opened this issue Oct 4, 2022 · 0 comments
Open

Depth calculation #1125

sellendk opened this issue Oct 4, 2022 · 0 comments
Labels
bug fix These changes fix one or more bugs. bug

Comments

@sellendk
Copy link
Collaborator

sellendk commented Oct 4, 2022

Currently, there is an assumption in various shaders throughout megamol regarding the calculation of the fragment depth value.

For example, in the ellipsoid shader of the GlyphRenderer

depth_out = ((depth / depth_w) + 1.0) * 0.5;
// assumes gl_DepthRange.near = 0.0 and gl_DepthRange.far = 1.0

If these values in the host code are changed by glDepthRange(), the DB will be wrong.
A possible solution to account for a possible change of the these values could be

float near = gl_DepthRange.near;
float far = gl_DepthRange.far;
depth_out = ((far - near) / 2.0) * (depth / depth_w) + (far + near) / 2.0;
// same as depth_out = ((depth / depth_w) + 1.0) * 0.5
// if near = 0.0 and far = 1.0
@sellendk sellendk added bug bug fix These changes fix one or more bugs. labels Oct 4, 2022
@sellendk sellendk mentioned this issue Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix These changes fix one or more bugs. bug
Projects
None yet
Development

No branches or pull requests

1 participant