« Water Shader | Main | Wiggle Shader »
Wednesday
Jan162013

Z-up shader

this is a simple one, and there's a video on it here: http://www.youtube.com/watch?v=lH6SIFQ0ROE

this tutorial is pretty much that exact video, I made this shader by following it so the credit is the video's creator.

basically whatever surfaces of the mesh are facing "up" get one texture and the rest another, this is great for snow, moss or sand.

here's some break downs myself:

This shows the connections for the shader.  At 73 instructions it's not too expensive.

very simple tiling controls, just one for each set of textures.

using the tiling controls to alter the UV's of the two texture sets, the base diffuse texture is the one that needs to mask out nicely.  The base goes into the first slot on the first lerp, and the top texture going into the second slot and then uses a procedural alpha created by the other nodes. using the blue channel of the base diffuse allows for the top texture to speckle out rather than just feathering.  The last lerp gets it's alpha from the normal direction calculations at the bottom of the shader.

this chunk is just plugging in the blending calculations with the spec and spec power.

the two normal maps with the tiling controls in their UV's being lerped by the z up controls.

this one is what makes the shader tick, this calculates the normals of the object in the world, telling the shader what is "up" based on the color parameter.  the final constant clamp (0 min, 1 max) plugs into the final lerps for each of the other chunks as their alpha. I would also like to point out that the color parameters channels of RGBA correspond to XYZ(alpha does not do anything I think).

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>