How can I get good shadows

tutorial
#1

I tried a lot
https://www.babylonjs-playground.com/#164IC3#2

for(var i =0; i < 100;i++){
change to
for(var i =0; i < 10;i++){

  • The shadows are getting better
#2

Hello and welcome!
The problem you are facing is due to the fact that your shadow map will lose a lot of precision to make sure it can embrace the entire scene.

Ideally we should have cascaded shadow maps to help with your case (wink wink @sebavan) but we do not support this feature yet.

So the idea is to keep in the shadow map only the meshes close to the camera. In any way this will be far better from a performance standpoint

1 Like
#3

Thanks!

Actually I use it in buildings. They are a mesh.

#4

Does the light move? Because if it does not move it could be worth baking the shadows into a texture so you can have the best rendering

#5

But DK… with baked-into-ground-texture building-shadows… user-carried flashlights/torches… cannot illuminate shadowed areas. :wink: (small price to pay, for huge added performance of baked shadows… I know) :slight_smile:

I think user will ALSO lose building shadows on OTHER buildings… with baked shadows on ground.

(Wingy prices supercomputers) :slight_smile:

#6

Yes I agree. If the op needs a dynamic shadow then we need to decouple the mesh into multiple meshes (like block by block for instance)

1 Like
#7

Yeah, essentially you are saying… “Don’t let the camera do such a WIDE view”. Keep things close-in… as much as possible, and do render-only-what’s-needed wisdom. nod. Tiling ops.

City is currently single mesh, huh? Interesting.

#8

Is there a good way to separate the mesh?

#9

A stupid question just occurred to me… Why do we need a shadow renderer? If there is no light, everything is dark. That is already the shadow! If the light is switched on, the rays only come where they are not hindered by objects, i.e. the dark areas remain dark!