Hey guys,
I’m facing a problem since a few weeks: I have several objects with a lighting material (the block chunks of my world, 1 geomtry per chunk).
If I now add an object into the scene, which has a lighting material and look at it, the chunk under the camera becomes a bit darker.
When looking at the cow (lighing material):
When changing the ground material to unshaded:
It’s not easy to explain, I’ll try again: If I look away from the cow, the ground becomes brighter (as the other chunks, same result as in the second picture). Since this behaviour must be somehow related to the camera, I tracked down the error to the directional light. If I change the light’s direction from (-0.5f, -1, -0.5f).normalize() to something like (-1, -10, -1).normalize(), the effect becomes weaker. (If I remove the light from the scene, all works fine - Adding/Removing the DirectionalShadowRenderer doesn’t change anything)
Your screenshots aren’t showing up for me but I’m pretty sure I ran into this problem about a year ago when I was working on the lighting system for my game. I believe it has something to do with how multiple lighting passes are handled. I ran into it when I was using an ambient light and a directional light but I don’t really remember the specifics.
Shadows were my first guess, too. But even when removing the DirectionalLightRenderer, the texture gets darker when looking at the cow and brighter, when not looking at it. (It’s always the geometry under the camera -So when I move to the next chunk and look at the cow, another chunk becomes dark instead of the old one)
I’m only using the DirectionalShadowRenderer, initialized with the used DirectionalLight. (And an AmbientLight)
I can’t really reproduce the error, I tried making a test case, but it didn’t work out.
EDIT: Yes, it’s the shadow renderer from jME, not a custom implementation.
mhhh so the darker area matches a chunk of your terrain right?
About shadows, I can’t see a way the directional renderer would make a shadow with a corner and with a brighter intensity than the rest of the shadow. And with shadows inside shadows. (Yo dawg!)
Unless you have 2 shadow processors and that you are unaware of the second one…
That’s all I do related to lights and shadows:
[java]AmbientLight ambientLight = new AmbientLight();
ambientLight.setColor(ColorRGBA.White.mult(2.5f));
mainApplication.getRootNode().addLight(ambientLight);
DirectionalLight directionalLight = new DirectionalLight();
directionalLight.setDirection(lightDirection);
directionalLight.setColor(ColorRGBA.White.mult(0.5f));
mainApplication.getRootNode().addLight(directionalLight);
DirectionalLightShadowRenderer shadowRenderer = new DirectionalLightShadowRenderer(mainApplication.getAssetManager(), 2048, 3);
shadowRenderer.setLight(directionalLight);
shadowRenderer.setShadowIntensity(0.3f);
mainApplication.getViewPort().addProcessor(shadowRenderer);[/java]
(private final Vector3f lightDirection = new Vector3f(-0.5f, -1, -0.5f).normalizeLocal()
@destroflyer said:
Ok, sorry. Here's a second video with the DirectionalShadowRenderer being not added:
http://destroflyer.mania-community.de/other/videos/videos/light_bug2.avi
But as I said, the bevaviour is the same.
I hope you understand why we couldn’t take your word for it.
I think we will have to know more about your geometry and material setup to diagnose what might be wrong. Your best approach is to put together a simple test case since once you replicate the problem in the test case then you will know what is wrong. The fact that you are having trouble replicating the issue points even further to something in your code.
Does each chunk share a material or does each chunk have its own material? How are these materials setup? Do you do camera-specific changes to any part of your scene such as LOD, etc…? All of these are things to look into.