Hello guys,
While I slowly get familiar with jme, I encountered some issues with lighting.
I get the ambient light to work like a charm easily.
But even by copy-pasting the code in http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:light_and_shadow, I can’t manage to get directional light nor ambient occlusion to work properly (and directional light shadows do not even show).
Here are some screenshots of what I got (the top consists on a flat green layer with regularly spaced green blocks dropped on it):
With only an ambient light I got what I expected:
Only directional light:
Ambient light with some ambient occlusion (look like the occlusions are shifted to the side):
Ambient light, ambient occlusion and directional light (it is starting to get creepy):
As you can see, it does not looks as we could expect.
I think the issue is when I set the mesh.
Here is how I build the materials:
Material mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);
mat.setBoolean(“UseMaterialColors”,true);
mat.setColor(“Diffuse”, ColorRGBA.White);
mat.setColor(“Ambient”, colorOf(btype));
mat.setColor(“Specular”, colorOf(btype));
mat.setFloat(“Shininess”, 50f);
(On the screenshots, every meshes normals were set to {1,0,0, 1,0,0, 1,0,0}).
I use custom meshes.
And here is the code I copy-pasted from the tutorial for the light sources and the filters :
// Ambient light
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White.mult(0.5f));
rootNode.addLight(al);
// Directionnal light
DirectionalLight sun = new DirectionalLight();
sun.setColor(ColorRGBA.White);
sun.setDirection(new Vector3f(-1,-1,-1));
rootNode.addLight(sun);
// Filter post processor
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
// Ambient Occlusion
SSAOFilter ssaoFilter = new SSAOFilter(12.94f, 43.92f, 0.33f, 0.61f);
fpp.addFilter(ssaoFilter);
viewPort.addProcessor(fpp);
// Directionnal light shadows
final int SHADOWMAP_SIZE=1024;
DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 3);
dlsr.setLight(sun);////
viewPort.addProcessor(dlsr);
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(assetManager, SHADOWMAP_SIZE, 3);
dlsf.setLight(sun);
dlsf.setEnabled(true);
fpp.addFilter(dlsf);
I would realy appreciate if you could help me
Have a nice day !