Bloom.hx 579 B

12345678910111213141516171819202122
  1. package hrt.shader;
  2. class Bloom extends h3d.shader.ScreenShader {
  3. static var SRC = {
  4. @param var texture : Sampler2D;
  5. @param var threshold : Float;
  6. @param var intensity : Float;
  7. @param var colorMatrix : Mat4;
  8. function fragment() {
  9. pixelColor = texture.get(calculatedUV);
  10. var lum = pixelColor.rgb.dot(vec3(0.2126, 0.7152, 0.0722));
  11. if( lum < threshold ) pixelColor.rgb = vec3(0.) else pixelColor.rgb *= (lum - threshold) / lum;
  12. pixelColor.rgb *= intensity;
  13. pixelColor.rgb = (vec4(pixelColor.rgb,1.) * colorMatrix).rgb;
  14. }
  15. };
  16. }