"Proper way" to light a dungeon like level?

I have level setups that can be best describes as dungeons. Lots of hallways and rooms seperated by doors. Now i am trying to figure out the best way to light the level.
Using directional light does not work because of ceilings, also the hallways and rooms should have different lighting, so htrowing light over the whole level is out of the question anyways.

I am using an ambient light and materials with no ambient color so the walls/floor/ceiling will at least be seen if there is no other light. The player has the ability to switch on a flashlight, no problem there. But with hallways and rooms that should even have a light in one corner and nearly darkness in another corner i would have to place a lot of light sources in the scene.

Now there is the question i am asking myself if that is a good way to do it. I read somewhere that the whole scene has to be rendered for every light source in the scene, altho i think that is true for standard opengl light sources, do the jm3 lights work in the same way ? If not it might not be as much of a problem to have several lights in the scene.

There will be a lot of light sources arround the level that won’t influence any surface the player sees at any given time, so i could try to remove lights that are far away from the player and add them if the distance is close enough so there is a chance that the player sees a surface influenced by it. Or will the lights be skiped anyways if they are not influencing the view anyways ?

So far i have just put in the ambient and flashlight and wanted to clear these questions before i think about how i handle the scene lights, so i have not tried out if there is a big performance issue with larger numbers of light.

http://hub.jmonkeyengine.org/forum/topic/wip-deferred-shading/

There were vague promises of this getting looked into after 3.0 gets released.

Yes, also there is a unofficial test proof of concept implementation of deferred rendering.

Or… a common approach is to forgo OpenGL/JME lighting and just back your lights into your geometry dynamically. You can’t use the shadow support this way (well, you have to do it differently) but you weren’t going to be able to do that anyway.

I don’t plan on using shadows anyways.
Problem with the light in geometry approach is that it means to put light maps into the materials if i understand that correctly.
But I am using a lot of geometries sharing one material, so several geometries with the same material could be lighted in a different way. Would have to clone the materials then which i wanted to prevent.

Or am i not understanding what you mean the right ay @pspeed ?

You could do vertex lighting as a color attribute on the vertexes. There are actually numerous ways to solve this problem with better and worse results.

For Mythruna, I store a light value (using the color attribute) on the vertexes and then feed that into normal lighting calculations using the view direction as the light direction (for local lighting) and the sun’s direction for an overall directional lighting. The color attributes are r,g,b,s in my case where the rgb is the local lighting and the s is the “sun factor” since I do light propagation and stuff. If yours is all indoors you might get away with just a light color on each vertex… especially if you don’t have huge quads and stuff, vertex-based lighting should be ok… better than nothing and easier than deferred rendering (right now).

Is there an example in the documentation somewhere for such a thing ?

It is all indoors, so no sun factor to blend in. Only thing that could become complicated might be that i also have flickering lights that go on and off, some timed, some triggered and also some enemies emmit light so i have moveing light sources too.

Might try to scatter pointlights arround for now and see how the performance is and look into vertex lighting later if performance drops too much.

@ryukajiya said: Is there an example in the documentation somewhere for such a thing ?

It is all indoors, so no sun factor to blend in. Only thing that could become complicated might be that i also have flickering lights that go on and off, some timed, some triggered and also some enemies emmit light so i have moveing light sources too.

Might try to scatter pointlights arround for now and see how the performance is and look into vertex lighting later if performance drops too much.

Some of the effects you describe could be done with regular lights in the cases that you need them. Or for the flickering you could use the alpha for frequency or something.

Any of these approaches will require custom shaders (or at least forked lighting shaders)… and to set the color buffer on the meshes to coincide with the lighting for those vertexes. It is a little non-trivial if you’ve never done it but it is doable.

If you go with point lights then you will probably get farther if you segment your world into zones and only add lights into the zones they affect. That way at least you avoid redrawing all of the geometry for every light.

Yes was planning to seperate the level into groups. Every room is a group and every hallway is one (maybe seperating longer ones into a few groups too) so at any given point in the level only those light in the current group and those that touch it are really needed.

Wanted to see if there is a better way to do it without too much trouble, but like to keep the project simple so i actualy complete it at some point and it does not haunt my harddrive as an incomplete work for ages :wink:
Can do more fancy stuff when it is done and i move on to the next one with the all the experienced i did with this one.

1 Like