I have a Material whose fragment shader sets color and depth, and the color is showing up but the depth is not. (To debug, I dump the color and depth textures to image files after rendering a frame.) I've fiddled with depth in a Material's fragment shader before, but previously the Material was used by a render_quad
pass, and now I am directly applying the Material to Items. The material script specifies depth_check off
and depth_write on
, and likewise when I create the Material
, I supply an HlmsMacroblock
with mDepthCheck = false
and mDepthWrite = true
. The rendering of these Items is happening in a render_scene
pass whose script specifies store { depth store }
.
The Metal fragment shader looks like:
Code: Select all
#include <metal_stdlib>
#include <metal_math>
using namespace metal;
struct PS_OUTPUT
{
float4 color [[color(0)]];
float depth [[depth(any)]];
};
fragment PS_OUTPUT main_metal
(
depth2d<float, access::read> reflectedDepthMap [[texture(0)]],
depth2d<float, access::read> mainDepthMap [[texture(1)]],
float4 gl_FragCoord [[position]]
)
{
PS_OUTPUT result;
// irrelevant stuff
result.depth = 0.0;
result.color = float4( 1.0, 0.5, 0.0, 1.0 );
return result;
}
Any idea what could be wrong?