Search Unity

How to apply Post Processing to specific layers while y sorting is enabled in top down game

Discussion in 'Image Effects' started by kijoe, Dec 19, 2018.

  1. kijoe

    kijoe

    Joined:
    Mar 25, 2017
    Posts:
    9
    I'm making a 2d top down game and I want to apply post processing effects like bloom to specific layers. So I've separated the game objects into specific layers. The objects which would respond to bloom are placed in post process layer which is rendered by a second camera which is at a depth lower than the main camera. This works fine however the objects are no longer y sorted as they are now being rendered by two different camera at different depths and their y sorting is being overridden by the depth of the cameras.Any help in this regard will be really appreciated.
     
  2. BabouDev

    BabouDev

    Joined:
    Feb 3, 2015
    Posts:
    12
    I would like some clarification on this as well. It seems like this tech stack was not developed with 2D in mind.

    So I can achieve the effect similar to what you want by not using LWRP. If I disable lwrp, I can have multiple cameras with separate post process profiles each applying or not applying specific effects.

    With LWRP enabled, the post process v2 does not work wihh multiple cameras and only takes the final rendered image. And on top of that the onrenderimage function does not exist in LWRP. So how does one go about doing post process effects in LWRP?
     
  3. kijoe

    kijoe

    Joined:
    Mar 25, 2017
    Posts:
    9
    I'm using the built-in pipeline the default one.The post processing works with multiple cameras.The problem is not that.Since my game is top down so I've enabled y-sorting.The problem is this y-sorting breaks if I use multiple cameras.
     
  4. DearUnityPleaseAddSerializableDictionaries

    DearUnityPleaseAddSerializableDictionaries

    Joined:
    Sep 12, 2014
    Posts:
    135
    Did you solve it?

    I've been trying to think of a solution for weeks.
     
  5. TotallyRonja

    TotallyRonja

    Joined:
    Oct 1, 2016
    Posts:
    9
    Postprocessing kinda has it in its name, it renders *after* everything else. And after everything is rendered, theres no way of reconstructing what layer a object that generated a certain pixel was part of.

    You could try to make your shaders render into the stencil buffer and then use that to only apply postprocessing to some parts of the image, keep in mind here that the stencil buffer has distinct values so it breaks as soon as you have semitransparent values which in 2D you have most of the time.

    Some effects can also be in the mesh shader itself, not in postprocessing and that gets around all that - sadly bloom isn't one of them and needs to operate on the whole image.

    TLDR: what you're looking for is not possible without complex workarounds that have artefacts or are very expensive