Search Unity

Scalable Ambient Occlusion issue!

Discussion in 'Image Effects' started by SpookyCat, Mar 14, 2022.

  1. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    I have a simple shader that scales a mesh based on a length value, works fine, but if I use Ambient Occlusion in Scalable Ambient Obscurance mode then I get the ambient occlusion applied to the unscaled mesh so I get a ghost of the original mesh and not the scaled one. If I switch to Multi Scale Volumetric Obscurance then it works just fine. Is there a tag or something needed in the shader to make this work correctly or is there an issue in in the Ambient Occlusion image effect. This is with the standard pipeline in Unity 2019.4 with version 3.0.3 of the Post Processing Package.
    Screenshots showing the issue.
    Original Mesh:
    Screenshot 2022-03-14 130306.jpg
    Scalable AO
    Screenshot 2022-03-14 130331.jpg
    Multi Scale Vol AO
    Screenshot 2022-03-14 130347.jpg
     
  2. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    At what point during the rendering process does your mesh get scaled? That will be the issue here. Can't comment on exactly when Unity's SAO does all of its depth-related testing but I would guess that's happening before your mesh deformation?
     
  3. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    It happens in the Vertex Fragment part of the shader.
     
  4. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    If it's happening in the vert/frag of your surface shader then I can only assume your shader doesn't write correctly to whatever buffers SAO (depth/depthnormals/normal Gbuffer/?) is reading from. Best way to confirm is to open up frame debugger and see what the inputs to SAO look like in its first/second pass.
     
  5. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,765
    Its odd that one form of AO works fine the other not, assume they just need a depth buffer.