@@ -8,6 +8,7 @@ uniform highp float u_floor_width_scale;
88uniform float u_alpha_discard_threshold;
99uniform highp vec2 u_trim_offset;
1010uniform highp vec2 u_trim_fade_range;
11+ uniform highp vec2 u_trim_gradient_mix_range;
1112uniform lowp vec4 u_trim_color;
1213
1314in vec2 v_width2;
@@ -119,12 +120,14 @@ void main() {
119120 highp float start_transition = max (0.0 , min (1.0 , (line_progress - trim_start) / max (u_trim_fade_range[0 ], 1.0e-9 )));
120121 highp float end_transition = max (0.0 , min (1.0 , (trim_end - line_progress) / max (u_trim_fade_range[1 ], 1.0e-9 )));
121122 highp float transition_factor = min (start_transition, end_transition);
122- #ifdef LINE_GRADIENT_AS_TRIM_COLOR
123- out_color = mix (color, out_color, transition_factor);
124- #else
125- out_color = mix (out_color, u_trim_color, transition_factor);
123+ highp float gradient_trim_color_mix_factor = 0.0 ;
124+ #ifdef RENDER_LINE_GRADIENT
125+ gradient_trim_color_mix_factor = smoothstep (u_trim_gradient_mix_range.x, u_trim_gradient_mix_range.y, line_progress);
126126#endif
127-
127+ highp vec4 trim_color = mix (u_trim_color, out_color, gradient_trim_color_mix_factor);
128+ // Note: if u_trim_gradient_mix_range.x < 1.0 the non-trimmed part will use the non-gradient color
129+ // This sets the usage of line-gradient as a trim-color
130+ out_color = mix (u_trim_gradient_mix_range.x < 1.0 ? color : out_color, trim_color, transition_factor);
128131 trim_alpha = 1.0 - transition_factor;
129132 }
130133#endif
0 commit comments