aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh
diff options
context:
space:
mode:
authorMoulberry <james.jenour@student.scotch.wa.edu.au>2020-07-26 12:12:25 +1000
committerMoulberry <james.jenour@student.scotch.wa.edu.au>2020-07-26 12:12:25 +1000
commitf0293a74282cece3aa8a2a328559889d6e187209 (patch)
treee4bb3d101b8b7e70a58f521a41a44071bb6cc0fa /src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh
parent16b89f752b83aa91f1697238d785eb97a4f01f61 (diff)
downloadNotEnoughUpdates-f0293a74282cece3aa8a2a328559889d6e187209.tar.gz
NotEnoughUpdates-f0293a74282cece3aa8a2a328559889d6e187209.tar.bz2
NotEnoughUpdates-f0293a74282cece3aa8a2a328559889d6e187209.zip
1.11.7
Diffstat (limited to 'src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh')
-rw-r--r--src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh b/src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh
new file mode 100644
index 00000000..ca64470a
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/shaders/program/blur2.fsh
@@ -0,0 +1,34 @@
+#version 120
+
+uniform sampler2D DiffuseSampler;
+
+varying vec2 texCoord;
+varying vec2 oneTexel;
+
+uniform vec2 InSize;
+
+uniform vec2 BlurDir;
+uniform float Radius;
+uniform float AlphaMult;
+
+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 sample = texture2D(DiffuseSampler, texCoord + oneTexel * r * BlurDir);
+
+ // Accumulate average alpha
+ totalAlpha = totalAlpha + sample.a;
+ totalSamples = totalSamples + 1.0;
+
+ // Accumulate smoothed blur
+ //float strength = (2.0 - abs(r / Radius))*sample.a;
+ float strength = sample.a;
+ totalStrength = totalStrength + strength;
+ blurred = blurred + sample;
+ }
+ float alpha = totalAlpha/totalSamples*AlphaMult;
+ gl_FragColor = vec4(blurred.rgb / totalStrength, alpha);
+}