Created
December 5, 2012 19:36
-
-
Save mebens/4218802 to your computer and use it in GitHub Desktop.
Simple glow/bloom GLSL shader for Love2D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adapted from http://www.youtube.com/watch?v=qNM0k522R7o | |
extern vec2 size; | |
extern int samples = 5; // pixels per axis; higher = bigger glow, worse performance | |
extern float quality = 2.5; // lower = smaller glow, better quality | |
vec4 effect(vec4 colour, Image tex, vec2 tc, vec2 sc) | |
{ | |
vec4 source = Texel(tex, tc); | |
vec4 sum = vec4(0); | |
int diff = (samples - 1) / 2; | |
vec2 sizeFactor = vec2(1) / size * quality; | |
for (int x = -diff; x <= diff; x++) | |
{ | |
for (int y = -diff; y <= diff; y++) | |
{ | |
vec2 offset = vec2(x, y) * sizeFactor; | |
sum += Texel(tex, tc + offset); | |
} | |
} | |
return ((sum / (samples * samples)) + source) * colour; | |
} |
Probably the canvas or window size.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What does size represent?