Differential D16990 Diff 60050 source/blender/compositor/realtime_compositor/shaders/compositor_blur_variable_size.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/realtime_compositor/shaders/compositor_blur_variable_size.glsl
| Show All 11 Lines | |||||
| * the weights texture and result will be zero. However, what we expect is that pixels to the right | * the weights texture and result will be zero. However, what we expect is that pixels to the right | ||||
| * of the white pixel will be white, that is, they should sample a weight of 1 from the right side | * of the white pixel will be white, that is, they should sample a weight of 1 from the right side | ||||
| * of the weights texture, hence the need for inversion. */ | * of the weights texture, hence the need for inversion. */ | ||||
| vec4 load_weight(ivec2 texel, float radius) | vec4 load_weight(ivec2 texel, float radius) | ||||
| { | { | ||||
| /* The center zero texel is always assigned a unit weight regardless of the corresponding weight | /* The center zero texel is always assigned a unit weight regardless of the corresponding weight | ||||
| * in the weights texture. That's to guarantee that at last the center pixel will be accumulated | * in the weights texture. That's to guarantee that at last the center pixel will be accumulated | ||||
| * even if the weights texture is zero at its center. */ | * even if the weights texture is zero at its center. */ | ||||
| if (texel == ivec2(0)) { | if (texel.x == 0 && texel.y == 0) { | ||||
| return vec4(1.0); | return vec4(1.0); | ||||
| } | } | ||||
| /* Add the radius to transform the texel into the range [0, radius * 2], with an additional 0.5 | /* Add the radius to transform the texel into the range [0, radius * 2], with an additional 0.5 | ||||
| * to sample at the center of the pixels, then divide by the upper bound plus one to transform | * to sample at the center of the pixels, then divide by the upper bound plus one to transform | ||||
| * the texel into the normalized range [0, 1] needed to sample the weights sampler. Finally, | * the texel into the normalized range [0, 1] needed to sample the weights sampler. Finally, | ||||
| * invert the textures coordinates by subtracting from 1 to maintain the shape of the weights as | * invert the textures coordinates by subtracting from 1 to maintain the shape of the weights as | ||||
| * mentioned in the function description. */ | * mentioned in the function description. */ | ||||
| return texture(weights_tx, 1.0 - ((texel + vec2(radius + 0.5)) / (radius * 2 + 1))); | return texture(weights_tx, 1.0 - ((vec2(texel) + vec2(radius + 0.5)) / (radius * 2.0 + 1.0))); | ||||
| } | } | ||||
| void main() | void main() | ||||
| { | { | ||||
| ivec2 texel = ivec2(gl_GlobalInvocationID.xy); | ivec2 texel = ivec2(gl_GlobalInvocationID.xy); | ||||
| /* The mask input is treated as a boolean. If it is zero, then no blurring happens for this | /* The mask input is treated as a boolean. If it is zero, then no blurring happens for this | ||||
| * pixel. Otherwise, the pixel is blurred normally and the mask value is irrelevant. */ | * pixel. Otherwise, the pixel is blurred normally and the mask value is irrelevant. */ | ||||
| Show All 34 Lines | |||||