(PolySpatial) Unable to Manipulate Custom Global Properties in Shader Graph

Hello,

I’m trying to implement fog in a shader I created myself. The problem I’m facing is that although it works as expected in the editor, it behaves strangely when run in the editor or simulator with PolySpatial. When calling Shader.SetGlobalColor and Shader.SetGlobalVector from a C# script, it seems like they’re not functioning.

Are custom global parameters for shaders not supported at the moment? Is there any plan to support them in the future?

(I thought the following topic might possibly be related: Custom Lighting and Conversion to Shader Graph - #2)

Hello! Globals are supported, but there is a PolySpatial-specific API required to use them. Rather than calling Shader.SetGlobalColor and Shader.SetGlobalVector, try using Unity.PolySpatial.PolySpatialShaderGlobals.SetColor(string, Color) and Unity.PolySpatial.PolySpatialShaderGlobals.SetVector(string, Vector4) (similar to Shader, variants also exist for Float, Integer, Matrix, and Texture). These methods let PolySpatial know to transfer the globals to visionOS.

1 Like

Thank you for your response, Mr. kapolka! I was able to see in the game view of the editor that the global parameter is being set as expected!

On the other hand, a crash occurred in the Xcode simulator, so I have submitted a bug report. The issue seems to be solely with the global parameter, causing a crash every time the function is called.

I am looking forward to PolySpatial becoming even more awesome!

Thanks for the bug report! Do you have an incident number for it (IN-#####)? That will help me find it in our system.

Maybe the number is IN-56206!
(The reason I use “maybe” is because I cannot view the report status page via the attached URL although I submitted the report.)

Yes, that’s the one. Thanks!

Thanks again for the repro case. I found the issue, and it will be fixed in the next major release. The issue is strictly with color globals, so in the meantime, you should be able to work around this by using a Vector4 global instead of a Color global and calling PolySpatialShaderGlobals.SetVector.

Thank you for providing alternative solutions! I was able to confirm the expected color changes on the simulator as well.
This will be very helpful for my visit to the Apple office the day after tomorrow!

1 Like