Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Unity 5.4/SteamVR fullscreen quad convergence bug

Discussion in '5.4 Beta' started by kode80, May 30, 2016.

  1. kode80

    kode80

    Joined:
    Aug 1, 2013
    Posts:
    151
    For my volumetric cloud renderer kode80 Clouds I display the final render texture on screen by using a fullscreen quad mesh who's vertices are assigned in clipspace (-1.0 / 1.0), then in the vertex shader I simply send these unaltered verts to the fragment shader.

    In Unity 5.3, this works perfectly for; non-VR rendering, Unity's native VR rendering and the Steam VR plugin, tested with both Oculus + Vive.

    In Unity 5.4 beta (b19) this is broken, it appears that the left/right eye has a horizontal offset, the end result is that it looks like the cloud render texture does not converge correctly in the scene. If you alternately close your left/right eye you can see that the textures are mis-aligned by a significant amount.

    I've looked into the new TransformStereoScreenSpaceTex function in UnityCG.cginc however this makes no difference. (additionally, when single pass stereo is enabled, shadows in my scene are completely broken)
     
  2. thep3000

    thep3000

    Unity Technologies

    Joined:
    Aug 9, 2013
    Posts:
    400
    Can you submit a bug with a simple repro and post it here? I've asked QA to investigate your package but a simple repro will get the issue looked at quicker. Thanks!
     
  3. williamj

    williamj

    Unity Technologies

    Joined:
    May 26, 2015
    Posts:
    94
    Hi @kode80,

    I tried out the sample scene from your Unity package but I had some trouble getting a solid repro of what you described. A bug report with a small repro project attached would help me get a better idea of what's going on.

    Thanks,
    Will
    Unity QA
     
  4. kode80

    kode80

    Joined:
    Aug 1, 2013
    Posts:
    151
    Thanks for looking into this. If you import SteamVR and try that sample scene on a HMD, the left/right eye's clouds image will be completely misaligned horizontally (by at a rough guess 100 pixels). If you then try that same scene, in a HMD using Unity 5.3, you'll see that the left/right eye clouds image converges correctly (i.e. appears as a skybox in VR).

    If you think a smaller scene would help, I can throw something together when I get the time, but if you already have the sample scene all you should need to repro is a HMD to test (and possibly Valve's Steam VR plugin from the asset store, although I'm guessing this affects Unity's native VR in 5.4 too).

    Also if it helps, look at the FullScreenQuad.cs script - that's what's rendering the clouds texture.
     
    Last edited: Jun 1, 2016
  5. WandMagic

    WandMagic

    Joined:
    Jul 20, 2016
    Posts:
    2
    Any luck with this?
    I'm running into the same issue with my app too ~
     
    kode80 likes this.
  6. kode80

    kode80

    Joined:
    Aug 1, 2013
    Posts:
    151
    Yup. The way I was able to fix this, very much feels like a kludge but it works for me:
    1. Create a quad (with standard UVs 0->1), parented to your camera
    2. Calculate width/height of far clip plane using aspect ratio of VR eye texture dimensions
    3. Set quad's dimensions to width/height calculated in step 2, set quad Z position to far clip plane distance
    4. Use OpenVR api to calculate far clip plane for left/right eye matrix
    5. Calculate ratio of leftW/rightW and leftH/rightH
    6. Uses ratios in step 5 as X/Y scale for your parented quad
    What this is doing essentially is creating a quad that is stretched from the TL corner of the left eye to the BR corner of the right eye, while still parented to the center of the Unity camera in world space. The reason this is needed is due to the off axis projection now used by Unity VR. In very simple terms, the far clip quad of the frustum for each eye are offset and different sizes.

    This video was a big help:


    Also, here's a screenshot of an OpenVR frustum visualizer I made. Shown are the left/right frustums. What we are looking for is a world space quad, stretched so that it fits the combined bounds of the left/right far clip.
     
    Last edited: Jul 20, 2016
    kelloh likes this.