0

I am making a 3D application for ios and Android.

Each object in the below image has a different material than others.

enter image description here

I want to make the part of object 3 that intersects with object 2 appears and the part that intersects with object 1 disappears.

Notes:

Object 3 is moving up and down.

The 3 objects have the same depth from the camera (same z).

Edric
  • 24,639
  • 13
  • 81
  • 91
MBS
  • 673
  • 2
  • 16
  • 48

1 Answers1

0

You will have to write your own shaders in Unity's ShaderLab using Cg/HLSL and use stencil buffers. Unity's manual gives you the basics, while a good practical introduction can be found here.

In short, stencils allow you to enable/disable rending in the clip space, based on reference values of other shader passes. A caveat is that the values are global and all shaders can read and write in the buffer, so you should carefully choose a reference value.

Dimitar
  • 4,402
  • 4
  • 31
  • 47