O'Reilly logo

Developing AR Games for iOS and Android by Dominic Cushnan, Hassan EL Habbak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mask shader

We are mostly done with the game. We have the behavior of all our objects in place and are ready for deployment; but we are missing one last thing. We might have noticed that when the moles go underground, they are still visible from the side angle. This will be apparent as well when deploying the app to the device in AR environment. There is an easy solution we can do to hide those moles when they go underground in an AR environment, which is using a depth mask shader.

  1. Add the shader asset named DepthMask.shader, which can be found in the chapter's assets. Then, we want to create a cube in our scene that will be as big as the ground plane and name it mask, and hide all the moles behind it, as shown in the following screenshot. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required