default.effect 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. uniform float4x4 ViewProj;
  2. uniform float4x4 color_matrix;
  3. uniform texture2d image;
  4. sampler_state def_sampler {
  5. Filter = Linear;
  6. AddressU = Clamp;
  7. AddressV = Clamp;
  8. };
  9. struct VertInOut {
  10. float4 pos : POSITION;
  11. float2 uv : TEXCOORD0;
  12. };
  13. VertInOut VSDefault(VertInOut vert_in)
  14. {
  15. VertInOut vert_out;
  16. vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj);
  17. vert_out.uv = vert_in.uv;
  18. return vert_out;
  19. }
  20. float4 PSDrawBare(VertInOut vert_in) : TARGET
  21. {
  22. return image.Sample(def_sampler, vert_in.uv);
  23. }
  24. float4 PSDrawAlphaDivide(VertInOut vert_in) : TARGET
  25. {
  26. float4 rgba = image.Sample(def_sampler, vert_in.uv);
  27. float alpha = rgba.a;
  28. float multiplier = (alpha > 0.0) ? (1.0 / alpha) : 0.0;
  29. return float4(rgba.rgb * multiplier, alpha);
  30. }
  31. float4 PSDrawMatrix(VertInOut vert_in) : TARGET
  32. {
  33. float3 rgb = image.Sample(def_sampler, vert_in.uv).rgb;
  34. float3 yuv = mul(float4(rgb, 1.0), color_matrix).xyz;
  35. return float4(yuv, 1.0);
  36. }
  37. technique Draw
  38. {
  39. pass
  40. {
  41. vertex_shader = VSDefault(vert_in);
  42. pixel_shader = PSDrawBare(vert_in);
  43. }
  44. }
  45. technique DrawAlphaDivide
  46. {
  47. pass
  48. {
  49. vertex_shader = VSDefault(vert_in);
  50. pixel_shader = PSDrawAlphaDivide(vert_in);
  51. }
  52. }
  53. technique DrawMatrix
  54. {
  55. pass
  56. {
  57. vertex_shader = VSDefault(vert_in);
  58. pixel_shader = PSDrawMatrix(vert_in);
  59. }
  60. }