Cel-shading & actual lighting?

Started by
2 comments, last by Monder 19 years, 6 months ago
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.
Advertisement
Wouldn't that completly go against the whole concept of cell shading your characters, by creating smooth lighting on them?
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.
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 shadingOutColour.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]

This topic is closed to new replies.

Advertisement