Video.fx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //////////////////////////////////////////////////////////////////////////////
  2. // ©2006 Electronic Arts Inc
  3. //
  4. // FX Shader for video decoding
  5. //////////////////////////////////////////////////////////////////////////////
  6. #include "Common.fxh"
  7. // ----------------------------------------------------------------------------
  8. // Textures declaration
  9. // ----------------------------------------------------------------------------
  10. SAMPLER_2D_BEGIN(FrameY,
  11. string SasBindAddress = "Video.FrameY";
  12. )
  13. AddressU = Clamp;
  14. AddressV = Clamp;
  15. MinFilter = Linear;
  16. MagFilter = Linear;
  17. MipFilter = Linear;
  18. SAMPLER_2D_END
  19. SAMPLER_2D_BEGIN(FrameU,
  20. string SasBindAddress = "Video.FrameU";
  21. )
  22. AddressU = Clamp;
  23. AddressV = Clamp;
  24. MinFilter = Linear;
  25. MagFilter = Linear;
  26. MipFilter = Linear;
  27. SAMPLER_2D_END
  28. SAMPLER_2D_BEGIN(FrameV,
  29. string SasBindAddress = "Video.FrameV";
  30. )
  31. AddressU = Clamp;
  32. AddressV = Clamp;
  33. MinFilter = Linear;
  34. MagFilter = Linear;
  35. MipFilter = Linear;
  36. SAMPLER_2D_END
  37. static const float3 ColorBias = {-0.062745, -0.50196, -0.50196};
  38. static const float3x3 ColorTransform = { 1.1641444, 1.1641444, 1.1641444,
  39. -0.0017889, -0.3914428, 2.0178255,
  40. 1.5957862, -0.8134821, -0.0012458};
  41. // ---------------------------------------------------------------------------
  42. struct VSOutput
  43. {
  44. float4 Position : POSITION;
  45. float2 TexCoords : TEXCOORD0;
  46. float4 Color : COLOR0;
  47. };
  48. // ---------------------------------------------------------------------------
  49. VSOutput VS(float4 Position : POSITION, float2 TexCoord0 : TEXCOORD0, float4 color : COLOR0 )
  50. {
  51. VSOutput Out;
  52. Out.Position = float4((Position * 2 - 1) * float2(1, -1), 0, 1);
  53. Out.Color = color;
  54. Out.TexCoords = TexCoord0;
  55. return Out;
  56. }
  57. // ---------------------------------------------------------------------------
  58. float4 PS(VSOutput In) : COLOR
  59. {
  60. float3 color;
  61. color.r = tex2D(SAMPLER(FrameY), In.TexCoords).r;
  62. color.g = tex2D(SAMPLER(FrameU), In.TexCoords).r;
  63. color.b = tex2D(SAMPLER(FrameV), In.TexCoords).r;
  64. color += ColorBias;
  65. float4 res;
  66. res.rgb = color;
  67. res.rgb = mul(color, ColorTransform);
  68. res.a = 1.0;
  69. return res * In.Color;
  70. }
  71. // ---------------------------------------------------------------------------
  72. technique Default
  73. {
  74. pass P0
  75. {
  76. CullMode = None;
  77. ZEnable = false;
  78. ZWriteEnable = false;
  79. AlphaTestEnable = false;
  80. AlphaBlendEnable = true;
  81. SrcBlend = SrcAlpha;
  82. DestBlend = InvSrcAlpha;
  83. VertexShader = compile VS_2_0 VS();
  84. PixelShader = compile PS_2_0 PS();
  85. }
  86. }