2015-09-02 03:44:16 +03:00
|
|
|
#version 330
|
|
|
|
|
2016-05-18 13:04:27 +03:00
|
|
|
// Input vertex attributes (from vertex shader)
|
2015-09-02 03:44:16 +03:00
|
|
|
in vec2 fragTexCoord;
|
2016-05-18 13:04:27 +03:00
|
|
|
in vec4 fragColor;
|
2015-09-02 03:44:16 +03:00
|
|
|
|
2016-05-18 13:04:27 +03:00
|
|
|
// Input uniform values
|
2015-09-02 03:44:16 +03:00
|
|
|
uniform sampler2D texture0;
|
2016-07-19 11:57:35 +03:00
|
|
|
uniform vec4 colDiffuse;
|
2015-09-02 03:44:16 +03:00
|
|
|
|
2016-05-18 13:04:27 +03:00
|
|
|
// Output fragment color
|
|
|
|
out vec4 finalColor;
|
|
|
|
|
2015-09-02 03:44:16 +03:00
|
|
|
// NOTE: Add here your custom variables
|
|
|
|
|
2016-07-25 20:44:21 +03:00
|
|
|
const vec2 size = vec2(800, 450); // render size
|
|
|
|
const float samples = 5.0; // pixels per axis; higher = bigger glow, worse performance
|
|
|
|
const float quality = 2.5; // lower = smaller glow, better quality
|
|
|
|
|
2015-09-02 03:44:16 +03:00
|
|
|
void main()
|
|
|
|
{
|
|
|
|
vec4 sum = vec4(0);
|
2016-07-25 20:44:21 +03:00
|
|
|
vec2 sizeFactor = vec2(1)/size*quality;
|
|
|
|
|
|
|
|
// Texel color fetching from texture sampler
|
|
|
|
vec4 source = texture(texture0, fragTexCoord);
|
|
|
|
|
|
|
|
const int range = 2; // should be = (samples - 1)/2;
|
2015-09-02 03:44:16 +03:00
|
|
|
|
2016-07-25 20:44:21 +03:00
|
|
|
for (int x = -range; x <= range; x++)
|
2015-09-02 03:44:16 +03:00
|
|
|
{
|
2016-07-25 20:44:21 +03:00
|
|
|
for (int y = -range; y <= range; y++)
|
2015-09-02 03:44:16 +03:00
|
|
|
{
|
2016-07-25 20:44:21 +03:00
|
|
|
sum += texture(texture0, fragTexCoord + vec2(x, y)*sizeFactor);
|
2015-09-02 03:44:16 +03:00
|
|
|
}
|
|
|
|
}
|
2016-05-18 13:04:27 +03:00
|
|
|
|
2016-07-25 20:44:21 +03:00
|
|
|
// Calculate final fragment color
|
|
|
|
finalColor = ((sum/(samples*samples)) + source)*colDiffuse;
|
2015-09-02 03:44:16 +03:00
|
|
|
}
|