Animate the color mixing of separate texture images

I have two boxes one red and one blue


I can mix the color of these textures together into a separate box using a Mix RGB node and I get the correct color (magenta).


But when I try and animate the overlap of the two separate boxes the colors don't overlap to produce magenta how can I do this?


The idea is to import two separate textures images with several colors (could be hundreds of different colors) in a grid form and animate them overlapping / rotating while the colors are correctly combining and changing and export this animation Note: the textures imported will be different.


Texture image 1:


Texture image 2:


  • 3
    $\begingroup$ Your technique won't work because of Z fighting, you'll have some artifacts. You could render each object on a different view layer and composite them in post using their mask as a mixing factor. Do you need it in realtime ? $\endgroup$
    – Gorgious
    Jul 8, 2021 at 9:23
  • $\begingroup$ @Gorgious no it doesn't need to be in real time, I was hoping for a quick preview than render a full animation afterwards. I'm not sure what "Z fighting" is. $\endgroup$
    – Rick T
    Jul 8, 2021 at 13:28

2 Answers 2


But when I try and animate the overlap of the two separate boxes the colors don't overlap to produce magenta

They actually do:

Just not in the way you expect. The overlapping faces are on the same plane, that is, the algorithm that calculates (and saves to z-buffer) which of those faces is closer will get either blue or red cube depending on the rounding errors caused by limited float variable precision. Sometimes that error will favor the red cube, and sometimes the blue cube. Camera perspective is part of the calculation and therefore affects the error - this is why moving the camera changes which cube is visible at a given point. This phenomenon is called z-fighting.

Gorgious made a great suggestion with compositing, but in your particular case you could achieve the effect (and realtime preview!) with a few simple hacks: adding a minimal solidify to one cube, let's say the right one, so that now it's overlayed on top of the other cube. On the same cube (right, red in your example) change the Alpha Mode to Blend in the material and use this node setup:

(notice how it's the right cube but it uses Left cube's coordinates to calculate alpha)

  • $\begingroup$ Could be done without solidify with a little bit more elaborate setup 🤔 basically mixing both image textures on each cube, so that z-fighting doesn't matter. But it would still only work in limited scenarios like this one, while compositing will work always. $\endgroup$ Jul 8, 2021 at 21:21
  • $\begingroup$ That is, compositing will make the face marked red visible behind the right cube i.imgur.com/Azigqx4.png $\endgroup$ Jul 8, 2021 at 22:52

You can achieve an effect like this...

...using this node setup:

It can be simplified if you only care about the 3 sides visible to the camera:

Or you could make separate groups and only mix them based on normal.

Now that you can display the left cube's texture on the right cube, you can also display your own texture instead - if you're outside of the left cube:

No z-fighting, but no overlay yet - because the mix alternates 1/0, it needs to alternate .5/0:

Now you get z-fighting back, though a little less visible - you still have to duplicate the node setup on the other cube and flip left/right textures (remember to make a single user copy of the group node before modifying it) and change the Less Than 1 to Greater Than -1. Then you're finally done:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .