Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Custom Postprocessing Effect (BeforeTransparent) Breaks Transparent Objects on iOS

Discussion in 'Image Effects' started by noio, Oct 11, 2019.

  1. noio

    noio

    Joined:
    Dec 17, 2013
    Posts:
    224
    I think something is wrong with the way a custom PostProcessing effect affects the Depth texture.

    On iOS, when I introduce a simple BeforeTransparent PP effect that only blits the screen (without alteration), transparent objects are no longer rendered after that, if they have ZTest LEqual set. With ZTest Always the objects are visible. This makes me think something is wrong with the Depth. On desktop, things work normally.

    I have a simple PostProcessing effect that just blits:

    Code (CSharp):
    1.  
    2. public override void Render(PostProcessRenderContext context)
    3. {
    4.     [...]
    5.     context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
    6. }
    7.  
    Code (CSharp):
    1. float4 Frag(Varyings i) : SV_Target
    2. {
    3.     float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
    4.     return color;
    5. }
    FULL SOURCE: https://gist.github.com/noio/e2c4fbd9a1746abe5d06ea5e0d0700ff#file-justblit-shader

    The screenshots below show that the box with ZTest (the green one) is missing on iOS when the PP Blit is enabled. Additionally, the Screen Space (Camera) Canvas that I added with the box labels also doesn't render. I assume that this is also because of a broken depth test.

    https://i.imgur.com/ejXDtb2.png
     
    Last edited: Oct 11, 2019
  2. AdminLabGames

    AdminLabGames

    Joined:
    May 29, 2018
    Posts:
    1
    I came across the same issue did you find any solution to this?
     
  3. noio

    noio

    Joined:
    Dec 17, 2013
    Posts:
    224
    Nope. But I started using custom "Render Features" inside the URP, instead of Postprocessing passes.
     
  4. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    124
    We've just encountered the same issue. Which version of Unity are you guys using? We're on 2018.4... I'm wondering if it's worth an upgrade to see if this behaviour has been modified in future versions. Did you see this issue occurring in 2019 or 2020?

    Thanks!

    Ben
     
  5. Wriggler

    Wriggler

    Joined:
    Jun 7, 2013
    Posts:
    124
    To follow up on my own post: this issue is still present in the latest Unity 2018 LTS build (2018.4.25f1), but is fixed in Unity 2019. Seems like the issue is that any custom post-processing effect with BeforeTransparent resets the depth buffer in 2018 (only on iOS), so any subsequent render calls, i.e. for the transparent object pass, don't pass the z test. So nothing is rendered.

    This issue is iOS-specific, and appears to be fixed in Unity 2019.

    Ben
     
    noio likes this.