Color faces based on world space normal I would like to be able to render a model/scene using the standard renderer (not game mode) where the color of each face/polygon is determined by its world-space normal. For example, looking at a cube from an angle where I can see the +x/+y/+z faces should render the faces with colours (255, 127, 127) / (127, 255, 127) / (127, 127, 255) respectively.

Importantly, moving the camera slightly should not change these colours (not screen-space normal based) and rotating the cube should change the colours (not object-space normals).

I've managed to create the effect by following this guide and writing my own fragment shader, but can't figure out how to use it during a standard render. Likewise I have found the normal output mode for material nodes but this only gives screen-space information.

I'm not too picky about the method as long as it can be used to generate animations and be reasonably automated.
You can do this in cycles using the Vector Transform node:



No matter how the object is rotated, the faces facing a particular direction are always the same color.

To map colors to the normals, you can use Separate and Combine RGB nodes to manipulate each channel individually: