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

Using RenderTextures in VR mode distorts perspective projection [SOLVED]

Discussion in 'AR/VR (XR) Discussion' started by arnebp, Oct 20, 2015.

  1. arnebp

    arnebp

    Joined:
    Oct 15, 2013
    Posts:
    22
    I have a scene where I have set up a simple depth based LOD scheme. I am having trouble when running this in 'VR mode' in Unity 5.2.1 using Oculus DK2.

    In my scene, I have two cameras with each their frustum rendering 'near' and 'far' objects in the scene. The 'near' camera render close vicinity high polygon objects and the 'far' camera renders low polygon objects far away. Simple stuff.

    I have a third camera that combines the RenderTextures of the 'near' and 'far' camera using a custom 'depth combine' shader. The script CombineDepth.cs is responsible for this.

    There is something off in the output I get from my custom shader. The perspective projection matrix seems distorted and I am unable to figure out why. The output I get is this:



    where I would expect something more like this:



    Press 'Alpha0' aka zero key to switch between depth LOD camera and normal camera.

    The project can be downloaded from here. Please download and inspect in interested in this problem.

    Am I missing some obvious point when working with RenderTextures in VR mode? Or is this maybe related to the current state on the VR support in Unity?

    NOTE: This post is a extended question to this post.
     
  2. DrBlort

    DrBlort

    Joined:
    Nov 14, 2012
    Posts:
    72
    Hi again :)

    Try doubling the vertical size of the render textures (I tried halving the horizontal size, but the result is very blocky).

    EDIT: Almost forgot: You have a FoV of 106.1888 on "Depth Optimisation", but on the child cameras it's 60. You have to change those to 106.1888 to see more or less the same image.
     
  3. arnebp

    arnebp

    Joined:
    Oct 15, 2013
    Posts:
    22
    Hi again @DrBlort !

    Once more your input is much appreciated. Thanks!

    I am afraid that I can't identify/understand the logic behind the need to double the vert text res?
     
  4. DrBlort

    DrBlort

    Joined:
    Nov 14, 2012
    Posts:
    72
    I think it's because each eye is actually half the horizontal resolution on the stereo display, but don't quote me on that :)
     
  5. arnebp

    arnebp

    Joined:
    Oct 15, 2013
    Posts:
    22
    Sounds somewhat possible. If that is the case, then I am surprised I did not stumble across something as fundamental as this while searching HMD forums.

    I've updated the shared project in case anybody is interested.

    Thanks again @DrBlort