@@ -45,7 +45,7 @@ kernel void
4545
4646 float bendClose = 0.0;
4747 float bendCloseCount = 0.0;
48− float red = 0.0;
48+ float ball = 0.0;
4949
5050 for (x = 0; x < numberOfMetaballs; x += 1) {
5151 float distance1 = metaballDistances[x];
@@ -77,18 +77,17 @@ kernel void
7777 bendCloseCount += 1.0;
7878 }
7979
80− red += step(0.4, weightedValue);
80+ ball += step(0.4, weightedValue);
8181
82− if (weightedLink > greatestLinkWeight) {
83− greatestLinkWeight = weightedLink;
82+ float metaballValue = step(0.5, weightedValue + weightedLink);
83+
84+ if (metaballValue > 0.0) {
8485 colorSumLink = float3(0.0, 0.0, 0.0);
8586 colorSumLink += metaballColors[x] / distance1;
8687 colorSumLink += metaballColors[y] / distance2;
8788 colorSumLink /= (1 / distance1) + (1 / distance2);
8889 }
8990
90− float metaballValue = step(0.5, weightedValue + weightedLink);
91−
9291 sum += metaballValue;
9392 }
9493 }
@@ -107,7 +106,7 @@ kernel void
107106
108107 colorSum = colorSum / colorAccumulation;
109108
110− if (result > 0.0 && red < 1.0) {
109+ if (result > 0.0 && ball < 1.0) {
111110 colorSum = colorSumLink;
112111 }
113112