Sign in to follow this  
maya18222

Light Sources

Recommended Posts

Im trying to work out the best way to render my scenes objects with the lights they are affected by. For example, i may have a large hall full of lots of objects and many many hanging lights on the ceiling, (modeled as point lights for example). I wont want to send all those lights to the renderer for each object, but just the ones that affect it the most. Now my rendering is basic forward rendering, where i have restricted the lights affecting each object to a maximum of 8, which seems like a good number. My thinking is that when rendering each object, I'll want to perform a call such as:-
LightList = GetLightsMostAffectingObject(pObject);
RenderObject(pObject, LightList);

This seems fairly easy, as i could just compare a point lights radius and dpot lights cone against the objects bounding box. For parallel lights, i cant think of any tests, but i shouldnt have many of those anyway. My other idea was to only render objects with lights that intersect the camera frustum, such as:
LightList = GetLightsIntersectingFrustum);
RenderObject(pObject, LightList);

But this will generally return a lot more than 8 lights, so i think the first option is better. Now this approach seems to work ok, but my problem is that I dont render my objects one after the other like that. Instead, I batch my rendering so that its more efficient. At the moment, this is simply batches of: StaticMeshes SkinnedMeshes Skybox Terrain Water ParticleEffects etc etc Take for example, the staticmesh batch, which could contain 100's of meshs throughtout the camera frustum (once the list is culled). Each mesh is probaly going to be affected *most* by different lights. So if i was to go for the 1st option, i'd need to calculate and store a list of lights with each object. Is this the way to go? or is there a better way?

Share this post


Link to post
Share on other sites
Have you considered deferred shading/lighting ? That approach greatly simplifies this problem as you draw the objects, then you draw the lights, and there's no limit to how many lights affect an object

Otherwise, yes, a list of lights that affect each object isn't a bad idea. Presumably you cull both meshes and lights against the camera frustum

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