home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Multimedia / MPC-HC / MPC-HC-x64-Portable.exe / MPC-HC-x64-Portable / Shaders / Denoise.hlsl < prev    next >
Text File  |  2014-10-05  |  2KB  |  63 lines

  1. /*
  2.  * (C) 2008-2013 see Authors.txt
  3.  *
  4.  * This file is part of MPC-HC.
  5.  *
  6.  * MPC-HC is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 3 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * MPC-HC is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20.  
  21. // Fail early with ps_2_0 and ps_2_b shader profiles
  22. #ifdef MPC_HC_SHADER_PROFILE
  23. #    if MPC_HC_SHADER_PROFILE < 2
  24. #        error Usupported shader profile
  25. #    endif
  26. #endif
  27.  
  28. sampler s0 : register(s0);
  29. float4 p0 :  register(c0);
  30.  
  31. #define width  (p0[0])
  32. #define height (p0[1])
  33. #define val0 (1.0)
  34. #define val1 (0.125)
  35. #define effect_width (0.1)
  36.  
  37. float4 main(float2 tex : TEXCOORD0) : COLOR
  38. {
  39.     float dx = 0.0f;
  40.     float dy = 0.0f;
  41.     float fTap = effect_width;
  42.  
  43.     float4 cAccum = tex2D(s0, tex) * val0;
  44.  
  45.     for (int iDx = 0; iDx < 16; ++iDx) {
  46.         dx = fTap / width;
  47.         dy = fTap / height;
  48.  
  49.         cAccum += tex2D(s0, tex + float2(-dx, -dy)) * val1;
  50.         cAccum += tex2D(s0, tex + float2(  0, -dy)) * val1;
  51.         cAccum += tex2D(s0, tex + float2(-dx,   0)) * val1;
  52.         cAccum += tex2D(s0, tex + float2( dx,   0)) * val1;
  53.         cAccum += tex2D(s0, tex + float2(  0,  dy)) * val1;
  54.         cAccum += tex2D(s0, tex + float2( dx,  dy)) * val1;
  55.         cAccum += tex2D(s0, tex + float2(-dx, +dy)) * val1;
  56.         cAccum += tex2D(s0, tex + float2(+dx, -dy)) * val1;
  57.  
  58.         fTap  += 0.1f;
  59.     }
  60.  
  61.     return (cAccum / 16.0f);
  62. }
  63.