Spotlights and large Geometries

Hey Guys,

I’m currently working on a top-down-shooter with the actual nightly build jME3_2012-11-21.

There is a Spotlight, following the character’s movement and rotation.

Everything works fine, even the latest SpotLightShadowRenderer works (more or less) pretty well.

My Problem is, that large Geometries (for example a long wall or the ground) become darker and darker, the further the character/spotlight moves away from the Middle (0, 0, 0). The larger the Geometry, the faster it becomes darker.

It doesn´t matter if there is a spotlightshadowrenderer active or not… and with shorter geometries, everything works fine…

Here are some code-snippets:

init the light:


private void initLight() {


spotFront = new SpotLight();


spotFront.setSpotInnerAngle(25f * FastMath.DEG_TO_RAD); // inner light cone (central beam)

spotFront.setSpotOuterAngle(70f * FastMath.DEG_TO_RAD); // outer light cone (edge of the light)

spotFront.setColor(ColorRGBA.White.mult(1.4f)); // light color

spotFront.setPosition(barkerMainNode.getLocalTranslation()); // shine from camera loc


spotLightRendererFront = new SpotLightShadowRenderer(assetManager, 2048);








light following character:



public void update(float tpf) {


spotFront.setPosition(new Vector3f(barkerMainNode.getLocalTranslation().x, barkerMainNode.getLocalTranslation().y + 2,barkerMainNode.getLocalTranslation().z));

spotFront.setDirection(barkerGeomsNode.getLocalRotation().mult(new Vector3f(Vector3f.UNIT_X.x * -1, Vector3f.UNIT_X.y, Vector3f.UNIT_X.z)));

//System.out.println("spot: " + spotFront.getDirection().x + ", " + spotFront.getDirection().y + ", " + spotFront.getDirection().z);



One of the Geometries, that does not work:


matGround = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");

Texture floortexture = assetManager.loadTexture("sideeffects/assets/World/ground_planken.jpg");


matGround.setTexture("DiffuseMap", floortexture);

matGround.setTexture("Diffuse", floortexture);

matGround.setTexture("Ambient", floortexture);

Box gr = new Box(Vector3f.ZERO, Globals.WORLD_TILE_SIZE, Globals.GROUND_HEIGHT, Globals.WORLD_TILE_SIZE);

floor = new Geometry("Ground", gr);


floor.setLocalTranslation(0, Globals.GROUND_POSITION, 0);


I hope, these snippets are enough and somebody can help me! THX!

Could you post some screens? not sure i understand the issue

@schitzn said:
Everything works fine, even the latest SpotLightShadowRenderer works (more or less) pretty well.

Not really the subject, but since you bring that up. Could you elaborate on the "more or less"? maybe there is an issue with it?

Hey there nehon,

thanks for your fast reply!

Okay, here you go, there are some screens (including some setup & description):

Problems with Spotlight:

Screen 1:

Screen 2:

Screen 3:

But as i said in the last post, this issue is exactly the same, WITH and WITHOUT the SpotLightShadowRenderer!!!

Issues with SpotLightShadowRenderer:

Problem 1:

Problem 2:

Problem 3:

Problem 4:

The fourth problem is with macintosh and eclipse... as soon as setEdgeFilteringMode is set to PCFPOISSON OR setEdgesThickness is enabled, the application can not be run anymore...

Hope the images help a little bit!

1 Like

push xD

Don’t bump please, (not until its been a few days at least). People will look at it but they need time to do so (and some won’t even be in the same timezone as you!).

ok…i think i get it… your objects are boxes right?

The problem is that light direction is computed for each vertex and not for each pixel. So the less vertex you have the more inaccurate is the light.

You should subdivide the meshes and it should alleviate the issue.

Another way would be to compute the light direction in the frag shader of the lighting material instead of the vertex shader, but you 'll have to dive into evil shader code.

sry for bumping, zarch… :confused:

hey nehon, yes, my objects are standart boxes…

the problem is, that the world is generated automatically, depending on the given size by the user…

is there a way to subdivide the boxes depending on their size?

could not find anything in the javadocs or the forum…

You’d have to make your own mesh

But, why don’t you make a subdivided box model with blender (or any other modeling tool). Then you can use it as a template just by modifying the scale of it.

I guess if you make like 5 to 10 subdivisions on the mesh it will give good enough results in a fair range of scale.