Archived

This topic is now archived and is closed to further replies.

JustThisGuy2001

Silly - Where do lights go?

Recommended Posts

A bit of an odd question, but I am pondering where to put light structures in my scene hierarchy... There are basically three ideas I''ve thought of (would be happy to hear others though).. 1) Could specify light properties in the generic Material structure I am using. Potentially could mean *many* state changes during rendering, more effort in setting properties for each model, and also extra storage space required. Would probably allow the greatest flexibility though.. 2) Could specify lights at the nodes within my scene hierarchy that is currently used for object culling/collision detection (supports quadtrees/octrees currently). This is my preferred option actually - minimises state changes, provides a nice hierarchy.. There is one problem I can envisage. What happens if, for example, I want a light to be on in a "room" within my world, but the octree nodes don''t finish at the room walls - this would mean that the lights would be applied outside the room walls as well, until the edge of the scene node is reached.. Kindof hard to explain that - hope you know what I mean.. 3) Add some sort of extra hierarchical structure to my engine, in addition to the quad/octree used for culling and collision. For example, could use some kind of scene graph that is not based on spatial hierarchy, but provides a hierarchy of state changes only.. Problem with this is: I don''t know how (if possible) to reconcile the state changes in the scene graph efficiently with traversal of the quad/octree during rendering - somewhat defeats the purpose of a scene graph of state changes it seems... Any thoughts, suggestions, ideas on what is often used, other possibilities, or clearing up the issues I have with the above thoughts would be most appreciated!

Share this post


Link to post
Share on other sites
Well the problem with treating them as part of the world is that how do you know which objects should be rendered with which lights etc?

Say for example, there are 8 lights in your scene, now obviously it is pretty hard to get a vertex shader to apply 8 lights to a vertex, in addition to doing skinned animation etc (just not enough room in a vertex shader / enough constants etc), so by having lights in a hierarchy, each object can be rendered only with lights applicable to it.. This would speed up the rendering tremendously, without having a large visual effect when lights are too far away to really make any difference on certain objects etc... Know what I mean?

Share this post


Link to post
Share on other sites
first of all, use per-pixel attanuation. it looks very good and solves your problem. after that, i would suggest you to create a mesh list in every light, that will contain the meshes in the light''s range. i do it by creating one main list of meshses, and than creating lists with references to the main list for each light. when you render your scene, render by light.

for(all lights)
CurrentLight->MeshList->DrawList();

something like that. that is a really good method if you use shadow volumes and per pixel lighting. i think. thats what i do.

Share this post


Link to post
Share on other sites
Hi Ofer, don''t now that I want to go for per-pixel lighting at the moment (although I do eventually want to move towards there, just gotta work out how I''m going to do normal maps properly), but I like your idea about having mesh lists for each light... It would actually be quite a quick way to draw things, and since I have several dynamic objects I''ll add methods to the light class to determine whether a mesh has come within the light''s radius of influence I think... Thanks for the idea!

Share this post


Link to post
Share on other sites