@@ -25,23 +25,21 @@ kernel void drawMetaballs(texture2d<float, access::write> outTexture[[texture(0)
2525 }
2626
2727 for (i = 1, x = 0; i < metaballArraySize; i += 2, x += 1) {
28+ float value1 = 2048 / (metaballDistances[x] + 1);
29+ float2 direction1 = metaballDirections[x];
30+
2831 for (j = i + 2, y = x + 1; j < metaballArraySize; j += 2, y += 1) {
29− float value1 = 2048 / (metaballDistances[x] + 1);
32+
3033 float value2 = 2048 / (metaballDistances[y] + 1);
34+ float2 direction2 = metaballDirections[y];
3135
3236 float v = value1 + value2;
33−
3437 float weightedValue = 0.5 * v;
3538
3639 char edgeIndex = y * numberOfMetaballs + x;
3740 float edgeWeight = edgesBuffer[edgeIndex];
38− float2 direction1 = metaballDirections[x];
39− float2 direction2 = metaballDirections[y];
40−
4141 float cosine = dot(direction1, direction2);
42−
4342 float link = pow(((1 - cosine) * 0.5), 100);
44−
4543 float weightedLink = 0.6 * link * edgeWeight;
4644
4745 sum += step(0.5, weightedValue + weightedLink);