Cell Shading in games?

Well, it's relatively easy to do with fragment shaders. The simplest way to do it is to have a few distinct levels of lighting (from pitch black to full bright) and detect which level a pixel's lighting belongs to. Then simply clamp it to the appropriate value. Edge detection is a little more complicated, though. . .
 
From what little info I know there are two ways of producing the black out line.

#1 is the way Sega does it, it attaches loads of polygons to the out side of the object/characters they are all transparent and are shaded black (or what ever you want) based on the edge detection (I've forgoted it's tecky name), anyway this is easy to see running in some cut scenes of Jet Set Radio when the camera is rotating around the characters.

#2 is the cheap way, you product the character or object and shaded them totally black, you then render another copy of the object over top but this time with textures, lighting etc. The second render is slightly smaller than the original and thus lease a perfect black out line aorund the edge. This effect weakness is that it works on only the out sides of the objects and can't over lay each other like in JSR.
 
Well, the way ATI does it in one of their demos is by using a two pass rendering technique. They first render the scene, depth buffer, the surface normals, and material IDs into separate buffers. The scene is just a normal render with full lighting. The depth buffer is self-explanatory. The surface normals is the scene without any textures or lighting; the colours on the objects represent the normal vectors. With the matrial IDs buffer each object and material is assigned a different colour -- no lighting. In the second pass all these buffers are taken as inputs. The depth buffer is examined for sudden, large changes in depth; the normal buffer is checked for sudden, large changes in the normal vectors; the material buffer is checked for places where the colours change. The places where these changes are detected are marked as edges.
 
A 'cheap' nice looking way of doing lines

Step 1) You Render your cell shaded model normally.

Step 2) Re-Render the model smooth scaled, coloured black with inverted the backface cull. If everything works correctly, you will get really nice looking lines around the polygon edges.

This method will draw black lines for all the edges bettween culled and non culled triangles.

BTW Smooth scaling works like this vert = vert + normal * factor;
 
Colourless said:
BTW Smooth scaling works like this vert = vert + normal * factor;
But that only works correctly for convex objects where the origin is inside the object in model space.
 
Back
Top