Post process translucency for mesh dust particles

Hello,

I recently created a “fake” translucency for mesh dust particles and I’m quite satisfied with how it looks. The problem is optimisation, as always, and I need some help from more experienced UE4 devs to find a solution. With normal translucency there was a lot of overdraw and being able to see through dust (to a certain distance) is supposed to be an important feature, considering how this effect will cover the screen a lot of times. Currently effect based on post process looks like this:

Here is a video in HQ:

This is the process:

  1. Everything other than dust (blocks of buildings, terrain) must be placed in custom depth buffer.
  2. Using custom depth buffer and distance from the camera I create black and white image, that is supposed to be visible on the other side of the dust.
  3. Using both depth buffer (all objects including dust) and custom depth buffer (everything without dust) I create mask showing only dust pixels with custom depth actors “behind” them.
  4. I add some additional alpha and fresnel to the mask.
  5. I lerp between PostProcessInput0 and image from point 2, basing on alpha from 4.

It works quite nice if number of objects on the scene is not big, otherwise it slows down considerably, probably because actors in custom depth buffer are rendered in main depth buffer as well. I guess that’s the bottleneck here. I was thinking about different approaches, but have a few problems:

  • I have no idea how to force mesh particles to render in custom depth buffer.
  • I don’t know how to make object render only in custom depth buffer, without showing up in the main one, without turning off “Render in Main Pass” (doing that turns off its shadow and probably ambient occlusion as well).

So yeah, it would be nice to keep the effect this way (maybe plus shadows, which are turned off right now) and make it quicker. I’m even willing to modify engine’s code if necessary, but someone would need to show me where to start. I can also try to add and remove objects from custom depth buffer basing on distance from the camera in BPs, but that also sounds like an overkill.

I appreciate any advice. :slight_smile: