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

  1. /*
  2.  * (C) 2003-2006 Gabest
  3.  * (C) 2006-2013 see Authors.txt
  4.  *
  5.  * This file is part of MPC-HC.
  6.  *
  7.  * MPC-HC is free software; you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation; either version 3 of the License, or
  10.  * (at your option) any later version.
  11.  *
  12.  * MPC-HC is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19.  *
  20.  */
  21.  
  22. sampler s0 : register(s0);
  23. float4 p0 :  register(c0);
  24. float4 p1 :  register(c1);
  25.  
  26. #define width   (p0[0])
  27. #define height  (p0[1])
  28. #define counter (p0[2])
  29. #define clock   (p0[3])
  30. #define one_over_width  (p1[0])
  31. #define one_over_height (p1[1])
  32.  
  33. #define PI acos(-1)
  34.  
  35. static float4x4 r2y = {
  36.      0.299,  0.587,  0.114, 0.000,
  37.     -0.147, -0.289,  0.437, 0.000,
  38.      0.615, -0.515, -0.100, 0.000,
  39.      0.000,  0.000,  0.000, 0.000
  40. };
  41.  
  42. static float4x4 y2r = {
  43.     1.000,  0.000,  1.140, 0.000,
  44.     1.000, -0.394, -0.581, 0.000,
  45.     1.000,  2.028,  0.000, 0.000,
  46.     0.000,  0.000,  0.000, 0.000
  47. };
  48.  
  49. #define ymin ( 16.0 / 255)
  50. #define ymax (235.0 / 255)
  51.  
  52. // Brightness: -1.0 to 1.0, default 0.0
  53. // Contrast: 0.0 to 10.0, default 1.0
  54. // Hue: -180.0 to +180.0, default 0.0
  55. // Saturation: 0.0 to 10.0, default 1.0
  56.  
  57. #define Brightness 0.0
  58. #define Contrast   1.0
  59. #define Hue        0.0
  60. #define Saturation 1.0
  61.  
  62. // tv -> pc scale
  63. // #define Brightness (-ymin)
  64. // #define Contrast   (1.0 / (ymax - ymin))
  65.  
  66. static float2x2 HueMatrix = {
  67.      cos(Hue * PI / 180), sin(Hue * PI / 180),
  68.     -sin(Hue * PI / 180), cos(Hue * PI / 180)
  69. };
  70.  
  71. float4 main(float2 tex : TEXCOORD0) : COLOR
  72. {
  73.     float4 c0 = tex2D(s0, tex);
  74.     c0 = mul(r2y, c0);
  75.     c0.r = Contrast * (c0.r - ymin) + ymin + Brightness;
  76.     c0.gb = mul(HueMatrix, c0.gb) * Saturation;
  77.     c0 = mul(y2r, c0);
  78.     return c0;
  79. }
  80.