Change color of part of object inside mesh

First time poster here so sorry if this is not in the correct category.
I have a complex bezier curve in blender using the Cycles engine that loops in and out of different mesh objects.
The curve has a simple diffuse material and the mesh would normally be invisible (or completely transparent). What I would look is for the parts of the curve that are inside a mesh to be a different color (say white outside, red inside) and preferably even for this to be a different color for different meshes. Notably I would like the parts of the curve that are behind the mesh (from the perspective of the camera) to be the normal. I understand that somethings like this can be achieved with a complex setup of boolean modifiers but I was hoping there was a more flexible way to do this.

Any help would be greatly appreciated!

Like this?
It won’t work quite correctly if the cubes overlap though. Nor have I been able to change the color per transparent object.

Thanks for the suggestion! I also tried something like this but indeed the problem is there is no way to get separate color per object. Also it just so happens my curve is already within one large transparent object so this trick wont work.Thanks again though!

Does the curve need to deform?

No I could also convert it to a mesh for instance

Well then! Dynamic paint should work!:grinning:

Im not familiar with dynamic paint. Is there a way to programatically use that to color parts of a mesh that are inside another mesh?

If by programmatically, you mean “in an animated fashion,” yes.
I’m not super great with it myself, but it is a very powerful tool.
Just search on youtube.
Here’s a starter:

Cool I will have to try that! Btw, in my session it seems like physics (and dynamic paint) is disabled? How do I turn that?

Oh yes, alt+C -> convert to mesh

Wait does this only work in the game engine?

It works independent from the render engine.

Im sorry I blame this on bad wikihow articles :wink:

1 Like

dyn paint.blend (524.1 KB)
This should work. Select plane, bake frames to folder, and open in plane’s material.
(fingers crossed)

That works :slight_smile: Im having trouble applying it to my example. Is it necessary to use it as a baked image sequence?

I would assume so, but I’m not certain how the vert method works.

Got it to work now but it only seems to paint the edges of the mesh “brush” not the inside. Any ideas?

Is the brush set to volume?

yes it is set to volume

So the brush is only painting where the faces intersect?

Just to make sure:

The converted curve is a canvas.

The mesh is a brush and is solid volumetricly as in no holes.