Search Unity

Bug Vector3 parameter in Shader behaves differently on Android (Oculus Quest)

Discussion in 'Shader Graph' started by shellyalon, Mar 31, 2021.

  1. shellyalon

    shellyalon

    Joined:
    Mar 26, 2013
    Posts:
    27
    Hello, this is a weird one. I've already submitted a bug report. Posting it here, because I feel like I missed something.

    So. I've got a shader (built with Shader Graph) that calculates the distance of a frag from a specific Vector3 position parameter in the scene. Then it calculates the colors accordingly. In this example it just puts a black dot on the position. In the screenshot you see the plane has this shader. The black dot is where HighlightPosition is. The cylinders are just markers.

    Shader.png
    EditorView.png

    Now, when I build for Windows, everything's fine. But when we build for Android, specifically Oculus Quest, it doesn't work anymore. The position is offseted. I can't attach a screenshot out of the Oculus Quest right now, but just imagine the black dot being somewhere else. After some tries I figured out:

    • For the X value the HighlightPosition.y value is being read. So if I have (1,0,0) as HighlightPosition, in the Editor the black dot would move one cylinder to the right. But on the Quest nothing would happen. If I have (0,1,0), then in the Quest the black dot would move one to the right - but in the Editor it would go one up.
    • Y is nothing. It's just not sampled out of HighlightPosition.
    • I haven't tested what Z is.
    • It has nothing to do with the Position-Node. I've tested that and it behaves how you would expect. It definitely has something to do with the Vector3 parameter.
    • If I don't use a parameter for a Vector3, but just use a Vector3-Node then it works fine.

    Vector3Parameter (2).png Vector3Parameter.png

    But I found a workaround: If I replace the Vector3 parameter with 3 seperate Vector1's, there isn't a problem. See the three seperate Vector1's that I combine.

    Am I missing something? Or is this just a weird bug? I mean, it shouldn't happen, right?
    I've tested on Unity 2019.4.10 and 2019.4.23.
     
  2. shellyalon

    shellyalon

    Joined:
    Mar 26, 2013
    Posts:
    27
    I've found something! It matters if a parameter is exposed or not!
    Not only on Android platform, but on windows, too.

    Edit: I understand that un-exposed parameters are supposed to be set through code. So that may be working as intended. The original problem still stands - exposed vector3 parameters are behaving differently on Oculus Quest (and maybe all of Android)

    Not exposed (doesn't work)

    not_exposed.png

    Exposed (works in Editor, not on Android)

    exposed.png
     
    Last edited: Mar 31, 2021
  3. shellyalon

    shellyalon

    Joined:
    Mar 26, 2013
    Posts:
    27
    So, another workaround: Just use a Vector4 for HighlightPosition.