Dual Kawase Blur (down)

This is a downscale dual kawase post processing blur for compositor.

You can use it with a plugin: https://godotengine.org/asset-library/asset/4640

The plugin source code: https://github.com/Ultipuk/godot-dual-kawase-blur

Shader code
#[compute]
#version 450

/* License: MIT */
/* Author: Alexander Begichev, https://ultipuk.xyz */
/* Link: https://github.com/Ultipuk/godot-dual-kawase-blur */

layout(local_size_x = 32, local_size_y = 32, local_size_z = 1) in;

layout(push_constant, std430) uniform Params {
	float offset_multiplier;
} params;

layout(set = 0, binding = 0, rgba32f) uniform image2D OUTPUT_TEXTURE;
layout(set = 0, binding = 1) uniform sampler2D INPUT_TEXTURE;

void main() {
    ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
    ivec2 size = imageSize(OUTPUT_TEXTURE);
    if (texel.x >= size.x || texel.y >= size.y) {
    	return;
    }
    vec2 uv = (vec2(texel) + 0.5) / size;
    vec2 o = 0.5 / size * params.offset_multiplier;

    vec4 color = texture(INPUT_TEXTURE, uv);

    color *= 4.0;

    color += texture(INPUT_TEXTURE, uv + vec2(-o.x, -o.y)); /* bottom-left */
	color += texture(INPUT_TEXTURE, uv + vec2( o.x, -o.y)); /* bottom-right */
	color += texture(INPUT_TEXTURE, uv + vec2(-o.x,  o.y)); /* top-left */
	color += texture(INPUT_TEXTURE, uv + vec2( o.x,  o.y)); /* top-right */
	
	color /= 8.0;

    imageStore(OUTPUT_TEXTURE, texel, color);
}
Live Preview
Tags
blur, compositor, GLSL, kawase, Post processing
The shader code and all code snippets in this post are under MIT license and can be used freely. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from breadpack

Related shaders

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments