Texture by Normals

How can I apply a texture ONLY to certain sections of a model who’s normals face vertically? I have a terrain model with flat sections and bumpy sections. I am using material nodes and I have two textures, grass and water, I want the water texture to only show up on the flat sections (facing up) and the grass to appear everywhere else. How can I do this?

Add a sun lamp pointing straight down on your scene, add it to its own light group, make a new material and have it exclusively linked to that light group, in the nodes have your grass and water nodes, and add the new light material node. Then add a color ramp node. Using a mix node, mix the grass and water materials using the new light group-assigned material as the factor plugin. Adjust the color ramp until you get what you’re looking for. Keep the black and white sliders as close together as possible.

The only problem with this method is that at the peaks of bumps you’ll still have normals facing up, and therefore you will get some material artifacts unless you add a second texture to control the maximum height at which there can be a water material. Attached is a .blend with an example scene setup. Hope this helps!


Actually, I’d have water as a separate object that you place in the terrain instead. Otherwise you would have to fiddle with trying to an ultra-sharp line between the water material and the transparent material and good luck trying to create some transparency without seeing the sky below the water line.

Also, using the lighting information in a normal way with the stencil material will fail if you use any kind of AO, which is why you would need the extended material node so you can use the diffuse output (which doesn’t take AO into account)

oh yeah, if it’s not absolutely imperative that you do it that way, the water should definitely just be a separate object.