Free Web Site - Free Web Space and Site Hosting - Web Hosting - Internet Store and Ecommerce Solution Provider - High Speed Internet
Search the Web
TOON SHADERS: AN EXPLANATION AND HOW TO

 

Home Page

Whats New Page

Life in California

Animation Houses in Toronto

Edit Arcanum Save Games

Mel Scripts

Tutorials

Recipes

Usefull Links  

TOON SHADERS MADE SIMPLE

 

You can get this script and other of my items on TurboSquid:

<=- click to enlarge

 

I understand there are a lot of people at different levels of knowledge. This explanation is based on limited knowledge of 3D software, and focuses it’s examples on maya. I hesitate to call this advanced or even intermediate, but you do require a knowledge of 3D software. Let’s begin.

 

Explanation of a toon shader: What is it?

 

A toon shader is a shading technique used to draw an outline around your object and flatten it. How that is calculated? The software generally compares the normal from the camera to the normals from the objects being rendered. [A normal being a line drawn perpendicular from the face of the object in question.]

 

Working with the normals, it is possible to calculate a ratio of how a particular object normal differs from the camera normal. Using a dot product calculation, the ratio can become a 0 to 1 range.

 

Using this range, one can then specify that an outline should be rendered in the desired area. That is, we could set up a render to draw a black line between numbers ranging from 0 to 0.4 in our example image, to get a thick line in that area. Using that example, our results would look like this:

 

 

 

Create your own toon shader: How-to? (maya)

 

If you want to create a toon shader using your new found knowledge, the simple way, you can use my mel script. The beauty of this script is it will create an interface to control your shading network, but leave the network visible. The benefit of that is you can pick apart the network and understand how it is functioning.

You can get this script and other of my items on TurboSquid:

 

Ok, let’s create a simpler version than the tweaked out one generated from the script by ourselves:

 

1.     Launch Maya and create your surface for use, don’t forget to throw in a few lights for test rendering.

2.     Start your surfacing of the object with a surface shader and assign it to your object.

3.     Create a lambert. This will act as the ink outline, so set it to black.

4.     Create a condition utility. Link your lambert out colour rgb to the colour 2 rgb in the condition. Link your condition out colour to your surface shader out colour. Set the condition to greater than. The second term will be our line thickness ratio, let’s try 0.4 as in the above explanations.

5.     Create a sampler info utility. Link your sampler info’s facing ratio to the first term of the condition.

6.     Create a blinn.

7.     Create a clamp utility. Link your blinn out colour to the input of the clamp. Set all min values to 0 on the clamp, while its’ max values go to 1,0,0. This allows us todetermine where to put the shadows and highlights, while clamping them to a value range between 0 and 1.

8.     Create a ramp. Set the ramp to V Ramp with smooth interpolation. Remove one colour so you only have two. The ramp will be the paint colours. The top being the brightest colour, and the bottom being where the paint falls into shadow but is not yet outlined with black. Set up your two colours appropriately, stacking them fairly close together (eg. at 0.385 and 0.190).

9.     Connect the clamp output R to the vCoord of the ramp, to drive the highlighting area appropriately.

10. Connect the out colour of the ramp to the colour 1 rgb of the condition.

 

At this point, you have created a rudimentary toon shader. However, for more options and a better overall render, it is advised to use the above mentioned script and tweak it for your scene. Again, you can find my script at: http://www.highend3d.com/maya/shaders/ - 1545

 

 

 

Some Quick Examples:

<=- click to enlarge

 

<=- click to enlarge

 

==========================================================================================================================

 

 

Author: TJ Galda, © 2002 All rights reserved.

Author takes no responsibility for any use of this document whatsoever.

 

 

 


Get a GoStats hit counter