2
0

opengl_fragment.glsl 761 B

1234567891011121314151617181920212223242526272829303132333435
  1. #define rendered texture0
  2. struct ExposureParams {
  3. float compensationFactor;
  4. };
  5. uniform sampler2D rendered;
  6. uniform mediump float bloomStrength;
  7. uniform ExposureParams exposureParams;
  8. #ifdef GL_ES
  9. varying mediump vec2 varTexCoord;
  10. #else
  11. centroid varying vec2 varTexCoord;
  12. #endif
  13. #ifdef ENABLE_AUTO_EXPOSURE
  14. varying float exposure; // linear exposure factor, see vertex shader
  15. #endif
  16. void main(void)
  17. {
  18. vec2 uv = varTexCoord.st;
  19. vec3 color = texture2D(rendered, uv).rgb;
  20. // translate to linear colorspace (approximate)
  21. color = pow(color, vec3(2.2));
  22. color *= exposureParams.compensationFactor * bloomStrength;
  23. #ifdef ENABLE_AUTO_EXPOSURE
  24. color *= exposure;
  25. #endif
  26. gl_FragColor = vec4(color, 1.0); // force full alpha to avoid holes in the image.
  27. }