Well, basically toon shading is another simple technique which you can be easily done in shader. (I mean a basic toon shading. If you want to do advanced toon shading, of cause it is difficult)
Since mostly toon shading gives you an unrealistic lighting. Basically it just has about 3 or 4 bands of lighting. So what you need to do is clamping the lighting value based on the look-up table.
What is the look-up table? Well, it just store the pre-defined value which you are going to use for the lighting clamping. Which mean, if your look-up table has only 3 values. You final result of the whole model (lighting) will only have 3 values as well.
For example:
The lighting value for that particular pixel is 0.4f, by using look-up table:
if (light > 0.8f)
light = 1.3f;
else if (light > 0.5)
light = 0.9f;
else
light = 0.5f;
From the pseudocode above, you can see that, no matter what value you get from the calculation, it will convert to either one of the 3 pre-defined values.
Here are some screenshots:
*Original model
*After applying toon shading (You can see that there are only 3 intensity level of light on the model)
*Toon shading with outline
If you wish to know more about toon shading, you can wiki it.
Key control:
1: Default model
2: Toon shading
3: Toon shading with black outline
4: Change the background color to white/black
No comments:
Post a Comment