Shadow in both sides of an sphere

I am getting shadow from both sides of an sphere as shows in the picture :

The shadow code is super simple, it just have an sun attached to the shadow render, and all objects just cast, only the planet receive shadows.

Any ideas ?

It seems to be an common problem :
I gues in order to the shadow render to be able to render shadows from behind the objects to other objects, in the second pass it may have this kind of problem like in the second part of the picture (sphere shadow showing in the wall back).
I wander how could I disable it, if its possible, I will not have shadow casting from one object to another, just from the light to the object.
Anyone ?

Isn’t the wall a shadow receiver, but not a shadow caster, in the right side of the picture?
In that scenario, that would be the expected behavior then.

I understand, but my question is, is that possible to disable this shadows from the back ?
If I put my planet as cast and receive it fix this shadow problem, but I lost my sun effect around the planet because of the shadows.

Maybe make your planet cast, but not receive, then?

I maybe mistaken, but If I do it I am just disabling the shadows from the entire app, since the planet is the only object that should receive shadows… I am really missing options to customize the shadows, I know this is an special case, but still…

In the first image the block is properly lightened, one of it’s faces is covered in light while another is shadowed. So the block must have CastAndRecieve set, which cause that the one of it’s faces is shadowed by the second face.
This will probably work for full black shadows only, because JME draws shadows instead of not lightening the pixels that are covered in shadow.

The correct solution is to implement in-pass shadows as @FrozenShade mentioned… jME3 uses post-pass shadows which are physically incorrect as the shadows are drawn on top of an already lit scene, as opposed to using the shadow information to change the lighting from the shadowed light.

I’m almost sure that there was an possibility to adjust the shadow’s length. I used such thing at the very beginning of my adventure with JME’s shadows for point light. It would be a nice hack to cut the shadows in the middle of the planet.
I just can’t find it…

Well, that is exactly what I am looking for, if you find it, let me know ok ?
If I understood it, with it I could set an limit in distance for the shadow to be casted I am right ?

You mean that you lose the sun on the side of the planet where the sun doesn’t shine?

…so, in some cases you want the sun to shine through the planet and in some not?

Its hard to explain.
To have the effect I want from the sun, I simulate the sun + 4 lamps in the borders of the sun to get more light, so I can get the effect from the picture ( 70% of the planet illuminated from the lights ), other else I will get only 50% of the planet with lights. If I put the planet to cast and receive it will shadow itself and will disable the additional light I have in the scene.
Also, what I want have nothing to do with light, but shadow, I just want to disable the shadows that is getting from behind the planet ( other side of the sun ).
An option to configure the max distance to shadow like @FrozenShade said would fix it for me, since I could just configure it to planet_radious / 2.
There is one shadowMapSize but I dont think its what I am looking for…

The issue is that double-shadowing occurs, once from the lighting algorithm and then a second time from the shadow map being applied.

I found one method : getShadowZExtend
But there is no set for it, and also the result returns 0 ?
Is that correct ?

To disable the second shadow map would fix it as well, there is anyway to do it ?

You can use ambient or you can modify the shader’s code to gain different illumination.
I had similar ‘problem’, read my old topic, start from here. I made some ugly modifications, which works pretty even now. Get rid of additional lights, try to use only one but with different formula.

In that topic you’ll find some solution for shadows, to render them in other (correct) way.

But will this fix the shadow problem ?
I mean, I understand that if I build an new shader it will affect only the lights not the shadows or I am mistaken ?

first of all: use only one light, if you have sun, use only it, with different formula, if you need only one light to cast shadow. Or use ambient. anyway, those additional lights are unnatural and will complicate your scene and slow down your rendering.

After that you have two ways to go:

  1. continue to rebuild the shader and renderer to have natural shadowing, which will solve your current and future problems with shadows, or
  2. investigate the setShadowZExtend function and if it won’t help, override the shadow renderer and play with light radius passed to the shadow renderer.

I suggest option 1.

setShadowZExtend is unrelated to this issue, it’s meant to cap the range to render shadows for the camera point of view. Else shadows are rendered along the whole frustum of the camera.
Any value you can put into it won’t fix your issue.

Your issue is inherent to the very structure of the shadow passes.
Something could be done I guess though to detect this kind of situation, but not sure the computation would worth it as it would add some overhead for a very corner case issue.
Another solution would be to compose shadows in the lighting pass, This has been discussed many times and think that’s what @FrozenShade ended up doing. But that’s a difficult way.

But what I don’t get, is, why does the planet only receive shadows?

I think your question is, why I am not using cast and receive on the planet right ?
I already explain it, but I guess to understand it would be necessary to show some pics, the result is terrible on the planet light, it may be because I am using very poor quality shadows for performance, but anyway, I cant turn it on.
What I would like to ask you is about the second solution from @FrozenShade, the on extending the DirectionalLightShadowRenderer and changing the radius, I mean something like setShadowZExtend function from the light not from the camera. I didnt have time to look on this, but if you say this dosent worth I will give up on this.
I was thinking to try in another solution, something like, if the ship is behind the planet I could force disable the shadows, if this is simple, maybe calling something like setShadowIntensity(0), or disabling the shadow on all objects in loop ?
About creating the lighting pass approach, I have done this long time a go when using direct opengl functions, but I lost the code, it will require to rewrite all of this, and I dont know, I will do this as a last resort for now, unless there is something half ready or ready somewhere in the forum…
I also need some time to read all the FrozenShade topic, I know there is a lot of information there, not sure if it will help on my problem thought…