home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 275 / DPCS0111DVD.ISO / Toolkit / Audio-Visual / VirtualDub / Source / VirtualDub-1.9.10-src.7z / src / Riza / source / displaydx9_ps2.fxh < prev    next >
Encoding:
Text File  |  2009-10-24  |  19.3 KB  |  693 lines

  1. //    VirtualDub - Video processing and capture application
  2. //    A/V interface library
  3. //    Copyright (C) 1998-2008 Avery Lee
  4. //
  5. //    This program is free software; you can redistribute it and/or modify
  6. //    it under the terms of the GNU General Public License as published by
  7. //    the Free Software Foundation; either version 2 of the License, or
  8. //    (at your option) any later version.
  9. //
  10. //    This program is distributed in the hope that it will be useful,
  11. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. //    GNU General Public License for more details.
  14. //
  15. //    You should have received a copy of the GNU General Public License
  16. //    along with this program; if not, write to the Free Software
  17. //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. #ifndef DISPLAYDX9_PS2_FXH
  20. #define DISPLAYDX9_PS2_FXH
  21.  
  22. ////////////////////////////////////////////////////////////////////////////////////////////////////
  23. //
  24. //    Pixel shader 2.0 paths
  25. //
  26. ////////////////////////////////////////////////////////////////////////////////////////////////////
  27.  
  28. void VertexShaderPointBilinear_2_0(VertexInput IN, out float4 oPos : POSITION, out float2 oT0 : TEXCOORD0, out float2 oT1 : TEXCOORD1) {
  29.     oPos = IN.pos;
  30.     oT0 = IN.uv;
  31.     oT1 = IN.uv2 * vd_vpsize.xy / 16.0f;
  32. }
  33.  
  34. float4 PixelShaderPointBilinear_2_0(float2 t0 : TEXCOORD0, float2 ditherUV : TEXCOORD1) : COLOR0 {
  35.     float3 c = tex2D(samp0, t0).rgb;
  36.                  
  37.     return float4(c, 0) * (254.0f / 255.0f) + tex2D(samp1, ditherUV) / 256.0f;
  38. };
  39.  
  40. technique point_2_0 {
  41.     pass p0 <
  42.         bool vd_clippos = true;
  43.     > {
  44.         VertexShader = compile vs_2_0 VertexShaderPointBilinear_2_0();
  45.         PixelShader = compile ps_2_0 PixelShaderPointBilinear_2_0();
  46.  
  47.         MinFilter[0] = Point;
  48.         MagFilter[0] = Point;
  49.         MipFilter[0] = Point;
  50.         AddressU[0] = Clamp;
  51.         AddressV[0] = Clamp;
  52.         Texture[0] = <vd_srctexture>;
  53.  
  54.         MinFilter[1] = Point;
  55.         MagFilter[1] = Point;
  56.         MipFilter[1] = Point;
  57.         AddressU[1] = Wrap;
  58.         AddressV[1] = Wrap;
  59.         Texture[1] = <vd_dithertexture>;
  60.  
  61.         AlphaBlendEnable = false;
  62.     }
  63. }
  64.  
  65. technique bilinear_2_0 {
  66.     pass p0 <
  67.         bool vd_clippos = true;
  68.     > {
  69.         VertexShader = compile vs_2_0 VertexShaderPointBilinear_2_0();
  70.         PixelShader = compile ps_2_0 PixelShaderPointBilinear_2_0();
  71.  
  72.         MinFilter[0] = Linear;
  73.         MagFilter[0] = Linear;
  74.         MipFilter[0] = Linear;
  75.         AddressU[0] = Clamp;
  76.         AddressV[0] = Clamp;
  77.         Texture[0] = <vd_srctexture>;
  78.  
  79.         MinFilter[1] = Point;
  80.         MagFilter[1] = Point;
  81.         MipFilter[1] = Point;
  82.         AddressU[1] = Wrap;
  83.         AddressV[1] = Wrap;
  84.         Texture[1] = <vd_dithertexture>;
  85.  
  86.         AlphaBlendEnable = false;
  87.     }
  88. }
  89.  
  90. struct VertexOutputBicubic_2_0 {
  91.     float4    pos        : POSITION;
  92.     float2    uvfilt    : TEXCOORD0;
  93.     float2    uvsrc0    : TEXCOORD1;
  94.     float2    uvsrc1    : TEXCOORD2;
  95.     float2    uvsrc2    : TEXCOORD3;
  96. };
  97.  
  98. VertexOutputBicubic_2_0 VertexShaderBicubic_2_0_A(VertexInput IN) {
  99.     VertexOutputBicubic_2_0 OUT;
  100.     
  101.     OUT.pos = IN.pos;
  102.     OUT.uvfilt.x = IN.uv2.x * vd_vpsize.x * vd_interphtexsize.w;
  103.     OUT.uvfilt.y = 0;
  104.  
  105.     OUT.uvsrc0 = IN.uv + float2(-1.5f, vd_fieldinfo.y)*vd_texsize.wz;
  106.     OUT.uvsrc1 = IN.uv + float2( 0.0f, vd_fieldinfo.y)*vd_texsize.wz;
  107.     OUT.uvsrc2 = IN.uv + float2(+1.5f, vd_fieldinfo.y)*vd_texsize.wz;
  108.     
  109.     return OUT;
  110. }
  111.  
  112. VertexOutputBicubic_2_0 VertexShaderBicubic_2_0_B(VertexInput IN, out float2 ditherUV : TEXCOORD4) {
  113.     VertexOutputBicubic_2_0 OUT;
  114.     
  115.     OUT.pos = IN.pos;
  116.     OUT.uvfilt.x = IN.uv2.y * vd_vpsize.y * vd_interpvtexsize.w;
  117.     OUT.uvfilt.y = 0;
  118.     
  119.     float2 uv = IN.uv2 * float2(vd_vpsize.x, vd_srcsize.y) * vd_tempsize.wz;
  120.     OUT.uvsrc0 = uv + float2(0, -1.5f)*vd_tempsize.wz;
  121.     OUT.uvsrc1 = uv + float2(0,  0.0f)*vd_tempsize.wz;
  122.     OUT.uvsrc2 = uv + float2(0, +1.5f)*vd_tempsize.wz;
  123.     
  124.     ditherUV = IN.uv2 * vd_vpsize.xy / 16.0f;
  125.     
  126.     return OUT;
  127. }
  128.  
  129. float4 PixelShaderBicubic_2_0_A(VertexOutputBicubic_2_0 IN) : COLOR0 {        
  130.     float4 weights = tex2D(samp0, IN.uvfilt) * float4(0.5, 1.0, -0.25, -0.25) + float4(0, 127.0f / 255.0f, 0, 0);
  131.         
  132.     float4 c = tex2D(samp2, IN.uvsrc1) * weights.g
  133.              + tex2D(samp1, IN.uvsrc0) * weights.b
  134.              + tex2D(samp1, IN.uvsrc2) * weights.a
  135.              + tex2D(samp1, IN.uvsrc1) * weights.r;
  136.              
  137.     return c;
  138. }
  139.  
  140. float4 PixelShaderBicubic_2_0_B(VertexOutputBicubic_2_0 IN, float2 ditherUV : TEXCOORD4) : COLOR0 {
  141.     float4 weights = tex2D(samp0, IN.uvfilt) * float4(0.5, 1.0, -0.25, -0.25) + float4(0, 127.0f / 255.0f, 0, 0);
  142.     
  143.     float3 c = tex2D(samp2, IN.uvsrc1).rgb * weights.g
  144.              + tex2D(samp1, IN.uvsrc0).rgb * weights.b
  145.              + tex2D(samp1, IN.uvsrc2).rgb * weights.a
  146.              + tex2D(samp1, IN.uvsrc1).rgb * weights.r;
  147.                           
  148.     return float4(c * (254.0f / 255.0f), 0) + tex2D(samp3, ditherUV) / 256.0f;
  149. }
  150.  
  151. technique bicubic_2_0 {
  152.     pass horiz <
  153.         string vd_target="temp";
  154.         string vd_viewport="out, src";
  155.     > {
  156.         VertexShader = compile vs_2_0 VertexShaderBicubic_2_0_A();
  157.         PixelShader = compile ps_2_0 PixelShaderBicubic_2_0_A();
  158.         
  159.         Texture[0] = <vd_interphtexture>;
  160.         AddressU[0] = Wrap;
  161.         AddressV[0] = Clamp;
  162.         MipFilter[0] = None;
  163.         MinFilter[0] = Point;
  164.         MagFilter[0] = Point;
  165.  
  166.         Texture[1] = <vd_srctexture>;
  167.         AddressU[1] = Clamp;
  168.         AddressV[1] = Clamp;
  169.         MipFilter[1] = None;
  170.         MinFilter[1] = Point;
  171.         MagFilter[1] = Point;
  172.         
  173.         Texture[2] = <vd_srctexture>;
  174.         AddressU[2] = Clamp;
  175.         AddressV[2] = Clamp;
  176.         MipFilter[2] = None;
  177.         MinFilter[2] = Linear;
  178.         MagFilter[2] = Linear;
  179.     }
  180.     
  181.     pass vert <
  182.         string vd_target="";
  183.         string vd_viewport="out,out";
  184.     > {
  185.         VertexShader = compile vs_2_0 VertexShaderBicubic_2_0_B();
  186.         PixelShader = compile ps_2_0 PixelShaderBicubic_2_0_B();
  187.         Texture[0] = <vd_interpvtexture>;
  188.         Texture[1] = <vd_temptexture>;
  189.         Texture[2] = <vd_temptexture>;
  190.         
  191.         Texture[3] = <vd_dithertexture>;
  192.         AddressU[3] = Wrap;
  193.         AddressV[3] = Wrap;
  194.         MipFilter[3] = None;
  195.         MinFilter[3] = Point;
  196.         MagFilter[3] = Point;
  197.     }
  198. }
  199.  
  200. ////////////////////////////////////////////////////////////////////////////////////////////////////
  201. //
  202. //    UYVY/YUY2 to RGB -- pixel shader 2.0
  203. //
  204. ////////////////////////////////////////////////////////////////////////////////////////////////////
  205.  
  206. void VS_UYVY_to_RGB_2_0(
  207.     float4 pos : POSITION,
  208.     float2 uv : TEXCOORD0,
  209.     float2 uv2 : TEXCOORD1,
  210.     out float4 oPos : POSITION,
  211.     out float2 oT0 : TEXCOORD0,
  212.     out float2 oT1 : TEXCOORD1,
  213.     out float2 oT2 : TEXCOORD2)
  214. {
  215.     oPos = pos;
  216.     oT0 = uv;
  217.     oT1 = oT0 + vd_texsize.wz * float2(0.25, 0);
  218.     oT2.x = vd_srcsize.x * uv2.x / 16.0f;
  219.     oT2.y = 0;
  220. }
  221.  
  222. float4 PS_UYVY_to_RGB_2_0(float2 uvY : TEXCOORD0, float2 uvC : TEXCOORD1, float2 uvSelect : TEXCOORD2) : COLOR0 {
  223.     float4 pxY = tex2D(samp0, uvY);
  224.     float4 pxC = tex2D(samp1, uvC);
  225.     float4 pxSelect = tex2D(samp2, uvSelect);
  226.  
  227.     float y = lerp(pxY.g, pxY.a, pxSelect.a);
  228.     float cr = pxC.r;
  229.     float cb = pxC.b;
  230.     
  231.     return ConvertYCbCrToRGB(y, cb, cr);
  232. }
  233.  
  234. technique uyvy_to_rgb_2_0 {
  235.     pass < string vd_viewport = "unclipped,unclipped"; > {
  236.         VertexShader = compile vs_2_0 VS_UYVY_to_RGB_2_0();
  237.         PixelShader = compile ps_2_0 PS_UYVY_to_RGB_2_0();
  238.         
  239.         Texture[0] = <vd_srctexture>;
  240.         AddressU[0] = Clamp;
  241.         AddressV[0] = Clamp;
  242.         MinFilter[0] = Point;
  243.         MagFilter[0] = Point;
  244.  
  245.         Texture[1] = <vd_srctexture>;
  246.         AddressU[1] = Clamp;
  247.         AddressV[1] = Clamp;
  248.         MinFilter[1] = Linear;
  249.         MagFilter[1] = Linear;
  250.         
  251.         Texture[2] = <vd_hevenoddtexture>;
  252.         AddressU[2] = Wrap;
  253.         AddressV[2] = Clamp;
  254.         MinFilter[2] = Point;
  255.         MagFilter[2] = Point;
  256.     }
  257. }
  258.  
  259. float4 PS_HDYC_to_RGB_2_0(float2 uvY : TEXCOORD0, float2 uvC : TEXCOORD1, float2 uvSelect : TEXCOORD2) : COLOR0 {
  260.     float4 pxY = tex2D(samp0, uvY);
  261.     float4 pxC = tex2D(samp1, uvC);
  262.     float4 pxSelect = tex2D(samp2, uvSelect);
  263.  
  264.     float y = lerp(pxY.g, pxY.a, pxSelect.a);
  265.     float cr = pxC.r;
  266.     float cb = pxC.b;
  267.     
  268.     return ConvertYCbCrToRGB_709(y, cb, cr);
  269. }
  270.  
  271. technique hdyc_to_rgb_2_0 {
  272.     pass < string vd_viewport = "unclipped,unclipped"; > {
  273.         VertexShader = compile vs_2_0 VS_UYVY_to_RGB_2_0();
  274.         PixelShader = compile ps_2_0 PS_HDYC_to_RGB_2_0();
  275.         
  276.         Texture[0] = <vd_srctexture>;
  277.         AddressU[0] = Clamp;
  278.         AddressV[0] = Clamp;
  279.         MinFilter[0] = Point;
  280.         MagFilter[0] = Point;
  281.  
  282.         Texture[1] = <vd_srctexture>;
  283.         AddressU[1] = Clamp;
  284.         AddressV[1] = Clamp;
  285.         MinFilter[1] = Linear;
  286.         MagFilter[1] = Linear;
  287.         
  288.         Texture[2] = <vd_hevenoddtexture>;
  289.         AddressU[2] = Wrap;
  290.         AddressV[2] = Clamp;
  291.         MinFilter[2] = Point;
  292.         MagFilter[2] = Point;
  293.     }
  294. }
  295.  
  296. float4 PS_YUY2_to_RGB_2_0(float2 uvY : TEXCOORD0, float2 uvC : TEXCOORD1, float2 uvSelect : TEXCOORD2) : COLOR0 {
  297.     float4 pxY = tex2D(samp0, uvY);
  298.     float4 pxC = tex2D(samp1, uvC);
  299.     float4 pxSelect = tex2D(samp2, uvSelect);
  300.  
  301.     float y = lerp(pxY.b, pxY.r, pxSelect.a);
  302.     float cr = pxC.a;
  303.     float cb = pxC.g;
  304.     
  305.     return ConvertYCbCrToRGB(y, cb, cr);
  306. }
  307.  
  308. technique yuy2_to_rgb_2_0 {
  309.     pass < string vd_viewport = "unclipped,unclipped"; > {
  310.         VertexShader = compile vs_2_0 VS_UYVY_to_RGB_2_0();
  311.         PixelShader = compile ps_2_0 PS_YUY2_to_RGB_2_0();
  312.         
  313.         Texture[0] = <vd_srctexture>;
  314.         AddressU[0] = Clamp;
  315.         AddressV[0] = Clamp;
  316.         MinFilter[0] = Point;
  317.         MagFilter[0] = Point;
  318.  
  319.         Texture[1] = <vd_srctexture>;
  320.         AddressU[1] = Clamp;
  321.         AddressV[1] = Clamp;
  322.         MinFilter[1] = Linear;
  323.         MagFilter[1] = Linear;
  324.         
  325.         Texture[2] = <vd_hevenoddtexture>;
  326.         AddressU[2] = Wrap;
  327.         AddressV[2] = Clamp;
  328.         MinFilter[2] = Point;
  329.         MagFilter[2] = Point;
  330.     }
  331. }
  332.  
  333. ////////////////////////////////////////////////////////////////////////////////////////////////////
  334. //
  335. //    NV12 to RGB -- pixel shader 2.0
  336. //
  337. ////////////////////////////////////////////////////////////////////////////////////////////////////
  338.  
  339. void VS_NV12_to_RGB_2_0(
  340.     float4 pos : POSITION,
  341.     float2 uv : TEXCOORD0,
  342.     float2 uv2 : TEXCOORD1,
  343.     out float4 oPos : POSITION,
  344.     out float2 oT0 : TEXCOORD0,
  345.     out float2 oT1 : TEXCOORD1)
  346. {
  347.     oPos = pos;
  348.     oT0 = uv;
  349.     oT1 = oT0 + vd_texsize.wz * float2(0.25, 0);
  350. }
  351.  
  352. float4 PS_NV12_to_RGB_2_0(float2 uvY : TEXCOORD0, float2 uvC : TEXCOORD1) : COLOR0 {
  353.     float4 pxY = tex2D(samp0, uvY);
  354.     float4 pxC = tex2D(samp1, uvC);
  355.     
  356.     return ConvertYCbCrToRGB(pxY.g, pxC.g, pxC.a);
  357. }
  358.  
  359. technique nv12_to_rgb_2_0 {
  360.     pass < string vd_viewport = "unclipped,unclipped"; > {
  361.         VertexShader = compile vs_2_0 VS_NV12_to_RGB_2_0();
  362.         PixelShader = compile ps_2_0 PS_NV12_to_RGB_2_0();
  363.         
  364.         Texture[0] = <vd_srctexture>;
  365.         AddressU[0] = Clamp;
  366.         AddressV[0] = Clamp;
  367.         MinFilter[0] = Point;
  368.         MagFilter[0] = Point;
  369.  
  370.         Texture[1] = <vd_src2atexture>;
  371.         AddressU[1] = Clamp;
  372.         AddressV[1] = Clamp;
  373.         MinFilter[1] = Linear;
  374.         MagFilter[1] = Linear;
  375.     }
  376. }
  377.  
  378. ////////////////////////////////////////////////////////////////////////////////////////////////////
  379. //
  380. //    YCbCr to RGB -- pixel shader 2.0
  381. //
  382. ////////////////////////////////////////////////////////////////////////////////////////////////////
  383.  
  384. void VS_YCbCr_to_RGB_2_0(
  385.     float4 pos : POSITION,
  386.     float2 uv : TEXCOORD0,
  387.     float2 uv2 : TEXCOORD1,
  388.     out float4 oPos : POSITION,
  389.     out float2 oT0 : TEXCOORD0,
  390.     out float2 oT1 : TEXCOORD1,
  391.     uniform float2 scale,
  392.     uniform float2 offset)
  393. {
  394.     oPos = pos;
  395.     oT0 = uv;
  396.     oT1 = (uv2 * scale * vd_srcsize.xy + offset) * vd_tex2size.wz;
  397. }
  398.  
  399. float4 PS_YCbCr_to_RGB_2_0(float2 uvY : TEXCOORD0, float2 uvC : TEXCOORD1) : COLOR0 {
  400.     float y = tex2D(samp0, uvY).b;
  401.     float cb = tex2D(samp1, uvC).b;
  402.     float cr = tex2D(samp2, uvC).b;
  403.         
  404.     return ConvertYCbCrToRGB(y, cb, cr);
  405. }
  406.  
  407. technique yvu9_to_rgb_2_0 {
  408.     pass < string vd_viewport = "unclipped,unclipped"; > {
  409.         VertexShader = compile vs_2_0 VS_YCbCr_to_RGB_2_0(float2(0.25, 0.25), float2(0, 0));
  410.         PixelShader = compile ps_2_0 PS_YCbCr_to_RGB_2_0();
  411.         
  412.         Texture[0] = <vd_srctexture>;
  413.         AddressU[0] = Clamp;
  414.         AddressV[0] = Clamp;
  415.         MinFilter[0] = Point;
  416.         MagFilter[0] = Point;
  417.  
  418.         Texture[1] = <vd_src2atexture>;
  419.         AddressU[1] = Clamp;
  420.         AddressV[1] = Clamp;
  421.         MinFilter[1] = Linear;
  422.         MagFilter[1] = Linear;
  423.         
  424.         Texture[2] = <vd_src2btexture>;
  425.         AddressU[2] = Clamp;
  426.         AddressV[2] = Clamp;
  427.         MinFilter[2] = Linear;
  428.         MagFilter[2] = Linear;
  429.     }
  430. }
  431.  
  432. technique yv12_to_rgb_2_0 {
  433.     pass < string vd_viewport = "unclipped,unclipped"; > {
  434.         VertexShader = compile vs_2_0 VS_YCbCr_to_RGB_2_0(float2(0.5, 0.5), float2(-0.25, 0));
  435.         PixelShader = compile ps_2_0 PS_YCbCr_to_RGB_2_0();
  436.         
  437.         Texture[0] = <vd_srctexture>;
  438.         AddressU[0] = Clamp;
  439.         AddressV[0] = Clamp;
  440.         MinFilter[0] = Point;
  441.         MagFilter[0] = Point;
  442.  
  443.         Texture[1] = <vd_src2atexture>;
  444.         AddressU[1] = Clamp;
  445.         AddressV[1] = Clamp;
  446.         MinFilter[1] = Linear;
  447.         MagFilter[1] = Linear;
  448.         
  449.         Texture[2] = <vd_src2btexture>;
  450.         AddressU[2] = Clamp;
  451.         AddressV[2] = Clamp;
  452.         MinFilter[2] = Linear;
  453.         MagFilter[2] = Linear;
  454.     }
  455. }
  456.  
  457. technique yv16_to_rgb_2_0 {
  458.     pass < string vd_viewport = "unclipped,unclipped"; > {
  459.         VertexShader = compile vs_2_0 VS_YCbCr_to_RGB_2_0(float2(0.5, 1), float2(-0.25, 0));
  460.         PixelShader = compile ps_2_0 PS_YCbCr_to_RGB_2_0();
  461.         
  462.         Texture[0] = <vd_srctexture>;
  463.         AddressU[0] = Clamp;
  464.         AddressV[0] = Clamp;
  465.         MinFilter[0] = Point;
  466.         MagFilter[0] = Point;
  467.  
  468.         Texture[1] = <vd_src2atexture>;
  469.         AddressU[1] = Clamp;
  470.         AddressV[1] = Clamp;
  471.         MinFilter[1] = Linear;
  472.         MagFilter[1] = Linear;
  473.         
  474.         Texture[2] = <vd_src2btexture>;
  475.         AddressU[2] = Clamp;
  476.         AddressV[2] = Clamp;
  477.         MinFilter[2] = Linear;
  478.         MagFilter[2] = Linear;
  479.     }
  480. }
  481.  
  482. technique yv24_to_rgb_2_0 {
  483.     pass < string vd_viewport = "unclipped,unclipped"; > {
  484.         VertexShader = compile vs_2_0 VS_YCbCr_to_RGB_2_0(float2(1, 1), float2(0, 0));
  485.         PixelShader = compile ps_2_0 PS_YCbCr_to_RGB_2_0();
  486.         
  487.         Texture[0] = <vd_srctexture>;
  488.         AddressU[0] = Clamp;
  489.         AddressV[0] = Clamp;
  490.         MinFilter[0] = Point;
  491.         MagFilter[0] = Point;
  492.  
  493.         Texture[1] = <vd_src2atexture>;
  494.         AddressU[1] = Clamp;
  495.         AddressV[1] = Clamp;
  496.         MinFilter[1] = Linear;
  497.         MagFilter[1] = Linear;
  498.         
  499.         Texture[2] = <vd_src2btexture>;
  500.         AddressU[2] = Clamp;
  501.         AddressV[2] = Clamp;
  502.         MinFilter[2] = Linear;
  503.         MagFilter[2] = Linear;
  504.     }
  505. }
  506.  
  507. ////////////////////////////////////////////////////////////////////////////////////////////////////
  508. //
  509. //    YCbCr (v210) to RGB -- pixel shader 2.0
  510. //
  511. ////////////////////////////////////////////////////////////////////////////////////////////////////
  512.  
  513. void VS_v210_to_RGB_2_0_A(
  514.     float4 pos : POSITION,
  515.     float2 uv : TEXCOORD0,
  516.     float2 uv2 : TEXCOORD1,
  517.     out float4 oPos : POSITION,
  518.     out float stipple : TEXCOORD0,
  519.     out float2 oT0 : TEXCOORD1,
  520.     uniform float stippleOffset,
  521.     uniform float2 offset0)
  522. {
  523.     oPos = pos;
  524.     stipple = (uv2.x * vd_srcsize.x - stippleOffset) / 6.0f;
  525.     
  526.     float2 uvbase = uv2 * vd_srcsize.xy * float2(4.0f/6.0f, 1.0f) + 0.1f;
  527.     oT0 = (uvbase + offset0) * vd_texsize.wz;
  528. }
  529.  
  530. void VS_v210_to_RGB_2_0_B(
  531.     float4 pos : POSITION,
  532.     float2 uv : TEXCOORD0,
  533.     float2 uv2 : TEXCOORD1,
  534.     out float4 oPos : POSITION,
  535.     out float stipple : TEXCOORD0,
  536.     out float2 oT0 : TEXCOORD1,
  537.     out float2 oT1 : TEXCOORD2,
  538.     uniform float stippleOffset,
  539.     uniform float2 offset0,
  540.     uniform float2 offset1)
  541. {
  542.     oPos = pos;
  543.     stipple = (uv2.x * vd_srcsize.x - stippleOffset) / 6.0f;
  544.  
  545.     float2 uvbase = uv2 * vd_srcsize.xy * float2(4.0f/6.0f, 1.0f) + 0.1f;
  546.     oT0 = (uvbase + offset0) * vd_texsize.wz;
  547.     oT1 = (uvbase + offset1) * vd_texsize.wz;
  548. }
  549.  
  550. void VS_v210_to_RGB_2_0_C(
  551.     float4 pos : POSITION,
  552.     float2 uv : TEXCOORD0,
  553.     float2 uv2 : TEXCOORD1,
  554.     out float4 oPos : POSITION,
  555.     out float stipple : TEXCOORD0,
  556.     out float2 oT0 : TEXCOORD1,
  557.     out float2 oT1 : TEXCOORD2,
  558.     out float2 oT2 : TEXCOORD3,
  559.     uniform float stippleOffset,
  560.     uniform float2 offset0,
  561.     uniform float2 offset1,
  562.     uniform float2 offset2)
  563. {
  564.     oPos = pos;
  565.     stipple = (uv2.x * vd_srcsize.x - stippleOffset) / 6.0f;
  566.  
  567.     float2 uvbase = uv2 * vd_srcsize.xy * float2(4.0f/6.0f, 1.0f) + 0.1f;
  568.     oT0 = (uvbase + offset0) * vd_texsize.wz;
  569.     oT1 = (uvbase + offset1) * vd_texsize.wz;
  570.     oT2 = (uvbase + offset2) * vd_texsize.wz;
  571. }
  572.  
  573. //           A   B   G   R
  574. // dword 0: XX Cr0  Y0 Cb0
  575. // dword 1: XX  Y2 Cb2  Y1
  576. // dword 2: XX Cb4  Y3 Cr2
  577. // dword 3: XX  Y5 Cr4  Y4
  578. // dword 4: XX Cr6  Y6 Cb6
  579.  
  580. float4 PS_v210_to_RGB_2_0_pass0(float stipple : TEXCOORD0, float2 t0 : TEXCOORD1) : COLOR0 {
  581.     clip((1.0f / 6.0f) - frac(stipple));
  582.  
  583.     float4 d0 = tex2D(samp0, t0);
  584.         
  585.     return ConvertYCbCrToRGB(d0.g, d0.r, d0.b);
  586. }
  587.  
  588. float4 PS_v210_to_RGB_2_0_pass1(float stipple : TEXCOORD0, float2 t0 : TEXCOORD1, float2 t1 : TEXCOORD2, float2 t2 : TEXCOORD3) : COLOR0 {
  589.     clip((1.0f / 6.0f) - frac(stipple));
  590.  
  591.     float4 d0 = tex2D(samp0, t0);
  592.     float4 d1 = tex2D(samp0, t1);
  593.     float4 d2 = tex2D(samp0, t2);
  594.         
  595.     return ConvertYCbCrToRGB(d1.r, 0.5f*(d0.r + d1.g), 0.5f*(d0.b + d2.r));
  596. }
  597.  
  598. float4 PS_v210_to_RGB_2_0_pass2(float stipple : TEXCOORD0, float2 t0 : TEXCOORD1, float2 t1 : TEXCOORD2) : COLOR0 {
  599.     clip((1.0f / 6.0f) - frac(stipple));
  600.  
  601.     float4 d1 = tex2D(samp0, t0);
  602.     float4 d2 = tex2D(samp0, t1);
  603.         
  604.     return ConvertYCbCrToRGB(d1.b, d1.g, d2.r);
  605. }
  606.  
  607. float4 PS_v210_to_RGB_2_0_pass3(float stipple : TEXCOORD0, float2 t0 : TEXCOORD1, float2 t1 : TEXCOORD2, float2 t2 : TEXCOORD3) : COLOR0 {
  608.     clip((1.0f / 6.0f) - frac(stipple));
  609.  
  610.     float4 d1 = tex2D(samp0, t0);
  611.     float4 d2 = tex2D(samp0, t1);
  612.     float4 d3 = tex2D(samp0, t2);
  613.         
  614.     return ConvertYCbCrToRGB(d2.g, 0.5f*(d1.g + d2.b), 0.5f*(d2.r + d3.g));
  615. }
  616.  
  617. float4 PS_v210_to_RGB_2_0_pass4(float stipple : TEXCOORD0, float2 t0 : TEXCOORD1, float2 t1 : TEXCOORD2) : COLOR0 {
  618.     clip((1.0f / 6.0f) - frac(stipple));
  619.  
  620.     float4 d2 = tex2D(samp0, t0);
  621.     float4 d3 = tex2D(samp0, t1);
  622.         
  623.     return ConvertYCbCrToRGB(d3.r, d2.b, d3.g);
  624. }
  625.  
  626. float4 PS_v210_to_RGB_2_0_pass5(float stipple : TEXCOORD0, float2 t0 : TEXCOORD1, float2 t1 : TEXCOORD2, float2 t2 : TEXCOORD3) : COLOR0 {
  627.     clip((1.0f / 6.0f) - frac(stipple));
  628.  
  629.     float4 d2 = tex2D(samp0, t0);
  630.     float4 d3 = tex2D(samp0, t1);
  631.     float4 d4 = tex2D(samp0, t2);
  632.         
  633.     return ConvertYCbCrToRGB(d3.b, 0.5f*(d2.b + d4.r), 0.5f*(d3.g + d4.b));
  634. }
  635.  
  636. technique v210_to_rgb_2_0 {
  637.     // pass 0 - base offset 0
  638.     pass < string vd_viewport = "unclipped,unclipped"; > {
  639.         VertexShader = compile vs_2_0 VS_v210_to_RGB_2_0_A(0, 0);
  640.         PixelShader = compile ps_2_0 PS_v210_to_RGB_2_0_pass0();
  641.         
  642.         Texture[0] = <vd_srctexture>;
  643.         AddressU[0] = Clamp;
  644.         AddressV[0] = Clamp;
  645.         MinFilter[0] = Point;
  646.         MagFilter[0] = Point;
  647.  
  648.         Texture[1] = <vd_srctexture>;
  649.         AddressU[1] = Clamp;
  650.         AddressV[1] = Clamp;
  651.         MinFilter[1] = Point;
  652.         MagFilter[1] = Point;
  653.         
  654.         Texture[2] = <vd_srctexture>;
  655.         AddressU[2] = Clamp;
  656.         AddressV[2] = Clamp;
  657.         MinFilter[2] = Point;
  658.         MagFilter[2] = Point;
  659.     }
  660.     
  661.     // pass 1 - base offset 1
  662.     pass < string vd_viewport = "unclipped,unclipped"; > {
  663.         VertexShader = compile vs_2_0 VS_v210_to_RGB_2_0_C(1, -1, 0, 1);
  664.         PixelShader = compile ps_2_0 PS_v210_to_RGB_2_0_pass1();
  665.     }
  666.     
  667.     // pass 2 - base offset 1
  668.     pass < string vd_viewport = "unclipped,unclipped"; > {
  669.         VertexShader = compile vs_2_0 VS_v210_to_RGB_2_0_B(2, 0, 1);
  670.         PixelShader = compile ps_2_0 PS_v210_to_RGB_2_0_pass2();
  671.     }
  672.     
  673.     // pass 3 - base offset 2
  674.     pass < string vd_viewport = "unclipped,unclipped"; > {
  675.         VertexShader = compile vs_2_0 VS_v210_to_RGB_2_0_C(3, -1, 0, 1);
  676.         PixelShader = compile ps_2_0 PS_v210_to_RGB_2_0_pass3();
  677.     }
  678.     
  679.     // pass 4 - base offset 3
  680.     pass < string vd_viewport = "unclipped,unclipped"; > {
  681.         VertexShader = compile vs_2_0 VS_v210_to_RGB_2_0_B(4, -1, 0);
  682.         PixelShader = compile ps_2_0 PS_v210_to_RGB_2_0_pass4();
  683.     }
  684.     
  685.     // pass 5 - base offset 3
  686.     pass < string vd_viewport = "unclipped,unclipped"; > {
  687.         VertexShader = compile vs_2_0 VS_v210_to_RGB_2_0_C(5, -1, 0, 1);
  688.         PixelShader = compile ps_2_0 PS_v210_to_RGB_2_0_pass5();
  689.     }    
  690. }
  691.  
  692. #endif
  693.