Reverse depth buffer now the default for the VulkanSceneGraph

50 views
Skip to first unread message

Robert Osfield

unread,
Jan 12, 2022, 7:24:27 AM1/12/22
to vsg-users : VulkanSceneGraph Developer Discussion Group
Hi All,

A suggestion from Tim Moore in the thread:

   Please provide feedback : Tasks left to complete VulkanSceneGraph-1.0

was to adopt reverse depth buffer convention the to help with precision of the depth buffer/reduce z fighting artefacts.  Tim volunteered to implement it and provided the a PR with the required changes to vsg::perspective() and vsg::orthographic().

Background reading on reverse depth:

The PR didn't include all the required changes to keep features like vsg::LineSegmentIntersector working and changes to the vsgExamples and the .vsgt models in vsgExamples to work with the reverse depth buffer convention so I've picked up the baton and made the required changes.

This work is now checked into VulkanSceneGraph master and vsgExamples.  The changes are:


I recommend looking over all the changes to vsgExamples as you may well need to make the same changes to your own models and source files.  Without these changes you may well see nothing displayed on screen whatsoever.

In order to see depth precision benefits of reverse depth you'll also need to set the Window creation up so that a float depth buffer is used, you can do this by setting the depthFormat thus:

   windowTraits->depthFormat = VK_FORMAT_D32_SFLOAT;

Potentially we could make this the default WindowTraits::depthFormat setting but I haven't done any testing other than on my desktop system with a Geforce 2060 so  can't say how portable this will be.  I would appreciate input from the community on this.

In order to help differentiate versions of the VSG that use conventional depth buffer with a 0 near to 1 far range to now where depth buffer varies from 1 near to 0 range I have updated the VulkanSceneGraph version to 0.2.4 and SOVERSION to 6.

For newly created models and new applications I don't expect users will see any problems, but for existing application and .vsgt/.vsgb models linking to the latest VSG master could cause problems so be aware.  If you have issues let us know - they should be resolvable with the tweaks I had to make to vsgExamples so follow the link above.

Cheers,
Robert.

Reply all
Reply to author
Forward
0 new messages