-const char* const BLOOM_INTENSITY_PROPERTY_NAME = "uBloomIntensity";
-const char* const BLOOM_SATURATION_PROPERTY_NAME = "uBloomSaturation";
-const char* const IMAGE_INTENSITY_PROPERTY_NAME = "uImageIntensity";
-const char* const IMAGE_SATURATION_PROPERTY_NAME = "uImageSaturation";
-
-const char* const EFFECT_IMAGE_NAME( "sEffect" );
-
-///////////////////////////////////////////////////////
-//
-// Bloom shaders
-//
-
-const char* const BLOOM_EXTRACT_FRAGMENT_SOURCE =
- "varying mediump vec2 vTexCoord;\n"
- "uniform sampler2D sTexture;\n"
- "uniform lowp vec4 uColor;\n"
- "uniform mediump float uBloomThreshold;\n"
- "uniform mediump float uRecipOneMinusBloomThreshold;\n"
- "void main()\n"
- "{\n"
- " mediump vec4 col;\n"
- " col = texture2D(sTexture, vTexCoord);\n"
- " col = (col - uBloomThreshold) * uRecipOneMinusBloomThreshold;\n" // remove intensities lower than the thresold and remap intensities above the threshold to [0..1]
- " gl_FragColor = clamp(col, 0.0, 1.0);\n"
- "}\n";
-
-const char* const COMPOSITE_FRAGMENT_SOURCE =
- "precision mediump float;\n"
- "varying mediump vec2 vTexCoord;\n"
- "uniform sampler2D sTexture;\n"
- "uniform sampler2D sEffect;\n"
- "uniform lowp vec4 uColor;\n"
- "uniform float uBloomIntensity;\n"
- "uniform float uImageIntensity;\n"
- "uniform float uBloomSaturation;\n"
- "uniform float uImageSaturation;\n"
-
- "vec4 ChangeSaturation(vec4 col, float sat)\n"
- "{\n"
- " float grey = dot(col.rgb, vec3(0.3, 0.6, 0.1));\n"
- " return mix(vec4(grey, grey, grey, 1.0), col, sat);\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- " mediump vec4 image;\n"
- " mediump vec4 bloom;\n"
- " image = texture2D(sTexture, vTexCoord);\n"
- " bloom = texture2D(sEffect, vTexCoord);\n"
- " image = ChangeSaturation(image, uImageSaturation) * uImageIntensity;\n"
- " bloom = ChangeSaturation(bloom, uBloomSaturation) * uBloomIntensity;\n"
- " image *= 1.0 - clamp(bloom, 0.0, 1.0);\n" // darken base where bloom is strong, to prevent excessive burn-out of result
- " gl_FragColor = image + bloom;\n"
- "}\n";