View Full Version : Cel-Shading effect on BMP model textures?

11-21-2011, 04:17 AM
Hello all,

I am not sure if this is the right board, I'm relatively new to OGL but this issue might be slightly more advanced....

I was just looking at Nehe's Cel Shading tutorial (http://nehe.gamedev.net/tutorial/cel_shading/25001/) , I understand from the code that the effect is obtained by applying one uni-color texture to the model.... I was wondering if there was a way to have the effect work with a Bitmap texture?.... I understand that the relevant code is:

// Cel-Shading Code
glEnable (GL_TEXTURE_1D); // Enable 1D Texturing
glBindTexture (GL_TEXTURE_1D, shaderTexture[0]); // Bind Our Texture

glColor3f (1.0f, 1.0f, 1.0f);


After having processed the shader.txt file... Is there a way to run that on a normal bitmap texture? My model loader starts its drawing code with these lines

glBindTexture(GL_TEXTURE_2D, textureId);

And then goes on do draw the vertices...

Thank you very much!

11-21-2011, 08:25 AM
There are techniques for edge detection that can be done on a bitmap. Photoshop and Paint Shop pro and other such image editors have had such functions since a very long time.

You can probably run those algorithms through shaders. I have seen examples here and there on the web using a Sobel filter. Do a websearch, I'm sure you'll find a few.

11-22-2011, 01:09 AM
I think he means he wants to use a 2D texture rather than a 1D texture to store the color ramp.

If that's indeed your question, yes it is possible. You *should* be able to exchange GL_TEXTURE_1D for GL_TEXTURE_2D, and glTexImage1D for glTexImage2D and it should just work. If it doesn't, verify if your color ramp texture has power-of-two (POT) dimensions, though on most modern GL versions this limitation is no longer an obstacle. You will probably want to avoid mipmapping, as it does not work well without 2-component texture coordinates.