# Camera depth fade not working

**URL:** <https://forums.unrealengine.com/t/camera-depth-fade-not-working/480748>\
**Category:** Cinematics & Media\
**Tags:** fade-inout-a-scene, unreal-engine, question\
**Created:** [March 23, 2021, 11:00am UTC](https://forums.unrealengine.com/t/camera-depth-fade-not-working/480748 "2021-03-23T11:00:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin114987](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kevin114987](https://forums.unrealengine.com/u/kevin114987)\
**Post date:** [March 23, 2021, 11:00am UTC](https://forums.unrealengine.com/t/camera-depth-fade-not-working/480748/1 "2021-03-23T11:00:55Z")

</div>

Hello all.

I have a question about using camera depth fade in my material. I have fog in my scene that needs to fade out when I get close to it. Best would be if it was based on camera location, but I cant seem to get it to work.

In the material editor, it gets the result I want, but in game it just messes up my texture.

Any idea how to implement the fade? My texture already has so many nodes, I don’t know where to implement the depth fade.

My material is translucent.

(iam not using UE fog because aim making a VR game for quest, which can’t handle fog very well)

 ![333307-cameradepthfade.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/e/0/8e0b800daf5bb3be21c1af8ee2a169888712f071.jpeg)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 23, 2021, 1:56pm UTC](https://forums.unrealengine.com/t/camera-depth-fade-not-working/480748/2 "2021-03-23T13:56:26Z")

</div>

You can read the camera distance with:

![333334-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/2/5/e25a574ce2ee2830169b29333a0163fdbc5cc717.jpeg)

Just use this to make sure the opacity is 0 when it’s close.

---

<div class="post-metadata">

**Author:** ![kevin114987](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kevin114987](https://forums.unrealengine.com/u/kevin114987)\
**Post date:** [March 24, 2021, 10:50am UTC](https://forums.unrealengine.com/t/camera-depth-fade-not-working/480748/3 "2021-03-24T10:50:00Z")

</div>

Thank you for your response. It didn’t work, I think it has to do with the multiple opacity layers that are connected to the material. I have a mask for the fog transparency, then a gradient on the corners to fade out the material and then the distance fade.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 24, 2021, 10:54am UTC](https://forums.unrealengine.com/t/camera-depth-fade-not-working/480748/4 "2021-03-24T10:54:04Z")

</div>

Opacity is opacity 🙂

If you put this ( probably with a little extra math ) right on the opacity pin, when this reaches zero, you will see nothing.

---

<div class="post-metadata">

**Author:** ![kevin114987](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kevin114987](https://forums.unrealengine.com/u/kevin114987)\
**Post date:** [March 24, 2021, 11:08am UTC](https://forums.unrealengine.com/t/camera-depth-fade-not-working/480748/5 "2021-03-24T11:08:02Z")

</div>

![333433-materialpic-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/6/4/4640a419227c5c7b487041e7d53e394f69a59dac.jpeg)

I don’t know if aim doing this right. But placing it like this will just completely remove all the opacity I have attached.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 24, 2021, 11:09am UTC](https://forums.unrealengine.com/t/camera-depth-fade-not-working/480748/6 "2021-03-24T11:09:49Z")

</div>

Ok, no no… 😉 Those nodes are instead of CDF.

Lemme knock something up…

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 24, 2021, 11:21am UTC](https://forums.unrealengine.com/t/camera-depth-fade-not-working/480748/7 "2021-03-24T11:21:30Z")

</div>

So, I took the basic shape material from the engine, and made it fade to nothing as the camera moves closer than 500 units like this:

 ![333422-screenshot-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/8/7/b87d2e14c1c3fd3ebf603044a87019d6e6b614ab.jpeg)

I think you already have opacity code, just to show the fog shapes, this needs to be multiplied by the network I’ve shown here. That has the effect of showing what you have now when the camera is \> 500 and fading anything you have when it’s \< 500:

![333423-ezgifcom-optimize.gif](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/4/4/2448fd0d706365bed4585d9e8b735522d62518e8.gif)

---

<div class="post-metadata">

**Author:** ![kevin114987](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kevin114987](https://forums.unrealengine.com/u/kevin114987)\
**Post date:** [March 24, 2021, 11:43am UTC](https://forums.unrealengine.com/t/camera-depth-fade-not-working/480748/8 "2021-03-24T11:43:29Z")

</div>

Thank you so much for your time and having patient with me haha, still figuring this all out.  
It works perfectly now, thank you!!!
