Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

  1. //===== Copyright (c) 1996-2008, Valve Corporation, All rights reserved. ======//
  2. struct PS_IN
  3. {
  4. float2 TexCoord : TEXCOORD;
  5. };
  6. float SrgbGammaToLinear( float flSrgbGammaValue )
  7. {
  8. float x = saturate( flSrgbGammaValue );
  9. return ( x <= 0.04045f ) ? ( x / 12.92f ) : ( pow( ( x + 0.055f ) / 1.055f, 2.4f ) );
  10. }
  11. float X360LinearToGamma( float flLinearValue )
  12. {
  13. float fl360GammaValue;
  14. flLinearValue = saturate( flLinearValue );
  15. if ( flLinearValue < ( 128.0f / 1023.0f ) )
  16. {
  17. if ( flLinearValue < ( 64.0f / 1023.0f ) )
  18. {
  19. fl360GammaValue = flLinearValue * ( 1023.0f * ( 1.0f / 255.0f ) );
  20. }
  21. else
  22. {
  23. fl360GammaValue = flLinearValue * ( ( 1023.0f / 2.0f ) * ( 1.0f / 255.0f ) ) + ( 32.0f / 255.0f );
  24. }
  25. }
  26. else
  27. {
  28. if ( flLinearValue < ( 512.0f / 1023.0f ) )
  29. {
  30. fl360GammaValue = flLinearValue * ( ( 1023.0f / 4.0f ) * ( 1.0f / 255.0f ) ) + ( 64.0f / 255.0f );
  31. }
  32. else
  33. {
  34. fl360GammaValue = flLinearValue * ( ( 1023.0f /8.0f ) * ( 1.0f / 255.0f ) ) + ( 128.0f /255.0f );
  35. if ( fl360GammaValue > 1.0f )
  36. {
  37. fl360GammaValue = 1.0f;
  38. }
  39. }
  40. }
  41. fl360GammaValue = saturate( fl360GammaValue );
  42. return fl360GammaValue;
  43. }
  44. sampler detail : register( s0 );
  45. float4 main( PS_IN In ) : COLOR
  46. {
  47. float4 vTextureColor = tex2D( detail, In.TexCoord );
  48. return vTextureColor;
  49. };