diff options
| author | x2048 <codeforsmile@gmail.com> | 2022-09-29 20:34:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-29 20:34:05 +0200 |
| commit | 9df79a4b2d68979c3e15797d518d957787ba4e21 (patch) | |
| tree | 027f372a420f1aa3aa72bf72de34c5e6062b9090 /client/shaders/blur_v | |
| parent | 3978b9b8ed1c318c3f9a088beb331c26bca6de6b (diff) | |
| download | minetest-9df79a4b2d68979c3e15797d518d957787ba4e21.tar.xz | |
Bloom (#12791)
Adds configurable light exposure control and bloom effect (light bleeding) with client-side settings.
Diffstat (limited to 'client/shaders/blur_v')
| -rw-r--r-- | client/shaders/blur_v/opengl_fragment.glsl | 29 | ||||
| -rw-r--r-- | client/shaders/blur_v/opengl_vertex.glsl | 11 |
2 files changed, 40 insertions, 0 deletions
diff --git a/client/shaders/blur_v/opengl_fragment.glsl b/client/shaders/blur_v/opengl_fragment.glsl new file mode 100644 index 000000000..6820ca10d --- /dev/null +++ b/client/shaders/blur_v/opengl_fragment.glsl @@ -0,0 +1,29 @@ +#define rendered texture0 + +uniform sampler2D rendered; +uniform vec2 texelSize0; +uniform mediump float bloomRadius = 3.0; + +#ifdef GL_ES +varying mediump vec2 varTexCoord; +#else +centroid varying vec2 varTexCoord; +#endif + +void main(void) +{ + // kernel distance and linear size + mediump float n = 2. * bloomRadius + 1.; + + vec2 uv = varTexCoord.st - vec2(0., bloomRadius * texelSize0.y); + vec4 color = vec4(0.); + mediump float sum = 0.; + for (mediump float i = 0.; i < n; i++) { + mediump float weight = pow(1. - (abs(i / bloomRadius - 1.)), 1.3); + color += texture2D(rendered, uv).rgba * weight; + sum += weight; + uv += vec2(0., texelSize0.y); + } + color /= sum; + gl_FragColor = vec4(color.rgb, 1.0); // force full alpha to avoid holes in the image. +} diff --git a/client/shaders/blur_v/opengl_vertex.glsl b/client/shaders/blur_v/opengl_vertex.glsl new file mode 100644 index 000000000..12692c296 --- /dev/null +++ b/client/shaders/blur_v/opengl_vertex.glsl @@ -0,0 +1,11 @@ +#ifdef GL_ES +varying mediump vec2 varTexCoord; +#else +centroid varying vec2 varTexCoord; +#endif + +void main(void) +{ + varTexCoord.st = inTexCoord0.st; + gl_Position = inVertexPosition; +} |
