diff options
Diffstat (limited to 'resources/shaders/overhang.shader')
-rw-r--r-- | resources/shaders/overhang.shader | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/resources/shaders/overhang.shader b/resources/shaders/overhang.shader index 7f1b04dd59..3438c1b3ca 100644 --- a/resources/shaders/overhang.shader +++ b/resources/shaders/overhang.shader @@ -38,9 +38,10 @@ fragment = varying highp vec3 f_vertex; varying highp vec3 f_normal; + uniform lowp float u_renderError; + void main() { - mediump vec4 finalColor = vec4(0.0); // Ambient Component @@ -60,10 +61,16 @@ fragment = highp float NdotR = clamp(dot(viewVector, reflectedLight), 0.0, 1.0); finalColor += pow(NdotR, u_shininess) * u_specularColor; - finalColor = (-normal.y > u_overhangAngle) ? u_overhangColor : finalColor; + finalColor = (f_vertex.y > 0.0001 && -normal.y > u_overhangAngle) ? u_overhangColor : finalColor; + + highp vec3 grid = vec3(f_vertex.x - floor(f_vertex.x - 0.5), f_vertex.y - floor(f_vertex.y - 0.5), f_vertex.z - floor(f_vertex.z - 0.5)); + finalColor.a = (u_renderError > 0.5) && dot(grid, grid) < 0.245 ? 0.667 : 1.0; + if (f_vertex.y <= 0.0) + { + finalColor.rgb = vec3(1.0, 1.0, 1.0) - finalColor.rgb; + } gl_FragColor = finalColor; - gl_FragColor.a = 1.0; } vertex41core = @@ -98,6 +105,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; @@ -111,7 +119,6 @@ fragment41core = void main() { - mediump vec4 finalColor = vec4(0.0); // Ambient Component @@ -131,10 +138,15 @@ fragment41core = highp float NdotR = clamp(dot(viewVector, reflectedLight), 0.0, 1.0); finalColor += pow(NdotR, u_shininess) * u_specularColor; - finalColor = (u_faceId != gl_PrimitiveID) ? ((-normal.y > u_overhangAngle) ? u_overhangColor : finalColor) : u_faceColor; + finalColor = (u_faceId != gl_PrimitiveID) ? ((f_vertex.y > 0.0001 && -normal.y > u_overhangAngle) ? u_overhangColor : finalColor) : u_faceColor; frag_color = finalColor; - frag_color.a = 1.0; + if (f_vertex.y <= 0.0) + { + frag_color.rgb = vec3(1.0, 1.0, 1.0) - frag_color.rgb; + } + vec3 grid = f_vertex - round(f_vertex); + frag_color.a = (u_renderError > 0.5) && dot(grid, grid) < 0.245 ? 0.667 : 1.0; } [defaults] @@ -144,6 +156,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 |