Archived

This topic is now archived and is closed to further replies.

RipTorn

black ambient light not really black...

Recommended Posts

ok, considering the following code (being run once when the window is created):
  
	glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS,25);
	glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT,white);
	glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,white);
	glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,white);
	glMaterialfv(GL_FRONT_AND_BACK,GL_EMISSION,black);
  
where white and black are {1,1,1,1} and {0,0,0,1} now, my question, no matter the number of lights I have enabled, to get absolutly no ambient light, I need to have the total abient over those lights adding up to {-0.2,-0.2,-0.2}... which doesn''t make any sense at all... I''ve tried all sorts of stuff, and I guarentee it''s not the lights, only some lights use ambient in my project (hence I don''t want to set the material level to black), and I''ve put in code to test with all lights to 0 ambient, yet it still comes out with 0.2 ambient... the docs say the default ambient material setting is (0.2, 0.2, 0.2, 1.0) - which sounds aweful familiar... yet I''m setting this to 1,1,1,1, so this shouldn''t have any effect.. anyway... over all it''s just a bit weird and confusing... The problem is obviously easy to fix, it just doesn''t make sense and I want to know it''s not a driver bug, or whatnot... (I don''t want people to have overly dark lighting) the individual light setup code is:
  
		Vector4 position=Light.position;
		if (light.infinite)
			position.w=0;
glLightfv(GL_LIGHT0+lightID,GL_POSITION,(float*)&position);
		glLightfv(GL_LIGHT0+lightID,GL_DIFFUSE,(float*)&Light.colour);
		if (lightID==0)
			glLightfv(GL_LIGHT0+lightID,GL_AMBIENT,(float*)&(Light.ambient-Vector4(0.2f,0.2f,0.2f,0)));
		else
			glLightfv(GL_LIGHT0+lightID,GL_AMBIENT,(float*)&Light.ambient);
		glLightfv(GL_LIGHT0+lightID,GL_SPECULAR,(float*)&Light.colour);
		
		glLightf(GL_LIGHT0+lightID,GL_CONSTANT_ATTENUATION,(float)Light.infinite);
		if (Light.infinite)
			glLightf(GL_LIGHT0+lightID,GL_QUADRATIC_ATTENUATION,0);
		else
			glLightf(GL_LIGHT0+lightID,GL_QUADRATIC_ATTENUATION,1/(Light.falloff*Light.falloff));

  

Share this post


Link to post
Share on other sites
beauty.
thanks mate.

- I''m just happy I was able to get around it till I got the reason.. Not like the direct3d default of having all materials black :-)

Share this post


Link to post
Share on other sites