Unity 5.4/SteamVR fullscreen quad convergence bug

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)

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!

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

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.

Any luck with this?
I’m running into the same issue with my app too ~

1 Like

Yup. The way I was able to fix this, very much feels like a kludge but it works for me:

  • Create a quad (with standard UVs 0->1), parented to your camera
  • Calculate width/height of far clip plane using aspect ratio of VR eye texture dimensions
  • Set quad’s dimensions to width/height calculated in step 2, set quad Z position to far clip plane distance
  • Use OpenVR api to calculate far clip plane for left/right eye matrix
  • Calculate ratio of leftW/rightW and leftH/rightH
  • 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:

https://www.youtube.com/watch?v=lsKuGUYXHa4

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.

1 Like