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:
- Have max depth set to say 1000 (everything further than 1000 units from camera will be black)
- Have Vector4 set to value (0,0,0,0)
- Use SceneDepth Node to get Depth at current pixel and divide it by max depth (scene_depth/max_depth)
- Use value you get in step 3 to set it as A value of Vector4 in step 4
- Multiply value from Color pin in SceneTexture:PostProcessInput0 with Vector4 from step 4
- 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.