Draw prop only if it is in front of entity

I have been searching for proper stencil tutorials and none of them are really that comprehendable. I would like some help figuring out how to use stencils to only draw an entity’s model if the entity is behind a certain prop.


Basically, what would be a quick way to only draw the blue barrel if it is covered by the PHX plate?

Think about it logically. Draw the barrel first and assign a reference value to each pixel. Draw the phx prop second and increment the changes pixels. If the reference value has changed then draw it, if not don’t. I can’t write this up any better from my phone ^^

I’ve read the tutorials about stencils and I really don’t know what you mean by set the reference value. Do I just pick a random number? How am I supposed to know what number to put there?