Browse Source

Add option to overhang shader to make rendering model errors optional

CURA-7147
Jaime van Kessel 4 years ago
parent
commit
020f66b245
2 changed files with 15 additions and 6 deletions
  1. 1 0
      cura/PreviewPass.py
  2. 14 6
      resources/shaders/overhang.shader

+ 1 - 0
cura/PreviewPass.py

@@ -61,6 +61,7 @@ class PreviewPass(RenderPass):
                 self._shader.setUniformValue("u_ambientColor", [0.1, 0.1, 0.1, 1.0])
                 self._shader.setUniformValue("u_specularColor", [0.6, 0.6, 0.6, 1.0])
                 self._shader.setUniformValue("u_shininess", 20.0)
+                self._shader.setUniformValue("u_renderError", 0.0)  # We don't want any error markers!.
                 self._shader.setUniformValue("u_faceId", -1)  # Don't render any selected faces in the preview.
 
         if not self._non_printing_shader:

+ 14 - 6
resources/shaders/overhang.shader

@@ -38,6 +38,8 @@ fragment =
     varying highp vec3 f_vertex;
     varying highp vec3 f_normal;
 
+    uniform lowp float u_renderError;
+
     float round(float f)
     {
         return sign(f) * floor(abs(f) + 0.5);
@@ -66,9 +68,11 @@ fragment =
 
         finalColor = (-normal.y > u_overhangAngle) ? u_overhangColor : finalColor;
 
-        vec3 grid = vec3(f_vertex.x - round(f_vertex.x), f_vertex.y - round(f_vertex.y), f_vertex.z - round(f_vertex.z));
-        finalColor.a = dot(grid, grid) < 0.245 ? 0.667 : 1.0;
-
+        if(u_renderError > 0.5)
+        {
+            vec3 grid = vec3(f_vertex.x - round(f_vertex.x), f_vertex.y - round(f_vertex.y), f_vertex.z - round(f_vertex.z));
+            finalColor.a = dot(grid, grid) < 0.245 ? 0.667 : 1.0;
+        }
         gl_FragColor = finalColor;
     }
 
@@ -104,6 +108,7 @@ fragment41core =
     uniform highp vec3 u_lightPosition;
     uniform mediump float u_shininess;
     uniform highp vec3 u_viewPosition;
+    uniform lowp float u_renderError;
 
     uniform lowp float u_overhangAngle;
     uniform lowp vec4 u_overhangColor;
@@ -139,9 +144,11 @@ fragment41core =
         finalColor = (u_faceId != gl_PrimitiveID) ? ((-normal.y > u_overhangAngle) ? u_overhangColor : finalColor) : u_faceColor;
 
         frag_color = finalColor;
-
-        vec3 grid = f_vertex - round(f_vertex);
-        frag_color.a = dot(grid, grid) < 0.245 ? 0.667 : 1.0;
+        if(u_renderError > 0.5)
+        {
+            vec3 grid = f_vertex - round(f_vertex);
+            frag_color.a = dot(grid, grid) < 0.245 ? 0.667 : 1.0;
+        }
     }
 
 [defaults]
@@ -151,6 +158,7 @@ u_specularColor = [0.4, 0.4, 0.4, 1.0]
 u_overhangColor = [1.0, 0.0, 0.0, 1.0]
 u_faceColor = [0.0, 0.0, 1.0, 1.0]
 u_shininess = 20.0
+u_renderError = 1.0
 
 [bindings]
 u_modelMatrix = model_matrix