3
\$\begingroup\$

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?

\$\endgroup\$
3
  • \$\begingroup\$ So you are now ok with using shaders? (per fragment lighting refers to shaders right?) \$\endgroup\$
    – Notabene
    Jul 21, 2011 at 18:44
  • \$\begingroup\$ There is no difference between per-fragment lighting and per-pixel lighting. \$\endgroup\$ Jul 21, 2011 at 23:54
  • \$\begingroup\$ I know fragment/pixel = ogl/directx terminology ... I just wasn't sure when old game, bsp and fixed pipeline 8 lights was mentioned \$\endgroup\$
    – Notabene
    Jul 22, 2011 at 0:29

1 Answer 1

4
\$\begingroup\$

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:

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .