Search Unity

post effect, what's the benefit of multi-pass shader, if it can be implemented it in one pass?

Discussion in 'General Graphics' started by bobozzz, Aug 7, 2017.

  1. bobozzz

    bobozzz

    Joined:
    May 27, 2015
    Posts:
    38
    I've noticed that Unity does lots of multi-pass shader for image effects, for example, for a down sampling by 4 with a 4x4 finding the highest value kernel (fragment shader), Unity uses two passes, each time down by 2, instead of one pass directly down by 4. This is the case even for the latest post processing stack.

    But why not do this in a single pass?

    If I calculated correctly, for a 600x800 texture, if doing this in one pass, the texture sampling times is
    (600 / 4) * (800 / 4) * 4 * 4 = 480000

    If in two passes, the texture sampling times is
    (600 / 2) * (800 / 2) * 2 * 2 + (600 / 2 / 2) * (800 / 2 / 2) * 2 * 2 = 600000

    So in this case multi-pass has more texture sampling than one pass, not mention multi-pass takes more rendering time than one pass.

    I understand for some complicated shader, we have to do it in multiple pass, but I wonder what's the benefit of multi-pass shader if it can be implemented it in one pass?