Materials and lighting

Started by
5 comments, last by Aargyle 20 years, 11 months ago
I finally enabled GL_Lighting in my program, but now everything is rendered dark gray, haha. Anyway I first call this: glEnable( GL_LIGHTING ); GLfloat lmodel_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f}; // Set some ambient light for our scene glLightModelfv( GL_LIGHT_MODEL_AMBIENT, lmodel_ambient ); Then I set each vertex up with a material that contains a diffuse color. Buuuuut it still draws gray. So. Doesn''t glLightModelfv set the ambient light? Or do I need to use up one of the 8 dynamic lights for this.
Advertisement
glEnable(GL_LIGHT0);
Member of the Shove Pouya Off A Cliff club, SPOAC. (If you wish to join, add this line to your signature.)Member of "Un-Ban nes8bit" association, UNA (to join put this in your sig)"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
Ok so the default ambient light does *use up* one of the 8. I was thinking maybe there was background lighting that acted like a '9th' light.

So if glLightModelfv uses light 0, why have it at all?

Also, does anyone know how big a performance hit it is to turn the lighting off and on? I am thinking I will need to disable it when I draw my interface (text over the top of the rendered image, drawn in ortho mode), but I hate to have to switch it off and on every frame unless its fast to do so.

Any other way to make the interface look right? Thanks again!

[edited by - aargyle on April 29, 2003 7:24:34 AM]
You don''t have to disable lighting - just adjust the material properties of your quad (or whatever you''re using to draw your interface) so that it''s ambient value is full - it should then be drawn at full brightness whatever the lighting...

...I think

Get hold of a copy of the red book!
>>Ok so the default ambient light does *use up* one of the 8. I was thinking maybe there was background lighting that acted like a ''9th'' light.<<

there is also a global ambient light parameter (check red book)

>>Also, does anyone know how big a performance hit it is to turn the lighting off and on? I am thinking I will need to disable it when I draw my interface (text over the top of the rendered image, drawn in ortho mode), but I hate to have to switch it off and on every frame unless its fast to do so.
<<

once a frame will not affect performance in any way

http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html
I did check the red book, thats where I got the code above. They enable LIGHT_0 as well, I was just confused by the set abient light call.

IS there a ''9th'' ambient light that I can access?
don t you have to set the 4th variable of your position to 0 in order to get ambience light or environment light...?
http://www.8ung.at/basiror/theironcross.html

This topic is closed to new replies.

Advertisement