Camera depth fade not working

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)

1 Like

You can read the camera distance with:

333334-screenshot-1.jpg

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

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.

Opacity is opacity :slight_smile:

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

Ok, no no… :wink: Those nodes are instead of CDF.

Lemme knock something up…

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:

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

1 Like

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

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