Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am programming a graphics engine for an old game. The game uses a BSP geometry which I have rendering perfectly. For it's lights however, it simply has light instances with the standard x, y, z, rgba, brightness, type. Now I know that OpenGL has an 8 light limit. How should I go about handling multiple lights.

I am learning per fragment light just to have the concepts under my belt. I know per pixel lighting is the standard and I will eventually move there, just want to learn how to get this concept put in play as well.

I assume I will just calculate which lights are the closest and render those 8. Does anyone have any other ideas?

share|improve this question
    
So you are now ok with using shaders? (per fragment lighting refers to shaders right?) –  Notabene Jul 21 '11 at 18:44
    
There is no difference between per-fragment lighting and per-pixel lighting. –  Nicol Bolas Jul 21 '11 at 23:54
    
I know fragment/pixel = ogl/directx terminology ... I just wasn't sure when old game, bsp and fixed pipeline 8 lights was mentioned –  Notabene Jul 22 '11 at 0:29
add comment

1 Answer

up vote 3 down vote accepted

I expect that you are ok to use shaders


There are two approaches:

  • Forward rendering, one render pass per light and using additive blending between render targets. It works for "independent" number of lights.
  • Deferred rendering, is something like screen space rendering. Using few textures containing world space information.

Forward rendering is probably easier to handle. Also you don't have to use one shader pass per light as i mentioned. You can do it in a cycle in one shader pass. The only reason to have more shader passes per light is when light contains information like color texture (projective texturing) or intensity curve (stored in texture) ... so you run out of the texture units.

So i suggest simple forward rendering of all lights in one shader pass.

Deferred rendering is way faster than forward rendering (because it is practically screen space), but harder to handle.

I'm sure that you will find lots of good resources by googling for those two key words.

Some question from this site:

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.