Unexposed variables don't work in visionOS?

I had caught, that my shaders with unexposed variables don’t work properly. After this, I created, two super simple shader graphs with only one color parameter. One of them has exposed, and other has unexposed color variable, and just pass it to output color. Here they are:


And also I’ve created a simple script:

using UnityEngine;

public class ColorSetter : MonoBehaviour
{

    [SerializeField]
    private Material _exposedColorMaterial;

    private static readonly int SomeColor = Shader.PropertyToID("_SomeColor");

    // Start is called before the first frame update
    void Start()
    {
        _exposedColorMaterial.SetColor(SomeColor, Color.red);
        Shader.SetGlobalColor(SomeColor, Color.blue);
    }
    
}

When I run editor, I can see predictable result - cubes with these materials has red and blue colors.

But in simulator the one, that use unexpsed variables, keeps being black.

Can I somehow use unexposed shared shader variables for visionOS?

You need to use Unity.PolySpatial.PolySpatialShaderGlobals.SetXXX instead of Shader.SetGlobalXXX for it to be passed to RealityKit

2 Likes