Original Post
I’ve almost implemented cel shading using a vertex program. And while I am pleased with the results, when I applied a model outline, I lost all the nice cel shaded lighting. To better explain my issue, see the rendering and code snippet below:
The knight closest to the center has nice cel shading and lighting. The knight near the bottom edge has the outline applied and has lost all nice cel shading. Any ideas? If you require more code or additional information to resolve the issue, just ask. Thanks in advance. [Edited by - sjf on January 21, 2006 4:27:34 PM]
The knight closest to the center has nice cel shading and lighting. The knight near the bottom edge has the outline applied and has lost all nice cel shading.
/* Stencil one set of the checked tiles. */
...
/* Render the Reflections. */
...
/* Stencil all tiles. */
...
/* Render the checked floor. */
...
/* Render the shadows. */
...
...
/* Use the inverse model matrix to convert light position into model space. */
vector_ model_space_light_position = inverse_model_matrix * light_position;
/* Render the chess pieces. */
glBindTexture(GL_TEXTURE_1D, cel_brightness);
glEnable(GL_TEXTURE_1D);
glColor4f(0.75f, 0.95f, 1.0f, 1.0f);
vp->Bind();
vp->Enable();
vp->EnvParameter(0, model_space_light_position[x], model_space_light_position[y], model_space_light_position[z], model_space_light_position[w]);
RenderKnight(knight_x1, knight_z1, false);
RenderKnight(knight_x2, knight_z2, true);
glDisable(GL_TEXTURE_1D);
/* Outline the model. */
glLineWidth(3.0f);
glCullFace(GL_FRONT);
glColor4f(0.0f, 0.0f, 0.0f, 0.0f);
glPolygonMode(GL_BACK, GL_LINE);
RenderKnight(knight_x1, knight_z1, false);
glPolygonMode(GL_BACK, GL_FILL);
glCullFace(GL_BACK);
vp->Disable();
...
