Does PolySpatial Support Shaders with Clipping?

We have a Shader that uses a _ClipPlane to cut objects. This works for all our other hardware targets, but does not work for Vision Pro.

Shader functions fine in the Editor and fine on other devices. On Vision Pro, it still renders, but does not clip our objects. Play to Device, or in Build, simply doesn’t function.

Is there something happening on the VisionPro hardware that is changing shaders or disabling certain shader capabilities? If so, will VisionPro ever support clipping shaders?

Yes; MR apps on visionOS require that all custom shaders be supplied as shader graphs that we then convert to MaterialX. The only way to add a clipping plane to such a shader graph would be to use a Transparent or alpha-clipped target, provide the plane coefficients in a (local or global, Vector4) property, and test the position (probably transformed into Unity world space) again the plane, returning alpha = 1 if inside the plane or alpha = 0 if outside.

Thanks for confirming it should work Kapolka.

We are using a ShaderGraph Shader. As stated, it functions in Editor and on our other build targets (Meta Quest Pro, Hololens 2). It does not function in play to device (despite the desktop editor showing the item clipped) or in build on Apple Vision Pro.

We are, unfortunately, not shader experts. Is there any difference in the way a clipping shader should be setup in shader graph for Vision Pro specifically, compared to other platforms?

Without knowing how your particular shader is set up, I don’t know what the differences might be. I’m not aware of a standard way to handle clipping within shader graphs. If you submit a repro case as a bug report and let us know the incident number (IN-#####), we can take a look. Alternately, you could just post the shader graph here and describe how you’re supplying the clipping plane.

Is there a method for uploading ShaderGraph shaders to these forums? I don’t see a way to do it. So here’s just the parsed text from our ShaderGraph shader that has a clipping plane that we can see functioning in the editor, but not on device.

We have a separate script that collects GameObjects that can be clipped, and then passes to their material’s _ClipPlane the world space co-ordinates of our Clipping Plane, so that when a user manipulates and moves the Clipping plane, all clippable objects are cut appropriately relative to their position and orientation to the Clipping plane.

People often just post screenshots, but that doesn’t work great with larger graphs; your approach works better.

Your shader graph looks mostly correct; the main thing that’s missing is the coordinate space conversion of the world space position. The world space position that visionOS provides in shader graphs is relative to the rendered volume, so you need to use the PolySpatial Volume to World node to transform to Unity space. This is described in more detail in the PolySpatial shader graph documentation.

Another issue that may be relevant is that visionOS materials support alpha clipping or transparency, but not both. If you enable alpha clipping, all pixels with alpha values at or above the clip threshold will be rendered as opaque. To test your material with the coordinate space transform, I set the ClipPlane property to (1, 0, 0, 0) (clip against YZ plane), InnerGlow to 0 (to make it more visible), and AlphaClipThreshold to 0.5:

1 Like

Thank you for this help kapolka! We’ll go modify our implementation based on your suggestions and mark this as answered when we confirm it’s working.

1 Like

Things appear to be working thanks to the suggested changes you gave us kapolka. Marking this as solved for now, will return if we see any other issues.

Thanks for the assistance.

1 Like