PDA

View Full Version : GL_DECAL and lighting



Ehsan Kamrani
05-25-2005, 07:51 AM
Hi there
It seems that if we specify the following function:
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
The lighting doesn't affect the textured objects--Or at least, some of the lighting parameters don't work in this case. Isn't it?
-Ehsan-

Aeluned
05-25-2005, 08:58 AM
Right you are ken!

GL_DECAL flags OpenGL to replace the fragment color with the texture sample.
Since lighting is calculated first, then the texture is applied, lighting is obliterated.

If you want GL_DECAL application with lighting you have 2 choices:
1) perform the texture application yourself in a fragment shader or,
2) Use glLightModeli( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR );

Orzech
05-25-2005, 09:58 AM
Also, you can try to change GL_DECAY to GL_MODULATE. This way texels of a texture are blended with pixels in the buffer. Adding se glLightModeli( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR ); - like Aeuluend suggests - makes specular reflections more noticable when using textures.

Hope it helps! :)

Aeluned
05-25-2005, 10:10 AM
Indeed, however when using GL_MODULATE the alpha channel of the texture is modulated as well, so that areas in the texture that are alpha = 0.0 will 'cut holes' in the surface they are being mapped onto.

So the distinction becomes important when mapping textures containing text for example.

Ehsan Kamrani
05-25-2005, 10:41 AM
Originally posted by Aeluned:
Right you are ken!
Thank you.

Thanks for good responses.
-Ehsan-

Ehsan Kamrani
05-25-2005, 12:18 PM
Unfortunately i cannot use from the glLightModeli( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR ); function in my program. :( where can i download the latest version of the OpenGL API?
-Ehsan-

Aeluned
05-25-2005, 01:58 PM
get the latest headers here:
http://oss.sgi.com/projects/ogl-sample/registry/

should be in every OpenGL developer's bookmarks :p