Search Unity

Post Processing Stack V2 motion blur and transparency

Discussion in 'Image Effects' started by Graham-B, May 1, 2020.

  1. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    Does anyone know if it is possible to use the Post Processing Stack V2 motion blur effect with meshes containing transparent or fade materials?

    As soon as I add transparency to my custom shader or even simply switch the standard shader to fade or transparent, the motion blur effect no longer works properly. It looks great when using a fully opaque shader, but since I want to have hair on my character some transparency would be nice.

    Any advice would be much appreciated!
     
  2. tombuben

    tombuben

    Joined:
    Apr 2, 2019
    Posts:
    4
    Transparent shaders don't draw into the motion vector buffer, which is used to create the blur effect (as there's honestly no simple way of representing the optical flow at those places properly).

    Writing custom motion vector shaders is pretty much undocumented. I've been looking into how it's done in the built-in pipeline for a while now. I guess that the motion vector shaders aren't calculated at all for any material that are in the "Transparent" RenderQueue.
     
    Graham-B likes this.
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    What you can do though if on desktop, is render opaque and blend (sample) the previous frame's colour buffer (or current on some pipelines/setups).

    This fake transparency is only good for 1 level deep (you can't have transparent behind transparent also blur), but it it will motion blur correctly as you're only rendering opaque pretending to be transparent.

    It might be good for simple transparencies like cloaks, or parts, but won't hold up on close inspection where you need transparent blur behind transparent blur. So you would probably want to experiment and it would never look correct in all circumstances.

    I did this on PS Vita a few years ago, so it can be effective.
     
    tombuben and Graham-B like this.