Draw on area of contact

I have an object that goes through walls. however, just making it clip through it looks weird, so I want to add a black circle around the area where the object and the wall collide
151727-capturar.png

How would I go about doing that?

An easy way would be to add two projectors with a limited range on both ends of your object, pointed towards the center of the object. You can use a cookie as your effect texture.

This won’t work well in some settings though.


Another way is to use a shader using a depth test cleverly, and a stencil. Basically you have a flat-shaded capsule collider around your hand, that only displays if it is behind a wall.

The problem is that it will always render behind every wall, so you use another shader to limit this, by using a stencil to only allow rendering if the other shader has rendered on top of it.

You can do a lot of cool things like that:

https://forum.unity.com/threads/boolean-shader.161527/


You can do most of this using shader graph, without any code: