Jump to content
  • Advertisement
Sign in to follow this  
sjf

Cel shading [SOLVED]

This topic is 4506 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.
/* 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();
...


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]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Cel shading is the shiznast.

Share this post


Link to post
Share on other sites
Only thing I can think of is that the lighting is thinking that it needs to apply the black outline in its shading process. Maybe try rendering the object first, then render the outline afterwards. You know, that multipass render technique. ;)

Oh! When you render the outline, disable lighting. That might help.

Share this post


Link to post
Share on other sites
Thanks, that makes good sense. After a good night's sleep, I relised that I had one of my inverse_model_matrix's 180 degrees out of phase.

Here's the result:



Thanks to everyone who helped.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!