Hide out of sight units : stencil or distance Field ?

Wokay :slight_smile:

So, I make a service that is run by the AI of the foes.
This way, the calculus of the distance from a foes to an ally unit is repartited in time and every foes doesn’t perform the check at the same time.
The enemy units are hidden if they are outside the bubble but I had a little offset to the radius of the bubble for the ants to appear before they are inside the sphere and disappear after they’re out.

I also use the already existing distance field of the bubble to build an opacity mask in the foe’s material, witch is masked.

It works perfectly and smoothly !

I certainly can remove the shadow of the enemies when they are visible but outside the sphere but in fact, when I saw this, I was very happy with this unwanted effect :slight_smile:
It’s like the Martian can detect a presence a bit before seeing it for real… Or when the foe get out the sphere, we still see his shadow for a small time and it’s pretty cool !

My enemies have a masked material… but the impact on the render time is not so bad… Inside the sphere, they are fully opaque and doesn’t affect the shader complexity. When they are far enough, they are hidden.
portee_preview_complexity.jpg

They have a non 1 opacity only in the small zone around the sphere. It’s a good deal for me :slight_smile:

I still have to make the fancy effect at the intersection of the enemy and the bubble ! Let’s go ^^

Thank a lot for all your advises.