# Fixes and optimizations: Shadow Volumes Optimizations, Shadow Maps Refactor, Nintendo Switch updates, important fixes

**URL:** https://forum.castle-engine.io/t/fixes-and-optimizations-shadow-volumes-optimizations-shadow-maps-refactor-nintendo-switch-updates-important-fixes/1404
**Category:** News
**Created:** [October 27, 2024, 4:19pm UTC](https://forum.castle-engine.io/t/fixes-and-optimizations-shadow-volumes-optimizations-shadow-maps-refactor-nintendo-switch-updates-important-fixes/1404 "2024-10-27T16:19:09Z")
**Posts on this page:** 2
**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 27, 2024, 4:19pm UTC](https://forum.castle-engine.io/t/fixes-and-optimizations-shadow-volumes-optimizations-shadow-maps-refactor-nintendo-switch-updates-important-fixes/1404/1 "2024-10-27T16:19:09Z")

</div>

| [![LCL TCastleControl](https://forum.castle-engine.io/uploads/default/original/2X/f/f62019dadc7e013d0ef6d77a640fa2025440e662.png)](https://castle-engine.io/wp/wp-content/uploads/2024/10/lcl_viewer_run.png "LCL TCastleControl") | [![Pirates - at Dev Days Summer 2024!](https://forum.castle-engine.io/uploads/default/original/2X/3/34916a1a95ad69a9f881be9bce6c78260672d070.png)](https://castle-engine.io/wp/wp-content/uploads/2024/08/pirates_screenshot_editor.png "Pirates - at Dev Days Summer 2024!") | [![Pirates demo with shadows](https://forum.castle-engine.io/uploads/default/original/2X/6/6d6fa0dfb26c6f8a03a67d30b8c532be1a381e8a.png)](https://castle-engine.io/wp/wp-content/uploads/2024/10/Zrzut-ekranu-z-2024-10-27-17-16-50.png "Pirates demo with shadows") |

1. We’ve made a big optimization to processing of large worlds (which means: many `TCastleTransform` in a [viewport](https://castle-engine.io/viewport_and_scenes)), that in particular benefits cases when you use [shadow volumes](https://castle-engine.io/shadow_volumes).

This changes how an important rendering code works. We now make 1 pass to collect all the shapes, and reuse results of this pass a few times — 2x without shadow volumes (because we render opaque and then transparent objects), 4x for shadow volumes (was 5x before the optimization, but I managed to completely remove one). This means that “traversing transformations” (which matters for large worlds) is 2x-5x faster now.

This matters for a number of applications, in particular it is impactful for applications using shadow volumes and non-trivial amount of scenes: [pirates demo for Dev Days of Summery 2024](https://github.com/castle-engine/conference-dev-days-summer-2024) or games like [DSRally from DiDi](https://forum.castle-engine.io/t/dsrally-game-is-finished/1396).

For some technical details, see [notes in the GitHub issue](https://github.com/castle-engine/castle-engine/issues/614) and [notes about AddRenderEvent (how to make custom rendering code now)](https://github.com/Kagamma/cge-effekseer/pull/6).

_(This was done over a month ago, but I finally got to announcing it: ) )._

2. We made a [big refactor](https://github.com/castle-engine/castle-engine/commit/7031d20e73a38d66985e35f8e53cd298e252c519) to [the shadow maps processing](https://castle-engine.io/x3d_extensions_shadow_maps.php).

3. Small inspector rendering optimizations, and `FrameProfiler` shows now also rendering time spent in `DrawPrimitive2D` and `TDrawableImage`.

4. [Nintendo Switch](https://castle-engine.io/nintendo_switch) version updated.

5. Improvement: In the design mode (that is, in [editor](https://castle-engine.io/editor)), we always have _precise collisions_. You no longer need to worry to toggle `TCastleSceneCore.PreciseCollisions` just to select things in the editor.

6. Fix: Important fix has been pushed for physics. If you modify a transformation of `TCastleTransform` that has children `TCastleTransform`, and these children have physics behaviors ([colliders, rigid body](https://castle-engine.io/physics)) then it’s automatically OK now.

7. Fix: Saved JSONs are a bit shorter. No need to write JSON object for a vector / color with default value.

8. Fix: `Container.MousePosition` during `Motion` events could be wrong due to recent [Motion events collecting](https://github.com/castle-engine/castle-engine/blob/master/src/ui/castleuicontrols_container.inc#L27). It’s OK now. This also fixes `mdRotate` option of the `TCastleWalkNavigation`.

9. Fix: Billboards in multiple viewports are now rendered OK. This also fixes lights gizmos in editor, when using camera preview. This also fixes lights gizmos in editor in [terrain demo](https://github.com/castle-engine/castle-engine/tree/master/examples/terrain) blinking.

10. Improvements: [examples/lazarus/model\_3d\_viewer](https://github.com/castle-engine/castle-engine/tree/master/examples/lazarus/model_3d_viewer) for various UI improvements.

11. Improvements: default `.gitignore` for new projects is improved to ignore some files produced by Delphi.

---

<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: [December 28, 2024, 1:38pm UTC](https://forum.castle-engine.io/t/fixes-and-optimizations-shadow-volumes-optimizations-shadow-maps-refactor-nintendo-switch-updates-important-fixes/1404/2 "2024-12-28T13:38:17Z")

</div>


