Colour by height (linear interpolation!)?

Hi,
So basically, I’m trying to make a heightmap from some terrain that I’ve made in blender - I’m planning on using the heightmap for a game I’m making in Unity3d. In blender, its just a mesh thing, so to make the heightmap I’m trying to render it from above with an orthographic camera, but I need some sort of material that will make the highest points of the mesh render white, the lowest points black, and everything in between like fade between them if you get what I mean. Now, I managed to do this using some nodes and stuff, but the gradient of black to white that it made wasn’t linear. To do some tests I made a cube with this material, and rendered it from the side, so you can see the gradient, which should be linear:



I’m really inexperienced with nodes, so I don’t entirely know what I’m doing… Here is the nodes thing I made:


So the idea was that I’d get the position from the geometry thing, but then I needed a way of getting just the z height from that. For some reason, it seemed that the seperate rgb worked… sortof… Then the multiply I put in so I could change how big a height the gradient would fade over. Anyway, it didn’t work - with this material, the gradient seems to fade to black really suddenly…

Well, basically, if anyone has any idea how to made a material that would do this but with a linear gradient instead of whatever I’ve managed to create that would be like super crazy awesome very muchness. I don’t know if this makes any difference, but I’m using blender render atm.

Thanks,
James


Maybe this allows to get there. At least you can tweak it more.

Thanks! It works perfectly now! :slight_smile: