 |
Step
1
Reference.
Anyone
who has held a frog in their hand can tell you that a frog's skin
is rough and scaley on the back, but smooth and leathery on their
belly. Creating a procedural shader which can automatically "detect"
what part of the body it is currently shading, and adjust accordingly
is a very powerful technique which can be used in many shaders.
This tutorial will show you one method of doing this. You will also
learn a simple technique which quickly simulates the effects of
ambient occlusion in displaced geometry. |
| 
|
Step
2
Surface Normals.
How can
we create a shader that automatically changes from hard and scaly
on the top to soft and leathery on the bottom? Simple. We use the
Surface_Angle node. This returns the x, y or z component of N (the
surface normal). |
 |
Step
3
How it works.
If we
just use the y component of the surface normal (Ny), we get a value
that varies from 1 at the top, to 0 on the side and -1 on the bottom.
This is almost exactly what we need. |
 |
Step
4
A little math (very little).
We don't
want the scales to start tapering off right away. We want them to
be very scaley across all of the top and part of the side, with
just a little tapering at the end. To do this, we simply multiply
Ny by three. Then, to prevent our value from going outside of the
0-1 range, we clamp the result. That wasn't too bad, was it? |
 |
Step
5
A simple shader network.
The image
at left shows a shader network that implements the ideas discussed
so far (click image to enlarge). We are simply using a scaled, clamped
Ny to blend between green (Ny >= 1) and blue (Ny <= 0). |
 |
Step
6
Displacement.
Now we
can take what we have learned so far and build a displacement shader
that creates the scales. Click on the image at left to enlarge. |
 |
Step
7
Skin.
The shader
so far is using a simple diffuse model. Real skin reflects light
much differently than this simple model can reproduce (see this
paper for details). Fortunately we have provided a shader node
which was designed to render skin. Oddly enough, it is called "skin".
The image at left shows the effects of replacing the clay node from
the shader above, with a skin node. |
 |
Step
8
Coloring the skin.
The first
thing we will do is change the color of the skin to match the change
in texture. The scales will be a dark green, while the underbelly
will be a light tan. Click on the image at left to enlarge. |
 |
Step
9
Simulating ambient
occlusion.
We can
use the same procedural function that was used to displace the surface
to simulate the effects of ambient occlusion. Basically, deep cracks
in the surface will receive less ambient light. In this shader,
we have to use another blender node to taper this effect off as
the surface wraps around to the belly. Click on the image at left
to enlarge. |
 |
Step
10
Tweak the shader.
To give
the skin a little more "glow", I increased kd to 2.0 and
ks to 1.5. |