# Easy shadows (in editor, at design-time, too) by shadow volumes (and shadow maps are coming as well)

**URL:** <https://forum.castle-engine.io/t/easy-shadows-in-editor-at-design-time-too-by-shadow-volumes-and-shadow-maps-are-coming-as-well/652>\
**Category:** News\
**Created:** [October 3, 2022, 11:23am UTC](https://forum.castle-engine.io/t/easy-shadows-in-editor-at-design-time-too-by-shadow-volumes-and-shadow-maps-are-coming-as-well/652 "2022-10-03T11:23:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [October 3, 2022, 11:23am UTC](https://forum.castle-engine.io/t/easy-shadows-in-editor-at-design-time-too-by-shadow-volumes-and-shadow-maps-are-coming-as-well/652/1 "2022-10-03T11:23:38Z")

</div>

| [![Easy shadows](https://forum.castle-engine.io/uploads/default/original/1X/c6a5fbfe2b87941c42e3527b5f5548f26337842e.png)](https://i0.wp.com/castle-engine.io/wp/wp-content/uploads/2022/10/Zrzut-ekranu-z-2022-10-03-04-40-19.png?ssl=1 "Easy shadows") |
| [![Easy shadows](https://forum.castle-engine.io/uploads/default/original/1X/c0d0cbbb61d2688c5dabd48317fc2985455e8227.png)](https://i0.wp.com/castle-engine.io/wp/wp-content/uploads/2022/10/Zrzut-ekranu-z-2022-10-03-04-40-38.png?ssl=1 "Easy shadows") |

You can now activate shadows by _shadow volumes_ by toggling a trivial boolean property [Shadows](https://castle-engine.io/apidoc/html/CastleScene.TCastlePunctualLight.html#Shadows) at the light source to `true`! This works (also) in editor at design-time.

This makes the [shadow volumes we have documented here](https://castle-engine.io/x3d_extensions_shadow_volumes.php) easily available, finally. No more messing around with X3D lights nodes.

A simple demo is in [examples/viewport\_and\_scenes/shadows](https://github.com/castle-engine/castle-engine/tree/master/examples/viewport_and_scenes/shadows).

We also publish `TCastleTransform.CastShadows` property to control if some object casts shadows.

**Future** :

This is just the beginning of _“really easy shadows”_. I enjoy how simple API we have (just a checkbox really!) and how great it is to play with shadows in the editor. But we can improve the functionality underneath now 🙂

1. The most important TODO here is that we plan to expose [shadow maps](https://castle-engine.io/x3d_extensions_shadow_maps.php) in the same way. Actually shadow maps should be in the future the default algorithm activated by `Shadows` (and toggling between _shadow maps_ and _shadow volumes_ should be done using an independent property like `ShadowMode = smShadowMaps, smShadowVolumes`). 

2. Shadow volumes for now carry a few limitations:

---

<div class="post-metadata">

**Author:** ![Didi](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/didi/32/1908_2.png) [@Didi](https://forum.castle-engine.io/u/Didi)\
**Post date:** [October 4, 2022, 8:57am UTC](https://forum.castle-engine.io/t/easy-shadows-in-editor-at-design-time-too-by-shadow-volumes-and-shadow-maps-are-coming-as-well/652/2 "2022-10-04T08:57:27Z")

</div>

Easy shadows looks very good. When will this be available?

---

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [October 4, 2022, 3:34pm UTC](https://forum.castle-engine.io/t/easy-shadows-in-editor-at-design-time-too-by-shadow-volumes-and-shadow-maps-are-coming-as-well/652/3 "2022-10-04T15:34:29Z")

</div>

It is available already! 🙂

Most things we announce are available immediately, unless I specifically write they are only on some branch/PR. Just head over to our downloads on [Download | Castle Game Engine](https://castle-engine.io/download) , they point now to _“7.0-alpha.snapshot”_ version (already newer than _“7.0-alpha.2”_). This “snapshot” version is automatically updated whenever the “master” branch changes, after it passes a lot of automatic tests (it takes ~6h to make sure it compiles and all tests pass everywhere).

It already contains working shadows, including the ` examples/viewport_and_scenes/shadows` .

You can always take a look at [Release Latest release of Castle Game Engine (Auto-Updated Snapshot) · castle-engine/castle-engine · GitHub](https://github.com/castle-engine/castle-engine/releases/tag/snapshot) to see when were the last snapshot files updated (now it says “3 hours ago”) and what commit is there (now it is [Add zero vectors to initialize tex coords in TCastleImageTransform · castle-engine/castle-engine@343fb75 · GitHub](https://github.com/castle-engine/castle-engine/commit/343fb757cfabb6f8ab96c0d6febc5b1be8a0af43) , the very last commit I did yesterday to “master”).

---

<div class="post-metadata">

**Author:** ![AveryCTF](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/averyctf/32/958_2.png) [@AveryCTF](https://forum.castle-engine.io/u/AveryCTF)\
**Post date:** [October 4, 2022, 7:09pm UTC](https://forum.castle-engine.io/t/easy-shadows-in-editor-at-design-time-too-by-shadow-volumes-and-shadow-maps-are-coming-as-well/652/4 "2022-10-04T19:09:52Z")

</div>

I see this method effects self-shadowing, as well. Lovely!

If you can increase this to 2 lights, it would allow for more impactful effects, because your user could use one for, say, the sun, and the second reserved for special effects like explosions or car headlights. You definitely want things like explosions and headlights to cast shadows because they look very weird without it.

If you could make this a dynamic thing per object, such as determined by the most intense lightsource nearby, or to multiply the amount of shadows per object based on relevant lightsources, it would make it possible for scenes like large medieval war-camps with lamps and firepits to have rich cast-shadow effects all around that move appropriately with the characters.

But this is an exciting start! Keep up the awesome work, CGE is becoming more impressive with everything you do!

 ![ShadowsExample](https://forum.castle-engine.io/uploads/default/original/1X/3d1d3ab38e6962c7af8b83c4ebf469b9ffda922d.jpeg)

---

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [October 5, 2022, 8:14am UTC](https://forum.castle-engine.io/t/easy-shadows-in-editor-at-design-time-too-by-shadow-volumes-and-shadow-maps-are-coming-as-well/652/5 "2022-10-05T08:14:23Z")

</div>

Thank you for the good words, glad you like it!

As for incoming improvements to shadows:

1. On top of my priority is now to also enable “shadow maps” in the same way (i.e. the trivial checkbox `Shadows` should turn them on, and some additional property like `ShadowMode` should control the algorithm - shadow volumes or shadow maps).

2. Extending shadow volumes to enable multiple lights is still useful of course.

---

<div class="post-metadata">

**Author:** ![Didi](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/didi/32/1908_2.png) [@Didi](https://forum.castle-engine.io/u/Didi)\
**Post date:** [October 5, 2022, 9:16am UTC](https://forum.castle-engine.io/t/easy-shadows-in-editor-at-design-time-too-by-shadow-volumes-and-shadow-maps-are-coming-as-well/652/6 "2022-10-05T09:16:31Z")

</div>

Hi,

I tried the shadow with my characters (GLTF). It doesn’t work. The characters are in a correct shape (2-manifold), but I used more then one material in blender to set the colors.  
After rebuilding to one material with image and uv-editing it works.  
Is this behaviour correct? Is the limit only one material?

---

<div class="post-metadata">

**Author:** ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)\
**Post date:** [October 5, 2022, 10:15am UTC](https://forum.castle-engine.io/t/easy-shadows-in-editor-at-design-time-too-by-shadow-volumes-and-shadow-maps-are-coming-as-well/652/7 "2022-10-05T10:15:06Z")

</div>

> [@Didi](#):
>
> I tried the shadow with my characters (GLTF). It doesn’t work. The characters are in a correct shape (2-manifold), but I used more then one material in blender to set the colors.  
> After rebuilding to one material with image and uv-editing it works.  
> Is this behaviour correct? Is the limit only one material?

Unfortunately yes.

This is a consequence of limit " **each shape must be 2-manifold**" mentioned on [Shadow Volumes | Manual | Castle Game Engine](https://castle-engine.io/x3d_extensions_shadow_volumes.php#section_requirements) . In glTF it means “each glTF primitive must be 2-manifold” (glTF primitive corresponds to X3D shape). When exporting, Blender splits your object (with multiple materials) into multiple glTF primitives.

So, it would be more precise to say there “each glTF primitive (which is a subset of Blender mesh, limited to a single material)” must be 2-manifold.

It is possible to counter this limitation in the future. We could consider, for shadow volumes, larger units – and then only such “larger unit” (like whole Blender object) would need to be 2-manifold.
