Lights and shadows issues

Greetings !

I’m having a little issue working with lights and shadows currently.
I think it may be what’s called self-shadowing but I’m not really sure (for starters, nothing from this topic worked: [url]preventing objects from self-shadowing]).

Here’s a screenshot of the result:
postimage.org/image/61hl77lk1/

And this is how a set up the light and shadow caster:

    _sunLight = new DirectionalLight("sun_light");

    _sunLight->set_shadow_caster(true, 2048, 2048);
    _sunLight->get_lens()->set_near_far(1.f, 50.f);
    _sunLight->get_lens()->set_film_size(5096);

    _sunLightNode = window->get_render().attach_new_node(_sunLight);
    _sunLightNode.set_pos(0, -10.f, 0);
    _sunLightNode.set_hpr(-30, -80, 0);
    window->get_render().set_light(_sunLightNode);

As it turns out the shadows also look kinda weird. They’re a bit blurry, but setting the values of the shadow caster, I only managed to get no shadows at all, blurry shadows like that, and blurry shadows much much bigger than they should be.

So, is this self-shadowing, or does this come from the values I pass to the light ?

Thanks again.

Self-shadowing issues usually occur when you have doublesided faces, is that the case?

In any case, the depth map resolution is rather horrible, so you should consider setting the film size and possibly the view distance (far-near) to a lower value. Use showFrustum to show a visual representation of the frustum, and then adjust the values to make the frustum as small as possible by adjusting the film size and near/far planes.

Also, your sun is positioned at ground level (z=0), you should probably adjust that.

Hey ! It’s been a while but I’m back on this topic and worked a lot on it.

I have much better results following your adivces (the shadows are looking good now), but I still have self-shadowing issues.
I did a window->get_render()->set_two_sided(false);
Shouldn’t it resolve these kind of issues ?

I also realized that the self-shadowing only happened on the models I made myself.
Maybe they have doublesided faces indeed. I’m so bad at modeling I wouldn’t have noticed if I did it myself.

set_two_sided doesn’t override this for models that are loaded, since they simply get duplicate faces (with one set reversed). Check if your models are double-sided using pview and then using the option to enable back-face culling (‘i’, I think), and if the model doesn’t change, it must have double faces.

Alternatively, you could try and see if set_depth_offset(1) on your double-sided model does the trick.

Alright. This is what it looks like now with both set_two_sided(false) and set_depth_offset(1) on all of my models:

postimage.org/image/71y2lcfjf/

I checked the models with pview and they do have two-sided faces, no doubt about that.

set_two_sided(false) only undoes a previous call of set_two_sided(true). It won’t fix models that were already double-sided.

Anyway, it’s hard to tell from that screenshot what’s going on. I can’t tell which shadow is supposed to belong to which object.