Say that I have a cube. I'd like for it to change into one of 5 colors: black, red, green, blue, or white depending on which direction the camera is facing towards it.

If the camera moves to face the cube's right side, for instance, it will turn green. The same concept applies with the other parts (front, back, and left), each color blending into the other. The cube then would default to white if the camera faces either the top or bottom.

See the gifs below:

The result I'd like Part 1 The result I'd like Part 2

The cube would be free to rotate on its own without having to worry about its color changing. It would only be the camera that would affect it.

How could that be done in Blender (specifically EEVEE) using nodes/drivers? I really don't want to use scripts if I can avoid them.


I should probably add that the closest I've gotten thus far is in separating the Incoming vector (from the Geometry node) into separate color channels, however it poses this issue:

Observe the Gradient

It's so irritatingly close to a solution, yet the lack of solid coloring renders it useless for my purposes.

  • $\begingroup$ You may find something here related to Camera Data "View Vector" blender.stackexchange.com/a/132840/111042 $\endgroup$
    – james_t
    Oct 26, 2021 at 20:14
  • $\begingroup$ @james_t Yeah, I was actually looking at that! However, I can't use it like I said in the edit. From what I can tell, vectors (and therefore nodes by association) aren't the way to go for something like this, as a gradient of that sort is an inevitability with them. Drivers seem to be the only way. $\endgroup$
    – Trasche
    Oct 26, 2021 at 20:30
  • 1
    $\begingroup$ No apology needed :) So the object could spin as much as it liked, but would always be red, say, if it was being looked at from positive world X direction? $\endgroup$
    – Robin Betts
    Oct 26, 2021 at 20:51
  • 1
    $\begingroup$ @RobinBetts That is correct! $\endgroup$
    – Trasche
    Oct 26, 2021 at 20:54
  • 1
    $\begingroup$ @RobinBetts After fiddling around with it for a bit longer, I noticed that if you have multiple objects in different areas, they all have different colors. I found one solution via attaching an empty to the camera and using its coordinates, but if there's a better way you can think of, feel free to let me know! Thanks again. $\endgroup$
    – Trasche
    Oct 27, 2021 at 2:50

1 Answer 1


The point (0,0,0), converted from Camera Space to World Space using a Vector Transform node, is the location of the camera in World Space.

If you subtract the object's World Space location from that, you get the WS vector from the object to the camera.

We're only interested in the direction of that vector, not its length, so we can Normalize that, and use the result to base the color of the object on the angle from which it is being viewed:

enter image description here

You commentary tells me you're interested only in the World Space orientation of the camera, regardless of the shaded object's location. That's simpler. You just have to get Vector Transform to convert the Camera-Space vector (0,0,-1) (its viewing axis,) to World Space:

enter image description here

The Gradient > Radial texture effectively converts XY coordinates to an angle mapped from 0 to 1. You may want to do the same for Z, and map that to a transition that suits you:

enter image description here

enter image description here


You must log in to answer this question.

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