Shader Graph: Expose property to material X but not to Unity?

If I set the property in Shader Graph, to not exposed, it will not be exposed in either material X or Unity. In Unity this allows me to use Shader.SetGlobalXX for that property, but it means that the property is not reflected on the material X side, so PolySpatialShaderGlobals.SetXX won’t work on device/simulator.

So instead I have to keep all properties exposed, and keep track of all materials in the scene and set (the same global) properties on each one. It would be nice to be able to use Shader.SetGlobalXX / PolySpatialShaderGlobals.SetXX instead.

Is there a solution for exposing only in the material X shaders?

Using an unexposed property with PolySpatialShaderGlobals.SetXX should allow you to set globals on the MaterialX side as well as the Unity side. I just tested it with a color property and it seemed to work fine (keeping in mind that you have to use the reference property name–e.g., “_Color” rather than “Color”). If that doesn’t work for you, I suggest you file a bug report and let me know the incident number so that I can take a look.

1 Like

It looks like it’s only the texture globals that are not working correctly.

I have posted a bug report here: IN-58388 - visionOS - PolySpatialShaderGlobals.SetTexture does not apply texture on simulator or device

Thanks; I will take a look. I seem to remember a fix for texture globals that may not have made it into the current release, but should be in an upcoming one.

Thanks for the report. I was able to reproduce the issue, and a fix should be out soon.

1 Like

@kapolka Has there been any updates on this? PolySpatialShaderGlobals.SetTexture does not seem to work for me still. Thanks!

Yes; the issue described in this thread was fixed in 0.5.0. If you’re having issues with PolySpatialShaderGlobals.SetTexture in the current release (1.0.3), please submit a bug report with a repro case and let me know the incident number (IN-#####) so that I can look into it.