summaryrefslogtreecommitdiff
path: root/drivers/gles3/shaders/effect_blur.glsl
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2016-12-08 09:48:38 -0300
committerJuan Linietsky <reduzio@gmail.com>2016-12-08 09:48:38 -0300
commit18ebd22000478dffc91255e89b9845f74b05b606 (patch)
tree868b51e8d4645a38e369003b7331a0eaf1729949 /drivers/gles3/shaders/effect_blur.glsl
parent8534ced22d7b889dafb64ab0c40435c5b12b7cbc (diff)
Multi stage glow with light bleeding from HDR
Diffstat (limited to 'drivers/gles3/shaders/effect_blur.glsl')
-rw-r--r--drivers/gles3/shaders/effect_blur.glsl67
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/gles3/shaders/effect_blur.glsl b/drivers/gles3/shaders/effect_blur.glsl
index 211b60ca2e..589af64d44 100644
--- a/drivers/gles3/shaders/effect_blur.glsl
+++ b/drivers/gles3/shaders/effect_blur.glsl
@@ -35,6 +35,31 @@ uniform vec4 ssao_color;
#endif
+#if defined (GLOW_GAUSSIAN_HORIZONTAL) || defined(GLOW_GAUSSIAN_VERTICAL)
+
+uniform float glow_strength;
+
+#endif
+
+
+#ifdef GLOW_FIRST_PASS
+
+uniform float exposure;
+uniform float white;
+
+#ifdef GLOW_USE_AUTO_EXPOSURE
+
+uniform highp sampler2D source_auto_exposure; //texunit:1
+uniform highp float auto_exposure_grey;
+
+#endif
+
+uniform float glow_bloom;
+uniform float glow_hdr_treshold;
+uniform float glow_hdr_scale;
+
+#endif
+
void main() {
@@ -57,6 +82,48 @@ void main() {
frag_color = color;
#endif
+
+
+#ifdef GLOW_GAUSSIAN_HORIZONTAL
+ vec4 color =textureLod( source_color, uv_interp+vec2( 0.0, 0.0)*pixel_size,lod )*0.174938;
+ color+=textureLod( source_color, uv_interp+vec2( 1.0, 0.0)*pixel_size,lod )*0.165569;
+ color+=textureLod( source_color, uv_interp+vec2( 2.0, 0.0)*pixel_size,lod )*0.140367;
+ color+=textureLod( source_color, uv_interp+vec2( 3.0, 0.0)*pixel_size,lod )*0.106595;
+ color+=textureLod( source_color, uv_interp+vec2(-1.0, 0.0)*pixel_size,lod )*0.165569;
+ color+=textureLod( source_color, uv_interp+vec2(-2.0, 0.0)*pixel_size,lod )*0.140367;
+ color+=textureLod( source_color, uv_interp+vec2(-3.0, 0.0)*pixel_size,lod )*0.165569;
+ color*=glow_strength;
+ frag_color = color;
+#endif
+
+#ifdef GLOW_GAUSSIAN_VERTICAL
+ vec4 color =textureLod( source_color, uv_interp+vec2(0.0, 0.0)*pixel_size,lod )*0.174938;
+ color+=textureLod( source_color, uv_interp+vec2(0.0, 1.0)*pixel_size,lod )*0.165569;
+ color+=textureLod( source_color, uv_interp+vec2(0.0, 2.0)*pixel_size,lod )*0.140367;
+ color+=textureLod( source_color, uv_interp+vec2(0.0, 3.0)*pixel_size,lod )*0.106595;
+ color+=textureLod( source_color, uv_interp+vec2(0.0,-1.0)*pixel_size,lod )*0.165569;
+ color+=textureLod( source_color, uv_interp+vec2(0.0,-2.0)*pixel_size,lod )*0.140367;
+ color+=textureLod( source_color, uv_interp+vec2(0.0,-3.0)*pixel_size,lod )*0.165569;
+ color*=glow_strength;
+ frag_color = color;
+#endif
+
+#ifdef GLOW_FIRST_PASS
+
+#ifdef GLOW_USE_AUTO_EXPOSURE
+
+ frag_color/=texelFetch(source_auto_exposure,ivec2(0,0),0).r/auto_exposure_grey;
+#endif
+ frag_color*=exposure;
+
+ float luminance = max(frag_color.r,max(frag_color.g,frag_color.b));
+ float feedback = max( smoothstep(glow_hdr_treshold,glow_hdr_treshold+glow_hdr_scale,luminance), glow_bloom );
+
+ frag_color *= feedback;
+
+#endif
+
+
#ifdef SIMPLE_COPY
vec4 color =textureLod( source_color, uv_interp,0.0);
frag_color = color;