# Is adding onAfterShadowMap RenderObservable possible?

**URL:** <https://forum.babylonjs.com/t/is-adding-onaftershadowmap-renderobservable-possible/3020>\
**Category:** Feature requests\
**Created:** [May 6, 2019, 4:28pm UTC](https://forum.babylonjs.com/t/is-adding-onaftershadowmap-renderobservable-possible/3020 "2019-05-06T16:28:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)\
**Post date:** [May 6, 2019, 4:28pm UTC](https://forum.babylonjs.com/t/is-adding-onaftershadowmap-renderobservable-possible/3020/1 "2019-05-06T16:28:41Z")

</div>

I see in the 4.0 what’s new that we now have a onBeforeShadowMapRenderObservable, which is great.

So I was wondering, has getting very deep black shadows - especially in gltf workflow - could be impossible, if we can be able to use this to turn all scene to black/every-color-you-need just before shadows rendering, then come back to normal render.

I don’t know if this could even works, and it seems a little overkill for the performances 😓 but I tried it anyway:

- the cornell box example with yellow shadows: [Babylon.js Playground](https://www.babylonjs-playground.com/indexStable.html#PZX7IR)
- a simpler example: [https://playground.babylonjs.com/#I8TW2J#4](https://playground.babylonjs.com/#I8TW2J#4)

In both playgrounds I want yellow shadows, and I use scene.ambientColor for that, but I need my ambientColor back to normal when shadow computation is done, that’s why I’m talking about onAfterShadowMapRenderObservable.

Also… maybe the way I want to to this is totally wrong?

PS: the already existing onBeforeShadowMapRenderObservable [is still not in the doc/api](https://doc.babylonjs.com/search/?bjsq=onBeforeShadowMapRenderObservable).

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [May 6, 2019, 5:05pm UTC](https://forum.babylonjs.com/t/is-adding-onaftershadowmap-renderobservable-possible/3020/2 "2019-05-06T17:05:10Z")

</div>

All in for the idea! Please open a repo issue and reference it from here 😉

---

<div class="post-metadata">

**Author:** ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)\
**Post date:** [May 6, 2019, 5:42pm UTC](https://forum.babylonjs.com/t/is-adding-onaftershadowmap-renderobservable-possible/3020/3 "2019-05-06T17:42:30Z")

</div>

Job done! [shadowGenerator: add onAfterShadowMapRenderObservable · Issue #6314 · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/issues/6314)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [May 6, 2019, 5:50pm UTC](https://forum.babylonjs.com/t/is-adding-onaftershadowmap-renderobservable-possible/3020/4 "2019-05-06T17:50:29Z")

</div>

Will take care of it!

---

<div class="post-metadata">

**Author:** ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)\
**Post date:** [May 6, 2019, 6:19pm UTC](https://forum.babylonjs.com/t/is-adding-onaftershadowmap-renderobservable-possible/3020/5 "2019-05-06T18:19:26Z")

</div>

issue duration: 20 minutes. Nice 😃

---

<div class="post-metadata">

**Author:** ![Vinc3r](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/vinc3r/32/25340_2.png) [@Vinc3r](https://forum.babylonjs.com/u/Vinc3r)\
**Post date:** [May 7, 2019, 7:41am UTC](https://forum.babylonjs.com/t/is-adding-onaftershadowmap-renderobservable-possible/3020/6 "2019-05-07T07:41:13Z")

</div>

OK so my “hack” attempt doesn’t works at all 😃 [https://playground.babylonjs.com/#I8TW2J#6](https://playground.babylonjs.com/#I8TW2J#6)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [May 7, 2019, 3:36pm UTC](https://forum.babylonjs.com/t/is-adding-onaftershadowmap-renderobservable-possible/3020/7 "2019-05-07T15:36:30Z")

</div>

Hehe, the shadowmap does not contains colors but only depth values (distances from the light)

The shadowmap is then used during mesh rendering to evaluate if the light can reach each pixel
