home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Multimedia / MPC-HC / MPC-HC_Portable.exe / MPC-HC_Portable / mpc-hc.exe / SHADER / 702 < prev   
Text File  |  2014-10-05  |  942b  |  30 lines

  1. #define LUT3D_ENABLED (_LUT3D_ENABLED_VALUE_)
  2.  
  3. sampler image : register(s0);
  4.  
  5. sampler ditherMatrix : register(s1);
  6. float2 ditherMatrixCoordScale : register(c0);
  7.  
  8. // Maximum quantized integer value
  9. static const float QUANTIZATION = _QUANTIZATION_VALUE_;
  10.  
  11. #if LUT3D_ENABLED
  12. sampler lut3D : register(s2);
  13. static const float LUT3D_SIZE = _LUT3D_SIZE_VALUE_;
  14.  
  15. // 3D LUT texture coordinate scale and offset required for correct linear interpolation
  16. static const float LUT3D_SCALE = (LUT3D_SIZE - 1.0f) / LUT3D_SIZE;
  17. static const float LUT3D_OFFSET = 1.0f / (2.0f * LUT3D_SIZE);
  18. #endif
  19.  
  20. float4 main(float2 imageCoord : TEXCOORD0) : COLOR {
  21.     float4 pixel = tex2D(image, imageCoord);
  22.  
  23. #if LUT3D_ENABLED
  24.     pixel = tex3D(lut3D, pixel.rgb * LUT3D_SCALE + LUT3D_OFFSET);
  25. #endif
  26.  
  27.     float4 ditherValue = tex2D(ditherMatrix, imageCoord * ditherMatrixCoordScale);
  28.     return floor(pixel * QUANTIZATION + ditherValue) / QUANTIZATION;
  29. }
  30.