Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmarSquircleArt <mail@OmarEmara.dev>2020-09-03 19:56:27 +0300
committerOmarSquircleArt <mail@OmarEmara.dev>2020-09-03 19:56:27 +0300
commit340cbc7f153737fbd228bdf35b0cabb450decb1f (patch)
tree2c19a0e0b67f8d053a21113770896018faf8b263 /source/blender/gpu/shaders/material
parentd2c52d4de2ca20dd2ba0254dd6207a70e9bd0597 (diff)
Fix T79803: Wrong Distance To Edge 1D Voronoi
The current 1D Voronoi implementation for the Distance to Edge option computes the distance to the cells instead. This patch fixes that and compute the distance to the edge. Reviewed By: JacquesLucke, brecht Differential Revision: https://developer.blender.org/D8634
Diffstat (limited to 'source/blender/gpu/shaders/material')
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_tex_voronoi.glsl15
1 files changed, 7 insertions, 8 deletions
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_tex_voronoi.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_tex_voronoi.glsl
index 0d8847176c9..470ce1a1fa7 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_tex_voronoi.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_tex_voronoi.glsl
@@ -158,14 +158,13 @@ void node_tex_voronoi_distance_to_edge_1d(vec3 coord,
float cellPosition = floor(scaledCoord);
float localPosition = scaledCoord - cellPosition;
- float minDistance = 8.0;
- for (int i = -1; i <= 1; i++) {
- float cellOffset = float(i);
- float pointPosition = cellOffset + hash_float_to_float(cellPosition + cellOffset) * randomness;
- float distanceToPoint = voronoi_distance(pointPosition, localPosition, metric, exponent);
- minDistance = min(distanceToPoint, minDistance);
- }
- outDistance = minDistance;
+ float midPointPosition = hash_float_to_float(cellPosition) * randomness;
+ float leftPointPosition = -1.0 + hash_float_to_float(cellPosition - 1.0) * randomness;
+ float rightPointPosition = 1.0 + hash_float_to_float(cellPosition + 1.0) * randomness;
+ float distanceToMidLeft = distance((midPointPosition + leftPointPosition) / 2.0, localPosition);
+ float distanceToMidRight = distance((midPointPosition + rightPointPosition) / 2.0, localPosition);
+
+ outDistance = min(distanceToMidLeft, distanceToMidRight);
}
void node_tex_voronoi_n_sphere_radius_1d(vec3 coord,