Differential D16990 Diff 60050 source/blender/compositor/realtime_compositor/shaders/compositor_morphological_distance_threshold.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/realtime_compositor/shaders/compositor_morphological_distance_threshold.glsl
| Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | for (int x = -radius; x <= radius; x++) { | ||||
| if (is_center_masked != is_sample_masked) { | if (is_center_masked != is_sample_masked) { | ||||
| minimum_squared_distance = min(minimum_squared_distance, x * x + y * y); | minimum_squared_distance = min(minimum_squared_distance, x * x + y * y); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Compute the actual distance from the squared distance and assign it an appropriate sign | /* Compute the actual distance from the squared distance and assign it an appropriate sign | ||||
| * depending on whether it lies in a masked region or not. */ | * depending on whether it lies in a masked region or not. */ | ||||
| float signed_minimum_distance = sqrt(minimum_squared_distance) * (is_center_masked ? 1.0 : -1.0); | float signed_minimum_distance = sqrt(float(minimum_squared_distance)) * | ||||
| (is_center_masked ? 1.0 : -1.0); | |||||
| /* Add the erode/dilate distance and divide by the inset amount as described in the discussion, | /* Add the erode/dilate distance and divide by the inset amount as described in the discussion, | ||||
| * then clamp to the [0, 1] range. */ | * then clamp to the [0, 1] range. */ | ||||
| float value = clamp((signed_minimum_distance + distance) / inset, 0.0, 1.0); | float value = clamp((signed_minimum_distance + distance) / inset, 0.0, 1.0); | ||||
| imageStore(output_img, texel, vec4(value)); | imageStore(output_img, texel, vec4(value)); | ||||
| } | } | ||||