mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Add flow color scheme on preview
This commit is contained in:
parent
1808476c1b
commit
62bc71572a
5 changed files with 160 additions and 9 deletions
|
@ -12,6 +12,8 @@ vertex41core =
|
|||
uniform lowp float u_min_thickness;
|
||||
uniform lowp float u_max_line_width;
|
||||
uniform lowp float u_min_line_width;
|
||||
uniform lowp float u_max_flow_rate;
|
||||
uniform lowp float u_min_flow_rate;
|
||||
uniform lowp int u_layer_view_type;
|
||||
uniform lowp mat4 u_extruder_opacity; // currently only for max 16 extruders, others always visible
|
||||
|
||||
|
@ -105,6 +107,22 @@ vertex41core =
|
|||
return vec4(red, green, blue, 1.0);
|
||||
}
|
||||
|
||||
float clamp(float v)
|
||||
{
|
||||
float t = v < 0 ? 0 : v;
|
||||
return t > 1.0 ? 1.0 : t;
|
||||
}
|
||||
|
||||
// Inspired by https://stackoverflow.com/a/46628410
|
||||
vec4 flowRateGradientColor(float abs_value, float min_value, float max_value)
|
||||
{
|
||||
float t = 2.0 * ((abs_value - min_value) / (max_value - min_value)) - 1;
|
||||
float red = clamp(1.5 - abs(2.0 * t - 1.0));
|
||||
float green = clamp(1.5 - abs(2.0 * t));
|
||||
float blue = clamp(1.5 - abs(2.0 * t + 1.0));
|
||||
return vec4(red, green, blue, 1.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 v1_vertex = a_vertex;
|
||||
|
@ -130,6 +148,10 @@ vertex41core =
|
|||
case 4: // "Line width"
|
||||
v_color = lineWidthGradientColor(a_line_dim.x, u_min_line_width, u_max_line_width);
|
||||
break;
|
||||
case 5: // "Flow"
|
||||
float flow_rate = a_line_dim.x * a_line_dim.y * a_feedrate;
|
||||
v_color = flowRateGradientColor(flow_rate, u_min_flow_rate, u_max_flow_rate);
|
||||
break;
|
||||
}
|
||||
|
||||
v_vertex = world_space_vert.xyz;
|
||||
|
@ -318,7 +340,6 @@ geometry41core =
|
|||
EndPrimitive();
|
||||
}
|
||||
|
||||
|
||||
if ((u_show_starts == 1) && (v_prev_line_type[0] != 1) && (v_line_type[0] == 1)) {
|
||||
float w = size_x;
|
||||
float h = size_y;
|
||||
|
@ -337,7 +358,7 @@ geometry41core =
|
|||
myEmitVertex(v_vertex[0] + vec3(-w, -h, -w), u_starts_color, normalize(vec3(-1.0, -1.0, -1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4(-w, -h, -w, 0.0))); // Back-bottom-right
|
||||
myEmitVertex(v_vertex[0] + vec3( w, h, -w), u_starts_color, normalize(vec3( 1.0, 1.0, -1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4( w, h, -w, 0.0))); // Back-top-left
|
||||
myEmitVertex(v_vertex[0] + vec3(-w, h, -w), u_starts_color, normalize(vec3(-1.0, 1.0, -1.0)), viewProjectionMatrix * (gl_in[0].gl_Position + vec4(-w, h, -w, 0.0))); // Back-top-right
|
||||
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue