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. Dismiss Notice

Bug unity_CameraToWorld not being filled for right eye when doing single-pass stereo

Discussion in 'Shaders' started by sondreutheim, Sep 15, 2023.

  1. sondreutheim

    sondreutheim

    Joined:
    Sep 15, 2023
    Posts:
    2
    Maybe I've missed the memo on something, but it seems unity_StereoCameraToWorld[1] and so by extension unity_CameraToWorld, is not being set to be accessible in the vertex shader in the two versions of Unity I've tried, 2023.1 and 2021.3 using URP.

    So I'm having a great deal of trouble accessing the camera direction in my custom fx shader that uses camera direction to compute final world position.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,221
    Sounds more like you're not setting up the instance & eye ID via
    UNITY_SETUP_INSTANCE_ID(input);
     
  3. sondreutheim

    sondreutheim

    Joined:
    Sep 15, 2023
    Posts:
    2
    I thought so as well but I should have what I need according to the docs.

    The end of my appdata has:
    UNITY_VERTEX_INPUT_INSTANCE_ID

    The end of my v2f has:
    UNITY_VERTEX_OUTPUT_STEREO

    and the top of my vertex shader:
    Code (CSharp):
    1. v2f vert (appdata v, uint vertID : SV_VertexID)
    2. {
    3.     v2f o;
    4.     UNITY_SETUP_INSTANCE_ID(v);
    5.     UNITY_INITIALIZE_OUTPUT(v2f, o);
    6.     UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);