How can i get a dark distance like fog?

Hey, I like me shaders, so I suggesst using post-processing material and Scene Depth with masking. What you can do is to have a Black color mask (Vector4) and based on the Scene Depth set alpha value (A value of RGBA in Vector4).
Specifically:

  1. Have max depth set to say 1000 (everything further than 1000 units from camera will be black)
  2. Have Vector4 set to value (0,0,0,0)
  3. Use SceneDepth Node to get Depth at current pixel and divide it by max depth (scene_depth/max_depth)
  4. Use value you get in step 3 to set it as A value of Vector4 in step 4
  5. Multiply value from Color pin in SceneTexture:PostProcessInput0 with Vector4 from step 4
  6. Plug result of multiplication to Emission Color pin in output node

Should probably do the trick. For more information on how to work with post-process material check documentation Post Process Materials | Unreal Engine Documentation

Hope it helps.

EDIT: Another way is to use value from step 3 to create Vector3, where each component of the vector is equal to value from step 3, this gives you a grey color and pretty much just makes objects further from camera darker. You can avoid doing step 2 then.

2 Likes

Hello peoples! I was wondering how do you make your game have a dark distance effect sorta how fog is but black. because you cant have black fog it will just be transparent and no fog will be there. Something like this ECHOES of P.T. | RE77 - YouTube see how when hes walking down the hallway its dark but as he moves he can see gives it a really nice horror vibe. If anyone knows how to do it would be helpful <3

1 Like