• Advertisement

Archived

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

Materials and lighting

This topic is 5408 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 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.

Share this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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!

Share this post


Link to post
Share on other sites
>>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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
don t you have to set the 4th variable of your position to 0 in order to get ambience light or environment light...?

Share this post


Link to post
Share on other sites

  • Advertisement