home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 April / PCWorld_2007-04_cd.bin / audio-video / kmplayer / kmp.exe / Shader / Sharpen_5x5.txt < prev    next >
Encoding:
Text File  |  2006-09-19  |  2.2 KB  |  64 lines

  1. // Sharpen_5x5=ps_3_0
  2. // http://www.homecinema-fr.com/forum/viewtopic.php?t=29814317 
  3.  
  4. sampler s0 : register(s0); 
  5.  
  6. float4 p0 : register(c0); 
  7. float4 p1 : register(c1); 
  8.  
  9. #define width (p0[0]) 
  10. #define height (p0[1]) 
  11. #define counter (p0[2]) 
  12. #define clock (p0[3]) 
  13. #define one_over_width (p1[0]) 
  14. #define one_over_height (p1[1]) 
  15.  
  16. #define PI acos(-1) 
  17.  
  18. #define x 0.8 
  19.  
  20. float4 main(float2 tex : TEXCOORD0) : COLOR 
  21.    float dx = one_over_width * x;
  22.    float dy = one_over_height * x;
  23.  
  24.    float dx2 = one_over_width * 2; 
  25.    float dy2 = one_over_height * 2; 
  26.  
  27.    float4 coef = float4( 0.025, 0.05, 0.1, 2.0 ); 
  28.  
  29.    float4 c0 = tex2D( s0, tex ) * coef[3]; 
  30.  
  31.    float4 c1 =  tex2D( s0, tex + float2( -dx2 , -dy2 ) ) * coef[0]; 
  32.    c1 +=  tex2D( s0, tex + float2( -dx , -dy2 ) ) * coef[0]; 
  33.    c1 +=  tex2D( s0, tex + float2( 0 , -dy2 ) ) * coef[0]; 
  34.    c1 +=  tex2D( s0, tex + float2( dx , -dy2 ) ) * coef[0]; 
  35.    c1 +=  tex2D( s0, tex + float2( dx2 , -dy2 ) ) * coef[0]; 
  36.  
  37.    c1 +=  tex2D( s0, tex + float2( -dx2 , -dy ) )  * coef[0]; 
  38.    c1 +=  tex2D( s0, tex + float2( -dx , -dy ) ) * coef[1] ; 
  39.    c1 +=  tex2D( s0, tex + float2( 0 , -dy ) ) * coef[2] ; 
  40.    c1 +=  tex2D( s0, tex + float2( dx , -dy ) ) * coef[1] ; 
  41.    c1 +=  tex2D( s0, tex + float2( dx2 , -dy ) )  * coef[0]; 
  42.  
  43.    c1 +=  tex2D( s0, tex + float2( -dx2 , 0 ) )  * coef[0]; 
  44.    c1 +=  tex2D( s0, tex + float2( -dx , 0 ) ) * coef[2] ; 
  45.    c1 +=  tex2D( s0, tex + float2( dx , 0 ) ) * coef[2] ; 
  46.    c1 +=  tex2D( s0, tex + float2( dx2 , 0 ) )  * coef[0]; 
  47.  
  48.    c1 +=  tex2D( s0, tex + float2( -dx2 , dy ) )  * coef[0]; 
  49.    c1 +=  tex2D( s0, tex + float2( -dx , dy ) ) * coef[1] ; 
  50.    c1 +=  tex2D( s0, tex + float2( 0 , dy ) ) * coef[2] ; 
  51.    c1 +=  tex2D( s0, tex + float2( dx , dy ) ) * coef[1] ; 
  52.    c1 +=  tex2D( s0, tex + float2( dx2 , dy ) )  * coef[0]; 
  53.  
  54.    c1 +=  tex2D( s0, tex + float2( -dx2 , dy2 ) ) * coef[0]; 
  55.    c1 +=  tex2D( s0, tex + float2( -dx , dy2 ) ) * coef[0]; 
  56.    c1 +=  tex2D( s0, tex + float2( 0 , dy2 ) ) * coef[0]; 
  57.    c1 +=  tex2D( s0, tex + float2( dx , dy2 ) ) * coef[0]; 
  58.    c1 +=  tex2D( s0, tex + float2( dx2 , dy2 ) ) * coef[0]; 
  59.  
  60.    c0 -= c1; 
  61.  
  62.    return c0;