Search Unity

Transparency not working with single pass stereo rendering?

Discussion in 'AR/VR (XR) Discussion' started by jlindeman, Oct 20, 2016.

  1. jlindeman

    jlindeman

    Joined:
    Oct 20, 2016
    Posts:
    5
    Hi all, we're in the middle of the Oculus submission process, and need to eek out a few more fps, so we decided to give single pass stereo rendering another go (tried a while back but it didn't play nice with our screen effects, so we shelved it) After updating the Effects standard assets it's seems to work great for us except for one tiny problem, no transparency! Anything with transparency doesn't show up at all. That applies to particle effects, as well as a few objects using the standard shader. Any suggestions?
    Thanks!

    PS We're running in deferred mode, but I tried switching to forward just for grins and it didn't make a difference.
     
  2. NickAtUnity

    NickAtUnity

    Unity Technologies

    Joined:
    Sep 13, 2016
    Posts:
    84
    I'm not seeing this in the current build I'm using. What version of Unity are you using? Can you use the in-editor bug reporter to file a repro bug so we can investigate?
     
  3. jlindeman

    jlindeman

    Joined:
    Oct 20, 2016
    Posts:
    5
    We're on version 5.4.1p4. Yeah, I can file a bug report if that'll be helpful! If it works for you, and apparently for everybody else judging by the lack of forum posts about it, I can't help but think I'm just missing something. It wasn't until I realised that I needed to update the Standard Asset effects in my project that I was able to get Single Pass Stereo Rendering to work at all... is there something that I may need to update to get the transparency to work? Something super obvious and dumb that I somehow missed ;)
    Thanks for your help!
     
  4. jlindeman

    jlindeman

    Joined:
    Oct 20, 2016
    Posts:
    5
    UPDATE: It looks like the Global Fog screen effect was the culprit! After disabling it everything works great. I'd still like to find a way to have fog though, so the investigation continues...
     
  5. KellyJelly

    KellyJelly

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    12
    Hi @jlindeman,
    I've got a fix for global fog in the pipe, should ship in 5.5. If you absolutely can not wait for 5.5, I can help you fix the global fog script to work in 5.4.
     
  6. jlindeman

    jlindeman

    Joined:
    Oct 20, 2016
    Posts:
    5
    I'm not sure we can wait as we're mid-submission! If it's not too much trouble could you explain the fix to us so we can attempt it on our end?
    Thanks!
     
  7. Poupi

    Poupi

    Joined:
    Jan 11, 2012
    Posts:
    111
    Hey,
    Can someone tell me if a solution to this problem was submitted for Unity 5.4 ? We're close to release our game and we want to avoid upgrading to a newer version of Unity, so if we can fix this issues in Unity 5.4 that would be awesome.

    Thanks.
     
  8. KellyJelly

    KellyJelly

    Unity Technologies

    Joined:
    Sep 29, 2016
    Posts:
    12
    Sure! The issue with the global fog is that it's not using the built in Graphics.Blit() call, and the way it's passing in frustum corners to the shader is incorrect for APIs with asymmetric viewing frustums.

    if you'd like, you can copy the script and shader from the 5.5 standard assets, and replace the call to CalculateFrustumCorners with the following code:

    Code (csharp):
    1.  
    2.         void GetFrustumRays(Camera cam, ref Vector4[] outRays, float z)
    3.         {
    4.             Matrix4x4 proj = cam.projectionMatrix;
    5.             Matrix4x4 invProj = proj.inverse;
    6.  
    7.             const float projZ = 0.95f;
    8.             outRays[0] = invProj * new Vector4(-1, -1, projZ, 1);
    9.             outRays[1] = invProj * new Vector4(-1, 1, projZ, 1);
    10.             outRays[2] = invProj * new Vector4(1, 1, projZ, 1);
    11.             outRays[3] = invProj * new Vector4(1, -1, projZ, 1);
    12.  
    13.             for (int i = 0; i < 4; i++)
    14.             {
    15.                 outRays[i] /= outRays[i].w;
    16.                 outRays[i].z = -outRays[i].z;
    17.                 outRays[i] *= z / outRays[i].z;
    18.             }
    19.         }
    20.  
    And then transform these rays to world space using cam.transform.TransformVector()
    the call to cam.projectionMatrix will do the right thing (get the per eye projection matrix) in a rendering callback, but if you need to get the projection matrix outside of a rendering callback, use cam.GetStereoProjectionMatrix(eye).
     
  9. dhuang

    dhuang

    Joined:
    Jan 5, 2016
    Posts:
    40
    I have unity 5.4 and when I turn on single pass rendering, all the transparent objects get flipped upside down. Only the transparent objects, not any other objects. Is it related to this issue?
     
  10. Alex_curiscope

    Alex_curiscope

    Joined:
    Apr 4, 2017
    Posts:
    55
    I'd like to know more about this. Why does sending in strange frustum corners to global fog break transparency? I have written a fog effect that breaks transparency in single pass in a similar way to the global fog - it's drawn using GL.GL_QUADS instead of Blit. What's the difference? Why does transparency not work using one method but not the other?

    @dhuang: Try searching for UNITY_UV_STARTS_AT_TOP