# Cycles texture mapping, generated coordinates with world orientation?

Basically I want to map a texture in cycles with the generated coordinates, but have it ignore the orientation of the object.

The effect I want to achieve is a material that has a gradient, spread top to bottom of the individual objects dimensions, but always orientated top to bottom of the world no-matter how the object is rotated.

Any way to achieve this? thanks

Yes, this is possible.

There are several ways to achieve this, here are a couple:

## Position:

You can use the Position output of the Geometry node and separate out the blue (vertical) channel:

Note that since it's based on the world center some objects end up with values outside the 0-1 range:

## Texture Coordinate:

You can also use the Object or the Generated output of the Texture coordinate node and convert it to world space with the Vector Transform node:

Now each object will have a gradient from 1 at the top to 0 at the bottom regardless of rotation:

• Hmm, almost, but it is not quite right, see the gradient is not spread all the way. Black should only be at the very bottom of the object. – Rhys Feb 21 '14 at 3:16
• Just add 1.0 to the gradient, and multiply by 0.5. That'll move it to the bottom and then spread it back up to reach the top – Greg Zaal Feb 21 '14 at 7:38
• It's not taking into consideration the actual bounds of the mesh, this is a gradient around the origin of the object that spreads from 0 to 1 on the world Z axis starting from the object origin. For example just move the mesh in edit mode away from the object center. – Rhys Feb 21 '14 at 9:49
• @Rhys It's possible if you know the dimensions of the object, but the dimension data blender stores in object.dimensions is based on the origin, so even if you use a driver to get the Z dimension into the node editor you still need to center the origin. – gandalf3 Feb 24 '14 at 8:02