Search Unity

Screen Space Ambient Obscurance with Orthographic Camera?

Discussion in 'Image Effects' started by ChubbyBoy, Feb 4, 2016.

  1. ChubbyBoy

    ChubbyBoy

    Joined:
    Jan 24, 2016
    Posts:
    1
    It would appear the standard Obscurance effect doesn't work with an Orthographic camera. Its basic SSAO script works perfectly fine for me though. I've gone through the setup script for Obscurance and I can't see anything that would making it unsupported. There are no errors or warnings... I very much suspect the culprit is bad matrices/vectors that are assumed to be projection.
     
  2. rdescartes

    rdescartes

    Joined:
    May 28, 2014
    Posts:
    1
    Maybe it's a little bit late, but i just faced the same problem, here is how to solve:

    (Change ScreenSpaceAmbientObscurance.shader)
    Code (CSharp):
    1. float LinearEyeDepthOrth(float z)
    2. {
    3.     // uniform float4 _ProjectionParams;
    4.     // x = 1 or -1 (-1 if porject is flipped)
    5.     // y = near plane
    6.     // z = far plane
    7.     // w = 1/far plane
    8.  
    9.     // http://www.derschmale.com/2014/03/19/reconstructing-positions-from-the-depth-buffer-pt-2-perspective-and-orthographic-general-case/
    10.     // Z_view = Z_near + Z_ndc(Z_far - Z_near)
    11.     return _ProjectionParams.y + z * (_ProjectionParams.z - _ProjectionParams.y);
    12. }
    13.  
    14. float3 ReconstructCSPosition(float2 S, float z)
    15. {
    16.     float linEyeZ = LinearEyeDepthOrth(z);
    17.     //return float3(( ( S.xy * _MainTex_TexelSize.zw) * _ProjInfo.xy + _ProjInfo.zw) * linEyeZ, linEyeZ);
    18.     return float3(( ( S.xy * _MainTex_TexelSize.zw) * _ProjInfo.xy + _ProjInfo.zw), linEyeZ);
    19.     ...
    20. }
     
    Tim-C likes this.
  3. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    We need to do some fixes for this to make sure our effects construct properly in ortho. I've notified the team.
     
    rdescartes likes this.
  4. Bazoo_Studios

    Bazoo_Studios

    Joined:
    Dec 18, 2011
    Posts:
    92
    It looks like nobody ever fixed it yet, or am I missing something?
     
  5. Bitwak

    Bitwak

    Joined:
    May 10, 2014
    Posts:
    27
    Any update from the team @Tim-C ? the issue seems to be still there
     
  6. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    It's not that simple to 'fix' SSAO with orthographic rendering, most SSAO depends on a smooth transition of values for depth and normals, and orthographic rendering by its very nature, does not render depth that way.