Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Draw Shader's second pass after Image Effects

Discussion in 'Shaders' started by DuvE, Sep 9, 2017.

  1. DuvE

    DuvE

    Joined:
    May 22, 2016
    Posts:
    167
    I have a custom shader applied to my particles and it has "edge detection/edge glow" image effect in the second pass. Is it possible to somehow draw that second pass after image effects (OnRenderImage)?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    No.

    All Passes in a shader are rendered in the same Queue as their parent SubShader.
    https://docs.unity3d.com/Manual/SL-SubShaderTags.html

    ImageEffects and CommandBuffer events don't have mid-queue granularity. They don't even have per-queue granularity. You can only do an image effect something before everything has rendered, after all opaque has been rendered, or after everything has been rendered.

    The solution for this is usually to render your objects with a replacement shader to a render texture that gets used as part of an image effect later. Search for "highlight effect".