My shadow depth passes need to consider transparent objects as well. If the transparent fragments are "too transparent", I clip them away in the pixel shader. I don't really care about the remaining, non-clipped fragments, except for the depth value. So, I wonder if this is a legal PS (seems to compile fine)?
float PS(PSInputTexture input) : SV_Depth {
const float a = g_dissolve * g_diffuse_texture.Sample(g_sampler, input.tex).a;
clip(a - 0.8f);
return input.p.z;
}
In order to achieve this, I wonder what SV_Position.zw represents? SV_Position.xy are screen space coordinates. I presume SV_Position.z (projection Z -> homogeneous divide -> NDC Z -> viewport transform -> "viewport" Z, which will still be equal to NDC Z for a viewport Z range of [0.0f, 1.0f]) should be equal to SV_Depth?
↧