Skip to content

Commit

Permalink
fix(LineMaterial): don't multiply unset vertexColors (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett authored Jan 15, 2024
1 parent 6a37a19 commit fd81ff3
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions src/lines/LineMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,16 @@ class LineMaterial extends ShaderMaterial {
attribute vec3 instanceStart;
attribute vec3 instanceEnd;
#ifdef USE_LINE_COLOR_ALPHA
varying vec4 vLineColor;
attribute vec4 instanceColorStart;
attribute vec4 instanceColorEnd;
#else
varying vec3 vLineColor;
attribute vec3 instanceColorStart;
attribute vec3 instanceColorEnd;
#ifdef USE_COLOR
#ifdef USE_LINE_COLOR_ALPHA
varying vec4 vLineColor;
attribute vec4 instanceColorStart;
attribute vec4 instanceColorEnd;
#else
varying vec3 vLineColor;
attribute vec3 instanceColorStart;
attribute vec3 instanceColorEnd;
#endif
#endif
#ifdef WORLD_UNITS
Expand Down Expand Up @@ -100,7 +102,11 @@ class LineMaterial extends ShaderMaterial {
void main() {
vLineColor = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
#ifdef USE_COLOR
vLineColor = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
#endif
#ifdef USE_DASH
Expand Down Expand Up @@ -303,10 +309,12 @@ class LineMaterial extends ShaderMaterial {
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
#ifdef USE_LINE_COLOR_ALPHA
varying vec4 vLineColor;
#else
varying vec3 vLineColor;
#ifdef USE_COLOR
#ifdef USE_LINE_COLOR_ALPHA
varying vec4 vLineColor;
#else
varying vec3 vLineColor;
#endif
#endif
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
Expand Down Expand Up @@ -417,10 +425,12 @@ class LineMaterial extends ShaderMaterial {
#endif
vec4 diffuseColor = vec4( diffuse, alpha );
#ifdef USE_LINE_COLOR_ALPHA
diffuseColor *= vLineColor;
#else
diffuseColor.rgb *= vLineColor;
#ifdef USE_COLOR
#ifdef USE_LINE_COLOR_ALPHA
diffuseColor *= vLineColor;
#else
diffuseColor.rgb *= vLineColor;
#endif
#endif
#include <logdepthbuf_fragment>
Expand Down

0 comments on commit fd81ff3

Please sign in to comment.