Nodes: Color to global Z-Normal?

Ad salutem, I have a Question.
With Material Nodes I want to color a Material according to how much the Face’s Normal (in Global Coords, not View Coords) is directed upwards on the Z-Axis.
Probably it is a simple Thing but neither is my Understanding of Vectors good enough nor did trying around bring me very far. :confused:
Thanks in Advance.

something like this?
z-coloring.blend (896 KB)

Thanks but no, not really: Your Example colors it according to the global Coords like in »where it is« though what I am looking for is a »which Direction does it point to«. So, a usual z-directed Plane would be affected, turning it around so it would point to c or y would decrease the Affection – like being lit by a top-down-directed Sunlight, only with nodal Color instead of Lighting. (Explaining it makes it sound really weird somehow. o_O )

Do you mean something as described in this video?

No, the Technique in that Video is about View-based Normals, which is how the Geometry-Node »Normal« usually works.
Here, this Time I will actually show a Picture that will of Course not impress anyone: A Sunlight directed downwards and changing the Object’s Appearance so that the more the Material is oriented upwards (i.e. towards the Sunlight) the Shader changes its Appearance. Now, I don’t need a Light, I need simple plain Color (or a Kind of Mask) on a Material.


To make it clear: I am trying to make a Snow-Shader in the Node Editor. Crysis has had a Snow Shader, UDK can do it too as I have seen in a Video, and for BGE it would be no Problem to have such too, at Least in the simple Form of a Material changing into a Snow-Material but only the Parts that are oriented upwards – after all, Snow does not come from below.

If you figure out how to get a world space normal, you will simply need a dot product with that world space normal and the vector (0, 0, 1). However, I do not know how to get a world space normal in the node editor.

I see, you want to do it for a land shader!
You can have the normals as Vector((x,y,z)), where 90º= pi/2.
Now if you get the normal you just need to set conditions: x and y should be close to 0.
So maybe you can set your limit values between 0 and pi/8.
I hope it was clear!
@ Monster, Nice vid, the cos A will make my life easier!

@ torakunsama:
I am confûûûsed! @_@ Though it sounds rather like mathematical Theory – would it be directly translatable to the Node Editor? Writing a custom Shader is little to no Option if Lights can’t affect it. :confused:

@ Kupoman:
Don’t make me lose Hope! D:

Actually, if Normals are handled in View Space, then wouldn’t the Normals MINUS View Space (like subtracting Normals-Vector with View-Vector??) have to neutralize the Viewspace-Factor and make the Normals »stablilized« against the View Vector? I know, the Result totally does not do that (rather like a cross-shaped Rim-Shader…), but wouldn’t the Thought go somewhere the right Direction? (Well, I really am not a Pro on Vectors, so Woe is mine if the Idea is flawed.)

You can’t subtract a vector from a matrix ;).

You can transform local space coordinates (vector) into world space coordinates (vector) and back.

You need the transformation (matrix) and multiply it with the vector.

localVector = transformation * worldVector

To do it the other way around you multiply the inverted transformation matrix with the vector.

worldVector = invertedTransformation * localVector

I do not know how to apply this to shaders or materials.

(Transformation = Pos/Rot/Scale in one matrix)