# How to interact with shadows in shaders that move vertices

**URL:** <https://forum.babylonjs.com/t/how-to-interact-with-shadows-in-shaders-that-move-vertices/61875>\
**Category:** Questions\
**Tags:** material, nme, shadows, shadowgenerator\
**Created:** [December 21, 2025, 1:17pm UTC](https://forum.babylonjs.com/t/how-to-interact-with-shadows-in-shaders-that-move-vertices/61875 "2025-12-21T13:17:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Panuchka](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/panuchka/32/12054_2.png) [@Panuchka](https://forum.babylonjs.com/u/Panuchka)\
**Post date:** [December 21, 2025, 1:17pm UTC](https://forum.babylonjs.com/t/how-to-interact-with-shadows-in-shaders-that-move-vertices/61875/1 "2025-12-21T13:17:02Z")

</div>

Hi everyone!

I’m hoping to get general guidance on how to interact with shadows with my node material shader. I have a _very_ complex main shader I use in my game. There is a part that moves the vertices a bit according to uv2 texture, so I can make trees and foliage wobble a bit, so I can simulate them being affected by “wind”.

Currently, the wobbly effect does not effect the shadows at all. Take a look at the picture below:

![shadowsss2](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/9/99c17a6335d76d2571c3f168434f48a389b3e4c9.gif)

So the shadows stay stationary the whole time. Is there any way to include the vertex movement to the shadows themselves? Will that be costly performance wise? I use the cascaded shadow generator in my case.

Thanks in advance for all the help 🤓

---

<div class="post-metadata">

**Author:** ![tanpopo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tanpopo/32/32025_2.png) [@tanpopo](https://forum.babylonjs.com/u/tanpopo)\
**Post date:** [December 22, 2025, 3:20am UTC](https://forum.babylonjs.com/t/how-to-interact-with-shadows-in-shaders-that-move-vertices/61875/2 "2025-12-22T03:20:18Z")

</div>

The reason is shadow use his own shader to render depth. You can use `ShadowDepthWrapper` using another node material with the same vertex part and a simple fragment part, this should not cost much but depends on your vertex code.

---

<div class="post-metadata">

**Author:** ![Panuchka](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/panuchka/32/12054_2.png) [@Panuchka](https://forum.babylonjs.com/u/Panuchka)\
**Post date:** [December 22, 2025, 9:01am UTC](https://forum.babylonjs.com/t/how-to-interact-with-shadows-in-shaders-that-move-vertices/61875/3 "2025-12-22T09:01:35Z")

</div>

Woah thank you, that was easier than I thought! Hooked it up and seems to work well 🤩 Thanks for pointing me to the solution!

![shadowsss4](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/3/8/389867ab13982c57e4794e598d5df9b4a6bc0011.gif)

Here is a relevant part of the docs for future readers: [Babylon.js docs](https://doc.babylonjs.com/features/featuresDeepDive/lights/shadows#per-material-shadow-depth-map-shader)
