home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Software / Utils / SPlayer / SPlayerSetup.exe / splayer.exe / 2052 / FILE / 700 < prev    next >
Encoding:
Text File  |  2009-12-01  |  2.9 KB  |  127 lines

  1.  
  2. sampler s0 : register(s0);
  3. //sampler s1 : register(s1);
  4. //sampler s2 : register(s2);
  5. //sampler s3 : register(s3);
  6. //sampler s4 : register(s4);
  7.  
  8. float4 dxdy05  : register(c0);
  9. float2 dxdy : register(c1);
  10. float2 dx : register(c2);
  11. float2 dy : register(c3);
  12.  
  13. #define    A _The_Value_Of_A_Is_Set_Here_
  14.  
  15. // none of the resizers here can be used for 1:1 mapping! 
  16. // tex * size won't be 0, 1, 2, 3, .. as you might expect, but something like 0, 0.999, 2.001, 2.999, ...
  17. // this means when the fractional part becomes 0.999 we will be interpolating with the wrong value!!!
  18.  
  19. struct PS_INPUT
  20. {
  21.     float2 t0 : TEXCOORD0;
  22. //    float2 t1 : TEXCOORD1;
  23. //    float2 t2 : TEXCOORD2;
  24. //    float2 t3 : TEXCOORD3;
  25. //    float2 t4 : TEXCOORD4;
  26. };
  27.  
  28. float4 main_bilinear(PS_INPUT input) : COLOR
  29. {
  30.     float2 PixelPos = input.t0;
  31.     float2 dd = frac(PixelPos);
  32.     float2 ExactPixel = PixelPos - dd;
  33.     float2 samplePos = ExactPixel*dxdy + dxdy05;
  34.  
  35.     float4 c = lerp(
  36.         lerp(tex2D(s0, samplePos), tex2D(s0, samplePos + dx), dd.x),
  37.         lerp(tex2D(s0, samplePos + dy), tex2D(s0, samplePos + dxdy), dd.x),
  38.         dd.y);
  39.         
  40.     return c;
  41. }
  42.  
  43. static float4x4    tco =
  44. {
  45.     0, A, -2*A, A,
  46.     1, 0, -A-3, A+2,
  47.     0, -A, 2*A+3, -A-2,
  48.     0, 0, A, -A
  49. };
  50.  
  51. float4 taps(float t)
  52. {
  53.     return mul(tco, float4(1, t, t*t, t*t*t));
  54. }
  55.  
  56. float4 SampleX(float4 tx, float2 t0)
  57. {
  58.     return
  59.         mul(tx,
  60.             float4x4(
  61.                 tex2D(s0, t0 - dx),
  62.                 tex2D(s0, t0),
  63.                 tex2D(s0, t0 + dx),
  64.                 tex2D(s0, t0 + dx + dx)
  65.             )
  66.         );
  67. }
  68.  
  69. float4 SampleY(float4 tx, float4 ty, float2 t0)
  70. {
  71.     //not sure with the reason, but without +0.001 it doesn't seem to work under 945G etc
  72.     // if you found better way, just email tomasen@gmail.com
  73.     //   -- by Tomasen
  74.     return
  75.         mul(ty,
  76.             float4x4(
  77.                 SampleX(tx, t0 - dy)+0.001, 
  78.                 SampleX(tx, t0)+0.001,
  79.                 SampleX(tx, t0 + dy)+0.001,
  80.                 SampleX(tx, t0 + dy + dy)+0.001
  81.             )
  82.         );
  83. }
  84.  
  85. float4 main_bicubic1pass(PS_INPUT input) : COLOR
  86. {
  87.     float2 PixelPos = input.t0;
  88.     float2 dd = frac(PixelPos);
  89.     float2 ExactPixel = PixelPos - dd;
  90.     float2 samplePos = ExactPixel*dxdy + dxdy05;
  91.     return SampleY(taps(dd.x), taps(dd.y), samplePos);
  92. }
  93.  
  94. float4 Sample(float4 t, float2 samplePos, float2 sampleD)
  95. {
  96.     return
  97.         mul(t, 
  98.             float4x4(
  99.                 tex2D(s0, samplePos - sampleD),
  100.                 tex2D(s0, samplePos),
  101.                 tex2D(s0, samplePos + sampleD),
  102.                 tex2D(s0, samplePos + sampleD + sampleD)
  103.             )
  104.         );
  105. }
  106.  
  107. float4 main_bicubic2pass_pass1(PS_INPUT input) : COLOR
  108. {
  109.     float2 PixelPos = input.t0;
  110.     float2 dd = frac(PixelPos);
  111.     float2 ExactPixel = PixelPos - dd;
  112.     float2 samplePos = ExactPixel*dxdy + dxdy05;
  113.     
  114.     return Sample(taps(dd.x), samplePos, dx);
  115. }
  116.  
  117. float4 main_bicubic2pass_pass2(PS_INPUT input) : COLOR
  118. {
  119.     float2 PixelPos = input.t0;
  120.     float2 dd = frac(PixelPos);
  121.     float2 ExactPixel = PixelPos - dd;
  122.     float2 samplePos = ExactPixel*dxdy + dxdy05;
  123.     
  124.     return Sample(taps(dd.y), samplePos, dy);
  125. }
  126.  
  127.