direct3d - Is it possible to skip color output in a pixel shader? -
i writing pixelshader (hlsl, sm40) , try skip output in cases. current code looks this:
float4 ps( ps_input input) : sv_target { float4 result=float4(1,1,1,0); if(input.col.r >= 0.999998f) result=float4(0,0,0,0); return result; }
but write black pixels not seen (as black backgroundcolor here). in cases pixel colored previously, pixels become black. intention skip writing rendertarget then. there way skip this, example code non working one:
float4 ps( ps_input input) : sv_target { float4 result=float4(1,1,1,0); if(input.col.r >= 0.999998f) return; //or 'return null;' return result; }
edit - have working (unoptimized keep comparable) sample:
float4 ps( ps_input input) : sv_target { float4 result=float4(1,1,1,0); if(input.col.r >= 0.999998f) discard; return result; }
this can achieved intrinsic function clip
(doc) or flow control statemant discard
(doc). in case clip
should best suited :)
Comments
Post a Comment