Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

VR (Occulus) + URP + screenspace UV

Discussion in 'Universal Render Pipeline' started by glennMediaMonks, Jun 16, 2022.

  1. glennMediaMonks

    glennMediaMonks

    Joined:
    Nov 3, 2016
    Posts:
    5
    My question is as follows.

    I need screenspace UVs to work in
    - Unity 2021.3
    - URP
    - on the Occulus
    - stereo renderingmode: SinglePassInstancing

    Could anyone provide a full code sample of a shader which will display a texture on a quad based on its screenspace uvs?

    Extra info:
    I've tried a multitude of forum posts but non gives the correct visual result, they are either distorted or not matching per eye making the texture appeared offset between the eyes. Off course simply using 'ComputeScreenPos' and dividing by the W component is the first thing I tried and does not work.

    https://docs.unity3d.com/Manual/SinglePassInstancing.html provides a helpfull start but sadly does not cover this topic.
     
  2. ennuma

    ennuma

    Joined:
    Aug 18, 2014
    Posts:
    1
    Using screenspace UV is tricky. VR devices such as Quest run a distortion pass to compensate for lens distortions which also distorts the screenspace UV. See: https://developer.oculus.com/documentation/native/pc/dg-render/
    The distortion mesh is private in HMD provider so no way we could access the mesh and revert that distortion.

    If your effect could be implemented using world space that would be the way to go.