Volume absorption like in Blender

Hello,

I want to use the following volume material (exemple made in Blender) in UE4.

It’s a volume. Objects placed inside get darker and darker with the distance, until it gets pitch black.

I don’t think it require raytracing, since it works in Eevee, but I didn’t manage to do anything with UE4 volume materials.

Do you guys have a solution for that ? Thanks.

Upping this.

I tried multiple things. I can do anything but invisible materials with “volume” as material domain. And with “surface domain”, it’s no use, as it only apply the material on the mesh.

You need a post process effect.

I’m not sure you have access to distance from nearest surface within it - or the object pivot.

If you don’t have access, its still pretty simple.
make a material parameter collection with a v3 locatiom, make a blueprint, and tie the value of the v3 location to the location of the post process pivot.

Then you use that value which is in world space, to perform the math that generates the effect based in worldspace distance from the variable.

If you add volumetric fog onto it, you should be able to achieve the same effect.

If you need the value of the PP bounds to use as a distance and object bounds isn’t a thing inside the pp material, use the same trick as before. Create a v3 in the pp material, and make the BP keep track of the bound size.

Basically follow this for the base of the PP material

if you want to learn more volume effects try this one

If it’s a translucent material, could you not just use SceneDepth (which returns the depth value of pixels rendered behind a translucent material) and use that to drive some sort of multiplier or subtractive value that makes materials rendered behind it darker? This isn’t technically correct since it will also have the effect of further darkening anything which is not inside of the volume, but is instead just behind it (i.e. if the volume is between you and the object) but depending on the use case that probably wouldn’t be an issue anyway.

Thanks all. The solution was indeed to use a PostProcess Material, and Unreal Engine 4 Tutorial - Creating a Depth Fog Post Process - YouTube was a fantastic introduction.

Sorry I wasn’t very clear, as I forgot to mention the effect wasn’t dependent of the camera position, but just operate on an axis.

Here’s a solution for a fade-to-black effect on the Z axis, operating linearly between Z=-500 and Z=-1000.