Fix #117317: Empty Defocus output when Z is less than 0
The Defocus node produces an empty output when the Z input is less than 0. This patch fixes that by ensuring zero or positive blur radius.
This commit is contained in:
@@ -45,7 +45,7 @@ void main()
|
||||
return;
|
||||
}
|
||||
|
||||
float center_size = texture_load(size_tx, texel).x * base_size;
|
||||
float center_size = max(0.0, texture_load(size_tx, texel).x * base_size);
|
||||
|
||||
/* Go over the window of the given search radius and accumulate the colors multiplied by their
|
||||
* respective weights as well as the weights themselves, but only if both the size of the center
|
||||
@@ -55,7 +55,7 @@ void main()
|
||||
vec4 accumulated_weight = vec4(0.0);
|
||||
for (int y = -search_radius; y <= search_radius; y++) {
|
||||
for (int x = -search_radius; x <= search_radius; x++) {
|
||||
float candidate_size = texture_load(size_tx, texel + ivec2(x, y)).x * base_size;
|
||||
float candidate_size = max(0.0, texture_load(size_tx, texel + ivec2(x, y)).x * base_size);
|
||||
|
||||
/* Skip accumulation if either the x or y distances of the candidate pixel are larger than
|
||||
* either the center or candidate pixel size. Note that the max and min functions here denote
|
||||
|
||||
@@ -31,7 +31,7 @@ void main()
|
||||
{
|
||||
ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
|
||||
|
||||
float center_radius = texture_load(radius_tx, texel).x;
|
||||
float center_radius = max(0.0, texture_load(radius_tx, texel).x);
|
||||
vec4 center_color = texture_load(input_tx, texel);
|
||||
|
||||
/* Go over the window of the given search radius and accumulate the colors multiplied by their
|
||||
@@ -42,7 +42,7 @@ void main()
|
||||
vec4 accumulated_weight = vec4(0.0);
|
||||
for (int y = -search_radius; y <= search_radius; y++) {
|
||||
for (int x = -search_radius; x <= search_radius; x++) {
|
||||
float candidate_radius = texture_load(radius_tx, texel + ivec2(x, y)).x;
|
||||
float candidate_radius = max(0.0, texture_load(radius_tx, texel + ivec2(x, y)).x);
|
||||
|
||||
/* Skip accumulation if either the x or y distances of the candidate pixel are larger than
|
||||
* either the center or candidate pixel radius. Note that the max and min functions here
|
||||
|
||||
@@ -8,5 +8,5 @@ void main()
|
||||
{
|
||||
ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
|
||||
float radius = texture_load(radius_tx, texel).x;
|
||||
imageStore(radius_img, texel, vec4(min(max_radius, radius * scale)));
|
||||
imageStore(radius_img, texel, vec4(clamp(radius * scale, 0.0, max_radius)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user