# Unreal 5 Material Runtime Opacity problem with Shadows

**URL:** <https://forums.unrealengine.com/t/unreal-5-material-runtime-opacity-problem-with-shadows/1388474>\
**Category:** Rendering\
**Tags:** Shadows, opacity, unreal-engine, Rendering, Lighting, question\
**Created:** [November 13, 2023, 10:45pm UTC](https://forums.unrealengine.com/t/unreal-5-material-runtime-opacity-problem-with-shadows/1388474 "2023-11-13T22:45:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![BlackFlicka](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BlackFlicka](https://forums.unrealengine.com/u/BlackFlicka)\
**Post date:** [November 13, 2023, 10:45pm UTC](https://forums.unrealengine.com/t/unreal-5-material-runtime-opacity-problem-with-shadows/1388474/1 "2023-11-13T22:45:21Z")

</div>

Hello !

So I made a simple test level where I just change the opacity of some object material with a press of a button. But when the object disappears, its shadow stays on the level until I turn the camera around. When I turn the camera the shadows get cleaned up.  
I tried the same test on Unreal 4 and it seems to work fine, the shadows disappear immediately along with the object when I change its opacity.

What can I do to force the shadows to disappear along with the object ?  
 ![ezgif.com-video-to-gif](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/b/f/ebf02120be9b3c4206ac4eee97929181cdf0f3ce.gif)

 ![testmat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/c/3/5c38983afedc45c0409f5d51399bd2a80058d143.png)

---

<div class="post-metadata">

**Author:** ![BananableOffense](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BananableOffense](https://forums.unrealengine.com/u/BananableOffense)\
**Post date:** [November 13, 2023, 11:41pm UTC](https://forums.unrealengine.com/t/unreal-5-material-runtime-opacity-problem-with-shadows/1388474/2 "2023-11-13T23:41:57Z")

</div>

This is due to Virtual Shadow Maps. Shadow data is cached, and only updated when certain events invalidate the cache. If the cache is not invalidated by the material change along, you will need to force an invalidation somehow.  
This may require changing the objects mobility if it is set to static.  
This is because normally a static objects shadow never changes and never needs to be invalidated, until the light itself moves.  
Dynamic objects, like characters or meshes using WPO on the other hand invalidate the cache every frame.

You can also disable VSM and switch to CSM to get the same behavior as in UE4.

---

<div class="post-metadata">

**Author:** ![BlackFlicka](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BlackFlicka](https://forums.unrealengine.com/u/BlackFlicka)\
**Post date:** [November 14, 2023, 8:09pm UTC](https://forums.unrealengine.com/t/unreal-5-material-runtime-opacity-problem-with-shadows/1388474/3 "2023-11-14T20:09:25Z")

</div>

I already set the object to be Movable

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/3/77394bd5ebb1ec37248510ff1d8b7ac0da1bdd2e.jpeg)

---

<div class="post-metadata">

**Author:** ![BlackFlicka](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BlackFlicka](https://forums.unrealengine.com/u/BlackFlicka)\
**Post date:** [November 15, 2023, 7:00pm UTC](https://forums.unrealengine.com/t/unreal-5-material-runtime-opacity-problem-with-shadows/1388474/4 "2023-11-15T19:00:37Z")

</div>

Thank you ! Disabling the VSM worked !

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [December 15, 2023, 7:00pm UTC](https://forums.unrealengine.com/t/unreal-5-material-runtime-opacity-problem-with-shadows/1388474/5 "2023-12-15T19:00:50Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
