Jump to content
  • Advertisement


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


How to simulate multiple light sources?

This topic is 5288 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

Began working with Vertex/Pixel shaders recently. I know opengl only has suport for 8 lights, but there are ways to work arround that, and have as many as one wants... So, what are those ways? I can process all the static lights in a map and create a lightmap for all polygons in the map, I guess. What about dinamic lights, ala Doom 3 for example? Im guessing they aren''t constrained by any n amount of lights... Salsa cooked it, your eyes eat it!
[Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
                          Prozak - The GameDever formally known as pentium3id

Share this post

Link to post
Share on other sites
Well, you could render the scene multiple times, with subsequent times using additive blending.

You probably don''t need to do this, tho. It''s very unusual for more than 8 lights to actually have a significant impact on a single object. Just pick the eight that''ll have the greatest intensity (light_intensity / (distance * distance)) and use those.

"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post

Link to post
Share on other sites
I''m fairly new to graphics programming, but here''s what I know about real time lighting methods.

Firstly, as far as I know, OpenGL''s lighting model is purely vertex-based. This makes it awkward to use, and the results, when compared to current engines, are generally poor.

As Sneftel suggests, the best way is to render the scene several times, once for each light, using additive blending. To render a scene, you''d do the following:

1. Disable writes to colour buffer. Render scene to depth buffer.

2. Enable colour writes.

3. For each light, render scene using additive blending.

How you do the lighting depends on how much you want to use pixel shaders. I don''t have great shader support on my PC, so I use a slightly inelegant lighting model that involves lots of multitextuing and a slightly crude approximation of the lighting. Look around online for a tutorial if you''re not sure.

Of course, if you want Doom 3 style lighting, you''ll need the shadows as well. The shadow volume/stencil buffer combo is easily combined with such a lighting technique. Google for more on that as well.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!