uniform float4x4 ViewProj; uniform float4x4 color_matrix; uniform texture2d image; sampler_state def_sampler { Filter = Linear; AddressU = Clamp; AddressV = Clamp; }; struct VertInOut { float4 pos : POSITION; float2 uv : TEXCOORD0; }; VertInOut VSDefault(VertInOut vert_in) { VertInOut vert_out; vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj); vert_out.uv = vert_in.uv; return vert_out; } float4 PSDrawBare(VertInOut vert_in) : TARGET { return image.Sample(def_sampler, vert_in.uv); } float4 PSDrawAlphaDivide(VertInOut vert_in) : TARGET { float4 rgba = image.Sample(def_sampler, vert_in.uv); float alpha = rgba.a; float multiplier = (alpha > 0.0) ? (1.0 / alpha) : 0.0; return float4(rgba.rgb * multiplier, alpha); } float4 PSDrawMatrix(VertInOut vert_in) : TARGET { float3 rgb = image.Sample(def_sampler, vert_in.uv).rgb; float3 yuv = mul(float4(rgb, 1.0), color_matrix).xyz; return float4(yuv, 1.0); } technique Draw { pass { vertex_shader = VSDefault(vert_in); pixel_shader = PSDrawBare(vert_in); } } technique DrawAlphaDivide { pass { vertex_shader = VSDefault(vert_in); pixel_shader = PSDrawAlphaDivide(vert_in); } } technique DrawMatrix { pass { vertex_shader = VSDefault(vert_in); pixel_shader = PSDrawMatrix(vert_in); } }