Jump to content
  • Advertisement
Sign in to follow this  
Gamble007

OpenGL Cel-shading & actual lighting?

This topic is 5040 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

Ok, I'm hoping someone can help out with this question... My team and I are currently developing a game in OpenGL that we hope to cel-shade. Now, from what I understand, lighting has to be disabled in order to do this and you then use a light vector to simulate lighting from a particular direction in order to create the shading. My question is, can you somehow get "actual" lighting to work on cel-shaded models? The scenario that we're considering is having a spotlight moving across cel-shaded models or maybe characters walking underneath a streetlight with a spotlight projecting downward. Any help or advice would be greatly appreciated.

Share this post


Link to post
Share on other sites
Advertisement
Wouldn't that completly go against the whole concept of cell shading your characters, by creating smooth lighting on them?

Share this post


Link to post
Share on other sites
Well, it IS possible, but only if you want to have every single object on the screen celshaded and untextured.
You can use gammaramp to divide the colors into 2-3 different intensities, but that affects the whole screen.
Just do it using shaders instead.

Share this post


Link to post
Share on other sites
Shaders are the way to go. One way to do cel-shading within shaders is to create your normal lighting shader, only intead of directly outputing the RGB triplet you get you use each component of it to look up a 1d texture, this texture is basically a gradient only it's only a few blocks of colour, i.e. you may have 4 or 5 blocks in it going from black to white. You then use the value looked from this 1d-texture as the final value for one of the components in the output colour. E.g something like this:


//calculate lighting as normal for this fragment
//ending up with a colour LightColour that you
//would directly output if not cel shading

OutColour.R = Tex1D(CelTex, LightColour.R);
OutColour.G = Tex1D(CelTex, LightColour.G);
OutColour.B = Tex1D(CelTex, LightColour.B);

//OutColour now contains the final colour to
//output from the fragment shader


Doing it this way basically allows you to do lighting however you want and have it in a cel-shading style.

[edit]Actually I'm not so sure how good it would look doing it this way, another (very similar) way is apply the same technique but to the diffuse and specular intensity terms (i.e. n dot l and n dot h respectively) instead (so you'd calculate the value as normal then use it to lookup into a texture to get a different value which is the one you'd actually use) [/edit]

[Edited by - Monder on October 3, 2004 12:59:23 PM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!