Shadow and ambient light

I have a simple scene with a box, ambient light (color 0.5f), directional light (color 0.5f) and a DirectionalLightShadowFilter (though the problem is the same with a renderer).

The problem is that the shadow seems to affect also the color contribution from ambient light, which seems to be strange for me. Is this behavior correct? In my opinion, the color from ambient light should be “added” after the shadow, i.e. the shadow should only “cancel” the color contribution from the directional light.

This behavior also leads to the strange behavior that when having directional light of color (0,0,0,1) and ambient light of color 1, there are still shadows with full intensity.

1 Like

Welcome to our community.

In JMonkeyEngine, the intensity of shadows is determined by filter.setShadowIntensity(), not by the lights themselves.

Thank you for your fast response.
So you can confirm that there is no way to make a plane having the same “brightness” in the following two scenarios:

  1. The plane receives no shadows and is only influenced by ambient light
  2. The plane receives an arbitrary amount of directional light, but is shadowed

Shadows are post-processed. This means the shadows are calculated after lighting. Their calculations have no bearing on lighting at all.

Game development is all about smoke and daggers, though. If you could explain your situation as a game-type problem there might be a known solution.

For example, typically when characters enter tunnels and caves, the lighting is changed somewhat to reflect that. It may appear as if it “just works” - but in fact lighting values are changed to “simulate” being indoors.

1 Like

Ok, here is my game-type problem:
I have a small object which is completely shadowed by a large object. It looks absolutely unrealistic, because a face of the object facing to the sun (directional light) is much brighter than a face facing away from the sun, although both faces are completely shadowed.

I would like to render the scene first with only directional light (and apply shadows with intensity 1.0) and render the scene afterwards with only ambient light (without shadow). The sum of both passes would be the correct, final result.

Is it possible to separate your scene graph?

For example,

* rootnode
  Ambient Light
  outdoors
    directional light
    stuff that is outdoors
  indoors
    stuff that is indoors

This way the things that are indoors are not affected by the directional light, but everything is affected by the ambient light.

Edit: To elaborate, a light will only affect the node and it’s children that it is added to.

Everything is outside, so that’s not possible. But I got around the worst issue by just disabling back face shadows, now it looks acceptable.

Thank you for your help.

1 Like