Download

Trick for Masking off an object using ARKit

May be obvious but took me a bit to realize. We wanted to have a character walk from behind a wall using ARKit. We can detect the plane but needed to mask off the character. I would normally use a Depth-only write in a pre-pass to occlude the objects.

I couldn’t figure out a way to do this in UE4 for opaque materials. I could change them to transparent and use a post past or a stencil mask but then the objects render wrong in the transparent layer. They have complex shaders.

Hack solution is to apply the same screen space camera material to the object I want to use as a mask. Works a charm.

Hey thanks for the tip! Could you provide a simple example screenshot of how to set that material up?

I just used the ARCameraColorCorrected material that was included with the ARKit sample from Github. It is a bit complicated shader but similar to just applying the ARKitCamera Texture with screen coordinates as in this tutorial. https://youtube.com/watch?v=Z6FAl6v0ax0
The one included did some scaling of the texture to keep aspect ratio correct and color corrected from srgb to linear color.