Does Flash Export support "Depth Only" camera clear?

We have a multi-layered Unity scene that uses several different cameras – a 2D background GUI layer, a 3D viewport containing a model, and then a viewport overlay containing labels with 3D lines pointing into the 3D model.

The background layer uses a camera that does a solid colour clear, then the viewport cameras each use CameraClearFlags.Depth, to clear and reuse the depth buffer.

This works great in the Editor, but when we export to Flash it seems that camera depth clear is not supported – it appears to do a solid colour clear. The result is that when we turn on the labels, the 3D model disappears and is covered up by the background colour of the label camera.

I can think of some possible workarounds, but first of all, should CameraClearFlags.Depth work in Flash?

EDIT: I created a simple test case for this and it does not show the problem. Continuing to investigate, will update this question if I learn anything new.

After some investigation with a simple test scene, it seems CameraClearFlags.Depth does work in Flash – but only if the viewport of the camera fills the entire screen. If the viewport fills a portion of the screen then setting depth-only clear will clear the camera to the background colour (wiping out everything rendered to that region by previously rendered cameras).

This is in Unity 3.5.2. I haven’t tested other versions. I filed a bug report.

EDIT: Until this bug is fixed, here’s a workaround …

Add the following shader to your project. It will set the depth buffer without touching the colour of any pixels. Create a material using this shader and attach it to a plane behind all the geometry viewed by your overlay camera. This plane will be drawn first, filling the depth buffer and allowing the contents of the overlay camera to be drawn with a “fresh” depth buffer.

Shader "Custom/DepthClear"
{
    SubShader
    {
        Tags {"Queue"="Background-1"}

        Pass
        {
            ZWrite On
            ZTest Always
            AlphaTest Off
            Cull Off
            Blend Zero One
            ColorMask 0
        }
    } 
    FallBack "Diffuse"
}

I don’t see a good reason why it shouldn’t work. Are you sure you have the correct camera-depth (order) setup?

If it really doesn’t work, i would call it a bug.