Stencil Support in PolySpatial

Can we have stencil support in PolySpatial?
I’m adding stencil on top of the supported shader (for example, the basic lit URP shader graph)
Stencil{
ref 1
comp always
pass replace
}
and couldn’t able to get the shader rendered.

Is stencil in general not supported or is there any way around to get stencil effect?

Thanks.

Unfortunately, no, there is no support for stencil buffer operations in visionOS’s MaterialX support.

Is there another way to achieve this effect? I noticed the game Synth Riders on Apple Vision Pro accomplished this.

You can create geometry and apply an occlusion shader to it.



Thanks for the support, Dan! I’m relieved and excited that there is a way to get this effect done. I’m unfamiliar with occlusion shaders. Is there anyway you can explain / show me how you did this with this geometry example?

It’s a built-in material type that ships with Unity, if you change the shader of any material and then apply it to the geometry it will occlude all virtual content hidden by the occlusion geometry.


2 Likes

Any update on this? it is still not supported?

If you mean support for stencil operations in MR, then no, it is still not available. This is a limitation of Apple’s RealityKit, which does not provide any support for stencil operations. If you are interested in such support, I suggest you request it from Apple via their Feedback Assistant.

1 Like

Hello, i’m trying to achieve exactly this, but I’m missing something …

Can you explain to me a little deeply which object get which shader ?

Maybe can you send a zip file of the project ?

Thanks you very much

I created a sphere with a hole and applied the occlusion shader to that. That will occlude all the content that is behind the sphere geometery except the hole.

Can you share a little bit about what you are trying to achieve?

Hey all!

Thank you so much for your example @DanMillerU3D - This is pretty close to what I’m trying to achieve

I’ve been exploring different ways to create a 3D screen where objects won’t be visible if their position happens to be “outside the screen” (between the player and the screen or in your example, outside the “hole”).

I’ve been able to successfully create this effect on full VR using stencil buffers and custom passes but having passthrough is a must for my use case so looking for possible approaches to achieve the same effect in MR.

@DanMillerU3D do you think this is achievable in MR?

And now, still no support?

If you mean for stencil operations, no, there is still no support in RealityKit and thus we can’t offer any support on our side.

1 Like