diff options
Diffstat (limited to 'deps/raylib/examples/shaders/resources/shaders/glsl120/bloom.fs')
-rw-r--r-- | deps/raylib/examples/shaders/resources/shaders/glsl120/bloom.fs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/deps/raylib/examples/shaders/resources/shaders/glsl120/bloom.fs b/deps/raylib/examples/shaders/resources/shaders/glsl120/bloom.fs new file mode 100644 index 0000000..b8c4495 --- /dev/null +++ b/deps/raylib/examples/shaders/resources/shaders/glsl120/bloom.fs @@ -0,0 +1,37 @@ +#version 120 + +// Input vertex attributes (from vertex shader) +varying vec2 fragTexCoord; +varying vec4 fragColor; + +// Input uniform values +uniform sampler2D texture0; +uniform vec4 colDiffuse; + +// NOTE: Add here your custom variables + +const vec2 size = vec2(800, 450); // Framebuffer size +const float samples = 5.0; // Pixels per axis; higher = bigger glow, worse performance +const float quality = 2.5; // Defines size factor: Lower = smaller glow, better quality + +void main() +{ + vec4 sum = vec4(0); + vec2 sizeFactor = vec2(1)/size*quality; + + // Texel color fetching from texture sampler + vec4 source = texture2D(texture0, fragTexCoord); + + const int range = 2; // should be = (samples - 1)/2; + + for (int x = -range; x <= range; x++) + { + for (int y = -range; y <= range; y++) + { + sum += texture2D(texture0, fragTexCoord + vec2(x, y)*sizeFactor); + } + } + + // Calculate final fragment color + gl_FragColor = ((sum/(samples*samples)) + source)*colDiffuse; +}
\ No newline at end of file |