![]() |
![]() |



Submitted by: rikh
Date Submitted: 2003-11-09 18:12:03
Downloads: textures.zip
textures/toonshade
{
{
tex map textures/colourgrad
rgbsrc white
texsrc toon
tex clamp
tex no_mipmap
}
}
textures/toonink
{
vertexmod pulse square 0.010 0.000 0.000 1.000
cull front
sort 9.000
{
tex map white
rgbsrc constant 0.000 0.000 0.000
}
}

This effect makes use of 2 shaders to create a cartoon rendering effect. The first shader deals with the coloured interior of the model and the second shader deals with the black inking for the outline of the model.
The interior is rendered using the toon texture coordinate generation function and a special texture. If you want to be able to colour different parts of your model differently, you might want to consider changing the texture to contain a greyscale gradient and set the model vertex colours to what you want (you should also change the rgbsrc command to one that selects the vertex colours in the model). The clamp command is needed to stop the dark side of the model appearing to get brighter again.
The outline is created using a second shader (so you would need to draw the model twice, using the shader override feature in cipher). The first thing it does is to expand the model outwards a little. This will make it slightly bigger than the original model. If you drew this bigger version of the model first, and then draw the slightly smaller coloured version of the model over the top of it, you will be left with a thin outline. You may need to adjust the amount that the model is expanded by to something appropriate to your coordinate system.
Because of the Z buffer, there is no need to draw this version first and then draw the coloured version of the top though. In this example, we only draw the triangles that are facing away from the camera (ie, those faces around the back of the model). The sort command has been added to ensure it is rendered after the main model, but this is only to increase performance (most of this outline model won't be visible in the final image, so we can take advantage of the z buffer here to speed things up a bit).
Finally we get to the bit that controls how to draw the model. This is very simple. We just draw the entire thing in solid black.
When the two effects are combined, the result in a toon shaded model, with a black outline.
Note: It is also possible to create an outline using a second pass on the first shader using a different method, though I don't feel it looks as good.
[Recent Contributions] [Recent Shaders]
User Contributed Comments