# Separate \`DepthRenderer\`s not created for \`Camera\`s with the same name

**URL:** <https://forum.babylonjs.com/t/separate-depthrenderer-s-not-created-for-camera-s-with-the-same-name/63268>\
**Category:** Questions\
**Tags:** camera, depthrenderer\
**Created:** [April 25, 2026, 8:10am UTC](https://forum.babylonjs.com/t/separate-depthrenderer-s-not-created-for-camera-s-with-the-same-name/63268 "2026-04-25T08:10:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![regna](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/regna/32/23915_2.png) [@regna](https://forum.babylonjs.com/u/regna)\
**Post date:** [April 25, 2026, 8:10am UTC](https://forum.babylonjs.com/t/separate-depthrenderer-s-not-created-for-camera-s-with-the-same-name/63268/1 "2026-04-25T08:10:39Z")

</div>

According to [this part of the Babylon.js source](https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Rendering/depthRendererSceneComponent.ts#L60-L70), `new DepthRenderer()`is only created for every `Camera` with a unique name.

I have the (bad?) habit of not naming any Babylon objects (leaving the names as empty ‘’ strings). This caused 2 cameras to share a `DepthRenderer`, which caused `SelectionOutlineLayer` to sometimes not or partially render when swapping cameras.

Please see the video below where outlines render well with the player’s `ArcRotateCamera`, but switching to a `FreeCamera` causes outline rendering issues.

I simply solved this by giving both cameras unique names.

I was wondering if it would be preferable to create `new DepthRenderer()`for every `Camera` regardless of their names?

[![](https://img.youtube.com/vi/kgg31r0knmI/maxresdefault.jpg "DepthRenderer shared between Cameras bug") ](https://www.youtube.com/watch?v=kgg31r0knmI)

---

<div class="post-metadata">

**Author:** ![CrashMaster](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/crashmaster/32/23662_2.png) [@CrashMaster](https://forum.babylonjs.com/u/CrashMaster)\
**Post date:** [April 27, 2026, 7:23am UTC](https://forum.babylonjs.com/t/separate-depthrenderer-s-not-created-for-camera-s-with-the-same-name/63268/2 "2026-04-27T07:23:30Z")

</div>

I agree, using the name as key is error prone. I also got bitten by this a few months ago 😆

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [April 27, 2026, 9:06am UTC](https://forum.babylonjs.com/t/separate-depthrenderer-s-not-created-for-camera-s-with-the-same-name/63268/3 "2026-04-27T09:06:57Z")

</div>

Thanks for the report (and the clear repro video)!

You’re right that this is error-prone. The internal **Scene.\_depthRenderer** dictionary was keyed by **camera.id** , and since **Node.id** falls back to **name** , two unnamed cameras end up colliding on “” and sharing a single **DepthRenderer** — which is exactly what’s causing your **SelectionOutlineLayer** issue when switching cameras.

I just opened a PR that switches the key from **camera.id** to **camera.uniqueId** (which is guaranteed unique per **Camera** instance): [fix(depthRenderer): key Scene.\_depthRenderer by camera.uniqueId instead of camera.id by Popov72 · Pull Request #18384 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/pull/18384)

Each camera will now get its own **DepthRenderer** regardless of name/id, so the workaround of giving them unique names won’t be needed once this is merged.

---

<div class="post-metadata">

**Author:** ![regna](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/regna/32/23915_2.png) [@regna](https://forum.babylonjs.com/u/regna)\
**Post date:** [April 27, 2026, 11:22pm UTC](https://forum.babylonjs.com/t/separate-depthrenderer-s-not-created-for-camera-s-with-the-same-name/63268/4 "2026-04-27T23:22:38Z")

</div>

Thank you so much, Evgeni! 😄
