Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multiple Lights?

Started by Antorian Jun 12, 2002 at 8:36 AM 12 replies 1.7k views
Original Post
Antorian
Antorian
I''m a beginner on OpenGL and I''would like to know how to use multiple lights with OpenGL Lightning. I saw that depends on Hardware and that OpenGL allow only 8 lights in best cases. And with implementation it''s possible to go through this limitation. How can I do (I know and I use already Lightmaps but I would like to use dynamic lights)? Thanks for All. (Other Question Where can I found librairies or header for Opengl 1.2 1.3 or more?) I''''m 4 & I draw
I''m 4 & I draw
Brother Bob
Brother Bob
quote:

I saw that depends on Hardware and that OpenGL allow only 8 lights in best cases.


OpenGL requires a minimum of 8 lights. In other words, 8 light is therefore the "worst" case.

You can use some multipass algorithm; draw your scene many times. Enable as many lights as you can (read your implementation supports) and render the scene. Then enable some other lights, and render the scene again, ontop of the old image.
Antorian
Antorian
Thanks, the multi pass way looks as a good thing.
But if I get 8 Lights in OpenGL, and more with my hardware...how can I acces it? Is there something after GL_LIGHT7 ?

I''''m 4 & I draw
I''m 4 & I draw
benjamin bunny
benjamin bunny
This question comes up a lot.

OpenGL''s limit is 8 lights per polygon . Just enable/disable lights as you need them during the render. You shouldn''t ever need more than 8 lights on a single polygon.

Drawing the scene multiple times would be a very bad idea.

BTW, using multiple lights becomes increasingly slow the more you use, especially with positional lights. Use them sparingly.

____________________________________________________________
www.elf-stone.com
Antorian
Antorian
Ok I''ve Noticed that rendering the scene several times per frame issue to a lost of FPS but the quality image isn''t good enough to tolerate this leak of speed.
So using vertex color with multitexturing and morphing processing is simple but takes a lot of CPU time...
I currently using Hardware Lighting with a 8 Max per polygon some times.
I would like to know how to obtain (wich procedure) that get the max Hardware number of light that support GFX card and how to acces to those one.
So if I use a voodoo card (that if I remember don''t have hardware lighting) I must know how many light are allowed (perhaps 0) and adapt this value to render correctly the scene when I haven''t light on hardware...
Sorry for my "Question that comes up a lot." but I must start from somewhere
And sorry for my poor English.



I''''m 4 & I draw
I''m 4 & I draw
benjamin bunny
benjamin bunny
I have a feeling 8 is the minimum, so if you call glGetInteger(GL_MAX_LIGHTS) it''ll report 8 if you have none, and it''ll probably dump you in software mode if you try to use them. Still, it might be worth a try.

____________________________________________________________
www.elf-stone.com
Antorian
Antorian
So there is no way to know if hardware support Lighting?
So I can test if after enabling lights I go in render mode but I think it''s not the good way....
I will limit my number of light per frame (I think too taht 8 lights per polygon is suffisant), but I want to test if hardware support that....
But how to do ? to know if the hardware support 0,1 ...4,5...8 lights...? when the GetInteger(GL_MAX_LIGHT) return 8 if It doesn''t support?
Worried about this....
Still searching (But thx for the advice)

I''''m 4 & I draw
I''m 4 & I draw
benjamin bunny
benjamin bunny
One way to test: download wall3D from my site (below) and see if it runs at a playable speed. If it does, you have hardware lighting, and glGetIntegerfv(GL_MAX_LIGHTS) will correctly return the number of lights your card can support (ie in hardware). Another way to test would be to stick a light in your code and enable lighting and see if the framerate drops significantly.

____________________________________________________________
www.elf-stone.com

[edited by - benjamin bunny on June 12, 2002 8:51:00 PM]
_the_phantom_
_the_phantom_
tbh, I some what doubt anyone REALLY needs all 8 hardware lights anyways, if you''ve seen 3dMark 2001s demo with the hardware lights you''ll know the kinda slow down you can get

most games you see with impressive lighting use light maps, giving you in effect infinte lights, and very few ''real'' lights at all..
benjamin bunny
benjamin bunny
There are always uses for dynamic lights. Static lights have major disadvantages, which is why they''re being used less and less. I''d like to see you light a moving character with lightmaps.

____________________________________________________________
www.elf-stone.com
Antorian
Antorian


Yes it''s exactly what I want to do so lightmaps aren''t easy for that.
And with Vertex Lighting (using vertex color) ? I don''t really know what happen when a face is front of the light and one other move behind, is the behind face lighted ?(that''s not correct) or shadow by front face?
(I understand that depends of coding...but vertex lighting also include this fact in its theory?)
And just a last question: what is faster ? sofware render using GL_LIGHT or computing vertex Lighting with VertexColor??

Thx
Antorian shadowed by his face
I''m 4 & I draw
python_regious
python_regious
You can rely on hardware to have hardware lighting capabilities, that isn''t an issue. I don''t think I''ve ever had a card that doesn''t support that...

Death of one is a tragedy, death of a million is just a statistic.
If at first you don't succeed, redefine success.
MazyNoc
MazyNoc
Moving characters and projected textures (lightmaps) work perfect.. pertexel by the way..

[edit]: and many cards dont have light in HW.. only those with HW T&L has it..

[edited by - MazyNoc on June 13, 2002 6:59:11 PM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.