Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple glow/bloom GLSL shader for Love2D
// 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;
}
@gamepopper

This comment has been minimized.

Copy link

commented Feb 12, 2016

What does size represent?

@AxisAngles

This comment has been minimized.

Copy link

commented Feb 22, 2016

Probably the canvas or window size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.