How to change material color based on intersection

Hello everyone.

I have a situation where cars go through detection area.

I want that detection area to change color when any car is in it (car object is intersecting with detection object), and change back when there is no car in it.
I could animate this by hand, but I am looking for an automated/rigged solution since there is a lot of cars and a lot of detection areas.

Cars are animated by keyframes on path.

Thanks :slight_smile:

1 Like

I’m interested in this too , ive seen that dynamic paint can do it but i’m looking for a real time solution witout the need to bake

I tried to construct it but without succes - In the end I did it by hand (keyframing it) , wasn’t as hard as I thought.

But I would be happy to now if this can be done without keyframing.

regards.

Done perfectly, with any type of (manifold) mesh? Duplicate the car. Make the duplicate non-rendering. Give it a boolean modifier with the detection zone (intersection). Create a pair of empties at the same location as each other, someplace out of the way of the detector. Shrinkwrap one of them to your duplicate.

If there is no intersection, the shrinkwrap won’t do anything, and the empties will stay in the same location, which you can tell by looking for a difference in object coordinates from each empty. If there is an intersection, one of the empties will move, and you can light up the detection zone:

Take a look at data transfer mod.

Wow - looks really nice but I assume that I would need separate material for every car ( car are different meshes - but the same material) for detection to work, so I could feed the particular mesh of particular car into the texture coordinate node - am I right?

Maybe a picture of what you want to acheive would help.
If the detection area shape is complex, a detection or boolean trick will be needed. But if it’s a cube or a sphere, a simple driver with a distance property would fit.
Also, it’s not clear what you want when you say :

Do you mean that only the detection object changes its color (and not the car) or do you mean the part of the car inside the detection changes it’s color ?

See you :slight_smile: ++
Tricotou

To do it that way, with multiple cars, you need a non-rendering duplicate mesh for each car, but not a new material-- you look at multiple empties and do some OR logic (which is just a clamped math/add.) The object coordinates are not from the cars in that example, because that wouldn’t give you mesh intersection like you wanted, but from empties that shrinkwrap to the cars if and only if the cars are inside the detection zone.

Here is what I did with keyframing:

Ok then, as it’s a very simple shape, you can totaly do it with drivers.
Create an inpue Value node, and add a driver to it.


Here is a simple example :

Screenshot%20from%202019-10-21%2011-48-29


See you :slight_smile: ++
Tricotou