-
Notifications
You must be signed in to change notification settings - Fork 24
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
VisGL depth buffer #60
Comments
Yes, that's a hole in VisGL at the moment. It just maps whatever is in the depth buffer without attempting any conversion: VisRTX/devices/gl/src/VisGLFrameObject.cpp Line 225 in c760f26
The triangle shaders don't explicitly do anything and you just get default depth behavior. The reason why the sphere/cylinder ones have explicit handling is that they have to adjust the depth from the bounding geometry to the "exact geometry" to be consistent with each other and triangles. To get the correct behavior the code above should run an additional full screen pass or compute shader to linearize the gl depth values based on camera parameters. I just haven't gotten around to it yet and it wasn't higher priority until someone asked. So now it is. I'll get around to it this or next week. Another approach would be to have a "raw" depth buffer channel and allow querying the gl projection parameters (near/far, or the entire matrix) as a property. But that would be in addition to the spec behavior I guess and be more an opengl interop feature. |
In fact, the current behavior would be useful to us as an extension, because we do the exact opposite of what you do (or, plan to do), i.e., Either way, I'm leaving this issue open for now if this is ok, to keep track of the fact that the depth buffer one currently gets is not linear and that this is a to-do. |
Linear depth is now implemented in commit 40a7a4a a quirk of the rasterizer is that the background will have the depth of the far plane which is just slightly behind the actual geometry. |
Testing the VisGL device with our example code, we found that the depth values wouldn't behave as expected (or, e.g., as the depths provided by the "visrtx" device do). According to @jeffamstutz the depth values returned by ANARI are supposed to be linear, and should originate at the camera position. For interop with OpenGL, our app therefore transforms these depth values to GL window coordinates (cf. this code).
So I'm wondering if the depth values that the "visgl" device generates are already in window coordinates (which to my understanding they're not supposed to be, according to the specs). Could you please clarify what the format is of the depth buffer obtained by VisGL? (for spheres and cylinders I found fragment shader code that I'm quite sure generates depth in WC, but have a bit of a hard time following what the triangle object shaders do.)
The text was updated successfully, but these errors were encountered: