I’m working for an architecture project(an academic project, btw), and I have this mesh of a terrain modeled(I did it in rhino and exported it as a Wavefront file to Blender). I was trying to accomplish the following feats: have a shader tell me which parts of the terrain are higher, and have a shader tell me which parts of the terrain have a higher slope.
The first one I kinda accomplished using a Blend texture mapped to the Z channel. I was thinking if anyone here has an idea of how to accomplish the second?
yes, CD(?) or LOTRJ(?) did this already. Search for for terrain slope, something like that in these forums. I’m a visual guy…and it was an image of a mountain and valley, and he was able to map certain textures based on slope (normal angle) and height.
If you float the camera above the terrain looking down, your Z will give you inverse height
Cyborg Dragon started the thread and did some awesome work that looked really good but ended up actually being camera dependent.
In the end, I found the forehead slapping answer on CGTalk. Basically, you can create a special material that is lit in a special way by a special light, and the color of that material will be the slope of your object. Typically then, that material would be used in a texture node setup to control the blending of other materials.
The special setup is this.
Create a pure white, 1.0 intensity sunlamp shining straight down. Create a new material set to take shading from that lamp only by using lighting groups, also setting ‘Exclusive’ so that the sunlamp doesn’t interfere with your other lighting. Set the material’s spec to 0.0, and diffuse to 1.0 and color to pure white. Now any geometry that is vertical is colored black, and any that is horizontal is colored white.
Wow, belated thanks to you both. I forgot about this thread as work swallowed me, as I finally solved the thing by not using a shader. Instead, I used normals: I created a simple “arrow” and duplifaced it on the terrain mesh. When shot from above, without perspective, faces that are horizontal show only a cross, while faces that are more vertical show arrows of different lenghts, which tells me the relative intensity of the slope, and the different directions it follows.
Nevertheless, I’m sure the methods you pointed to will prove useful. Thanks!