# Is there any way to use stencils in a masked or opaque material?

**URL:** <https://forums.unrealengine.com/t/is-there-any-way-to-use-stencils-in-a-masked-or-opaque-material/482452>\
**Category:** Rendering\
**Tags:** dfao, unreal-engine, mask, question\
**Created:** [April 25, 2021, 9:06pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-use-stencils-in-a-masked-or-opaque-material/482452 "2021-04-25T21:06:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivan316ivan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ivan316ivan](https://forums.unrealengine.com/u/ivan316ivan)\
**Post date:** [April 25, 2021, 9:06pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-use-stencils-in-a-masked-or-opaque-material/482452/1 "2021-04-25T21:06:44Z")

</div>

**Main question:** I want to hide the water inside my boat, I am using the Single Layer Water Material which can be either Masked or Opaque. However to use **stencils** I need to have a Translucent material, which I don’t want to do unless there is no other way.  
**Is there any way to use stencils in a masked or opaque material?**

**My alternative:**  
I have tried to use the Distance Field information (DistanceToNearestSurface node) however it obviously creates a shadow where placed and if I deactivate its shadow casting, distance field shadows or dynamic shadows it stops cutting the hole, which makes sense, but is there a way to use distance field info while not casting a shadow?

**Additional info on my alternative Distance Field method** :

- I use disable render in main pass to hide the cutout object
- Disabling lighting channels only hides the cascaded shadow not the DFAO

 ![337106-captura.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/0/e/90ea9e82fee6712690b1396cb3966bb6628349ea.jpeg)

I do not want to disable DFAO altogether, I would prefer using a Translucent material or some other alternative.

Spherical Masks or similar would be impractical if there is a lot of boats (I think).  
Do you know any other ways to mask out water?

Thank you for your time!

---

<div class="post-metadata">

**Author:** ![Kehel18](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kehel18](https://forums.unrealengine.com/u/Kehel18)\
**Post date:** [April 26, 2021, 4:56pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-use-stencils-in-a-masked-or-opaque-material/482452/2 "2021-04-26T16:56:57Z")

</div>

Take a look at this [Custom Depth and Custom Depth Stencil in UE4 - Superyateam Gamedev](https://superyateam.com/2019/06/17/custom-depth-and-custom-depth-stencil-in-ue4/)
