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-
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:
- perform the texture application yourself in a fragment shader or,
- Use glLightModeli( GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR );
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!
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.
Originally posted by Aeluned:
Right you are ken!
Thank you.
Thanks for good responses.
-Ehsan-
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-
get the latest headers here:
http://oss.sgi.com/projects/ogl-sample/registry/
should be in every OpenGL developer’s bookmarks