A Few Questions About the Shadow Calculation


I'm relatively new to Cesium and have taken a look at the documentary as well as the source code of the software. The ShadowMap seems to handle the calculation of shadows in relation to the sun as a light source.

I'm actually quite surprised that Cesium is able to display shadows with relative high accuracy in real time even for large models (e.g. city maps). I have a couple of questions about that because the source code is pretty complex and hard to understand if you are not familiar with the entire basics.

1) What algorithm is used to calculate the shadows?

2) Are all the calculations done in real time or are they pre-processed and then loaded into the application at launch or when required?

3) Does the 3D model itself hold any information about which parts are covered by shadow or is the shadow a texture with no actual ties to the model itself?

Thanks in advance for any replies.

I’m glad you like the shadows!

The core algorithm is called Cascaded Shadow Maps. I gave a presentation that covers shadow mapping and talks about some of the choices we made in Cesium, check it out here: https://cesiumjs.org/presentations/ShadowsAndCesiumImplementation.pdf.

The calculations are done in real time. Right now there are no analytics behind it, so the model doesn’t know how much of it is in shadow, all the info is just in the shadow texture.

That helps a lot, thank you so much! :slight_smile:

Glad you’re interested! One of the things on our roadmap is a tutorial for shadows in Cesium, part of our learning materials / documentation update. See here: https://github.com/AnalyticalGraphicsInc/cesium/issues/5207#issuecomment-296288242

If you have any thoughts about what would be most helpful and interesting to include in our documentation / tutorials / technical blog posts, please feel free to comment! We’d be glad to get your thoughts. =)


  • Rachel