Advertisement
Guest User

Untitled

a guest
Feb 3rd, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. uniform sampler2D Render;
  2. uniform sampler2D Tex0;
  3.  
  4. const float A = 0.22;
  5. const float B = 0.30;
  6. const float C = 0.10;
  7. const float D = 0.20;
  8. const float E = 0.01;
  9. const float F = 0.30;
  10. const float W = 11.2;
  11.  
  12. vec3 lerp(vec3 a, vec3 b, float w)
  13. {
  14. return a + w *(b - a);
  15. }
  16.  
  17. vec3 uncharted2Tonemap(vec3 x)
  18. {
  19. return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F;
  20. }
  21.  
  22. vec4 burgess (vec4 color,vec2 uv)
  23. {
  24. color = vec4(pow(color.rgb, vec3(2.2)), color.a);
  25. vec4 bloom = texture2D(Render, uv);
  26. color+= 0.0*bloom;
  27. vec3 x = max(0,color-0.004);
  28. vec3 retColor = (x*(6.2*x+.5))/(x*(6.2*x+1.7)+0.06);
  29. return vec4(pow(color.rgb, vec3(1.0 / 1.9)), color.a);
  30. }
  31.  
  32. vec4 applyToneMapping(vec4 color, vec2 uv)
  33. {
  34. color = vec4(pow(color.rgb, vec3(2.2)), color.a);
  35. vec4 bloom = texture2D(Render, uv);
  36. color+= 0.5*bloom;
  37. const float gamma = 1.8;
  38. float exposureBias = 4.0;
  39. color.rgb = uncharted2Tonemap(exposureBias * color.rgb);
  40. vec3 whiteScale = 1.0 / uncharted2Tonemap(vec3(W, W, W));
  41. color.rgb *= whiteScale;
  42. return vec4(pow(color.rgb, vec3(1.0 / gamma)), color.a);
  43. }
  44.  
  45. void main()
  46. {
  47. vec2 uv = gl_TexCoord[0].st;
  48. vec4 color = texture2D(Tex0, uv);
  49. gl_FragColor = applyToneMapping(color, uv);
  50. //gl_FragColor = burgess(color, uv);
  51. //gl_FragColor = color;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement