first commit
This commit is contained in:
22
blur.gdshader
Normal file
22
blur.gdshader
Normal file
@@ -0,0 +1,22 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform float sigma: hint_range(0.0, 20.0) = 3.3;
|
||||
|
||||
float gaussian(float x, float std) {
|
||||
return exp(x * x / (-2.0 * std * std)) / (sqrt(2.0 * PI) * std);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
float ksize = round(3.0 * sigma);
|
||||
float std = (sigma != 0.0 ? sigma : 1.0);
|
||||
vec4 col = vec4(0.0);
|
||||
float total_weight = 0.0;
|
||||
for(float i = -ksize ; i <= ksize; ++i) {
|
||||
for(float j = -ksize; j <= ksize; ++j) {
|
||||
float weight = gaussian(i, std) * gaussian(j, std);
|
||||
col += texture(TEXTURE, UV + vec2(i, j) * SCREEN_PIXEL_SIZE) * weight;
|
||||
total_weight += weight;
|
||||
}
|
||||
}
|
||||
COLOR = col / total_weight;
|
||||
}
|
||||
Reference in New Issue
Block a user