git.iko.soy/metal-metaballs
on master help sign in
Fixed artifacts in link coloring.
a9b95fbvinivendra
PixelImage.xcworkspace/xcuserdata/vini.xcuserdatad/UserInterfaceState.xcuserstate

Binary file not shown.

PixelImage/shaders.metal+6−7
@@ -45,7 +45,7 @@ kernel void
45
45
46 float bendClose = 0.0;
46 float bendClose = 0.0;
47 float bendCloseCount = 0.0;
47 float bendCloseCount = 0.0;
48− float red = 0.0;
48+ float ball = 0.0;
49
49
50 for (x = 0; x < numberOfMetaballs; x += 1) {
50 for (x = 0; x < numberOfMetaballs; x += 1) {
51 float distance1 = metaballDistances[x];
51 float distance1 = metaballDistances[x];
@@ -77,18 +77,17 @@ kernel void
77 bendCloseCount += 1.0;
77 bendCloseCount += 1.0;
78 }
78 }
79
79
80− red += step(0.4, weightedValue);
80+ ball += step(0.4, weightedValue);
81
81
82− if (weightedLink > greatestLinkWeight) {
82+ float metaballValue = step(0.5, weightedValue + weightedLink);
83− greatestLinkWeight = weightedLink;
83+
84+ if (metaballValue > 0.0) {
84 colorSumLink = float3(0.0, 0.0, 0.0);
85 colorSumLink = float3(0.0, 0.0, 0.0);
85 colorSumLink += metaballColors[x] / distance1;
86 colorSumLink += metaballColors[x] / distance1;
86 colorSumLink += metaballColors[y] / distance2;
87 colorSumLink += metaballColors[y] / distance2;
87 colorSumLink /= (1 / distance1) + (1 / distance2);
88 colorSumLink /= (1 / distance1) + (1 / distance2);
88 }
89 }
89
90
90− float metaballValue = step(0.5, weightedValue + weightedLink);
91−
92 sum += metaballValue;
91 sum += metaballValue;
93 }
92 }
94 }
93 }
@@ -107,7 +106,7 @@ kernel void
107
106
108 colorSum = colorSum / colorAccumulation;
107 colorSum = colorSum / colorAccumulation;
109
108
110− if (result > 0.0 && red < 1.0) {
109+ if (result > 0.0 && ball < 1.0) {
111 colorSum = colorSumLink;
110 colorSum = colorSumLink;
112 }
111 }
113
112