diff --git a/source/blender/draw/engines/overlay/overlay_cursor.hh b/source/blender/draw/engines/overlay/overlay_cursor.hh index da006d4a972..392fcfdb5a1 100644 --- a/source/blender/draw/engines/overlay/overlay_cursor.hh +++ b/source/blender/draw/engines/overlay/overlay_cursor.hh @@ -88,7 +88,7 @@ class Cursor : Overlay { pass.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA); pass.shader_set(GPU_shader_get_builtin_shader(GPU_SHADER_3D_POLYLINE_FLAT_COLOR)); pass.push_constant("viewportSize", float2(state.region->winx, state.region->winy)); - pass.push_constant("lineWidth", U.pixelsize); + pass.push_constant("lineWidth", U.pixelsize * 1.5f); pass.push_constant("lineSmooth", true); /* WORKAROUND: This is normally set by the GPUBatch or IMM API but we don't use them here. * So make sure it is set otherwise it can be in undefined state (see #136911). */ @@ -108,13 +108,12 @@ class Cursor : Overlay { float4x4 mvp_lines = float4x4(state.rv3d->winmat) * float4x4(state.rv3d->viewmat) * cursor_mat; - /* Render line first to avoid Z fighting. */ - pass.push_constant("ModelViewProjectionMatrix", mvp_lines); - pass.push_constant("gpu_vert_stride_count_offset", vert_stride_count_line); - pass.draw_expand(res.shapes.cursor_lines.get(), GPU_PRIM_TRIS, 2, 1); pass.push_constant("ModelViewProjectionMatrix", mvp); pass.push_constant("gpu_vert_stride_count_offset", vert_stride_count_circle); pass.draw_expand(res.shapes.cursor_circle.get(), GPU_PRIM_TRIS, 2, 1); + pass.push_constant("ModelViewProjectionMatrix", mvp_lines); + pass.push_constant("gpu_vert_stride_count_offset", vert_stride_count_line); + pass.draw_expand(res.shapes.cursor_lines.get(), GPU_PRIM_TRIS, 2, 1); } else { pass.push_constant("ModelViewProjectionMatrix", mvp); diff --git a/source/blender/draw/engines/overlay/overlay_shape.cc b/source/blender/draw/engines/overlay/overlay_shape.cc index 8d82e6ee32d..6ef1e7eac01 100644 --- a/source/blender/draw/engines/overlay/overlay_shape.cc +++ b/source/blender/draw/engines/overlay/overlay_shape.cc @@ -1329,16 +1329,17 @@ ShapeCache::ShapeCache() } /* cursor circle */ { - const int segments = 16; - - const float red[3] = {1.0f, 0.0f, 0.0f}; - const float white[3] = {1.0f, 1.0f, 1.0f}; + const int segments = 12; + const float radius = 0.38f; + const float color_dark[3] = {0.4f, 0.4f, 0.4f}; + const float color_light[3] = {0.8f, 0.8f, 0.8f}; Vector verts; for (int i = 0; i < segments + 1; i++) { float angle = float(2 * M_PI) * (float(i) / float(segments)); - verts.append({0.5f * float3(cosf(angle), sinf(angle), 0.0f), (i % 2 == 0) ? red : white}); + verts.append({radius * float3(cosf(angle), sinf(angle), 0.0f), + (i % 2 == 0) ? color_dark : color_light}); } cursor_circle = BatchPtr(GPU_batch_create_ex( @@ -1346,20 +1347,25 @@ ShapeCache::ShapeCache() } /* cursor lines */ { - const float f5 = 0.25f; - const float f20 = 1.0f; + const float f5 = 0.78f; + const float f20 = 0.43f; + const std::array axis_theme = {TH_AXIS_X, TH_AXIS_Y, TH_AXIS_Z}; float crosshair_color[3]; - UI_GetThemeColor3fv(TH_VIEW_OVERLAY, crosshair_color); Vector verts; for (int i = 0; i < 3; i++) { float3 axis(0.0f); axis[i] = 1.0f; + /* Draw the axes a little darker and desaturated. */ + UI_GetThemeColorBlendShade3fv(axis_theme[i], TH_WHITE, .25f, -20, crosshair_color); verts.append({f5 * axis, crosshair_color}); verts.append({f20 * axis, crosshair_color}); + + /* Draw the negative axis even darker. */ axis[i] = -1.0f; + UI_GetThemeColorBlendShade3fv(axis_theme[i], TH_WHITE, .33f, -90, crosshair_color); verts.append({f5 * axis, crosshair_color}); verts.append({f20 * axis, crosshair_color}); }