mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Render support meshes with a vertical stripe...
...so they are easier to tell apart from normal meshes, especially for single extrusion printers
This commit is contained in:
parent
7ad15c7dd2
commit
8bd6afad1f
2 changed files with 27 additions and 3 deletions
|
@ -28,6 +28,7 @@ class SolidView(View):
|
||||||
self._enabled_shader = None
|
self._enabled_shader = None
|
||||||
self._disabled_shader = None
|
self._disabled_shader = None
|
||||||
self._non_printing_shader = None
|
self._non_printing_shader = None
|
||||||
|
self._support_mesh_shader = None
|
||||||
|
|
||||||
self._extruders_model = ExtrudersModel()
|
self._extruders_model = ExtrudersModel()
|
||||||
self._theme = None
|
self._theme = None
|
||||||
|
@ -54,6 +55,11 @@ class SolidView(View):
|
||||||
self._non_printing_shader.setUniformValue("u_diffuseColor", Color(*self._theme.getColor("model_non_printing").getRgb()))
|
self._non_printing_shader.setUniformValue("u_diffuseColor", Color(*self._theme.getColor("model_non_printing").getRgb()))
|
||||||
self._non_printing_shader.setUniformValue("u_opacity", 0.6)
|
self._non_printing_shader.setUniformValue("u_opacity", 0.6)
|
||||||
|
|
||||||
|
if not self._support_mesh_shader:
|
||||||
|
self._support_mesh_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "striped.shader"))
|
||||||
|
self._support_mesh_shader.setUniformValue("u_vertical_stripes", True)
|
||||||
|
self._support_mesh_shader.setUniformValue("u_width", 5.0)
|
||||||
|
|
||||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||||
if global_container_stack:
|
if global_container_stack:
|
||||||
support_extruder_nr = global_container_stack.getProperty("support_extruder_nr", "value")
|
support_extruder_nr = global_container_stack.getProperty("support_extruder_nr", "value")
|
||||||
|
@ -117,6 +123,16 @@ class SolidView(View):
|
||||||
renderer.queueNode(node, shader = self._non_printing_shader, transparent = True)
|
renderer.queueNode(node, shader = self._non_printing_shader, transparent = True)
|
||||||
elif getattr(node, "_outside_buildarea", False):
|
elif getattr(node, "_outside_buildarea", False):
|
||||||
renderer.queueNode(node, shader = self._disabled_shader)
|
renderer.queueNode(node, shader = self._disabled_shader)
|
||||||
|
elif per_mesh_stack and per_mesh_stack.getProperty("support_mesh", "value"):
|
||||||
|
# Render support meshes with a vertical stripe that is darker
|
||||||
|
shade_factor = 0.6
|
||||||
|
uniforms["diffuse_color_2"] = [
|
||||||
|
uniforms["diffuse_color"][0] * shade_factor,
|
||||||
|
uniforms["diffuse_color"][1] * shade_factor,
|
||||||
|
uniforms["diffuse_color"][2] * shade_factor,
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
renderer.queueNode(node, shader = self._support_mesh_shader, uniforms = uniforms)
|
||||||
else:
|
else:
|
||||||
renderer.queueNode(node, shader = self._enabled_shader, uniforms = uniforms)
|
renderer.queueNode(node, shader = self._enabled_shader, uniforms = uniforms)
|
||||||
if node.callDecoration("isGroup") and Selection.isSelected(node):
|
if node.callDecoration("isGroup") and Selection.isSelected(node):
|
||||||
|
|
|
@ -32,6 +32,7 @@ fragment =
|
||||||
uniform highp vec3 u_viewPosition;
|
uniform highp vec3 u_viewPosition;
|
||||||
|
|
||||||
uniform mediump float u_width;
|
uniform mediump float u_width;
|
||||||
|
uniform mediump bool u_vertical_stripes;
|
||||||
|
|
||||||
varying highp vec3 v_position;
|
varying highp vec3 v_position;
|
||||||
varying highp vec3 v_vertex;
|
varying highp vec3 v_vertex;
|
||||||
|
@ -40,7 +41,9 @@ fragment =
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
mediump vec4 finalColor = vec4(0.0);
|
mediump vec4 finalColor = vec4(0.0);
|
||||||
mediump vec4 diffuseColor = (mod((-v_position.x + v_position.y), u_width) < (u_width / 2.)) ? u_diffuseColor1 : u_diffuseColor2;
|
mediump vec4 diffuseColor = u_vertical_stripes ?
|
||||||
|
(((mod(v_vertex.x, u_width) < (u_width / 2.)) ^^ (mod(v_vertex.z, u_width) < (u_width / 2.))) ? u_diffuseColor1 : u_diffuseColor2) :
|
||||||
|
((mod((-v_position.x + v_position.y), u_width) < (u_width / 2.)) ? u_diffuseColor1 : u_diffuseColor2);
|
||||||
|
|
||||||
/* Ambient Component */
|
/* Ambient Component */
|
||||||
finalColor += u_ambientColor;
|
finalColor += u_ambientColor;
|
||||||
|
@ -98,6 +101,7 @@ fragment41core =
|
||||||
uniform highp vec3 u_viewPosition;
|
uniform highp vec3 u_viewPosition;
|
||||||
|
|
||||||
uniform mediump float u_width;
|
uniform mediump float u_width;
|
||||||
|
uniform mediump bool u_vertical_stripes;
|
||||||
|
|
||||||
in highp vec3 v_position;
|
in highp vec3 v_position;
|
||||||
in highp vec3 v_vertex;
|
in highp vec3 v_vertex;
|
||||||
|
@ -108,7 +112,9 @@ fragment41core =
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
mediump vec4 finalColor = vec4(0.0);
|
mediump vec4 finalColor = vec4(0.0);
|
||||||
mediump vec4 diffuseColor = (mod((-v_position.x + v_position.y), u_width) < (u_width / 2.)) ? u_diffuseColor1 : u_diffuseColor2;
|
mediump vec4 diffuseColor = u_vertical_stripes ?
|
||||||
|
(((mod(v_vertex.x, u_width) < (u_width / 2.)) ^^ (mod(v_vertex.z, u_width) < (u_width / 2.))) ? u_diffuseColor1 : u_diffuseColor2) :
|
||||||
|
((mod((-v_position.x + v_position.y), u_width) < (u_width / 2.)) ? u_diffuseColor1 : u_diffuseColor2);
|
||||||
|
|
||||||
/* Ambient Component */
|
/* Ambient Component */
|
||||||
finalColor += u_ambientColor;
|
finalColor += u_ambientColor;
|
||||||
|
@ -138,6 +144,7 @@ u_diffuseColor2 = [0.5, 0.5, 0.5, 1.0]
|
||||||
u_specularColor = [0.4, 0.4, 0.4, 1.0]
|
u_specularColor = [0.4, 0.4, 0.4, 1.0]
|
||||||
u_shininess = 20.0
|
u_shininess = 20.0
|
||||||
u_width = 5.0
|
u_width = 5.0
|
||||||
|
u_vertical_stripes = 0
|
||||||
|
|
||||||
[bindings]
|
[bindings]
|
||||||
u_modelMatrix = model_matrix
|
u_modelMatrix = model_matrix
|
||||||
|
@ -145,7 +152,8 @@ u_viewProjectionMatrix = view_projection_matrix
|
||||||
u_normalMatrix = normal_matrix
|
u_normalMatrix = normal_matrix
|
||||||
u_viewPosition = view_position
|
u_viewPosition = view_position
|
||||||
u_lightPosition = light_0_position
|
u_lightPosition = light_0_position
|
||||||
u_diffuseColor = diffuse_color
|
u_diffuseColor1 = diffuse_color
|
||||||
|
u_diffuseColor2 = diffuse_color_2
|
||||||
|
|
||||||
[attributes]
|
[attributes]
|
||||||
a_vertex = vertex
|
a_vertex = vertex
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue