Point light not fully shadowing the mesh

Hi everyone!

A silly shadowing question that I look some insight into. I have a point light set up to my game main character, so I can get cool looking shadows from the corners and when I peek into rooms that are dark! Spooky…

Anyways. Here is a literal “corner case” I have:

As you can see, I’m missing a part of the shadow! The corner model has a baseboard (dark part) that is pretty much not shadowed at all. I think this is just some configuration issue on my part, but I can’t quite grasp on what is going on. More to that, the inspector doesn’t have all the shadow hinges for me to pull around to see where the problem might be :thinking:

I kind of feel like that css debug gif with the shadows right now:

Here is my point light setup (parented to the character of course):

  const frontSpotLight = new SpotLight(
    new Vector3(0, 1.1, 0.1),
    new Vector3(0, 0, 1),
  frontSpotLight.radius = 30
  frontSpotLight.falloffType = PointLight.FALLOFF_GLTF
  frontSpotLight.diffuse = new Color3(1, 1, 1)
  frontSpotLight.intensity = 3
  frontSpotLight.range = 10

Shadow generator:

  const frontGenerator = new ShadowGenerator(1024, frontSpotLight)
  frontGenerator.filteringQuality = ShadowGenerator.QUALITY_LOW
  frontGenerator.darkness = 0

It’s hard to tell without a repro…

Anyway, the angle parameter to the SpotLight constructor is in radians, not degrees. Also, 180 seems a bit too much, try a lower value.

1 Like

Yeah true, changed it to Math.PI / 2, but still same result.

Also it seems that the distance from the corner does not change the gap size at all… :thinking:

Are you able to provide a live link, even if it’s not in the Playground?

1 Like

Can’t provide a link yet to the full game, I will probably do a playground later on if someone doesn’t have a clue what could be the issue before that :smiley:

Could this have something to do with the Mesh.MergeMeshes? Since I am using that to combine different cloned meshes, the shadow kind of cuts from the end of the corner piece…

No, Mesh.MergeMeshes should not do that… In any case, maybe you can test without doing this call to rule out this possibility?

I’ll do that later on… I have a hunch that this is a “peter panning” issue, since the floor and the wall are part of the same mesh

Yeap, fine tuning the bias and normalBias have improved the result:

The values right now are:

frontGenerator.bias = 0.000002
frontGenerator.normalBias = 0.00001

Not quite sure how to set the normalBias here in relation to the bias and how it actually affects the whole thing…

Aaaaand some other artifacts are popping up :smiley:

I think I found the right values now!

frontGenerator.bias = 0.00001
frontGenerator.normalBias = 0.00002

These for now seem to result in the best result in my case.

The problem was peter panning that was countered by tinkering with bias and normalBias values. Read more here: Shadows | Babylon.js Documentation

1 Like