diff options
author | pryazha <pryadeiniv@mail.ru> | 2025-06-15 16:11:31 +0500 |
---|---|---|
committer | pryazha <pryadeiniv@mail.ru> | 2025-06-15 16:11:31 +0500 |
commit | 9d944f26d359e4bc1ffd8e44350b0df9f0935b18 (patch) | |
tree | 9759a83a76ab741a587b99f00c2463eafd05d813 /advanced_lighting/7.bloom/shaders/test_blur.frag | |
parent | d65ddd07a43d5ffdcf2ddf90d6f86626cf9b92d8 (diff) |
something
Diffstat (limited to 'advanced_lighting/7.bloom/shaders/test_blur.frag')
-rw-r--r-- | advanced_lighting/7.bloom/shaders/test_blur.frag | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/advanced_lighting/7.bloom/shaders/test_blur.frag b/advanced_lighting/7.bloom/shaders/test_blur.frag new file mode 100644 index 0000000..8d7ee9a --- /dev/null +++ b/advanced_lighting/7.bloom/shaders/test_blur.frag @@ -0,0 +1,28 @@ +#version 330 core + +in vert_t { + vec2 tex_coords; +} vert; + +out vec4 frag_color; + +uniform sampler2D colorbuffer; + +uniform float weights[5] = float[](0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162); + +void main() +{ + vec2 texture_offset = 1.0 / textureSize(colorbuffer, 0); + vec3 result = texture(colorbuffer, vert.tex_coords).rgb * weights[0]; + for (int x = 1; x < weights.length(); x++) { + vec2 offset = vec2(texture_offset.x * x, 0.0f); + result += texture(colorbuffer, vert.tex_coords + offset).rgb * weights[x]; + result += texture(colorbuffer, vert.tex_coords - offset).rgb * weights[x]; + } + for (int y = 1; y < weights.length(); y++) { + vec2 offset = vec2(0.0f, texture_offset.y * y); + result += texture(colorbuffer, vert.tex_coords + offset).rgb * weights[y]; + result += texture(colorbuffer, vert.tex_coords - offset).rgb * weights[y]; + } + frag_color = vec4(result, 1.0); +} |