• Advertisement
Sign in to follow this  

A question on dynamic scene lighting algorithms

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

Hi, I have come to a hurdle in one of my applications where I require a good algorithm for determining the priority of dynamic lights at runtime. I really need a facaded double solution (i.e. opengl(8 lights)/directx), however I would be happy to just reach an opengl solution for the moment. I know that distance checking on lights to the camera is a simple option but how would you check for intensity values etc on which lights affect a scene the most at a given time? Sorry if this is seen as a simple question, but I could really do with some peudo-code help from anyone that has done this before :) Thank you.

Share this post


Link to post
Share on other sites
Advertisement
I don't get the point. Typically you already know what the light intensity is since it's declared in the asset.
If you want to do that dinamically that's a bit more involved but it can be inferred from the light style and intensity, then mangled by distance for example.

Could you rephrase the question?

Share this post


Link to post
Share on other sites
Hi again, sorry for the lateness of posting back.

Basically what i need to do (say for OpenGL) is to determine the 8 most prominent dynamic lights that will affect a scene at a given time (even though i know its unlikely that 8 dynamic lights will be on the scene at once). However I can see three things that i need to take into account.

1. The distance of the light from the camera
2. The intensity of the light values (diffuse, ambient, attenuation etc) because a light that is far away could affect the scene more than a light which is closer.
3. The type of light it is (for example it could be a spotlight really close to the camera, but facing the opposite direction and not affecting the scene etc).

I just couldn't think of an efficient algorithm to achieve all this, particularly with point number 2.

If anyone could pass on any advice I would be thankful.

Thank you.

Share this post


Link to post
Share on other sites
Quote:
Original post by McFury
Basically what i need to do (say for OpenGL) is to determine the 8 most prominent dynamic lights that will affect a scene at a given time (even though i know its unlikely that 8 dynamic lights will be on the scene at once). However I can see three things that i need to take into account.

1. The distance of the light from the camera
2. The intensity of the light values (diffuse, ambient, attenuation etc) because a light that is far away could affect the scene more than a light which is closer.
3. The type of light it is (for example it could be a spotlight really close to the camera, but facing the opposite direction and not affecting the scene etc).
Just reproduce the OpenGL lighting equations themselves (they aren't that complicated, and they are fully described in the man pages), and run them for the camera location. This might nor be very accurate, so it might be better to find the 8 most important lights for each model in the scene instead.

Share this post


Link to post
Share on other sites
Quote:
Original post by McFury
Basically what i need to do (say for OpenGL) is to determine the 8 most prominent dynamic lights that will affect a scene at a given time...
I forgot to mention this, but if your target hardware is recent enough, you might want to look into deffered rendering, which allows you to render a huge number of lights at once (limited only by fillrate).

Share this post


Link to post
Share on other sites
Your best bet is to manually tag each light with a priority. Now that you can prioritise lights with this tag you are now cheaply able to query the most important lights at any time.

In your case, when there are more than 8 lights with the same priority, fall back to another algorithm; maybe based on distance or light frustum intersection with the camera view volume. Something like this is really easy to implement and no need for some crazy complicated solution.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement