Fix #138521: Overlay: Edit Mode Curves display in front of meshes

The lines were not drawn inside a depth aware framebuffer.

Splitting the display into 2 draw pass fixes the issue.
This commit is contained in:
Clément Foucault
2025-05-07 13:57:02 +02:00
parent 72e50a0285
commit 669a51904e
2 changed files with 29 additions and 3 deletions

View File

@@ -27,13 +27,17 @@ namespace blender::draw::overlay {
class Curves : Overlay {
private:
PassSimple edit_curves_ps_ = {"Curve Edit"};
PassSimple::Sub *edit_curves_points_ = nullptr;
PassSimple::Sub *edit_curves_lines_ = nullptr;
PassSimple edit_legacy_curve_handles_ps_ = {"Curve Edit Handles"};
PassSimple::Sub *edit_curves_points_ = nullptr;
PassSimple::Sub *edit_curves_handles_ = nullptr;
PassSimple edit_legacy_curve_ps_ = {"Legacy Curve Edit"};
PassSimple::Sub *edit_legacy_curve_wires_ = nullptr;
PassSimple::Sub *edit_legacy_curve_normals_ = nullptr;
PassSimple edit_curves_handles_ps_ = {"Legacy Curve Edit Handles"};
PassSimple::Sub *edit_legacy_curve_points_ = nullptr;
PassSimple::Sub *edit_legacy_curve_handles_ = nullptr;
@@ -76,6 +80,13 @@ class Curves : Overlay {
sub.push_constant("use_grease_pencil", false);
edit_curves_lines_ = ⊂
}
}
{
auto &pass = edit_curves_handles_ps_;
pass.init();
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
{
auto &sub = pass.sub("Handles");
sub.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
@@ -127,6 +138,13 @@ class Curves : Overlay {
else {
edit_legacy_curve_normals_ = nullptr;
}
}
{
auto &pass = edit_legacy_curve_handles_ps_;
pass.init();
pass.bind_ubo(OVERLAY_GLOBALS_SLOT, &res.globals_buf);
pass.bind_ubo(DRW_CLIPPING_UBO_SLOT, &res.clip_planes_buf);
{
auto &sub = pass.sub("Handles");
sub.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA, state.clipping_plane_count);
@@ -247,6 +265,8 @@ class Curves : Overlay {
view_edit_cage.sync(view.viewmat(), offset_data_.winmat_polygon_offset(view.winmat(), 0.5f));
GPU_framebuffer_bind(framebuffer);
manager.submit(edit_legacy_curve_ps_, view);
manager.submit(edit_curves_ps_, view_edit_cage);
manager.submit(edit_legacy_surface_handles_ps, view);
}
@@ -259,8 +279,8 @@ class Curves : Overlay {
view_edit_cage.sync(view.viewmat(), offset_data_.winmat_polygon_offset(view.winmat(), 0.5f));
GPU_framebuffer_bind(framebuffer);
manager.submit(edit_legacy_curve_ps_, view);
manager.submit(edit_curves_ps_, view_edit_cage);
manager.submit(edit_legacy_curve_handles_ps_, view);
manager.submit(edit_curves_handles_ps_, view_edit_cage);
}
};

View File

@@ -512,7 +512,9 @@ VERTEX_IN(1, uint, data)
VERTEX_OUT(overlay_edit_flat_color_iface)
PUSH_CONSTANT(bool, show_curve_handles)
PUSH_CONSTANT(int, curve_handle_display)
DEFINE("LINE_OUTPUT")
FRAGMENT_OUT(0, float4, frag_color)
FRAGMENT_OUT(1, float4, line_output)
VERTEX_SOURCE("overlay_edit_curve_point_vert.glsl")
FRAGMENT_SOURCE("overlay_point_varying_color_frag.glsl")
ADDITIONAL_INFO(draw_view)
@@ -530,7 +532,9 @@ VERTEX_IN(2, float3, tangent)
VERTEX_IN(3, float, rad)
PUSH_CONSTANT(float, normal_size)
VERTEX_OUT(overlay_edit_flat_color_iface)
DEFINE("LINE_OUTPUT")
FRAGMENT_OUT(0, float4, frag_color)
FRAGMENT_OUT(1, float4, line_output)
VERTEX_SOURCE("overlay_edit_curve_wire_vert.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_view)
@@ -553,7 +557,9 @@ PUSH_CONSTANT(int2, gpu_attr_3)
PUSH_CONSTANT(float, normal_size)
PUSH_CONSTANT(bool, use_hq_normals)
VERTEX_OUT(overlay_edit_flat_color_iface)
DEFINE("LINE_OUTPUT")
FRAGMENT_OUT(0, float4, frag_color)
FRAGMENT_OUT(1, float4, line_output)
VERTEX_SOURCE("overlay_edit_curve_normals_vert.glsl")
FRAGMENT_SOURCE("overlay_varying_color.glsl")
ADDITIONAL_INFO(draw_view)