Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Supporting Single Pass Stereo Rendering in Image Effects

Discussion in 'Image Effects' started by Kronnect, Aug 1, 2016.

  1. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,896
    Hi Unity,

    A few questions regarding this new feature in 5.4:

    - Do you have any technical note about upgrading existing image effects to support the new Single Pass Stereo Rendering in VR?

    - This option does not show up in build settings in the editor (Mac) using 5.4.0f3 and Gear VR. Any hint?

    - On http://forum.unity3d.com/threads/single-pass-stereo-image-effects.394197 seems like using TRANSFORM_TEX in the vertex shader for getting the screen buffer pos is enough so what's the difference from UnityStereoScreenSpaceUVAdjust macro?

    - Will the above macro work for the depth texture as well? I mean, I already have the inverted Y check, should this check be left as is?

    Here's the vertex code:

    Code (CSharp):
    1.  
    2.     struct v2f {
    3.         float4 pos : SV_POSITION;
    4.         float2 uv: TEXCOORD0;
    5.         float2 depthUV : TEXCOORD1;    
    6.     };
    7.  
    8.     v2f vert(appdata v) {
    9.         v2f o;
    10.         o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
    11.         o.depthUV = v.texcoord;
    12.         o.uv = o.depthUV;
    13.        
    14.         #if UNITY_UV_STARTS_AT_TOP
    15.         if (_MainTex_TexelSize.y < 0) {
    16.             // Depth texture is inverted WRT the main texture
    17.             o.depthUV.y = 1.0 - o.depthUV.y;
    18.         }
    19.         #endif
    20.         return o;
    21.     }
    Thanks in advance.
     
  2. robinb-u3d

    robinb-u3d

    Unity Technologies

    Joined:
    Jul 13, 2015
    Posts:
    20
    Hi

    We're busy working on an update for the Unity docs that will describe the issues with upgrading Image Effects to support Single-Pass Stereo.

    Single-Pass Stereo is currently only supported for DX11 on Windows and PS4 not for GearVR.

    The UnityStereoScreenSpaceUVAdjust() macro will compile out to just passing the UV through in non Single-Pass Stereo modes where as TRANSFORM_TEX will do a very similar thing but will always apply the transform (even if the transform itself doesn't effect the result as it's an identity one) thus possibly costing some shader cycles in the non Single-Pass Stereo case if for example you are sharing the same shader between GearVR and desktop VR then GearVR would be wasting extra cycles if you used TRANSFORM_TEX when it was just required for Single-Pass VR.

    UnityStereoScreenSpaceUVAdjust() can be used in either the vetex or pixel shader to adjust the UV it just depends on what happens to the UV when used in the Pixel Shader, is it used to read different textures (only some of which might be packed render textures) or are further maths performed on the UV etc. Just make sure to match the appropriate scale and transform value to the texture the UV will be used with.

    Finally UnityStereoScreenSpaceUVAdjust(uv, texture_ST) should only be used if you are rendering your image effect with Graphics.Blit() and not some other method like drawing a quad using the low level graphics API. For the non Graphics.Blit() case you will want to use UnityStereoTransformScreenSpaceTex(uv) instead which also compiles out to a pass through in non Single-Pass Stereo but assumes that the uv will be used with a packer render texture.

    Hope this helps.

    Robin
     
    Kronnect likes this.
  3. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,896
    Thanks for the explanation Robin, and glad to see you're going to update the docs.

    One more question: are current Image Effects in 5.4 upgraded to use single pass stereo, for example, Global Fog?
     
  4. robinb-u3d

    robinb-u3d

    Unity Technologies

    Joined:
    Jul 13, 2015
    Posts:
    20
    Most of the Standard Assets Image Effects have been updated to support Single-Pass Stereo. There are a couple that we are still working on that required us to expose more data from the engine to properly fix but the hope is to get these fixed up soon.

    Global Fog should I believe work however I am aware that there appears to be a bug where everything renders upside down that renders after it (so things like the GUI) when using it in Single-Pass Stereo mode that we still have to track down.

    Cheers

    Robin
     
  5. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,896
    ok, thank you.
     
  6. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,896
    Any news regarding documentation and possible samples?
     
  7. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    974
    Is there any ETA for when the cinematic image effects package will support Single-Pass Stereo?
     
  8. JVaughan

    JVaughan

    Joined:
    Feb 6, 2013
    Posts:
    23
    Sorry if this question is almost too basic, but how do you enable single pass stereo rendering to work with the Vive?
     
  9. ArchVizPRO

    ArchVizPRO

    Joined:
    Apr 27, 2014
    Posts:
    453
    You can enable it in Player Settings
     
  10. Thermos

    Thermos

    Joined:
    Feb 23, 2015
    Posts:
    148
    Any luck with the Global Fog in Single-Pass Stereo issue? I'v submit the bug report two months ago, not receiving anything since then. (Case 815234)
     
    nasos_333 likes this.
  11. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    +1 for volume fog, that would be very useful
     
  12. mos257

    mos257

    Joined:
    Sep 25, 2016
    Posts:
    4
    Also would be very useful if Screen Space Reflections would work with single pass stereo. Anyways, Unity 5.4 has been an awesome upgrade, only with single pass stereo and gpu instancing my framerate has sky rocketed like having a new computer! Fantastic job guys.
     
  13. Radius

    Radius

    Joined:
    May 11, 2013
    Posts:
    51
    Global Fog is not working for me in 5.5.0f3 with Single Pass Stereo Rendering, I planned to use it in combination with Beautify as that asset is all working great with Single Pass, however my one missing component for levels now is Fog:( any updates or possible issues with the version I am using? Thank you.
     
  14. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    791
    Is it documented yet ? I can't find it anywhere and I really need a documentation bit to adapt my HBAO asset for SPSR.
     
  15. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    The post you just quoted has all the info you need to port to SPSR. If you need a proper example you can look at the code in the post-processing stack as most of the effects there do support SPSR :)
     
    SunnySunshine and jimmikaelkael like this.
  16. dhuang

    dhuang

    Joined:
    Jan 5, 2016
    Posts:
    40
    any news on getting globalFog to work with single pass rendering (VR) ?
     
  17. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    791
    Hi @Chman,

    I've been able to adjust all my uv properly.

    However I'm still unable to get the proper resolution for rendering image effect in SPSR. I'm using command buffers so it seems the only way I can use to get the resolution at which I should render my post fx is to read Camera.pixelWidth and Camera.pixelHeight.
    The problem is that it never seems to return the proper resolution, at least not what's really used internally for rendering...
    Same goes for Unity 5.6 and 2017.1

    The first inconsistency I've noticed is that the Camera.pixelWidth is not the same in Multi Pass than in Single Pass, when in Single Pass it is half the width of MultiPass. I found it is quite strange as the resolution per eye should be the same in both Multi and Single.

    Second thing is that Camera.pixelWidth and Camera.pixelHeight is not consistent between Oculus SDK and Open VR, maybe this is expected tought I don't see why since Oculus resolution stays the same.

    The width returned always seems to be downscaled. The width and height are far lower than what's used internally for rendering into textures, which makes sense with warping.

    One way to get the proper resolution is to get it in OnRenderImage() with destination.width and destination.height (applying this resolution to my command buffer render textures fixes all problems), but this is a no go when using command buffers as it does add an un-necessary blit.

    Is there something I'm missing ? a workaround ?
     
    pachermann and cecarlsen like this.
  18. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    Hi,

    I have used the functions described in the documents and still get a black image in right eye in single pass instanced in MockVR in Unity 2019.3

    Is there anything new i am missing ?

    Thanks in advance