Hi,

glClipControl 
<https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glClipControl.xhtml> 
(available via osg::ClipControl) lets you specify how OpenGL converts 
between clip-space and window-space. This has the advantage that it lets 
you avoid the depth precision issues associated with the reverse-Z 
technique (described here 
https://nlguillemot.wordpress.com/2016/12/07/reversed-z-in-opengl/) when 
using OpenGL's default clip-space range of -1 to 1 instead of 
Direct3D/Vulkan/Metal's range of 0 to 1.

Obviously, to make use of this you need to make other changes, like using 
an alternative projection matrix, but mostly those are minor and well 
within the capabilities of the OSG.

There's one particular pain point, though. When the cull visitor applies a 
new camera, it calls CullStack::pushProjectionMatrix, which, among other 
things, sets up a new polytope for culling. This works by starting with a 
frustum representing clip space and transforming it using the projection 
matrix as the inverse in order to get one representing view space. The flaw 
with this is that it assumes the OpenGL default clip space is being used 
instead of whatever's been set with Clip Control.

For OpenMW, we've been experimenting with reverse Z and it's been 
ludicrously effective at removing Z-fighting with huge viewing distances. 
However, avoiding the culling issue described above has required a 
workaround that isn't as clean as we'd like.

I'm hoping that some discussion about how to potentially resolve the issue 
in the OSG itself will lead to a better long-term solution, and also 
inspire a better workaround we can use when targeting older OSG versions, 
too.

Thanks as always,

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osg-users/07d688ba-f1dc-4e8b-8f80-60b458801581n%40googlegroups.com.

Reply via email to