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

Beginner help with single pass

Discussion in 'AR/VR (XR) Discussion' started by serberusno1, Jul 1, 2018.

  1. serberusno1

    serberusno1

    Joined:
    Jan 28, 2017
    Posts:
    84
    Wondering if someone can tell me if there's more to setting up single pass than what's discussed in the Unity manual here: https://docs.unity3d.com/Manual/SinglePassStereoRendering.html

    I've followed the instructions but I get mixed results ranging from two pictures being rendered in my headset (rift) to everything being rendered black. I understand that some assets would etc may have trouble rendering correctly- shaders for example, but I'd like to just be able to get it working at a basic level.

    Using Unity 2017.3.1f1 currently
     
  2. BrandonFogerty

    BrandonFogerty

    Joined:
    Jan 29, 2016
    Posts:
    83
    Hi @serberusno1,

    The main problem that you can run into when using the single-pass stereo mode is shader compatibility. If you use a shader that is not compatible with the various flavors of single-pass, then the output will be very different from what you might expect. For example, you can see the same object drawn twice in one eye and not at all in another. With regards to post processing, you could see the scene rendered in one eye and not at all in another or you could see two versions of the scene rendered per eye. So it is very important that shaders are written with single-pass in mind. We have tried to make this a bit easier by ensuring that if you use our built-in shader methods when writing your shaders, those methods will work with all the various stereo rendering methods automatically. For example, you should use "UNITY_SAMPLE_SCREENSPACE_TEXTURE" instead of sampling the screen space texture manually. The reason for this is because single-pass renders to a single texture that is twice the width of a single eye texture. So special care must be given to ensure you are sampling from the correct half of the texture. If you were using single-pass instancing, then the texture you would need to sample from would be a texture array which must be indexed by the stereo eye index. "UNITY_SAMPLE_SCREENSPACE_TEXTURE" will automatically perform the correct operation regardless of which stereo rendering method you use. I specifically called out "UNITY_SAMPLE_SCREENSPACE_TEXTURE" as an example however we have a handful of other macros that perform in a similar fashion. All of the built-in shaders should work with all the various stereo rendering methods.

    Could you share an example shader that you are having issues with?
     
  3. serberusno1

    serberusno1

    Joined:
    Jan 28, 2017
    Posts:
    84
    Hey Brandon,

    Apologies but I got single pass to work last week. And yes it was down to 2 different shaders I happened to be testing. Appreciate it though man!