# More scenes are shadow casters for shadow volumes out-of-the-box, because of the auto-detection of 2-manifold scenes

**URL:** <https://forum.castle-engine.io/t/more-scenes-are-shadow-casters-for-shadow-volumes-out-of-the-box-because-of-the-auto-detection-of-2-manifold-scenes/1978>\
**Category:** News\
**Created:** [July 27, 2025, 3:42pm UTC](https://forum.castle-engine.io/t/more-scenes-are-shadow-casters-for-shadow-volumes-out-of-the-box-because-of-the-auto-detection-of-2-manifold-scenes/1978 "2025-07-27T15:42:21Z")\
**Posts on this page:** 3\
**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:** [July 27, 2025, 3:42pm UTC](https://forum.castle-engine.io/t/more-scenes-are-shadow-casters-for-shadow-volumes-out-of-the-box-because-of-the-auto-detection-of-2-manifold-scenes/1978/1 "2025-07-27T15:42:21Z")

</div>

| [![Demo from Delphi Summit 2025, with shadows](https://forum.castle-engine.io/uploads/default/original/2X/5/55f9d7698f35a7abaa93e70a11b4d7db43c5a08b.png)](https://castle-engine.io/wp/wp-content/uploads/2025/07/screenshot1.png "Demo from Delphi Summit 2025, with shadows") |
| [![Demo from Delphi Summit 2025, with shadows](https://forum.castle-engine.io/uploads/default/original/2X/f/f5fb96aa357fc9212a351460fcd973d3983d6184.png)](https://castle-engine.io/wp/wp-content/uploads/2025/07/screenshot2.png "Demo from Delphi Summit 2025, with shadows") |
| [![Alpaca, bull, shadows and WholeSceneManifold](https://forum.castle-engine.io/uploads/default/original/2X/f/f6896406badd139a3d492f39d9bd099a906ee8db.png)](https://castle-engine.io/wp/wp-content/uploads/2025/07/screenshot2-1.png "Alpaca, bull, shadows and WholeSceneManifold") |
| [![Throwing chickens demo](https://forum.castle-engine.io/uploads/default/original/2X/3/35807eb50b8489b1843ca99eea2b0da797888be9.png)](https://castle-engine.io/wp/wp-content/uploads/2025/07/screenshot-1.png "Throwing chickens demo") |

_(Yes, it’s a 3rd [news about Castle Game Engine](https://castle-engine.io/wp/) in 3 days. More to come — we have a backlog of things to announce! Brace yourselves 🙂 )_

We introduced an algorithm to detect _2-manifold_ scenes better, meaning that all scenes that are really 2-manifold (even if not all _shapes_ inside are 2-manifold) are automatically shadow casters for [shadow volumes](https://castle-engine.io/shadow_volumes).

This improves shadow volumes usage experience. You no longer have to mark such scenes with `TCastleRenderOptions.WholeSceneManifold`.

OK, I can see that the above description, while correct, may be confusing if you’re not familiar with how [shadow volumes](https://castle-engine.io/shadow_volumes) work. Let’s unpack this slowly 🙂

- [Shadow volumes](https://castle-engine.io/shadow_volumes) is one of the algorithms to achieve shadows using _Castle Game Engine_. It’s right now the simplest one to use, you only need to have 2-manifold models and then flip the `Shadows` checkbox at the light source to `true`.
  - Note: The _“simplest shadows algorithm to use”_ award will likely change to [shadow maps](https://castle-engine.io/roadmap#shadow_maps) in the future, once we implement a few improvements to it. See also [recent news post](https://castle-engine.io/wp/2025/06/21/slides-and-example-from-delphi-day-2025-presentation-and-after-thoughts-afterwarp-shadow-maps-bgfx-and-deferred-rendering/) about shadow maps plans.

  - But even then, both algorithms (_shadow volumes_ and _shadow maps_) will remain useful and available and in our engine. They both have their advantages and disadvantages (how shadows look, performance and possible optimizations, what is valid shadow caster…).

- For _shadow volumes_, only 3D objects that are _2-manifold_ can cast shadows. _2-manifold_ means that each edge has 2 neighbor faces. This is the most natural state for 3D models that represent real things, that have a _volume_ and are _watertight_, though in practice many 3D models have only _most_ edges with 2 neighbors. The _shadow volumes_ algorithm strictly requires that _all_ the edges of things that cast shadows have 2 neighbors.

- We allowed already 2 ways to cope with _2-manifold_ requirement: either make all _shapes_ 2-manifold, or use `TCastleRenderOptions.WholeSceneManifold` to treat whole scene (unchecked) as 2-manifold.

The new improvements means that you don’t need to touch `TCastleRenderOptions.WholeSceneManifold` if the scene is already 2-manifold.

Now, using the `TCastleRenderOptions.WholeSceneManifold` is only necessary if:

- You want to force the scene to be shadow caster for shadow volumes, even if it was _not_ detected as 2-manifold, Beware that rendering artifacts are possible in this case. However, we did find a number of cases when this forcing actually works properly (at least for the camera position/orientations that mattered in a given demo), despite scene not being a correct 2-manifold.

- Or if you just want to speed up loading. Marking scene as `TCastleRenderOptions.WholeSceneManifold` avoids any automatic detection, the appropriate check “passes automatically”.

We took care to check that this auto-detection doesn’t cause any issues:

- 

- We checked it doesn’t cause problems due to per-shape `TCastleScene.DistanceCulling` being disabled on scenes that are 2-manifold, but when shapes are not 2-manifold. The per-shape `TCastleScene.DistanceCulling` check is now really only done when shadow volumes are used, and scene is shadow caster, and whole scene is 2-manifold (but some shapes are not 2-manifold).

We have updated example on [examples/viewport\_and\_scenes/shadow\_volumes\_whole\_scene\_manifold](https://github.com/castle-engine/castle-engine/tree/master/examples/viewport_and_scenes/shadow_volumes_whole_scene_manifold), along with README description and screenshots inside. Part of this demo now works “out of the box”, alpaca model is automatically a shadow caster.

We also updated [documentation about shadow volumes](https://castle-engine.io/shadow_volumes). Many things have been upgraded, and naturally the section about 2-manifold objects (when they are detected, and when is `RenderOptions.WholeSceneManifold` useful) has been rewritten to reflect the current state.

We also updated the [Castle Model Viewer](https://castle-engine.io/castle-model-viewer) menu _“Help -\> 2-Manifold Information (Shadow Volumes Casting)”_. New colors of edges:

- _yellow_: manifold edges in the same shape, so this edge connects 2 faces within the same shape.
- _white_: manifold edges in the whole scene, so this edge connects 2 faces from different shapes.
- _blue_: border edge that doesn’t have 2 face neighbors. If you have this, this scene cannot be (reliably) a shadow caster for shadow volumes, because it is not 2-manifold.

Testing shows that this detection makes sense in many cases (and avoids you having to toggle dangerous `TCastleRenderOptions.WholeSceneManifold`) but also it fails in many cases (so `TCastleRenderOptions.WholeSceneManifold` still has a use-case, there are often no noticeable artifacts despite model not being 2-manifold).

- Examples where the new detection doesn’t help (`TCastleRenderOptions.WholeSceneManifold` still is necessary):
  - [physics\_throw\_chickens](https://github.com/castle-engine/castle-engine/tree/master/examples/physics/physics_throw_chickens) demo, both bull and chicken need `TCastleRenderOptions.WholeSceneManifold`
  - [split\_long\_animation](https://github.com/castle-engine/castle-engine/tree/master/examples/animations/split_long_animation)
  - [creature\_behaviors](https://github.com/castle-engine/castle-engine/tree/master/examples/creature_behaviors)
  - [cpp\_builder/window](https://github.com/castle-engine/castle-engine/tree/master/examples/delphi/cpp_builder/window)
  - [delphi summit 2025 game controllers demo](https://github.com/castle-engine/conference-delphi-summit-2025) (some models)

- Examples where the new detection helps (so shadow volumes are automatically ok):
  - [multiple\_viewports](https://github.com/castle-engine/castle-engine/tree/master/examples/viewport_and_scenes/multiple_viewports) (raptor)
  - [shadow\_volumes\_whole\_scene\_manifold](https://github.com/castle-engine/castle-engine/tree/master/examples/viewport_and_scenes/shadow_volumes_whole_scene_manifold) (alpaca)
  - [shadows\_distance\_culling](https://github.com/castle-engine/castle-engine/tree/master/examples/viewport_and_scenes/shadows_distance_culling)
  - [delphi summit 2025 game controllers demo](https://github.com/castle-engine/conference-delphi-summit-2025) (some models, like columns).

All in all, testing shows it’s a benefit, and doesn’t have any drawbacks 🙂

Sadly, it doesn’t mean we can get rid of `TCastleRenderOptions.WholeSceneManifold` (it would be nice to get rid of this dangerous checkbox, but it still makes sense).

Test it on your own projects and let us know (e.g. in the comments on the forum) how it works for you!

And if you like this work, please [support us on Patreon](https://www.patreon.com/c/castleengine). Thank you!

---

<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:** [July 27, 2025, 4:19pm UTC](https://forum.castle-engine.io/t/more-scenes-are-shadow-casters-for-shadow-volumes-out-of-the-box-because-of-the-auto-detection-of-2-manifold-scenes/1978/2 "2025-07-27T16:19:29Z")

</div>



---

<div class="post-metadata">

**Author:** ![edj](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/edj/32/1701_2.png) [@edj](https://forum.castle-engine.io/u/edj)\
**Post date:** [July 27, 2025, 6:26pm UTC](https://forum.castle-engine.io/t/more-scenes-are-shadow-casters-for-shadow-volumes-out-of-the-box-because-of-the-auto-detection-of-2-manifold-scenes/1978/3 "2025-07-27T18:26:24Z")

</div>

I would just force my terrain to manifold with WholeSceneManifold and never had issues. This sounds like a great update, but I gave up on volumetric shadows. Maybe they will be good for vehicles that move whenever I get back to them. I eagerly await the update for shadow maps.
