Files
blight/blight-assets/src/main/resources/Shaders/GaussianBlur.frag
2026-07-05 10:39:32 +02:00

46 lines
2.2 KiB
GLSL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#import "Common/ShaderLib/GLSLCompat.glsllib"
uniform sampler2D m_Texture;
uniform float m_BlurScale;
in vec2 texCoord;
// 5x5 Gauß-Kernel (σ≈1.2, vollständig normiert)
void main() {
vec2 ts = m_BlurScale / vec2(textureSize(m_Texture, 0));
vec4 c = vec4(0.0);
c += texture2D(m_Texture, texCoord + vec2(-2.0, -2.0) * ts) * 0.00731;
c += texture2D(m_Texture, texCoord + vec2(-1.0, -2.0) * ts) * 0.02075;
c += texture2D(m_Texture, texCoord + vec2( 0.0, -2.0) * ts) * 0.02936;
c += texture2D(m_Texture, texCoord + vec2( 1.0, -2.0) * ts) * 0.02075;
c += texture2D(m_Texture, texCoord + vec2( 2.0, -2.0) * ts) * 0.00731;
c += texture2D(m_Texture, texCoord + vec2(-2.0, -1.0) * ts) * 0.02075;
c += texture2D(m_Texture, texCoord + vec2(-1.0, -1.0) * ts) * 0.05890;
c += texture2D(m_Texture, texCoord + vec2( 0.0, -1.0) * ts) * 0.08334;
c += texture2D(m_Texture, texCoord + vec2( 1.0, -1.0) * ts) * 0.05890;
c += texture2D(m_Texture, texCoord + vec2( 2.0, -1.0) * ts) * 0.02075;
c += texture2D(m_Texture, texCoord + vec2(-2.0, 0.0) * ts) * 0.02936;
c += texture2D(m_Texture, texCoord + vec2(-1.0, 0.0) * ts) * 0.08334;
c += texture2D(m_Texture, texCoord + vec2( 0.0, 0.0) * ts) * 0.11792;
c += texture2D(m_Texture, texCoord + vec2( 1.0, 0.0) * ts) * 0.08334;
c += texture2D(m_Texture, texCoord + vec2( 2.0, 0.0) * ts) * 0.02936;
c += texture2D(m_Texture, texCoord + vec2(-2.0, 1.0) * ts) * 0.02075;
c += texture2D(m_Texture, texCoord + vec2(-1.0, 1.0) * ts) * 0.05890;
c += texture2D(m_Texture, texCoord + vec2( 0.0, 1.0) * ts) * 0.08334;
c += texture2D(m_Texture, texCoord + vec2( 1.0, 1.0) * ts) * 0.05890;
c += texture2D(m_Texture, texCoord + vec2( 2.0, 1.0) * ts) * 0.02075;
c += texture2D(m_Texture, texCoord + vec2(-2.0, 2.0) * ts) * 0.00731;
c += texture2D(m_Texture, texCoord + vec2(-1.0, 2.0) * ts) * 0.02075;
c += texture2D(m_Texture, texCoord + vec2( 0.0, 2.0) * ts) * 0.02936;
c += texture2D(m_Texture, texCoord + vec2( 1.0, 2.0) * ts) * 0.02075;
c += texture2D(m_Texture, texCoord + vec2( 2.0, 2.0) * ts) * 0.00731;
gl_FragColor = c; // Gewichte summieren sich auf 1.0
}