# Occlusion masking material affecting background

**URL:** <https://forums.unrealengine.com/t/occlusion-masking-material-affecting-background/1903043>\
**Category:** Blueprint\
**Tags:** occlusion, unreal-engine, question\
**Created:** [June 14, 2024, 1:30pm UTC](https://forums.unrealengine.com/t/occlusion-masking-material-affecting-background/1903043 "2024-06-14T13:30:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swevery](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Swevery](https://forums.unrealengine.com/u/Swevery)\
**Post date:** [June 14, 2024, 1:30pm UTC](https://forums.unrealengine.com/t/occlusion-masking-material-affecting-background/1903043/1 "2024-06-14T13:30:49Z")

</div>

I’m currently getting into materials and started work on a feature that’s masking out objects if they’re in between my character and my camera. I do this by comparing the distance between the pixels and my camera with the distance between my character and the camera. If the pixel is closer than the character and in a certain radius around it, they’re getting masked out. Now I’ve run into a few issues with this method. When applying the mask to a floor, or while standing in a corner, a big chunk of the objects are being masked out since they’re closer to the camera, although they aren’t really blocking the view.

 ![grafik](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/3/c/43ca818a3bbf1d179a4fee35c1b9bab003da4ff6.jpeg)

Any ideas for how I could filter these pixels out without just turning off the effect on the problematic objects? Here’s how my Material Function is currently set up:

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

---

<div class="post-metadata">

**Author:** ![ThorSeb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ThorSeb](https://forums.unrealengine.com/u/ThorSeb)\
**Post date:** [December 1, 2025, 4:00pm UTC](https://forums.unrealengine.com/t/occlusion-masking-material-affecting-background/1903043/2 "2025-12-01T16:00:39Z")

</div>

Did you find a solution? Im encountering the same issue.
