Sign in to follow this  
datalurkur

Large number of lights

Recommended Posts

So I'm working on an isometric tile-based RTS, and I'd like to have certain tiles with light sources. Now, I'm aware that the minimum number of light sources GL supports is 8, which is rather low. On the other hand, most tutorials I've read on virtual lighting shift lots of the computation from the GPU to the CPU (software lighting, essentially). I expect most of my light to be at least relatively static - the tiles themselves will be almost constantly lit - but as units pass by light sources, I would prefer they be affected by the lights as well. At this point, I'm looking for some basic suggestions and perhaps some starter code. I'm familiar with GL lighting, but....yeah, 8 just isn't enough.

Share this post


Link to post
Share on other sites
You would have to do light management. In general, 3 lights lighting a single triangle is enough cause if there is more, you won't visually see a difference.

And of course, with shaders and a SM 3 capable GPU, you can have MANY lights.

Share this post


Link to post
Share on other sites
There are methods out there to create more "lights", but most require a pixel-shader and I assume you're not into that.

I have three methods for you:

1 - recycling.
Use the lights seen. Example, your level has 10 light posts, obviously higher than 8. However, your "camera" only shows you 3 ( isometric view ) of the 10. Only use three lights. Then when you're at light "8, 9, and 10; use LIGHT6, LIGHT7, and LIGHT8. In a nutshell, you just re-use what you're currently not using.

2 - billboard images
Create a textured quad that is parallel to the "camera" of your level. There are tons of examples on billboarded images in OpenGL. One you might want to take a look at would be at Lighthouse3D's Billboard Tutorial. ( Google )

3 - both 1 + 2
By using the light recycling mentioned above and the billboarded images, you can pull of a really good illusion for light sources. I'd prefer this method.

I hope I set your on the right track. :]

~Maverick

Share this post


Link to post
Share on other sites
Actually, I would not rule out vertex shaders. Certainly those solutions will be more complex, but I've had some minimal experience with vertex and fragment shaders before, so I'm not entirely new to them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this