Light passes wall

Problem is that light passes wall. I do something wrong or is this bug of JME?

This is code example. For run need include jme3-test-data.jar.


package mygame;


import com.jme3.bounding.BoundingBox;

import com.jme3.light.AmbientLight;

import com.jme3.light.SpotLight;

import com.jme3.material.Material;

import com.jme3.math.ColorRGBA;

import com.jme3.math.FastMath;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.Spatial;

import com.jme3.scene.control.LightControl;

import com.jme3.scene.shape.Box;

import com.jme3.terrain.geomipmap.TerrainLodControl;

import com.jme3.terrain.geomipmap.TerrainQuad;

import com.jme3.terrain.geomipmap.lodcalc.DistanceLodCalculator;

public class Example extends SimpleApplication {

private TerrainQuad gameLevel;

public static void main(String[] args) {

Example app = new Example();




public void simpleInitApp() {


Material mat = assetManager.loadMaterial(“Textures/BumpMapTest/Tangent.j3m”);

gameLevel = new TerrainQuad(“terrain”, 65, 513, null);

TerrainLodControl control = new TerrainLodControl(gameLevel, cam);

control.setLodCalculator(new DistanceLodCalculator(65, 2.7f) );



gameLevel.setModelBound(new BoundingBox());


gameLevel.setLocalTranslation(0, -100, 0);

gameLevel.setLocalScale(1f, 1f, 1f);


Box box = new Box(Vector3f.ZERO, 30, 6.5f , 1);

Spatial wall = new Geometry(“Wall”, box);


wall.setLocalTranslation(0, 2.5f, 0);


Spatial light = new Geometry(“Light”, new Box(1, 1, 1));


light.setLocalTranslation(10, 5, 10);


SpotLight myLight = new SpotLight();


myLight.setDirection(new Vector3f(0, -1, 0));

myLight.setPosition(light.getLocalTranslation().add(0, -100, 0));

myLight.setSpotOuterAngle(80 * FastMath.DEG_TO_RAD);

myLight.setSpotInnerAngle(75 * FastMath.DEG_TO_RAD);



LightControl lightControl = new LightControl(myLight);


AmbientLight ambLight = new AmbientLight();

ambLight.setColor(new ColorRGBA(0.2f, 0.2f, 0.2f, 0.2f));





This is the way 3D rendering works, it’s not a bug.

What he said. You just put the stuff on the other side of the wall in a different node, that should work (for now, this per-node-lighting behavior in the engine might change).

This works fine when SpotLight not moving. I will use the SpotLight like player’s flashlight and I need illuminate objects from different nodes but not all objects from these nodes.

Essentially in 3d graphics light and shadow are two different things and are handled separately…

I maybe have a solution. When update method is called, get all objects which are to be lighted and add SpotLight into their nodes.

More to the point.

Organise your “rooms” so that all the objects inside one room is attached to the same node. Then attach the light to that node.

Then the light will only go through those objects but not objects attached to the other room nodes.

Then you just need something to cope with room transitions (maybe need two lights once the light gets close to a node boundary?). I dunno what people normally do for that situation?

Back in the days of Quake 1/2/3/4/etc when you mapped you would sometimes get that sort of result. One of the workaround was to make thicker walls. Even in Source you sometimes get that and the workaround was the same. I doubt this would be effective here, but it might be worth a shot.

Is a option to solve this problem? I cannot split the wall and light just one half because this is not useful in my case.

what might work, use two or more smaller lights attached directly to the wall. (so taht only the wall is rendered multiple times, as many lights can be extensive)

@agrach said:
Is a option to solve this problem? I cannot split the wall and light just one half because this is not useful in my case.

lol, you will have to decide whats more useful, splitting the wall or having the light "shine through".

I use the SpotLight like player’s flashlight. In singleplayer is no problem but in multiplayer, player can see light from other player behind wall and this is problem. For static lamp I split walls.

Sounds like your best option at the moment is light mapping. Are these lights static?