Search Unity

Question Custom Shader: Single Pass Instancing + Multiview Support for VR

Discussion in 'Shader Graph' started by airoll, Aug 31, 2021.

  1. airoll

    airoll

    Joined:
    Jan 12, 2021
    Posts:
    37
    Hello! Forgive me if this is a dumb question, but I am relatively new to Shader Graph. I'm trying to understand how to get a custom shader that our character artist has built using ShaderGraph to support Single Pass Instancing / Multiview for VR. I have properly configured my project according to this documentation. Then it states: "Custom shaders need to be modified for rendering in this mode. Use Unity's XR shader macros to simplify authoring custom shaders."

    My first naive attempt at this was to add the UNITY_SINGLE_PASS_STEREO, STEREO_INSTANCING_ON, and STEREO_MULTIVIEW_ON as individual keywords in Blackboard. However, as soon as I added STEREO_INSTANCING_ON, I received a series of errors along the lines of:

    Code (csharp):
    1. Shader error in 'hidden/preview/SampleTexture2D_9eae558546944157965940c7e63c6fc7': undeclared identifier 'unity_StereoEyeIndex' at /.../PackageCache/com.unity.render-pipelines.core@10.5.0/ShaderLibrary/UnityInstancing.hlsl(185) (on d3d11)
    Now I'm not sure what to do next, or if I am even starting in the right place. I also found this documentation but it makes no mention of Shader Graph, and none of the suggested edits appear in the generated shader code from Shader Graph.

    Alternatively, I do notice that the keywords for STEREO_MULTIVIEW_ON appear in the inspector for my ShaderGraph file. Does this mean it's already enabled and I need to set the keyword to true elsewhere?

    Would someone be able to help point me in the right direction for how I should be approaching this?
     
    Last edited: Aug 31, 2021
    jacek_gulij_setapp likes this.
  2. gamedevassets-sean

    gamedevassets-sean

    Joined:
    Jul 26, 2013
    Posts:
    76
    I'm looking at a similar problem with a Shader Graph asset (visuals appear distored / messed up in VR for one eye). Is this similar to the issue you had with your shader? Did you ever find a fix?
     
    jacek_gulij_setapp likes this.
  3. mrphilipjoel

    mrphilipjoel

    Joined:
    Jul 6, 2019
    Posts:
    60
    Howedy! It's 2 years later, and I'm having the same issue. Anyone find a fix?