Alternatives to Scene Depth node in URP Shader Graph for decals

Basically, there’s no point in using the Scene Depth node. It should simply be reported as Unsupported, but we haven’t gotten around to removing a legacy implementation. If the implementation actually works, what it will return is simply the depth of the current geometry being rendered, which is unlikely to be useful.

We target RealityKit for MR, and RealityKit doesn’t offer any kind of access to the depth map. It is possible to render to a RenderTexture and copy the depth for use in a shader graph, though the fact that you’ll need to set the Camera parameters to match the RealityKit scene view will make this very tricky (probably impossible in bounded mode, where you can’t even get the device transform). There’s some discussion of that approach in this thread.

Another possibility, if the mesh isn’t that big, would be to render the mesh again with the decal and use the VisionOS Sorting Group component to ensure that it renders on top of the base.

1 Like