mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 01:29:00 +08:00
Removed assignment to gl_FragDepth into gouraud.fs shader. Replaced with small offset of triangles along their normal.
This commit is contained in:
parent
2de1b863bb
commit
5e0590a93e
@ -26,8 +26,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;
|
||||||
@ -78,9 +76,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);
|
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,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;
|
||||||
@ -78,9 +76,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);
|
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,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;
|
||||||
@ -78,9 +76,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);
|
|
||||||
}
|
}
|
||||||
|
@ -918,8 +918,6 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
|||||||
|
|
||||||
assert(shader->get_name() == "gouraud");
|
assert(shader->get_name() == "gouraud");
|
||||||
|
|
||||||
ScopeGuard guard([shader]() { if (shader) shader->set_uniform("offset_depth_buffer", false);});
|
|
||||||
shader->set_uniform("offset_depth_buffer", true);
|
|
||||||
for (auto iva : {std::make_pair(&m_iva_enforcers, enforcers_color),
|
for (auto iva : {std::make_pair(&m_iva_enforcers, enforcers_color),
|
||||||
std::make_pair(&m_iva_blockers, blockers_color)}) {
|
std::make_pair(&m_iva_blockers, blockers_color)}) {
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
@ -1014,6 +1012,9 @@ void TriangleSelectorGUI::update_render_data()
|
|||||||
iva.release_geometry();
|
iva.release_geometry();
|
||||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
|
|
||||||
|
// small value used to offset triangles along their normal to avoid z-fighting
|
||||||
|
static const float offset = 0.001f;
|
||||||
|
|
||||||
for (const Triangle &tr : m_triangles) {
|
for (const Triangle &tr : m_triangles) {
|
||||||
if (!tr.valid() || tr.is_split() || (tr.get_state() == EnforcerBlockerType::NONE && !tr.is_selected_by_seed_fill()))
|
if (!tr.valid() || tr.is_split() || (tr.get_state() == EnforcerBlockerType::NONE && !tr.is_selected_by_seed_fill()))
|
||||||
continue;
|
continue;
|
||||||
@ -1037,15 +1038,17 @@ void TriangleSelectorGUI::update_render_data()
|
|||||||
//FIXME the normal may likely be pulled from m_triangle_selectors, but it may not be worth the effort
|
//FIXME the normal may likely be pulled from m_triangle_selectors, but it may not be worth the effort
|
||||||
// or the current implementation may be more cache friendly.
|
// or the current implementation may be more cache friendly.
|
||||||
const Vec3f n = (v1 - v0).cross(v2 - v1).normalized();
|
const Vec3f n = (v1 - v0).cross(v2 - v1).normalized();
|
||||||
|
// small value used to offset triangles along their normal to avoid z-fighting
|
||||||
|
const Vec3f offset_n = offset * n;
|
||||||
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
#if ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
iva.add_vertex(v0, n);
|
iva.add_vertex(v0 + offset_n, n);
|
||||||
iva.add_vertex(v1, n);
|
iva.add_vertex(v1 + offset_n, n);
|
||||||
iva.add_vertex(v2, n);
|
iva.add_vertex(v2 + offset_n, n);
|
||||||
iva.add_triangle((unsigned int)cnt, (unsigned int)cnt + 1, (unsigned int)cnt + 2);
|
iva.add_triangle((unsigned int)cnt, (unsigned int)cnt + 1, (unsigned int)cnt + 2);
|
||||||
#else
|
#else
|
||||||
iva.push_geometry(v0, n);
|
iva.push_geometry(v0 + offset_n, n);
|
||||||
iva.push_geometry(v1, n);
|
iva.push_geometry(v1 + offset_n, n);
|
||||||
iva.push_geometry(v2, n);
|
iva.push_geometry(v2 + offset_n, n);
|
||||||
iva.push_triangle(cnt, cnt + 1, cnt + 2);
|
iva.push_triangle(cnt, cnt + 1, cnt + 2);
|
||||||
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
|
||||||
cnt += 3;
|
cnt += 3;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user