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?
Answer
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:
No comments:
Post a Comment