Jump to content

  • Log In with Google      Sign In   
  • Create Account

Texturing light dependance?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 anique   Members   -  Reputation: 103

Like
0Likes
Like

Posted 23 December 2011 - 11:41 AM

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?

Sponsor:

#2 SaTANO   Members   -  Reputation: 418

Like
1Likes
Like

Posted 23 December 2011 - 03:42 PM

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 BindTexture 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)

#3 anique   Members   -  Reputation: 103

Like
0Likes
Like

Posted 24 December 2011 - 08:54 AM

That solved the problem. thx :)
I'm curious though. Why does enabling texture reduce the brightness of an object?

#4 mhagain   Crossbones+   -  Reputation: 8278

Like
0Likes
Like

Posted 24 December 2011 - 04:50 PM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS