As the title says. I am developing an app for IOS 18, which involves adding a building relatively far away from the user's place (around 10-20m.), and I need to building to show contact shadows with the floor for added realism.
Now, I know that RealityKit has automatic contact shadows using GroundingShadowComponent, but this only works if the object is placed in a plane that has been detected by ARKit... and ARKIt doesn't detect floors so far away, so I need to add my own shadows: add an invisible plane acting as a floor below my building, and have it receive shadows and show only the shadows.
The problem is that, from what I see, RealityKit has no materials that can do this:
-
UnlitMaterialignores all lighting, including shadows. -
SimpleMaterialdoes display the shadows, but the floor is displayed too. I can make the material almost transparent (setting the opacity to 0.01 or something), but the floor is still visible. -
OcclusionMaterialwithreceiveDynamicLightingis a solution, but it doesn't work either. If I declare it usingOcclusionMaterial(receivesDynamicLighting: true),all I get is an invisible plane with no contact shadows in it.
What do other people do for this? Do people just bake in the contact shadows in the 3D model?