# A masked material with opacity mask set through distance field always cast a shadow

**URL:** <https://forums.unrealengine.com/t/a-masked-material-with-opacity-mask-set-through-distance-field-always-cast-a-shadow/418401>\
**Category:** Rendering\
**Tags:** shadow, unreal-engine, masked, dynamic, question\
**Created:** [February 26, 2018, 7:02pm UTC](https://forums.unrealengine.com/t/a-masked-material-with-opacity-mask-set-through-distance-field-always-cast-a-shadow/418401 "2018-02-26T19:02:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoGoiA](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JoGoiA](https://forums.unrealengine.com/u/JoGoiA)\
**Post date:** [February 26, 2018, 7:02pm UTC](https://forums.unrealengine.com/t/a-masked-material-with-opacity-mask-set-through-distance-field-always-cast-a-shadow/418401/1 "2018-02-26T19:02:27Z")

</div>

Hello everybody 🙂

I have a material on a skeletal mesh that detect the distance field and set the opacity mask accordingly :

 ![232070-sans-titre-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/8/3/6831a6c4e40c6eea9a692a3df0334b61999f4326.jpeg)

When the skeletal mesh is inside a mesh, it is visible, when it is outside, it’s invisible.  
This thing works fluently.  
My problem is that the masked material still cast a shadow when it is fully transparent (opacity mask set to 0) :

 ![232081-portee-preview-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/f/9/6f9a00fb05e67cc1bd8ee90ae0002ed12ab80623.jpeg)

If I disconnect my DF mechanic in the material and set the opcity mask with a simple constant 0, the shadows desapears normally but when I use DF to build the mask, they remain.  
I tried to use an IF node and set the opacity to 1 or 0 acordingly to the result of the DF test but the shadow remains…  
I think it’s due to the absoluteWorldPosition node presence…

Is it a bug or a fiunctionnality ?  
How can mask my shadows in this case ?

---

<div class="post-metadata">

**Author:** ![C0dyTheDev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@C0dyTheDev](https://forums.unrealengine.com/u/C0dyTheDev)\
**Post date:** [December 6, 2022, 7:39pm UTC](https://forums.unrealengine.com/t/a-masked-material-with-opacity-mask-set-through-distance-field-always-cast-a-shadow/418401/2 "2022-12-06T19:39:35Z")

</div>

Hi, I’m having the same issue. Did you manage to solve it?

---

<div class="post-metadata">

**Author:** ![JDARRAS](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jdarras/32/619913_2.png) [@JDARRAS](https://forums.unrealengine.com/u/JDARRAS)\
**Post date:** [May 14, 2024, 8:35pm UTC](https://forums.unrealengine.com/t/a-masked-material-with-opacity-mask-set-through-distance-field-always-cast-a-shadow/418401/3 "2024-05-14T20:35:04Z")

</div>

Hello, did you find a solution ?  
JD
