PDA

View Full Version : cel shading with glColor is that possible ?



wizzo
01-11-2004, 10:19 AM
Why do people render cel shading with texture binding or vertex program ? Isn't it possible to use the dot product between the light vector and the polygon normal as a grayscale value ?

Zeno
01-11-2004, 11:08 AM
What you're talking about is simply gourad shading....opengl's built-in per-vertex lighting model. This is different from what people typically think of as toon shading because it shows a smooth gradient of color.

The typical method of doing toon shading is to use the result from that dot product you were talking about to look up a small (2-8 texels) 1-d texture with nearest filtering. It's the nearest filtering that prevents smooth interpolation and makes it look toon shaded. You can't do that with plain vertex lighting.

[This message has been edited by Zeno (edited 01-11-2004).]

jwatte
01-11-2004, 02:43 PM
However, you CAN get toon shading using plain 2-unit non-shader hardware. The trick is to use GL_NORMAL_MAP TexGen mode for diffuse lighting, indexing into your toon texture (cube map for per-pixel look; 1D NEAREST map for per-vertex look). You can also get specular highlight using REFLECTION_MAP and a similar cel-map texture.

To orient the reflections and normals WRT the light source, use the texture matrix.