I’ve searched through a few posts talking about light leaking through walls, but not found anything thats helped me figure it out (and read through the wiki entry on light and shadows a few times too)
I’ve created a single floor building in sketchup, exported as .obj, checked in openscenegraph and finally loaded in jme. I want to start populated it with light bulbs, and added a spot light at roughly ceiling height, pointing to the floor to illuminate a wall. I’ve added a general background ambient light so you can see the shot a bit better.
Looking down on the building, I’ve grabbed this screenshot:
Some aspects looks good - shadow is cast as id expect under the table in the left, but the light seems to fill the next room, casting an odd shadow of the wall, and to the door as well.
The wall seems to be noticed then to cast that shadow, but I’d expect it to occlude rather than let everything through.
The whole model is loaded as one, and attached to the rootnode, which is where I’ve attached the light to as well.
Other suggestions I saw talked about wall thickness, but this wall has a decent thickness (about 10cm in model) so I’m not sure thats it. I saw some suggestions about breaking a model into smaller parts too, but I’d rather avoid that if possible - plus then I’m not sure how light would leak when I’d really want it to (e.g. down a corridor from another room).
The light point is below the height of the wall too, incase thats hard to see from that angle.
Light in a game engine doesn’t work like light in real life. A simple way would be organizing you scene so that each room is a separate node with lights (light only works on the children of a node its attached to).
You need to rewrite engine’s shaders and shadow renderers.
Now: lights are drawn everywhere in the light’s radius, then, for every light a shadows are generated and drawn by darkening previously lightened pixels.
Should be: lights are drawn only on surfaces that are not covered by shadow. For multiple lights use additive blending.
It is possible, but it is a hard piece of work for someone, who does not know the engine. There is an topic about my first approach with shadows, you’ll find there a link to a project (not mine) which should be a good starting point for you. It is possible to have nice shadows in JME, the proof is here
Hm… I think i’ll chicken out of the rewrite of shaders! I only really wanted this for the ‘prettyness’ value - I’m trying to show smart home interactions more than pro game level visuals.
Normen, thanks for the tip, I should be able to export 5 different obj files easily enough and take the separate node approach. I was just being greedy hoping there was a quick easy way
OK, that makes quite an improvement, but still a niggling problem. The wall of the room containing the light source shows light on the outside of its wall. I thought I could get around this by halfing the thickness of each rooms wall, so that two rooms outside faces ‘block’ each other and you wouldn’t see the light.
That nearly works, but I seem to have a thin beam of light visible around where the wall meets the floor, and where the two walls meet (depending on the camera angle).
It feels almost like the light isn’t being occluded as I’d expect… is there some render queue I should set?
I’m checking the model closely too - the wall-floor leakage is through where the two meet rather than being one solid object, but they are touching.
Sounds like a classical shadowmap issue.
Can you provide the actual screen?