Terrain self-shadow with CascadedShadowGenerator

Hi, I am trying to use a CascadedShadowGenerator with terrain generated from a height map but I am unable to set it up correctly so that the terrain casts shadows on its self.

I always get stripes all over the terrain. I am tweaking the bias and normalBias, but all I can achieve is various sized stripes or no shadow at all. I have tweaked the height map example with CascadedShadowGenerator. I have also replaced the default light with a directional light with a position above the terrain:

I am able to get shadows with just ShadowGenerator and useBlurExponentialShadowMap, but I would like the have cascaded shadowmaps. What is could be the problem and what is generally a good shadow setup for larger terrains with self-shadowing? Should I rather bake the lightmap? And just let other objects cast shadows on the terrain?

The shadowGenerator.shadowMaxZ (the default value is 10000) was too high and was causing precision issues,

you can set it to smth like shadowGenerator.shadowMaxZ = 100; to avoid stripes : )

idk how to self cast shadows w/ just a bump map tho : O

1 Like

though if it’s just bump map it would make it self shadow already right? that’s what bump maps are for

There’s a bug with the terrain material when using CSM. This PR will fix it:

Once merged, this PR will work as expected:

3 Likes

@Evgeni_Popov Absolutely awesome, thank you! Now it is working as expected in my case too. Small tweak to the normalBias to fix self-shadow artifacts and it is perfect!

@Heaust-ops I mean a lightmap, not a bump/normal map. These have pre-computed lighting, including shadows, GI, etc.

1 Like