diff options
Diffstat (limited to 'source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl | 54 |
1 files changed, 20 insertions, 34 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl index 3d3a042de65..8325568988c 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl @@ -4,15 +4,13 @@ #define MID_VERTEX 65 -#ifndef USE_GPU_SHADER_CREATE_INFO - /* u is position along the curve, defining the tangent space. * v is "signed" distance (compressed to [0..1] range) from the pos in expand direction */ in vec2 uv; in vec2 pos; /* verts position in the curve tangent space */ in vec2 expand; -# ifdef USE_INSTANCE +#ifdef USE_INSTANCE /* Instance attrs. */ in vec2 P0; in vec2 P1; @@ -29,10 +27,21 @@ in float dash_alpha; uniform vec4 colors[6]; -# else +# define colStart (colid_doarrow[0] < 3 ? start_color : colors[colid_doarrow[0]]) +# define colEnd (colid_doarrow[1] < 3 ? end_color : colors[colid_doarrow[1]]) +# define colShadow colors[colid_doarrow[2]] +# define doArrow (colid_doarrow[3] != 0) +# define doMuted (domuted[0] != 0) + +#else /* Single curve drawcall, use uniform. */ uniform vec2 bezierPts[4]; +# define P0 bezierPts[0] +# define P1 bezierPts[1] +# define P2 bezierPts[2] +# define P3 bezierPts[3] + uniform vec4 colors[3]; uniform bool doArrow; uniform bool doMuted; @@ -41,7 +50,11 @@ uniform float thickness; uniform float dash_factor; uniform float dash_alpha; -# endif +# define colShadow colors[0] +# define colStart colors[1] +# define colEnd colors[2] + +#endif uniform float expandSize; uniform float arrowSize; @@ -54,33 +67,6 @@ flat out float lineLength; flat out float dashFactor; flat out float dashAlpha; flat out int isMainLine; -#endif - -#ifdef USE_INSTANCE -# define colStart (colid_doarrow[0] < 3 ? start_color : node_link_data.colors[colid_doarrow[0]]) -# define colEnd (colid_doarrow[1] < 3 ? end_color : node_link_data.colors[colid_doarrow[1]]) -# define colShadow node_link_data.colors[colid_doarrow[2]] -# define doArrow (colid_doarrow[3] != 0) -# define doMuted (domuted[0] != 0) - -#else -# define P0 node_link_data.bezierPts[0] -# define P1 node_link_data.bezierPts[1] -# define P2 node_link_data.bezierPts[2] -# define P3 node_link_data.bezierPts[3] -# define cols node_link_data.colors -# define doArrow node_link_data.doArrow -# define doMuted node_link_data.doMuted -# define dim_factor node_link_data.dim_factor -# define thickness node_link_data.thickness -# define dash_factor node_link_data.dash_factor -# define dash_alpha node_link_data.dash_alpha - -# define colShadow node_link_data.colors[0] -# define colStart node_link_data.colors[1] -# define colEnd node_link_data.colors[2] - -#endif /* Define where along the noodle the gradient will starts and ends. * Use 0.25 instead of 0.35-0.65, because of a visual shift issue. */ @@ -115,7 +101,7 @@ void main(void) vec2 normal = tangent.yx * vec2(-1.0, 1.0); /* Position vertex on the curve tangent space */ - point += (pos.x * tangent + pos.y * normal) * node_link_data.arrowSize; + point += (pos.x * tangent + pos.y * normal) * arrowSize; gl_Position = ModelViewProjectionMatrix * vec4(point, 0.0, 1.0); @@ -153,7 +139,7 @@ void main(void) finalColor[3] *= dim_factor; /* Expand into a line */ - gl_Position.xy += exp_axis * node_link_data.expandSize * expand_dist * thickness; + gl_Position.xy += exp_axis * expandSize * expand_dist * thickness; /* If the link is not muted or is not a reroute arrow the points are squashed to the center of * the line. Magic numbers are defined in drawnode.c */ |