Differential D16990 Diff 60050 source/blender/compositor/realtime_compositor/shaders/compositor_filter.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/realtime_compositor/shaders/compositor_filter.glsl
| #pragma BLENDER_REQUIRE(gpu_shader_compositor_texture_utilities.glsl) | #pragma BLENDER_REQUIRE(gpu_shader_compositor_texture_utilities.glsl) | ||||
| void main() | void main() | ||||
| { | { | ||||
| ivec2 texel = ivec2(gl_GlobalInvocationID.xy); | ivec2 texel = ivec2(gl_GlobalInvocationID.xy); | ||||
| /* Compute the dot product between the 3x3 window around the pixel and the filter kernel. */ | /* Compute the dot product between the 3x3 window around the pixel and the filter kernel. */ | ||||
| vec4 color = vec4(0); | vec4 color = vec4(0); | ||||
| for (int j = 0; j < 3; j++) { | for (int j = 0; j < 3; j++) { | ||||
| for (int i = 0; i < 3; i++) { | for (int i = 0; i < 3; i++) { | ||||
| color += texture_load(input_tx, texel + ivec2(i - 1, j - 1)) * kernel[j][i]; | color += texture_load(input_tx, texel + ivec2(i - 1, j - 1)) * ukernel[j][i]; | ||||
| } | } | ||||
| } | } | ||||
| /* Mix with the original color at the center of the kernel using the input factor. */ | /* 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); | color = mix(texture_load(input_tx, texel), color, texture_load(factor_tx, texel).x); | ||||
| /* Store the color making sure it is not negative. */ | /* Store the color making sure it is not negative. */ | ||||
| imageStore(output_img, texel, max(color, 0.0)); | imageStore(output_img, texel, max(color, 0.0)); | ||||
| } | } | ||||