Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl
| Show All 11 Lines | |||||
| #ifdef USE_INSTANCE | #ifdef USE_INSTANCE | ||||
| /* Instance attrs. */ | /* Instance attrs. */ | ||||
| in vec2 P0; | in vec2 P0; | ||||
| in vec2 P1; | in vec2 P1; | ||||
| in vec2 P2; | in vec2 P2; | ||||
| in vec2 P3; | in vec2 P3; | ||||
| in ivec4 colid_doarrow; | in ivec4 colid_doarrow; | ||||
| in vec4 start_color; | |||||
| in vec4 end_color; | |||||
| in ivec2 domuted; | in ivec2 domuted; | ||||
| in float dim_factor; | in float dim_factor; | ||||
| in float thickness; | in float thickness; | ||||
| in float dash_factor; | in float dash_factor; | ||||
| in float dash_alpha; | |||||
| uniform vec4 colors[6]; | uniform vec4 colors[6]; | ||||
| # define colStart colors[colid_doarrow[0]] | # define colStart (colid_doarrow[0] < 3 ? start_color : colors[colid_doarrow[0]]) | ||||
| # define colEnd colors[colid_doarrow[1]] | # define colEnd (colid_doarrow[1] < 3 ? end_color : colors[colid_doarrow[1]]) | ||||
| # define colShadow colors[colid_doarrow[2]] | # define colShadow colors[colid_doarrow[2]] | ||||
| # define doArrow (colid_doarrow[3] != 0) | # define doArrow (colid_doarrow[3] != 0) | ||||
| # define doMuted (domuted[0] != 0) | # define doMuted (domuted[0] != 0) | ||||
| #else | #else | ||||
| /* Single curve drawcall, use uniform. */ | /* Single curve drawcall, use uniform. */ | ||||
| uniform vec2 bezierPts[4]; | uniform vec2 bezierPts[4]; | ||||
| Show All 19 Lines | |||||
| uniform float arrowSize; | uniform float arrowSize; | ||||
| uniform mat4 ModelViewProjectionMatrix; | uniform mat4 ModelViewProjectionMatrix; | ||||
| out float colorGradient; | out float colorGradient; | ||||
| out vec4 finalColor; | out vec4 finalColor; | ||||
| out float lineU; | out float lineU; | ||||
| flat out float lineLength; | flat out float lineLength; | ||||
| flat out float dashFactor; | flat out float dashFactor; | ||||
| flat out float dashAlpha; | |||||
| flat out int isMainLine; | flat out int isMainLine; | ||||
| /* Define where along the noodle the gradient will starts and ends. | |||||
HooglyBoogly: These two comments "cause some visual shift issue" are very vague, I have no idea what that is… | |||||
| * Use 0.25 instead of 0.35-0.65, because of a visual shift issue. */ | |||||
| const float start_gradient_threshold = 0.25; | |||||
| const float end_gradient_threshold = 0.55; | |||||
| void main(void) | void main(void) | ||||
| { | { | ||||
| /* Parameters for the dashed line. */ | /* Parameters for the dashed line. */ | ||||
| isMainLine = expand.y != 1.0 ? 0 : 1; | isMainLine = expand.y != 1.0 ? 0 : 1; | ||||
| dashFactor = dash_factor; | dashFactor = dash_factor; | ||||
| dashAlpha = dash_alpha; | |||||
| /* Approximate line length, no need for real bezier length calculation. */ | /* Approximate line length, no need for real bezier length calculation. */ | ||||
| lineLength = distance(P0, P3); | lineLength = distance(P0, P3); | ||||
| /* TODO: Incorrect U, this leads to non-uniform dash distribution. */ | /* TODO: Incorrect U, this leads to non-uniform dash distribution. */ | ||||
| lineU = uv.x; | lineU = uv.x; | ||||
| float t = uv.x; | float t = uv.x; | ||||
| float t2 = t * t; | float t2 = t * t; | ||||
| float t2_3 = 3.0 * t2; | float t2_3 = 3.0 * t2; | ||||
| Show All 25 Lines | void main(void) | ||||
| colorGradient = expand_dist; | colorGradient = expand_dist; | ||||
| if (gl_VertexID < MID_VERTEX) { | if (gl_VertexID < MID_VERTEX) { | ||||
| /* Shadow pass */ | /* Shadow pass */ | ||||
| finalColor = colShadow; | finalColor = colShadow; | ||||
| } | } | ||||
| else { | else { | ||||
| /* Second pass */ | /* Second pass */ | ||||
| finalColor = mix(colStart, colEnd, uv.x); | if (uv.x < start_gradient_threshold) { | ||||
| finalColor = colStart; | |||||
| } | |||||
| else if (uv.x > end_gradient_threshold) { | |||||
| finalColor = colEnd; | |||||
| } | |||||
| else { | |||||
| /* Add 0.1 to avoid a visual shift issue. */ | |||||
| finalColor = mix(colStart, colEnd, uv.x + 0.1); | |||||
| } | |||||
| expand_dist *= 0.5; | expand_dist *= 0.5; | ||||
| if (doMuted) { | if (doMuted) { | ||||
| finalColor[3] = 0.65; | finalColor[3] = 0.65; | ||||
| } | } | ||||
| } | } | ||||
| finalColor[3] *= dim_factor; | finalColor[3] *= dim_factor; | ||||
| Show All 10 Lines | |||||
These two comments "cause some visual shift issue" are very vague, I have no idea what that is supposed to mean.
@Juanfran Matheu (jfmatheu), could you describe what you meant here in a little more detail?
"cause" is also incorrect grammar, it should say "because of".