[Bf-blender-cvs] [b1e6e63c222] master: Cleanup: Geometry Nodes dashed lines

Dalai Felinto noreply at git.blender.org
Tue Oct 5 15:39:03 CEST 2021


Commit: b1e6e63c22249edfb501a7579efa22810ea55aee
Author: Dalai Felinto
Date:   Tue Oct 5 15:37:19 2021 +0200
Branches: master
https://developer.blender.org/rBb1e6e63c22249edfb501a7579efa22810ea55aee

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.

===================================================================

M	source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl

===================================================================

diff --git a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl
index 55d5d941290..402a07ad4e8 100644
--- a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl
@@ -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));



More information about the Bf-blender-cvs mailing list