struct fragment { float4 position : POSITION; //screen position float4 color0 : COLOR0; float4 depthTexCoord: TEXCOORD0; }; struct pixel { float4 color : COLOR; }; pixel main(fragment IN, const uniform sampler2D depthMap) { pixel OUT; OUT.color = IN.color0; // the depth buffer has to be compared to the current depth float4 depth = tex2D(depthMap, IN.depthTexCoord.xy); float test = IN.depthTexCoord.z / IN.depthTexCoord.w; // reject by alpha test if (test < depth.x) { OUT.color.w = 0; // OUT.color.y += 0.5; } return OUT; }