Cleanup: Geometry Nodes dashed lines

No functional change, just cleaning up the shader code a bit.

Part of this is removing dead code (the discard was never called), and
part is shuffling mix/max around based on feedback by Sybren Stüvel.
This commit is contained in:
Dalai Felinto 2021-10-05 15:37:19 +02:00
parent 55b8fc718a
commit b1e6e63c22
1 changed files with 3 additions and 6 deletions

View File

@ -28,13 +28,10 @@ void main()
float t = ANTIALIAS / DASH_WIDTH;
float slope = 1.0 / (2.0 * t);
float alpha = min(1.0, max(0.0, slope * (normalized_distance_triangle - dashFactor + t)));
float unclamped_alpha = 1.0 - slope * (normalized_distance_triangle - dashFactor + t);
float alpha = max(0.0, min(unclamped_alpha, 1.0));
if (alpha < 0.0) {
discard;
}
fragColor.a *= 1.0 - alpha;
fragColor.a *= alpha;
}
fragColor.a *= smoothstep(1.0, 0.1, abs(colorGradient));