How to create a gradient material across an object's local z-axis? I can't figure out how to get this to work exactly, but I'm guessing I'll need Texture Coordinate and Mapping nodes.
I am trying to create a material that creates a gradient relative to an object's local z-axis. The idea would be that I could put this material on an object of arbitrary size, and the very bottom of the object might be red, and the very top might be green, with a gradient in between.
This is what I have so far, but the problem is that the material isn't relative to the mesh. If I put it on a smaller object, the whole thing might end up some yellow in the middle of the gradient, and if I put it on a larger object, I get a whole lot of red, a whole lot of green, and a tiny gradient in between.
Depending on what you’re looking for, you could get away with using Generated coordinates, which are normalized relative to the object’s bounding box: