repeat.effect 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. uniform float4x4 ViewProj;
  2. uniform float4x4 color_matrix;
  3. uniform float3 color_range_min = {0.0, 0.0, 0.0};
  4. uniform float3 color_range_max = {1.0, 1.0, 1.0};
  5. uniform texture2d image;
  6. uniform float2 scale;
  7. sampler_state def_sampler {
  8. Filter = Linear;
  9. AddressU = Repeat;
  10. AddressV = Repeat;
  11. };
  12. struct VertInOut {
  13. float4 pos : POSITION;
  14. float2 uv : TEXCOORD0;
  15. };
  16. VertInOut VSDefault(VertInOut vert_in)
  17. {
  18. VertInOut vert_out;
  19. vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj);
  20. vert_out.uv = vert_in.uv * scale;
  21. return vert_out;
  22. }
  23. float4 PSDrawBare(VertInOut vert_in) : TARGET
  24. {
  25. return image.Sample(def_sampler, vert_in.uv);
  26. }
  27. float4 PSDrawMatrix(VertInOut vert_in) : TARGET
  28. {
  29. float4 yuv = image.Sample(def_sampler, vert_in.uv);
  30. yuv.xyz = clamp(yuv.xyz, color_range_min, color_range_max);
  31. return saturate(mul(float4(yuv.xyz, 1.0), color_matrix));
  32. }
  33. technique Draw
  34. {
  35. pass
  36. {
  37. vertex_shader = VSDefault(vert_in);
  38. pixel_shader = PSDrawBare(vert_in);
  39. }
  40. }
  41. technique DrawMatrix
  42. {
  43. pass
  44. {
  45. vertex_shader = VSDefault(vert_in);
  46. pixel_shader = PSDrawMatrix(vert_in);
  47. }
  48. }