Jump to content
  • Advertisement
Sign in to follow this  
anique

Texturing light dependance?

This topic is 2547 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:

glColor3f(1,1,1);
for(int z=0;z<100;z++){
for(int x=0;x<100;x++){
if(pathMap[x][z]==1){
glPushMatrix();
glColor3f(1,0,0);
glTranslatef(x,0,z);
glutSolidCube(1);
glColor3f(1,1,1);
glPopMatrix();
}//else{


//tm->BindTexture(TEX_GROUND);
glBegin(GL_QUADS);
glNormal3d(0,1,0);
//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);
glEnd();


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
Advertisement
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!