Custom Postprocessing Effect (BeforeTransparent) Breaks Transparent Objects on iOS

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:

public override void Render(PostProcessRenderContext context)
{
    [...]
    context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
}
float4 Frag(Varyings i) : SV_Target
{
    float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
    return color;
}

FULL SOURCE: Simple Blit Postprocessing Effect · GitHub

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.

broken_blitting - Imgur

I came across the same issue did you find any solution to this?

Nope. But I started using custom “Render Features” inside the URP, instead of Postprocessing passes.

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

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

1 Like