Wanna know how I made this toon shader? Read on…
Toon Shader Basics
If you know the basics of a toon shader in Maya, feel free to skip ahead to Building Moom’s Shader.
A simple toon shader in Maya is a surface shader fed by a ramp containing two colors: The fill and the outline. This ramp isn’t driven by a regular texture placement node, but rather a SamplerInfo node.
Basic toon shader network (click to enlarge)
The SamplerInfo node has many useful properties, one of which is called facing ratio. This property indicates how directly a point on the object being rendered faces the camera. Here’s a definition from the Maya help files:
Facing Ratio gives you a number between 0 and 1 that tells you if the point being sampled is facing towards or away from the camera. A value of 1 means that it is facing the camera head-on. A value of 0 means that is is facing 90 degrees from the camera.
In a toon shader, the facing ratio of the SamplerInfo node is used to pick the color from the shading ramp. A point along the object’s edge is turned 90 degrees away from the camera, so its facing ratio = 0 and it gets the outline color. A point directly facing the camera has a facing ratio = 1, so it gets the fill color.
Basic toon shading ramp (click to enlarge)
Moom’s shader is built around this same basic structure, but adds a few bells and whistles along the way. Let’s take a look!
Building Moom’s Shader
In a nutshell, Moom’s shader is made from a soft, custom toon shader multiplied with a painted texture.
The complete shader network (click to enlarge)
Part A: The painted texture
The only reason I had to paint a texture here was to turn the inside of the mouth black, darken his lips and the soles of his feet. I felt it needed that contrast. Here’s the texture, superimposed on his UVs. Very basic, as you can see.
Painted body texture (click to enlarge)
Part B: The procedural shading network
The “soft toon shader” I mentioned earlier builds on the simple toon shader concept, but with a few interesting tricks. For one thing, instead of a hard toon line, I have a soft gradient on the shading ramp.
Final shading ramp
Since this part will be multiplied with the painted texture, most of this ramp is white. The multiply node in Maya works pretty much like the blending mode in Photoshop. Any color multiplied with white stays the same, so where this ramp is white, the final shader will look just like the painted texture. Where this ramp has color, the painted texture will get darkened and shaded by it.
Which brings us to the last part: How do I decide which color to pick from the shading ramp?
I’m doing this in two ways: With a SamplerInfo node, and with a little procedural NPR (Non Photo Realistic) network I built. Then I average the result of these two to get the final look (More on that in a bit).
We’ve already seen what the samplerinfo does; so I’ll just talk about what the procedural network is doing here.
The procedural shading network (click to enlarge)
It starts with a regular shiny Phong shader with a fractal bump map on it. The bump map’s job is to break up the shading and make it look rougher. It won’t really end up looking like a bump, as you’ll see.
The output of the Phong shader is clamped to a number between 0 and 1. Without getting technical about the clamp, I can say that I’m using it like “auto levels” in Photoshop: the lightest part of the shader is forced to become 1 (think of it as white), and the darkest part is forced to become 0 (black).
In effect, the clamp reduces the shading of my bumpy, shiny phong network to a simple number between 0 and 1. The samplerinfo node also provides me with the facing ratio which ranges from 0 to 1. The final trick here is to use the average of these two numbers to drive my shading ramp.
The Average Trick
While creating this shader, I first tried each of the two approaches by itself. The SamplerInfo node — which responds only to the facing angle — gave me a nice clean toon outline, but the result looked too flat and bland. On the other hand, the procedural network I made — which responds to the light in the scene — had some good rough texture, but its result looked too typically CG; too hard and plastic. By averaging both of these, I got the best of both worlds. See the images below.
And that’s how it works! If you have any questions or suggestions, please leave me a comment. If you try out this shader on your projects, please share the results! I’d love to see what you come up with.
Other posts in this series:
Behind the ‘toons, part 1: Backgrounds