I’m trying to find out what the best way is to do lighting and shadows. My setup is a dark indoor game with very few lights. But preferably these lights should cast shadows so that a light in a room doesn’t have (too much) influence on the adjacent rooms. The player also has a flashlight.
I have a basic working setup that uses SpotLightShadowFilter. It works but it has the very annoying problem that shadows are really very pervasive. i.e. if I’m in a dark room with an adjacent room that has a light then the flashlight isn’t able to work because the shadow of the light in the adjacent room is painting over the light of the flashlight too. I know the reason for this but I wonder how other people handle this? Are shadows completely useless for situations like these or is there a solution that would help me have the visual that I desire?
Edit: is Volumetric Lighting an option? I don’t know a lot about that and how hard it would be to have that in jME?
You might consider adding some pictures of what you describe.
Ok, so the first screenshot is without the flashlight. Shadows look fine here:
Then I turn on my flashlight. Notice how it fails to light up the dark areas because these are dark due to shadows and the shadows paint over the light apparently:
If I disable shadows then the flashlight lits everything up correctly. Also if the light is removed it is also correct.
I hope this makes it more clear?
What order do you add the shadow filters?
Edit: actually, nevermind… it probably doesn’t matter.
Perhaps a special ShadowFilter that can handle both point lights and spotlights would help. The problem may be that they’re in different passes?
Well I’m only using spotlights. The light that is coming from the door is also a spotlight
The issue is that shadows are painted on, not light. So it’s backwards from how real life works and it means when the next shadow processor comes along it happily paints over the light left by the previous shadows.
All of the lights contribute their light (one pass each)… then the shadows are painted on from each light (one pass each).
There are no easy solutions to this problem. You need to get some form of “in pass” shadows working, ie: render the shadows at the same time as the light.
Or go down the path of writing a deferred renderer… which I understand deals better with shadows from multiple lights but is a whole different ball of complication.
For me, with my engine knowledge, if I needed this feature in my own game I’d probably try in-pass shadows… but that’s only after I’ve exhausted every other trick I can think of (the key one being to bake all of the lighting except the player’s light).
Baking the lights is not an option because every light in that level has to be able to be turned off and on.
I don’t know a lot about deferred rendering. Do you have any resources of that? Or examples written with jME?
Baked lights are a texture that can be enabled/disabled. It just depends on what you are willing to compromise for flexibility.
If you care less about pixel level accuracy for the static lights then voxel lighting may also be an option.
Others know more about deferred rendering than I do… which is why it would not be my own first choice. Too steep of a learning curve for me.
Voxel lighting? That’s new to me. Any resources on that? Thanks
Voxel lighting is the way minecraft lighting works. That light “fills up” an area the way smoke would being emitted from light sources (so it does go round corners and tends not to have sharp edges).
Voxel lighting requires a full rebuild when the light changes though (so good for lights being turned on and off, more difficult for a moving flashlight)
Can you combine it? Use voxel lighting for the non moving lights and ‘normal’ lighting for the flashlight?
sure, why not. Tho it will look odd since voxel light is usually “blocky” and flashlight not
(while based on your screenshot i didnt knew its voxel)
It’s not voxel at all. I’m just trying to find out my best way to do nice looking (but not terribly accurate) indoor shadows for non-static lights
you can try test single-pass lighting, but if others didnt suggest it, then it will probably not work.
Generally i also had issues with shadows in interriors(bunker/etc) so i decided to skip shadows for things like that.(and leave just lights) Just looking at some Fallout 4 bunkers and i didnt seen shadows in a lot of gameplays at all. (there are, but didnt seen many)
Remember that you also have PBR and Environment Probe, that affect all PBR surrounding based on baked area (it might be room area for example). This also is affected by all “lit” areas.
Still i belive when new pipeline and deferred lightning will be done for JME, i belive interior shadows might be fixed too.
The problem with not doing shadows is that a light in a closed area will ‘leak’ through the walls which is less then desirable and looks really weird
so here i see 2 options
- bake light for a rooms
- set radius for lights so it dont
(can also mix both)
you could also render tham as different renderer(with own lights) for each part, but it sounds ugly way.
I am not good at graphics, lights and shadow, but just a suggestion, if you didn’t find an answer elsewhere, then you may try to adjust the shadow filter properties (like direction for instance based on flashlight direction) while using the flashlight, use a boolean flag to do so.
I think I’m going to try to either disable shadows and keep the lights very small or else try to play with shadow settings so that they don’t interphere with my flashlight too much
If your rooms are separate spatials then you can also just add lights to those spatials instead of to the root node. They won’t leak out at all in that case… but there will also be a sharp line at the doorways.
How big is your level?