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:


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

enter image description here

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

enter image description here

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:

enter image description here

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

enter image description here

  • $\begingroup$ 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. $\endgroup$ – Rhys Feb 21 '14 at 3:16
  • 1
    $\begingroup$ 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 $\endgroup$ – Greg Zaal Feb 21 '14 at 7:38
  • $\begingroup$ 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. $\endgroup$ – Rhys Feb 21 '14 at 9:49
  • $\begingroup$ @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. $\endgroup$ – gandalf3 Feb 24 '14 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.