Skip to content

Commit fd81ff3

Browse files
fix(LineMaterial): don't multiply unset vertexColors (#338)
1 parent 6a37a19 commit fd81ff3

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

src/lines/LineMaterial.js

+27-17
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,16 @@ class LineMaterial extends ShaderMaterial {
4646
attribute vec3 instanceStart;
4747
attribute vec3 instanceEnd;
4848
49-
#ifdef USE_LINE_COLOR_ALPHA
50-
varying vec4 vLineColor;
51-
attribute vec4 instanceColorStart;
52-
attribute vec4 instanceColorEnd;
53-
#else
54-
varying vec3 vLineColor;
55-
attribute vec3 instanceColorStart;
56-
attribute vec3 instanceColorEnd;
49+
#ifdef USE_COLOR
50+
#ifdef USE_LINE_COLOR_ALPHA
51+
varying vec4 vLineColor;
52+
attribute vec4 instanceColorStart;
53+
attribute vec4 instanceColorEnd;
54+
#else
55+
varying vec3 vLineColor;
56+
attribute vec3 instanceColorStart;
57+
attribute vec3 instanceColorEnd;
58+
#endif
5759
#endif
5860
5961
#ifdef WORLD_UNITS
@@ -100,7 +102,11 @@ class LineMaterial extends ShaderMaterial {
100102
101103
void main() {
102104
103-
vLineColor = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
105+
#ifdef USE_COLOR
106+
107+
vLineColor = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
108+
109+
#endif
104110
105111
#ifdef USE_DASH
106112
@@ -303,10 +309,12 @@ class LineMaterial extends ShaderMaterial {
303309
#include <logdepthbuf_pars_fragment>
304310
#include <clipping_planes_pars_fragment>
305311
306-
#ifdef USE_LINE_COLOR_ALPHA
307-
varying vec4 vLineColor;
308-
#else
309-
varying vec3 vLineColor;
312+
#ifdef USE_COLOR
313+
#ifdef USE_LINE_COLOR_ALPHA
314+
varying vec4 vLineColor;
315+
#else
316+
varying vec3 vLineColor;
317+
#endif
310318
#endif
311319
312320
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
@@ -417,10 +425,12 @@ class LineMaterial extends ShaderMaterial {
417425
#endif
418426
419427
vec4 diffuseColor = vec4( diffuse, alpha );
420-
#ifdef USE_LINE_COLOR_ALPHA
421-
diffuseColor *= vLineColor;
422-
#else
423-
diffuseColor.rgb *= vLineColor;
428+
#ifdef USE_COLOR
429+
#ifdef USE_LINE_COLOR_ALPHA
430+
diffuseColor *= vLineColor;
431+
#else
432+
diffuseColor.rgb *= vLineColor;
433+
#endif
424434
#endif
425435
426436
#include <logdepthbuf_fragment>

0 commit comments

Comments
 (0)