Archived

This topic is now archived and is closed to further replies.

[cel shading]how is mapped the 1d texture ?

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

Recommended Posts

previous question answered by the first post: [cel shading]why the lighting is managed by software and not by hardware ? why don't they use open gl functions for lighting ? new question : how is mapped the 1d texture ? is it mapped on all the surface of the polygon ? if yes how ? because the height is of 1, isn't it ? [edited by - airseb on January 15, 2004 1:39:26 PM]

Share on other sites
Because standard OpenGL lighting (with the fixed function pipeline) doesn''t allow enough control to produce good cell shaded lighting. It will always produce a continuous gradient, when you need non-linear shading. And when you need non-linear shading the answer is almost always to switch to texture based methods.

Share on other sites
up for the new question !

Share on other sites
I'm not an expert on cel-shading, but as far as I know, you "map" the lighting value you get (which will be from 0 to 1.0) into a 1D texture. Generally, the 1D texture is composed of chunks of different colors in a row, so as the lighting intensities change on the polygon, they skip to different colors rather than grading through various shades like real-life lighting would appear. You map it using glTexCoord1f(). Something like the following:

glBindTexture(GL_TEXTURE_1D, celtexture);glBegin(GL_TRIANGLES);float intensity = dot3(light_direction, poly.normal);if (intensity < 0.0f) intensity = 0.0f;glTexCoord2f(intensity);glVertex3f(poly.vertex[0], poly.vertex[1], poly.vertex[2]);glEnd();

You could accomplish this in a far more efficient manner with a vertex shader, but whatever

edit: the way I originally wrote it would interpolate texture values between the vertices, where each vertex had a separate calculation -- woops. You want the whole polygon one color... that's one way of doing it at least.

edit2: duh, don't need the for loop either, I'm stupid.
[edited by - chawk on January 15, 2004 6:46:13 PM]

[edited by - chawk on January 15, 2004 6:51:19 PM]

1. 1
2. 2
Rutin
13
3. 3
4. 4
5. 5

• 9
• 9
• 14
• 12
• 10
• Forum Statistics

• Total Topics
633260
• Total Posts
3011125
• Who's Online (See full list)

There are no registered users currently online

×