mirror of
https://github.com/lettier/3d-game-shaders-for-beginners.git
synced 2025-09-24 19:51:29 +02:00
47 lines
823 B
GLSL
47 lines
823 B
GLSL
/*
|
|
(C) 2019 David Lettier
|
|
lettier.com
|
|
*/
|
|
|
|
#version 150
|
|
|
|
uniform sampler2D colorTexture;
|
|
|
|
uniform vec2 parameters;
|
|
|
|
out vec4 fragColor;
|
|
|
|
void main() {
|
|
vec2 texSize = textureSize(colorTexture, 0).xy;
|
|
vec2 texCoord = gl_FragCoord.xy / texSize;
|
|
|
|
fragColor = texture(colorTexture, texCoord);
|
|
|
|
int size = int(parameters.x);
|
|
if (size <= 0) { return; }
|
|
|
|
float separation = parameters.y;
|
|
separation = max(separation, 1);
|
|
|
|
fragColor.rgb = vec3(0);
|
|
|
|
float count = 0.0;
|
|
|
|
for (int i = -size; i <= size; ++i) {
|
|
for (int j = -size; j <= size; ++j) {
|
|
fragColor.rgb +=
|
|
texture
|
|
( colorTexture
|
|
, ( gl_FragCoord.xy
|
|
+ (vec2(i, j) * separation)
|
|
)
|
|
/ texSize
|
|
).rgb;
|
|
|
|
count += 1.0;
|
|
}
|
|
}
|
|
|
|
fragColor.rgb /= count;
|
|
}
|