blob: e501c563dda0fbcbd9c9a60b94c4984cfd59d164 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#pragma BLENDER_REQUIRE(gpu_shader_compositor_texture_utilities.glsl)
void main()
{
ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
/* Compute the dot product between the 3x3 window around the pixel and the filter kernel. */
vec4 color = vec4(0);
for (int j = 0; j < 3; j++) {
for (int i = 0; i < 3; i++) {
color += texture_load(input_tx, texel + ivec2(i - 1, j - 1)) * kernel[j][i];
}
}
/* Mix with the original color at the center of the kernel using the input factor. */
color = mix(texture_load(input_tx, texel), color, texture_load(factor_tx, texel).x);
/* Store the color making sure it is not negative. */
imageStore(output_img, texel, max(color, 0.0));
}
|