No LoD for shadows?

LoD works fine. I use it to hide far away tiles of in OSM render.
Shadows are great to, makes the virtual world way more realistic.

If a tile gets invisible, its shadow should get invisible to, shouldn’t it?
But it doesn’t! (see appended picture).
The LoD visibility depends to the distance to the camera; fine.
The shadow visibility depends to the distance to the Shadow Camera? No please.

The GPU doing the cyclically LoD check and switching, not by BJS code, right?

I checked the BJS forum for that topic and found nothing.
But I found this related Playground https://www.babylonjs-playground.com/#RLQ5JX#5
by Babylon.js Documentation
And, o wonder, it works fine. The (box) shadows disappear with the boxes and are replaced by the sphere shadows.

So I checked, what’s different to my code: the playground uses instances.
LoD of shadows work fine with instances but NOT with the originals!
That’s not as it should be, hm?
Is it an error of the (my) GPU or is it caused and correctable by BJS code?

So what, I changed my code and used instances.
And yes, it works BUT the CPU load is twice as high, not useful to me.

To hand you a playground, I edited another example:
https://www.babylonjs-playground.com/#F7KZ7C#11

This time, even if I did not use instances, the shadow disappeared correctly :open_mouth:
Why? Because this time I did not use addLODLevel with the second parameter as null.
Only by using null, the BJS error occurs, if I many call it an error.

That means, I have a nice workaround: replace the near mesh by an (invisible) dummy-far-mesh :slight_smile:
!!! NOT working. Please wait …

LODs are not correctly handled by the render target texture for the time being.

This PR will correct these problems (but you already know it as you took the last PG from it :wink: ).

1 Like

Found a simple workaround for me:
I use scene.customLODSelector now
(so I can change the distance dynamically, according to the fps)

if (distance > max ) { mesh.isVisible = false; return null: }
else                 { mesh.isVisible = true;  return mesh; }

Setting isVisible also changes the visibility for the ShadowCamera :slight_smile:
The correct return is still needed for the actual camera;
Waiting for the BJS V5.0 to check if the workaround is obsolete.

What?:
If I use waterMaterial.addToRenderList, the objects get invisible!
(Not the shadows :dizzy_face: )