mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 05:55:53 +08:00
Add option to overhang shader to make rendering model errors optional
CURA-7147
This commit is contained in:
parent
9a2d2d32bf
commit
020f66b245
@ -61,6 +61,7 @@ class PreviewPass(RenderPass):
|
|||||||
self._shader.setUniformValue("u_ambientColor", [0.1, 0.1, 0.1, 1.0])
|
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_specularColor", [0.6, 0.6, 0.6, 1.0])
|
||||||
self._shader.setUniformValue("u_shininess", 20.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.
|
self._shader.setUniformValue("u_faceId", -1) # Don't render any selected faces in the preview.
|
||||||
|
|
||||||
if not self._non_printing_shader:
|
if not self._non_printing_shader:
|
||||||
|
@ -38,6 +38,8 @@ fragment =
|
|||||||
varying highp vec3 f_vertex;
|
varying highp vec3 f_vertex;
|
||||||
varying highp vec3 f_normal;
|
varying highp vec3 f_normal;
|
||||||
|
|
||||||
|
uniform lowp float u_renderError;
|
||||||
|
|
||||||
float round(float f)
|
float round(float f)
|
||||||
{
|
{
|
||||||
return sign(f) * floor(abs(f) + 0.5);
|
return sign(f) * floor(abs(f) + 0.5);
|
||||||
@ -66,9 +68,11 @@ fragment =
|
|||||||
|
|
||||||
finalColor = (-normal.y > u_overhangAngle) ? u_overhangColor : finalColor;
|
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));
|
if(u_renderError > 0.5)
|
||||||
finalColor.a = dot(grid, grid) < 0.245 ? 0.667 : 1.0;
|
{
|
||||||
|
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;
|
gl_FragColor = finalColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +108,7 @@ fragment41core =
|
|||||||
uniform highp vec3 u_lightPosition;
|
uniform highp vec3 u_lightPosition;
|
||||||
uniform mediump float u_shininess;
|
uniform mediump float u_shininess;
|
||||||
uniform highp vec3 u_viewPosition;
|
uniform highp vec3 u_viewPosition;
|
||||||
|
uniform lowp float u_renderError;
|
||||||
|
|
||||||
uniform lowp float u_overhangAngle;
|
uniform lowp float u_overhangAngle;
|
||||||
uniform lowp vec4 u_overhangColor;
|
uniform lowp vec4 u_overhangColor;
|
||||||
@ -139,9 +144,11 @@ fragment41core =
|
|||||||
finalColor = (u_faceId != gl_PrimitiveID) ? ((-normal.y > u_overhangAngle) ? u_overhangColor : finalColor) : u_faceColor;
|
finalColor = (u_faceId != gl_PrimitiveID) ? ((-normal.y > u_overhangAngle) ? u_overhangColor : finalColor) : u_faceColor;
|
||||||
|
|
||||||
frag_color = finalColor;
|
frag_color = finalColor;
|
||||||
|
if(u_renderError > 0.5)
|
||||||
vec3 grid = f_vertex - round(f_vertex);
|
{
|
||||||
frag_color.a = dot(grid, grid) < 0.245 ? 0.667 : 1.0;
|
vec3 grid = f_vertex - round(f_vertex);
|
||||||
|
frag_color.a = dot(grid, grid) < 0.245 ? 0.667 : 1.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[defaults]
|
[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_overhangColor = [1.0, 0.0, 0.0, 1.0]
|
||||||
u_faceColor = [0.0, 0.0, 1.0, 1.0]
|
u_faceColor = [0.0, 0.0, 1.0, 1.0]
|
||||||
u_shininess = 20.0
|
u_shininess = 20.0
|
||||||
|
u_renderError = 1.0
|
||||||
|
|
||||||
[bindings]
|
[bindings]
|
||||||
u_modelMatrix = model_matrix
|
u_modelMatrix = model_matrix
|
||||||
|
Loading…
x
Reference in New Issue
Block a user