openscenegraphconceptssao

SSAO, Opmizations and pipelines using OpenSceneGraph


I have some questions about the SSAO technique implementation:

  1. Does it really need a second (or more) pipeline with every geometry? I mean, I found some tutorials and stuff about it but mostly they just give you the directions to do it without entering in further details.

  2. Is there any optimization possible? I'm using OSG and the I've got the impression that if you send the textures for the CPU and throwing again to the GPU isn't the best solution possible.

  3. Is it possible to make the shaders generate a texture with the samples depth in a buffer and send it to the second pipe line using only the quad for the screen, the colors, the depth of the scene and the depth for the tests? I'm using osg and couldn't find how to properly do it in documentations.


Solution

  • In general, SSAO is best suited to being implemented as part of a deferred shading approach. A strictly forward shading approach is possible, but would still require two rendering passes, and SSAO can easily be added to the second rendering pass of a deferred shading engine. In SSAO, you need the complete depth buffer of your scene to be able to calculate occlusion, so the short answer to section 1 of your question is yes, SSAO requires two rendering passes.

    Note that in deferred shading, although there are two rendering passes, the complex geometry (i.e. your models) is only rendered during the first pass, and the second pass is generally made up of simple polygon shapes rendered for each type of light. This is almost what you're suggesting in section 3 of your question.

    With regards to section 2 of your question, when set up correctly, you shouldn't need to move your intermediate textures back to the CPU and then back to the GPU between the two rendering passes; you merely make your first rendering pass's textures available as a resource to your second rendering pass.