Screen Space Ambient Occlusion for Quest3D3dvrm.com/ssao/ssao_for_quest3d_v02.pdf · 2014. 12....

7
Screen Space Ambient Occlusion for Quest3D SSAO is a relatively cheap way to improve visual quality of lighting in dynamic and static scenes. Main benefits of SSAO are following: calculation of SSAO doesn’t depend on scene complexity works with dynamic as well as static scenes and objects easy to integrate into real-time rendering pipeline no pre-computation is needed executed completely on GPU There are disadvantages: to maintain reasonable performance SSAO should be used for small cavities relatively to their size on screen

Transcript of Screen Space Ambient Occlusion for Quest3D3dvrm.com/ssao/ssao_for_quest3d_v02.pdf · 2014. 12....

  • Screen Space Ambient Occlusion for Quest3D

    SSAO is a relatively cheap way to improve visual quality of lighting in dynamic and static scenes.

    Main benefits of SSAO are following:

    • calculation of SSAO doesn’t depend on scene complexity

    • works with dynamic as well as static scenes and objects

    • easy to integrate into real-time rendering pipeline

    • no pre-computation is needed

    • executed completely on GPU

    There are disadvantages:

    • to maintain reasonable performance SSAO should be used for small cavities relatively to their size on screen

  • • SSAO is not even close to be accurate ambient occlusion calculation as it view-dependent and changes as fast as camera rotates or moves

    • hardware limitation, SSAO is a shader intensive technique, with current implementation of SSAO we experienced huge difference in performance between PC’s with GeForce 7xxx and 8xxx series. At least 8xxx series is recommended. Latest test shows that biggest performance loss happens due double render of geometry – one time for depth render and one time for normal shading. Impact of SSAO calculation is much less significant.

    Basics:

    In this chapter we will briefly describe how you can setup SSAO for your render pipeline in Quest3D.

    As input data for calculation, SSAO uses depth of the scene. So first step before calculating SSAO is to render depth of your scene. For very complex scenes this can greatly affect performance if special care is not taken. At the same time scene depth can be used by many other effects, such as soft-particles, atmospheric scattering, depth of field, motion-blur, water scattering of light and water transparency. So if you considering to use any of this effects, that requires depth as input, you can easily add SSAO into your project or rendering pipeline.

    NOTE: depth on screenshot is specifically made for screenshot, don’t use it as a reference during SSAO integration

    Depth should be rendered into 32-bit or at least 16-bit texture, 32-bit is preferable as lower precision can leads to bugs.

    After SSAO was calculated you get a pixel-perfect screen size texture, similar to one on the right side of the illustration. Now you have a choice to use SSAO as a post process effect or treat it’s contribution individually for every object. Before explaining how it can be done let’s see why we need to choose between them. Post-process way is the most simple one - you don’t need to use shaders for every surface (except that you still need to get their depth). The downside is that you don’t control anymore how SSAO affects your lighting. For example, in our demo, isle, foliage and stones always use SSAO but for Athene statue SSAO is attenuated by diffuse lighting, so on sun side it almost doesn’t contribute to color of the surface. In general on dark textures SSAO would look good with any lighting, on bright and light tone textures, ambient occlusion just under direct light looks a bit strange.

    For using it as post-process, simply render you scene as usual and then render texture containing SSAO on top of scene using flat camera and pixel perfect square (similar to bloom and other post-process effects), use

  • Multiply blending mode. To use it individually you need to use shaders for every surface, using shader you would read SSAO value for current pixel on screen and attenuate final color of surface.

    Details:

    Now let’s discuss all the details. First I’ll explain what parameters of SSAO hybrid channel means and how you should work with them. Then we will see how rendering pipeline might look like when you use SSAO. If you prefer to work with smart materials, you will see what you need to add to them for SSAO. At the end we will discuss individual cases of using SSAO for skinned characters, nature painted objects, objects with transparency and non opaque objects.

    SSAO hybrid channel parameters and input values:

    Input parameters to SSAO hybrid channel are shown on the left and tweak able internal parameters are shown on the right.

    NOTE for source code owners: In case of using source code, instead of hybrid channel, you will be using public call channel to SSAO source code channel group, most of the parameters can be reached using HLSL interface of SSAO Calculation object (Object -> SSAO Calculation in SSAO source code channel group), others, like “Amount of samples” and “Downsampled depth?” need to be changed manually inside channel group.

  • Input parameters:

    1. Normal depth Render Texture – is a render to texture channel that contains depth of the scene

    2. Far clip and Near clip - are respectively Far and Near clipping plane values of your scene. It’s important to remember that these values are used for depth scaling and can be different than your actual Far and Near clipping plane values used by camera. You should tweak them according to type of your scene – is it an interior where objects would be near your camera? or it’s an huge exterior scene with distant mountains? Try different values and see which works best for you.

    Internal parameters:

    1. Downsample depth? – when checked original scene depth texture will be downsampled to smaller size (in hybrid example hardcoded to 512x512), this improves performance with bigger sampling radius. Downsampling has a negative impact on SSAO quality for small details of geometry, as they become blurred after downsampling and introduce depth precision error that can lead to thin repeatable line pattern in SSAO.

    2. Sampling radius scalar – is a global multiplier for SSAO sampling radius. Be aware that big radius ( > 1.0) can lead to performance drop, check “Downsample depth?” to get a better performance with big sampling radius.

  • 3. SSAO contrast – is a vector of three connected parameters. First two parameters (R and G) are responsible for contrast of SSAO, as you start to change them you will see that overall brightness of SSAO will change, so tweak third (B) parameter to set a desired brightness. The smaller difference between R and G the shorter will be gradient of SSAO, so you more contrast it will be. NOTE: if you make G bigger than R you will get inverse color of occlusion.

    4. First and second radius range – these parameters control how sampling radius will change with a distance. I’ll use following illustration to explain how it works.

    Special function is used to scale sampling radius depending on depth of pixel. First and second radius range parameters are setting control points of this function. It works like this: you have a certain distance from camera where sampling radius would become smaller and smaller with every meter until depth is equal to First radius range value, than it will start to grow until it reaches Second radius range and will stay constant. This is done to keep scale of sampling radius proportional for objects close to the camera and ensure that sampling is at maximum radius for distant objects like for example mountains . In example scene you hardly

  • notice any influence of these parameters, they will really matter in big scale environments and with big sampling radius. Currently, in hybrid proportion of sampling radius is hardcoded to quite small value, difference between biggest and smallest radius is 1/3 of biggest sampling radius. If you own source code, you can change them, check comments in source.

    5. Number of samples – currently only two options available, 8 and 16. In case of 16 samples, 8 samples is taken with one sampling radius and another 8 with two times smaller radius, this greatly improves quality and smoothness of occlusion gradient, but takes performance as well.

    6. Blurring depth threshold – during blurring of SSAO we keep hard edges of geometry and prevent SSAO leaking, by simply not taking into account samples that has a big difference in depth with current pixel. This parameter sets a threshold of depth difference.

  • Developed by VRM team

    Visit us at:www.3DVRM.com

    Contacts:[email protected]@3dvrm.com

    mailto:[email protected]:[email protected]://3dvrm.com/