Strange directional light bug

All geometries use the same material instance:
[java]blockMaterial = new Material(mainApplication.getAssetManager(), “Common/MatDefs/Light/Lighting.j3md”);
blockMaterial.setBoolean(“UseMaterialColors”, true);
blockMaterial.setColor(“Ambient”, new ColorRGBA(0.25f, 0.25f, 0.25f, 1));
blockMaterial.setColor(“Specular”, ColorRGBA.White);
blockMaterial.setColor(“Diffuse”, ColorRGBA.White);
blockMaterial.setFloat(“Shininess”, 5);[/java]
(Texture set via blockMaterial.setTexture(“DiffuseMap”, texture);)

There are no camera-specific changes like LOD. I’ll try to create a testcase, but I don’t know if I can track down the error^^

So you don’t clone the materials for each chunk or anything? Very strange.

Just for fun, can you change this ColorRGBA.White to this ColorRGBA.White.clone() in the above code block?

Also, can we see the full material setup? That doesn’t have textures or anything.

Do you use bump maps or normal maps? Do your chunks have normals for the geometry?

yeah if you use normal mapping do you generate the tangents on the mesh?

[java]blockMaterial.setTexture(“DiffuseMap”, assetManager.loadTexture(“Textures/terrain2.png”));[/java]

Texture used:

The chunks are custom meshes, I don’t generate tangents on it and I don’t use normal mapping, just the DiffuseMap.
(The mesh is generated here, it uses my Cubes framework: http://code.google.com/p/jmonkeyplatform-contributions/source/browse/trunk/cubes/Cubes/src/com/cubes/BlockChunk_MeshOptimizer.java)

EDIT: It could be something related to the mesh. In a seperated testcase with a small blockterrain and just a DirectionalLight, some block surfaces are completely black. So maybe something related to normals? I’ll finish the testcase and post the result here.
But I’m sure, it has to do with how the mesh is created.
EDIT²: Cloning the Color.White doesn’t help.

@destroflyer said: EDIT: It could be something related to the mesh. In a seperated testcase with a small blockterrain and just a DirectionalLight, some block surfaces are completely black. So maybe something related to normals? I'll finish the testcase and post the result here. But I'm sure, it has to do with how the mesh is created.
sounds like it yeah. According to the code your mesh has no normal buffer. Don't look further that's your issue.
1 Like

Thanks for your patience, guys. :slight_smile: The missing normal buffer was the solution.
In case, anyone encounters the same problem - The wiki describes it perfectly here: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:custom_meshes#exampleusing_meshes_with_lightingj3md