Differential D16990 Diff 60050 source/blender/compositor/realtime_compositor/shaders/compositor_symmetric_blur_variable_size.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/realtime_compositor/shaders/compositor_symmetric_blur_variable_size.glsl
| Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | void main() | ||||
| * the upper right quadrant, but since the filter is symmetric, the same weight is used for the | * the upper right quadrant, but since the filter is symmetric, the same weight is used for the | ||||
| * rest of the quadrants and we add all four of their contributions. */ | * rest of the quadrants and we add all four of their contributions. */ | ||||
| for (int y = 1; y < weights_size.y; y++) { | for (int y = 1; y < weights_size.y; y++) { | ||||
| for (int x = 1; x < weights_size.x; x++) { | for (int x = 1; x < weights_size.x; x++) { | ||||
| float weight = texture_load(weights_tx, ivec2(x, y)).x; | float weight = texture_load(weights_tx, ivec2(x, y)).x; | ||||
| /* Upper right quadrant. */ | /* Upper right quadrant. */ | ||||
| float upper_right_size = load_size(texel + ivec2(x, y)); | float upper_right_size = load_size(texel + ivec2(x, y)); | ||||
| vec2 upper_right_blur_radius = upper_right_size * weights_size; | vec2 upper_right_blur_radius = upper_right_size * vec2(weights_size); | ||||
| if (x < upper_right_blur_radius.x && y < upper_right_blur_radius.y) { | if (x < upper_right_blur_radius.x && y < upper_right_blur_radius.y) { | ||||
| accumulated_color += load_input(texel + ivec2(x, y)) * weight; | accumulated_color += load_input(texel + ivec2(x, y)) * weight; | ||||
| accumulated_weight += weight; | accumulated_weight += weight; | ||||
| } | } | ||||
| /* Upper left quadrant. */ | /* Upper left quadrant. */ | ||||
| float upper_left_size = load_size(texel + ivec2(-x, y)); | float upper_left_size = load_size(texel + ivec2(-x, y)); | ||||
| vec2 upper_left_blur_radius = upper_left_size * weights_size; | vec2 upper_left_blur_radius = upper_left_size * vec2(weights_size); | ||||
| if (x < upper_left_blur_radius.x && y < upper_left_blur_radius.y) { | if (x < upper_left_blur_radius.x && y < upper_left_blur_radius.y) { | ||||
| accumulated_color += load_input(texel + ivec2(-x, y)) * weight; | accumulated_color += load_input(texel + ivec2(-x, y)) * weight; | ||||
| accumulated_weight += weight; | accumulated_weight += weight; | ||||
| } | } | ||||
| /* Bottom right quadrant. */ | /* Bottom right quadrant. */ | ||||
| float bottom_right_size = load_size(texel + ivec2(x, -y)); | float bottom_right_size = load_size(texel + ivec2(x, -y)); | ||||
| vec2 bottom_right_blur_radius = bottom_right_size * weights_size; | vec2 bottom_right_blur_radius = bottom_right_size * vec2(weights_size); | ||||
| if (x < bottom_right_blur_radius.x && y < bottom_right_blur_radius.y) { | if (x < bottom_right_blur_radius.x && y < bottom_right_blur_radius.y) { | ||||
| accumulated_color += load_input(texel + ivec2(x, -y)) * weight; | accumulated_color += load_input(texel + ivec2(x, -y)) * weight; | ||||
| accumulated_weight += weight; | accumulated_weight += weight; | ||||
| } | } | ||||
| /* Bottom left quadrant. */ | /* Bottom left quadrant. */ | ||||
| float bottom_left_size = load_size(texel + ivec2(-x, -y)); | float bottom_left_size = load_size(texel + ivec2(-x, -y)); | ||||
| vec2 bottom_left_blur_radius = bottom_left_size * weights_size; | vec2 bottom_left_blur_radius = bottom_left_size * vec2(weights_size); | ||||
| if (x < bottom_left_blur_radius.x && y < bottom_left_blur_radius.y) { | if (x < bottom_left_blur_radius.x && y < bottom_left_blur_radius.y) { | ||||
| accumulated_color += load_input(texel + ivec2(-x, -y)) * weight; | accumulated_color += load_input(texel + ivec2(-x, -y)) * weight; | ||||
| accumulated_weight += weight; | accumulated_weight += weight; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| accumulated_color = safe_divide(accumulated_color, accumulated_weight); | accumulated_color = safe_divide(accumulated_color, accumulated_weight); | ||||
| if (gamma_correct) { | if (gamma_correct) { | ||||
| accumulated_color = gamma_uncorrect_blur_output(accumulated_color); | accumulated_color = gamma_uncorrect_blur_output(accumulated_color); | ||||
| } | } | ||||
| imageStore(output_img, texel, accumulated_color); | imageStore(output_img, texel, accumulated_color); | ||||
| } | } | ||||