mirror of
https://github.com/SangeloDev/SangeFault.git
synced 2024-11-13 00:52:43 +00:00
34 lines
817 B
Text
34 lines
817 B
Text
|
#version 150
|
||
|
|
||
|
uniform sampler2D DiffuseSampler;
|
||
|
|
||
|
in vec2 texCoord;
|
||
|
in vec2 oneTexel;
|
||
|
|
||
|
uniform vec2 InSize;
|
||
|
|
||
|
uniform vec2 BlurDir;
|
||
|
uniform float Radius;
|
||
|
|
||
|
out vec4 fragColor;
|
||
|
|
||
|
void main() {
|
||
|
vec4 blurred = vec4(0.0);
|
||
|
float totalStrength = 0.0;
|
||
|
float totalAlpha = 0.0;
|
||
|
float totalSamples = 0.0;
|
||
|
for(float r = -Radius; r <= Radius; r += 1.0) {
|
||
|
vec4 sampleValue = texture(DiffuseSampler, texCoord + oneTexel * r * BlurDir);
|
||
|
|
||
|
// Accumulate average alpha
|
||
|
totalAlpha = totalAlpha + sampleValue.a;
|
||
|
totalSamples = totalSamples + 1.0;
|
||
|
|
||
|
// Accumulate smoothed blur
|
||
|
float strength = 1.0 - abs(r / Radius);
|
||
|
totalStrength = totalStrength + strength;
|
||
|
blurred = blurred + sampleValue;
|
||
|
}
|
||
|
fragColor = vec4(blurred.rgb / (Radius * 2.0 + 1.0), totalAlpha);
|
||
|
}
|