Jump to content
  • Advertisement
Sign in to follow this  

Texturing light dependance?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I use the following code and get nice red cubes on a white plane:

for(int z=0;z<100;z++){
for(int x=0;x<100;x++){

//glTexCoord2f(0.0f, 0.0f);
glVertex3f(x, 0, z);

//glTexCoord2f(1.0f, 0.0f);
glVertex3f(x, 0, z+1);

//glTexCoord2f(1.0f, 1.0f);
glVertex3f(x+1, 0, z+1);

glTexCoord2f(0.0f, 1.0f);
glVertex3f(x+1, 0, z);

Then i remove the comments to apply the texturing and the cubes darken. Any idea whats happening?
How does texturing the ground darken these cubes?

Share this post

Link to post
Share on other sites
I am not sure what exactly you are trying to render but from what I read:
- you are rendering cubes vs planes in loop
- you want your cubes to be red and plane has texture applied
If your [color=#880000][font=CourierNew, monospace][size=2]BindTexture [/font]function also enable texturing you should disable it before rendering cube

so if you are using multiple texture units you should activate it
- glActiveTexture(GL_TEXTURE0)
and disable texturing by
- glDisable(GL_TEXTURE_2D)

Share this post

Link to post
Share on other sites
That solved the problem. thx :)
I'm curious though. Why does enabling texture reduce the brightness of an object?

Share this post

Link to post
Share on other sites
By default a texture is modulated by the light value, so the end result is texture * light. If you have a light of 0.5 with texturing disabled, you'll get 0.5 out. If you enable texturing, and if the average intensity of the texture is also 0.5, the end result will be 0.5 * 0.5 which is 0.25 - darker. A texture can never go above an intensity of 1.0 (well floating-point formats can, but let's ignore them for the purposes of this discussion) so the best you'll ever get is from a fully white texture and will be the same as if no texture was used. Any colour at all will always imply values less than 1.0, which will darken the scene. Yes, that sucks, but it's the way colours work on computers.

If you don't want that, look at GL_ARB_texture_env_combine - especially the RGB scale modes. An RGB scale of 2, when applied to light 0.5 and texture 0.5, will give an end result of 0.5, which is probably what you want.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!