I really don’t know what I’m doing…
I followed the lighting documentation and read a few threads and I do have shadows “working”, but for this simple icosphere (and other models) I’m getting some odd lighting.
Here is my code for my lighting:
DirectionalLight sun = new DirectionalLight();
sun.setColor(ColorRGBA.White);
sun.setDirection(new Vector3f(.7f, -0.5f, 0.05f));
rootNode.addLight(sun);
AmbientLight al = new AmbientLight();
al.setColor(ColorRGBA.White);
rootNode.addLight(al);
final int SHADOWMAP_SIZE = 4096;
final int nbSplits = 4;
DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, nbSplits);
dlsr.setLight(sun);
viewPort.addProcessor(dlsr);
DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(assetManager, SHADOWMAP_SIZE, nbSplits);
dlsf.setLight(sun);
dlsf.setEnabled(true);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
fpp.addFilter(dlsf);
viewPort.addProcessor(fpp);
And here’s my code for setting up my geometry before adding it to the scene:
geom = assetManager.loadModel("assets/Models/treething/testthing.scene");
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setBoolean("UseVertexColor", true);
mat.setBoolean("UseMaterialColors", true);
mat.setColor("Ambient", color);
mat.setColor("Diffuse", color);
mat.setColor("Diffuse", ColorRGBA.White);
mat.setColor("Specular", color);
mat.setBoolean("VertexLighting", true);
geom.setShadowMode(ShadowMode.CastAndReceive);
geom.setMaterial(mat);
I don’t think it being a part of a scene has much to do with my problem because I get strange lighting like this if I just load .mesh.xml models as well.
I’m sure there’s just something that I’m doing wrong, and that something could be easily fixed if I knew what I was doing. While an immediate solution to this problem would be greatly appreciated, I’d also like to be more independent instead of having to depend on the forums for simple things like this.
Thank you!