Archived

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

JinJo

Light question

Recommended Posts

JinJo    100
Im having my first stab at a decent engine (not just graphics by the way) for this new game idea. First i''ll explain the idea a wee bit so you can understand that its not a wild dream at doing a MMPORPG. The game has a sort of X-Files, DeusEx, Matrix feel to it (obviously im not trying to go as good as DeusEx). But the main problem with the game is i havnt completed the story for it (actually not got much of one anymore after losing a lot of notes) so i thought that making little episodes would be a good thing (obviously nothing new as games have been doing this for a while online). The reason for this is i''ll get a brainstorm for how my story can progress then i get a block for months so making the game like a series seemed like an interesting thing to do and gives me a much smaller project to handle. Now anyway I have decided to use OGL for graphics and my rendering class was going fine (all in design stage) as i had a scene manager that sorts vertices using an octree and then sends the vertices/tex coords/normals/ materials etc to the renderer, so far so good. Now the problem is lights, i thought i should derive lights from my objects base class as a lot of people have lights and sounds stored in there scene as objects, which seemed a good idea. But my objects have this physics entity class that has all sorts of stuff happening in it that a light wouldnt be effected by (suppose i could just move this down the chain a bit) Then i thought that obviously my renderer needs to know about the lights in a scene so i have decided that when i send vertex data to the renderer i should send a list of the lights that effect these vertices. Now i''ve never done anything with shaders so for now im just gonna limit my scene to the 8/9 lights that OGL provides and the renderer shall set the proper details and enable the lights before rendering the scene. Now I dont even know what i was asking or anything ''cos i think i just answered my question but if there is any flaws in this method or you have any advice I would be very greatful. Thanks. Oh one last thing how hard/timely would it be to change the lighting to use pixel shaders (taking in consideration I would need to learn about them), or do you think I should just try and get my scripting system up and running (using Lua).

Share this post


Link to post
Share on other sites
Wyrframe    2426
Teach them about programmable pipelines, and they forget everything about scene organization...

From the sound of what you have, yes, the lights should be entities. Who knows? Maybe you'll have an enemy someday who is nothing _but_ a light. Give the basic light entity a "Stay Right There" AI, turn of collision detection on him, and go ahead.

As for restricting your lights, that's what my snide comment at the top is about. What the limit of 8 lights means is "at most 8 lights per vertex". Break up your world into cuboid-rectagular non-overlapping "lighting zones", and 'relate' lights to them... each zone can have a maximum of 8 lights "affecting" it, each lighting zone can have its own ambient light value or can use the "global" ambient light value, and each light can be related to any number of zones.

Render each lighting zone using only the lights "related" to it. These lights do not have to be in the lighting zone, or even near; the lights related to a lighting zone are just the "relevant" lights, the ones that you want to have affect the contents of that lighting zone.

Now, you are restricted to up to 8 lights in a given spot, but are free to have as many lights as you want in a given scene.

[edited by - Wyrframe on May 29, 2003 6:46:42 PM]

Share this post


Link to post
Share on other sites