Scenario
I'm trying to get meshes to inherit color from other meshes that are in physically in front
example:
Mesh A Mesh B Camera
(white) (red)
+---+ |\
[] | | << | ]
+---+ |/
I don't want Mesh B to be visible at all BUT I want Mesh A to be red where Mesh B would be blocking the view of Mesh A. All I can think of is that this is a kind of color overlay.
Prototype
I made a three.js prototype where two planes are partially blocking the view of a white sphere. I want to be able to turn the plans into a color overlay so that the sphere shows red, white, and blue (accidental usa flag colors)
Question
Is there a way to do this with THREE? I'm not fixed to this way of doing things but it seems possible, I just haven't come across the right documentation yet.
You could set the blending mode of each plane's material to
blending: THREE.MultiplyBlending
, so the plane's color is multiplied with items behind it.See it in action here.
However, if you want it to apply to only the parts where the plane and the sphere overlap, you'd need to write a custom post-processing pass that knocks out the background. Or you could set the background color to
#000
, since multiplying any color by black yields black.