git.iko.soy/metal-metaballs
on master help sign in
A bit more progress in antialiasing.
commit120a2c47977445f62b2c5deae70ea16c6614254c authorvinivendra <vinivendra@gmail.com> dateThu 25 Feb 2016, 14:50 (11 years ago) parent9184f0f
1 file changed+8−7
PixelImage/shaders.metal+8−7
PixelImage/shaders.metal+8−7
@@ -71,11 +71,6 @@ kernel void
7171
7272 float result = weightedValue + weightedLink;
7373
74− if (result > 0.4 && result < 0.6) {
75− bendClose += result;
76− bendCloseCount += 1.0;
77− }
78−
7974 ball += step(0.4, weightedValue);
8075
8176 float metaballValue = step(0.5, weightedValue + weightedLink);
@@ -87,11 +82,16 @@ kernel void
8782 colorSumLink /= (1 / distance1) + (1 / distance2);
8883 }
8984
85+ if (result > 0.4) {
86+ bendClose += result;
87+ bendCloseCount += 1.0;
88+ }
89+
9090 sum += metaballValue;
9191 }
9292 }
9393
94− bendClose = bendClose / bendCloseCount;
94+ // bendClose = bendClose / bendCloseCount;
9595
9696 if (bendClose != 0.0) {
9797 bendClose = (bendClose - 0.4) * (1 / (0.6 - 0.4));
@@ -99,8 +99,8 @@ kernel void
9999 bendClose = 0.0;
100100 }
101101
102+
102103 float result = step(0.4, sum);
103− result += bendClose * 10;
104104 result = clamp(result, 0.0, 1.0);
105105
106106 colorSum = colorSum / colorAccumulation;
@@ -109,6 +109,7 @@ kernel void
109109 colorSum = colorSumLink;
110110 }
111111
112+
112113 colorSum *= result;
113114
114115 outTexture.write(float4(colorSum.bgr, 1), gid);