Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Getting Depth Textures to work in VR (Single-pass & Multi-pass)

Discussion in 'AR/VR (XR) Discussion' started by fantasticdev, Jan 11, 2017.

  1. fantasticdev

    fantasticdev

    Joined:
    May 8, 2013
    Posts:
    33
    NOTE: I have also posted this question in the Shaders forum here but have had no responses and I'm not sure which forum is best suited to getting feedback, hence this reposting.

    I'm in the (increasingly drawn out) process of adding VR support to my asset Fantastic Glass.

    I have the grab pass working, (most) inconsistencies caused by Single-pass dealt with, and everything is being synchronised to avoid any ghosting.

    The only issue I seem to be left with is getting depth values in my shader from depth textures rendered in other cameras.

    The depth textures when received by the material appear to be per-eye and include part of the dividing black border - they aren't requested in any special way; this is just how Unity renders / passes them along:


    Here is an example in VR of the depth issue causing an offset edge in the distortion:


    Here's an example with VR support disabled:


    Here's another screen showing that each eye receives a different offset in VR and even shows the border in Single-Pass:


    Here's an example in VR with the distortion effects disabled (red albedo for visibility as the sphere is unlit to make the edges clearer):

    Grab pass and normal (e.g. _MainTex) UVs are working fine. However, if I try to use a similar UV / Unity's various new stereo functions with the depth textures, the results are even worse than in these examples.

    Here's an example in VR of fogging and extinction showing the same edge - their intensity is derived only from the front, back, and other (non-glass) depth values:


    Does anyone have any experience in getting something like this to work or have an idea of what I should be doing to get the right values?

    I can't find an explanation of how Unity recommends integrating their VR support and would massively appreciate any help :)
     
  2. eastes

    eastes

    Joined:
    Sep 1, 2012
    Posts:
    48
    I'm still struggling to find a solution to this. I'm going to have to do without distortion effects for now.
     
  3. z_space

    z_space

    Joined:
    Jul 17, 2016
    Posts:
    9
    Did you ever solve this?