I'm trying to ray-march an SDF inside a RealityKit surface shader. For the SDF primitive to correctly render with other primitives, the depth of the fragment needs to be set according to the ray-surface intersection point. Is there a way to do that within a RealityKit surface shader? It seems the only values I can set are within surface::surface_properties.
If not, can an SDF still be rendered in RealityKit using ray-marching?
You can definitely do the raymarching part, but you’re right about there not being a way to output a custom depth value in a surface shader. If this is on a non-visionOS platform, you could try drawing your SDF in a full-screen post-processing pass with ARView’s PostProcessContext, which would give you access to the depth buffer produced by the rest of your scene to blend with as needed.