Fixed function cell shading with positional lights

Started by
-1 comments, last by Clapfoot 16 years, 6 months ago
Hi, I've implemented cell shading with directional lighting by using the technique described in this article (http://www.gamedev.net/reference/programming/features/celshading/). As described in the article, I take the dot product of the vertex normal (transformed by modelview matrx) and the light vector and use it as the 1D texture coordinate for the vertex. This works fine, but for faces where all vertex normals are pointing in the same direction, the face will have a uniform colour throughout (vs. having cell shaded gradiants). Now I believe that by using positional lights, I can get better results. I've been doing the following additional steps per frame: 1) Create a light vector by subtracing the vertex position from the light position. 2) Multiply the current modelview matrix (using glGet(GL_MODELVIEW_MATRIX)) with the light vector. 3) Normalize the light vector. 4) Take dot product of light vector and normalized vertex normal and use it as 1D texture coordinate. For some reason, the image doesn't look correct. Is there anything obviously missing from the technique described above? Thanks!

This topic is closed to new replies.

Advertisement