Advertisement
Guest User

Untitled

a guest
Jan 1st, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. void Main()
  2. {
  3.  
  4. float4 color = Sample();
  5.  
  6. float Gamma = 1.2;
  7. float IntensityContrast = 1.3;
  8. float Saturation = 1.7;
  9. float ToneMappingCurve = 2.0;
  10. float ToneMappingOversaturation = 40.0;
  11.  
  12. float Brightness = 0.16;
  13. float BrightnessCurve = 1.28;
  14. float BrightnessMultiplier = 0.85;
  15. float BrightnessToneMappingCurve = 0.42;
  16.  
  17. float HPDTonemappingExposure = 2.2;
  18. float HPDTonemappingClipping = 0.0004;
  19. float HPDTonemappingUpperTone = 6.2;
  20. float HPDTonemappingGreyTone = 0.5;
  21. float HPDTonemappingMiddleTone = 1.7;
  22. float HPDTonemappingLowerTone = 0.06;
  23.  
  24. color.r = pow(color.r, Gamma);
  25. color.g = pow(color.g, Gamma);
  26. color.b = pow(color.b, Gamma);
  27.  
  28. color.rgb *= Brightness;
  29. color.rgb += 0.000001;
  30. float3 xncol = normalize(color.rgb);
  31. float3 scl = color.rgb/xncol.rgb;
  32.  
  33. scl.r = pow(scl.r, IntensityContrast);
  34. scl.g = pow(scl.g, IntensityContrast);
  35. scl.b = pow(scl.b, IntensityContrast);
  36.  
  37. xncol.r = pow(xncol.r, Saturation);
  38. xncol.g = pow(xncol.g, Saturation);
  39. xncol.b = pow(xncol.b, Saturation);
  40.  
  41. color.rgb = scl*xncol.rgb;
  42.  
  43. float lumamax = ToneMappingOversaturation;
  44. color.rgb = (color.rgb * (1.0 + color.rgb/lumamax))/(color.rgb + ToneMappingCurve);
  45.  
  46. float Y = dot(color.rgb, float3(0.299, 0.587, 0.114)); //0.299 * R + 0.587 * G + 0.114 * B;
  47. float U = dot(color.rgb, float3(-0.14713, -0.28886, 0.436)); //-0.14713 * R - 0.28886 * G + 0.436 * B;
  48. float V = dot(color.rgb, float3(0.615, -0.51499, -0.10001)); //0.615 * R - 0.51499 * G - 0.10001 * B;
  49.  
  50. Y = pow(Y, BrightnessCurve);
  51. Y = Y*BrightnessMultiplier;
  52. Y = Y/(Y+BrightnessToneMappingCurve);
  53. float desaturatefact = clamp(Y*Y*Y*1.7, 0.0, 1.0);
  54. U = mix(U, 0.0, desaturatefact);
  55. V = mix(V, 0.0, desaturatefact);
  56. color.rgb = V * float3(1.13983, -0.58060, 0.0) + U * float3(0.0, -0.39465, 2.03211) + Y;
  57.  
  58. float3 xColor = color.xyz;
  59. xColor = max(xColor, HPDTonemappingClipping);
  60. xColor = abs((xColor * (HPDTonemappingUpperTone * xColor + HPDTonemappingGreyTone )) / (xColor * (HPDTonemappingUpperTone * xColor + HPDTonemappingMiddleTone) + HPDTonemappingLowerTone ));
  61.  
  62. color.r = pow(xColor.r, HPDTonemappingExposure);
  63. color.g = pow(xColor.g, HPDTonemappingExposure);
  64. color.b = pow(xColor.b, HPDTonemappingExposure);
  65.  
  66. SetOutput(color);
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement