Port of the changes made with 5e0590a93e852c532fb0ff59a72463c318c119e0 and 0995cfc658dfbfdbc61fde451d32d06a9195b9a7 to OpenGL ES

This commit is contained in:
enricoturri1966 2022-04-07 11:47:57 +02:00
parent aa468b3770
commit eba735d785
3 changed files with 4 additions and 13 deletions

View File

@ -29,8 +29,6 @@ struct SlopeDetection
uniform vec4 uniform_color; uniform vec4 uniform_color;
uniform SlopeDetection slope; uniform SlopeDetection slope;
uniform bool offset_depth_buffer;
#ifdef ENABLE_ENVIRONMENT_MAP #ifdef ENABLE_ENVIRONMENT_MAP
uniform sampler2D environment_tex; uniform sampler2D environment_tex;
uniform bool use_environment_tex; uniform bool use_environment_tex;
@ -81,9 +79,4 @@ void main()
else else
#endif #endif
gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha); gl_FragColor = vec4(vec3(intensity.y) + color * intensity.x, alpha);
// In the support painting gizmo and the seam painting gizmo are painted triangles rendered over the already
// rendered object. To resolved z-fighting between previously rendered object and painted triangles, values
// inside the depth buffer are offset by small epsilon for painted triangles inside those gizmos.
gl_FragDepth = gl_FragCoord.z - (offset_depth_buffer ? EPSILON : 0.0);
} }

View File

@ -3,14 +3,9 @@
precision highp float; precision highp float;
const float EPSILON = 0.0001;
uniform vec4 uniform_color; uniform vec4 uniform_color;
void main() void main()
{ {
gl_FragColor = uniform_color; gl_FragColor = uniform_color;
// Values inside depth buffer for fragments of the contour of a selected area are offset
// by small epsilon to solve z-fighting between painted triangles and contour lines.
gl_FragDepth = gl_FragCoord.z - EPSILON;
} }

View File

@ -7,5 +7,8 @@ attribute vec3 v_position;
void main() void main()
{ {
gl_Position = projection_matrix * view_model_matrix * vec4(v_position, 1.0); // Add small epsilon to z to solve z-fighting between painted triangles and contour lines.
vec4 clip_position = projection_matrix * view_model_matrix * vec4(v_position, 1.0);
clip_position.z -= 0.00001 * abs(clip_position.w);
gl_Position = clip_position;
} }