Lighting problem

Hi, i’m having some issues with lighting materials. I’m trying to build a warehouse, with shelvings, pallets and boxes and when I place some lights to illuminate the scene (PointLights with a big enough radius) the floor doesn’t illuminate. However if the lights are very close to the floor, we can finally see it, but the shelvings are overexposed. See the 2 images (the lights are in the position of the white spheres):

If I add a directionalLight with direction Vector3f(0, -1, 0), the floor is clearly illuminated, but I want to use PointLights only in that scene.

am I doing something wrong with lights or materials? why the floor isn’t as sensitive to light as the other objects?

Here I declare one of the pointlights

[java]PointLight pl = new PointLight();



pl.setPosition(new Vector3f(-5f, 50f, 7f));


Materials declaration.

[java]// Floor material

floorMat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

Texture tex = assetManager.loadTexture(“Textures/Ground/road_line.jpg”);


floorMat.setTexture(“DiffuseMap”, tex);

floorMat.setFloat(“Shininess”, 5f);

// Example of shelving materials

metalMat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

metalMat.setTexture(“DiffuseMap”, assetManager.loadTexture(“Textures/Metal/metal_4.jpg”));

metalMat.setFloat(“Shininess”, 5f);[/java]

Floor creation:

[java]Box floorBox = new Box(new Vector3f(0, -1.2f, 0), 50, .2f, 50);

Geometry floorGeometry = new Geometry(“floor”, floorBox);

floorBox.scaleTextureCoordinates(new Vector2f(15, 15));


Plane plane = new Plane(new Vector3f(0, 1, 0), 0);

floor_phy = new RigidBodyControl(new PlaneCollisionShape(plane), 0);




It happens because the floor is too low resolution in terms of vertices, since you’re scaling up a box to work as a floor. Light attenuation interpolates on the vertex level as it is more efficient than passing the light position to the fragment shader.

Best thing I can suggest is to model a plane in Blender3D with which is subdivided with many vertices, then use that as a floor.

Maybe you can use the Grid primitive for your floor

I think the grid primitive only supports line mesh, so it might not work.

oh…that explains why it’s in the debug package then :stuck_out_tongue:

thanks a lot for the answers!! that was clearly the problem

I’ve been reading blender basics tutorials because i’ve never used blender before, and i’ve imported a .blend file of a plane with a repeated texture (by converting it to .j3o).

I must have done something wrong, because the texture doesn’t show up, and it looks like floor is fading out.

But If I set a material, the floor is clearly visible, although I don’t know how to do the repeating texture effect.

Am I doing something else wrong? This is the code:

[java] protected Spatial makeFloor() {

Spatial floor = assetManager.loadModel(“Scenes/floor.j3o”);

floor.setLocalTranslation(0, -1.2f, 0);


Plane plane = new Plane(new Vector3f(0, 1, 0), 0);

floor_phy = new RigidBodyControl(new PlaneCollisionShape(plane), 0);



return floor;


yes you have to set a material.

for the texture to repeat you have to specify it in the j3m file like this :

DiffuseMap: Repeat your/path/texture.png

or if you load the texture directly from the code, you have a setWrapMode method on the Texture object, set it to WrapMode.Repeat

Also you’ll probably have to scale the texture coordinates

for this you have to get the mesh from your floor geom and use the scaleTextureCoordinate method on it

((Geometry)floor).getMesh().scaleTextureCoordinates(new Vector2f(5.0f,5.0f));

for example, and your texture will repeat 5 times on each axis (u,v) on the mesh.

thank you! that seems to be what I need

but I got a castException “java.lang.ClassCastException: com.jme3.scene.Node cannot be cast to com.jme3.scene.Geometry”

although there are no compilation errors.

how can I solve this cast?