diff options
author | Jaime van Kessel <nallath@gmail.com> | 2020-08-13 15:54:55 +0300 |
---|---|---|
committer | Jaime van Kessel <nallath@gmail.com> | 2020-08-13 15:54:55 +0300 |
commit | aba76d8bca0dd08bdd1d7fd7ea96178c2eff6d54 (patch) | |
tree | bf6ab7950ea3831862c8e392f88eba569b6f7b7c | |
parent | 5c8132a94452afb137ed1744df0b719246b8a125 (diff) | |
parent | 99cd8ab1b0cd7a506d97d7b47b1f628fdb894d10 (diff) |
Merge branch 'CURA-7586_striped_in_layerview' of github.com:Ultimaker/Cura
-rw-r--r-- | plugins/SimulationView/SimulationPass.py | 15 | ||||
-rw-r--r-- | resources/shaders/striped.shader | 7 |
2 files changed, 20 insertions, 2 deletions
diff --git a/plugins/SimulationView/SimulationPass.py b/plugins/SimulationView/SimulationPass.py index b720fc5758..f594fefbe5 100644 --- a/plugins/SimulationView/SimulationPass.py +++ b/plugins/SimulationView/SimulationPass.py @@ -32,6 +32,7 @@ class SimulationPass(RenderPass): self._current_shader = None # This shader will be the shadow or the normal depending if the user wants to see the paths or the layers self._tool_handle_shader = None self._nozzle_shader = None + self._disabled_shader = None self._old_current_layer = 0 self._old_current_path = 0 self._switching_layers = True # It tracks when the user is moving the layers' slider @@ -90,9 +91,17 @@ class SimulationPass(RenderPass): self._nozzle_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "color.shader")) self._nozzle_shader.setUniformValue("u_color", Color(*Application.getInstance().getTheme().getColor("layerview_nozzle").getRgb())) + if not self._disabled_shader: + self._disabled_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "striped.shader")) + self._disabled_shader.setUniformValue("u_diffuseColor1", Color(*Application.getInstance().getTheme().getColor("model_unslicable").getRgb())) + self._disabled_shader.setUniformValue("u_diffuseColor2", Color(*Application.getInstance().getTheme().getColor("model_unslicable_alt").getRgb())) + self._disabled_shader.setUniformValue("u_width", 50.0) + self._disabled_shader.setUniformValue("u_opacity", 0.6) + self.bind() tool_handle_batch = RenderBatch(self._tool_handle_shader, type = RenderBatch.RenderType.Overlay, backface_cull = True) + disabled_batch = RenderBatch(self._disabled_shader) head_position = None # Indicates the current position of the print head nozzle_node = None @@ -105,6 +114,9 @@ class SimulationPass(RenderPass): nozzle_node = node nozzle_node.setVisible(False) + elif getattr(node, "_outside_buildarea", False) and isinstance(node, SceneNode) and node.getMeshData() and node.isVisible(): + disabled_batch.addItem(node.getWorldTransformation(copy=False), node.getMeshData()) + elif isinstance(node, SceneNode) and (node.getMeshData() or node.callDecoration("isBlockSlicing")) and node.isVisible(): layer_data = node.callDecoration("getLayerData") if not layer_data: @@ -183,6 +195,9 @@ class SimulationPass(RenderPass): nozzle_batch.addItem(nozzle_node.getWorldTransformation(), mesh = nozzle_node.getMeshData()) nozzle_batch.render(self._scene.getActiveCamera()) + if len(disabled_batch.items) > 0: + disabled_batch.render(self._scene.getActiveCamera()) + # Render toolhandles on top of the layerview if len(tool_handle_batch.items) > 0: tool_handle_batch.render(self._scene.getActiveCamera()) diff --git a/resources/shaders/striped.shader b/resources/shaders/striped.shader index 71b1f7b0fa..07ce2bebe6 100644 --- a/resources/shaders/striped.shader +++ b/resources/shaders/striped.shader @@ -29,6 +29,7 @@ fragment = uniform mediump vec4 u_diffuseColor1; uniform mediump vec4 u_diffuseColor2; uniform mediump vec4 u_specularColor; + uniform mediump float u_opacity; uniform highp vec3 u_lightPosition; uniform mediump float u_shininess; uniform highp vec3 u_viewPosition; @@ -65,7 +66,7 @@ fragment = finalColor += pow(NdotR, u_shininess) * u_specularColor; gl_FragColor = finalColor; - gl_FragColor.a = 1.0; + gl_FragColor.a = u_opacity; } vertex41core = @@ -100,6 +101,7 @@ fragment41core = uniform mediump vec4 u_diffuseColor1; uniform mediump vec4 u_diffuseColor2; uniform mediump vec4 u_specularColor; + uniform mediump float u_opacity; uniform highp vec3 u_lightPosition; uniform mediump float u_shininess; uniform highp vec3 u_viewPosition; @@ -138,7 +140,7 @@ fragment41core = finalColor += pow(NdotR, u_shininess) * u_specularColor; frag_color = finalColor; - frag_color.a = 1.0; + frag_color.a = u_opacity; } [defaults] @@ -146,6 +148,7 @@ u_ambientColor = [0.3, 0.3, 0.3, 1.0] u_diffuseColor1 = [1.0, 0.5, 0.5, 1.0] u_diffuseColor2 = [0.5, 0.5, 0.5, 1.0] u_specularColor = [0.4, 0.4, 0.4, 1.0] +u_opacity = 1.0 u_shininess = 20.0 u_width = 5.0 u_vertical_stripes = 0 |