diff options
Diffstat (limited to 'source')
15 files changed, 57 insertions, 48 deletions
diff --git a/source/blender/draw/engines/overlay/overlay_edit_curve.c b/source/blender/draw/engines/overlay/overlay_edit_curve.c index d9b9fac6b4b..6456d6868a5 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_curve.c +++ b/source/blender/draw/engines/overlay/overlay_edit_curve.c @@ -66,6 +66,7 @@ void OVERLAY_edit_curve_cache_init(OVERLAY_Data *vedata) sh = OVERLAY_shader_edit_curve_point(); pd->edit_curve_points_grp = grp = DRW_shgroup_create(sh, psl->edit_curve_handle_ps); + DRW_shgroup_uniform_bool_copy(grp, "showCurveHandles", pd->edit_curve.show_handles); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); } } @@ -94,7 +95,7 @@ void OVERLAY_edit_curve_cache_populate(OVERLAY_Data *vedata, Object *ob) DRW_shgroup_call_no_cull(pd->edit_curve_handle_grp, geom, ob); } - geom = DRW_cache_curve_vert_overlay_get(ob, pd->edit_curve.show_handles); + geom = DRW_cache_curve_vert_overlay_get(ob); if (geom) { DRW_shgroup_call_no_cull(pd->edit_curve_points_grp, geom, ob); } @@ -110,7 +111,7 @@ void OVERLAY_edit_surf_cache_populate(OVERLAY_Data *vedata, Object *ob) DRW_shgroup_call_no_cull(pd->edit_curve_handle_grp, geom, ob); } - geom = DRW_cache_curve_vert_overlay_get(ob, false); + geom = DRW_cache_curve_vert_overlay_get(ob); if (geom) { DRW_shgroup_call_no_cull(pd->edit_curve_points_grp, geom, ob); } diff --git a/source/blender/draw/engines/overlay/overlay_grid.c b/source/blender/draw/engines/overlay/overlay_grid.c index 858ccf02625..f824f7736d2 100644 --- a/source/blender/draw/engines/overlay/overlay_grid.c +++ b/source/blender/draw/engines/overlay/overlay_grid.c @@ -60,8 +60,10 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata) const bool show_ortho_grid = (pd->v3d_gridflag & V3D_SHOW_ORTHO_GRID) != 0; shd->grid_flag = 0; + shd->zneg_flag = 0; + shd->zpos_flag = 0; - if (pd->hide_overlays || !(show_axis_y || show_axis_z || show_floor || show_ortho_grid)) { + if (pd->hide_overlays || !pd->v3d_gridflag) { return; } diff --git a/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl b/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl index b6576ba7a21..b444b3b0fec 100644 --- a/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl +++ b/source/blender/draw/engines/overlay/shaders/edit_curve_handle_geom.glsl @@ -1,7 +1,8 @@ /* Keep the same value of `ACTIVE_NURB` in `draw_cache_imp_curve.c` */ #define ACTIVE_NURB 1 << 2 -#define EVEN_U_BIT 1 << 3 +#define EVEN_U_BIT 1 << 4 +#define COLOR_SHIFT 5 layout(lines) in; layout(triangle_strip, max_vertices = 10) out; @@ -37,7 +38,7 @@ void main() vec4 v2 = gl_in[1].gl_Position; int is_active_nurb = (vertFlag[1] & ACTIVE_NURB); - int color_id = (vertFlag[1] >> 4); + int color_id = (vertFlag[1] >> COLOR_SHIFT); /* Don't output any edges if we don't show handles */ if (!showCurveHandles && (color_id < 5)) { diff --git a/source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl b/source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl index aca40bba171..6fa4576ae71 100644 --- a/source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl +++ b/source/blender/draw/engines/overlay/shaders/edit_curve_point_vert.glsl @@ -1,4 +1,9 @@ +/* Keep the same value of `BEZIER_HANDLE` in `draw_cache_imp_curve.c` */ +#define BEZIER_HANDLE 1 << 3 + +uniform bool showCurveHandles; + in vec3 pos; in int data; @@ -26,4 +31,9 @@ void main() #ifdef USE_WORLD_CLIP_PLANES world_clip_planes_calc_clip_distance(world_pos); #endif + + if (!showCurveHandles && ((data & BEZIER_HANDLE) != 0)) { + /* We set the vertex at the camera origin to generate 0 fragments. */ + gl_Position = vec4(0.0, 0.0, -3e36, 0.0); + } } diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c index 270a33fdd85..511dd563b46 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.c +++ b/source/blender/draw/engines/workbench/workbench_engine.c @@ -113,7 +113,6 @@ static void workbench_cache_sculpt_populate(WORKBENCH_PrivateData *wpd, Object *ob, eV3DShadingColorType color_type) { - const bool use_vcol = ELEM(color_type, V3D_SHADING_VERTEX_COLOR); const bool use_single_drawcall = !ELEM(color_type, V3D_SHADING_MATERIAL_COLOR); BLI_assert(wpd->shading.color_type != V3D_SHADING_TEXTURE_COLOR); diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 4306f9ac4d7..23d0d74534d 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -2898,12 +2898,12 @@ GPUBatch *DRW_cache_curve_edge_overlay_get(Object *ob) return DRW_curve_batch_cache_get_edit_edges(cu); } -GPUBatch *DRW_cache_curve_vert_overlay_get(Object *ob, bool handles) +GPUBatch *DRW_cache_curve_vert_overlay_get(Object *ob) { BLI_assert(ELEM(ob->type, OB_CURVE, OB_SURF)); struct Curve *cu = ob->data; - return DRW_curve_batch_cache_get_edit_verts(cu, handles); + return DRW_curve_batch_cache_get_edit_verts(cu); } GPUBatch *DRW_cache_curve_surface_get(Object *ob) diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 77c7b6b9307..221fb89612f 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -150,7 +150,7 @@ struct GPUBatch *DRW_cache_curve_edge_detection_get(struct Object *ob, bool *r_i /* edit-mode */ struct GPUBatch *DRW_cache_curve_edge_normal_get(struct Object *ob); struct GPUBatch *DRW_cache_curve_edge_overlay_get(struct Object *ob); -struct GPUBatch *DRW_cache_curve_vert_overlay_get(struct Object *ob, bool handles); +struct GPUBatch *DRW_cache_curve_vert_overlay_get(struct Object *ob); /* Font */ struct GPUBatch *DRW_cache_text_surface_get(struct Object *ob); diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h index 3ce8a7d4e43..de0cd027ece 100644 --- a/source/blender/draw/intern/draw_cache_impl.h +++ b/source/blender/draw/intern/draw_cache_impl.h @@ -93,7 +93,7 @@ struct GPUBatch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu); struct GPUBatch *DRW_curve_batch_cache_get_normal_edge(struct Curve *cu); struct GPUBatch *DRW_curve_batch_cache_get_edge_detection(struct Curve *cu, bool *r_is_manifold); struct GPUBatch *DRW_curve_batch_cache_get_edit_edges(struct Curve *cu); -struct GPUBatch *DRW_curve_batch_cache_get_edit_verts(struct Curve *cu, bool handles); +struct GPUBatch *DRW_curve_batch_cache_get_edit_verts(struct Curve *cu); struct GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals(struct Curve *cu); struct GPUBatch **DRW_curve_batch_cache_get_surface_shaded(struct Curve *cu, diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c index 4f03ab04862..72ee7fe17c1 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.c +++ b/source/blender/draw/intern/draw_cache_impl_curve.c @@ -49,7 +49,9 @@ #define SELECT 1 #define ACTIVE_NURB 1 << 2 -#define EVEN_U_BIT 1 << 3 /* Alternate this bit for every U vert. */ +#define BEZIER_HANDLE 1 << 3 +#define EVEN_U_BIT 1 << 4 /* Alternate this bit for every U vert. */ +#define COLOR_SHIFT 5 /* Used as values of `color_id` in `edit_curve_overlay_handle_geom.glsl` */ enum { @@ -376,7 +378,7 @@ typedef struct CurveBatchCache { GPUIndexBuf *curves_lines; GPUIndexBuf *edges_adj_lines; /* Edit mode */ - GPUIndexBuf *edit_verts_points; /* Only control points. Not handles. */ + GPUIndexBuf *edit_verts; GPUIndexBuf *edit_lines; } ibo; @@ -387,7 +389,6 @@ typedef struct CurveBatchCache { /* control handles and vertices */ GPUBatch *edit_edges; GPUBatch *edit_verts; - GPUBatch *edit_handles_verts; GPUBatch *edit_normals; GPUBatch *edge_detection; } batch; @@ -497,7 +498,6 @@ void DRW_curve_batch_cache_dirty_tag(Curve *cu, int mode) GPU_BATCH_DISCARD_SAFE(cache->batch.edit_edges); GPU_BATCH_DISCARD_SAFE(cache->batch.edit_verts); - GPU_BATCH_DISCARD_SAFE(cache->batch.edit_handles_verts); break; default: BLI_assert(0); @@ -686,14 +686,15 @@ static void curve_create_edit_curves_nor(CurveRenderData *rdata, GPUVertBuf *vbo } static char beztriple_vflag_get( - CurveRenderData *rdata, char flag, char col_id, int v_idx, int nu_id) + CurveRenderData *rdata, char flag, char col_id, int v_idx, int nu_id, bool handle_point) { char vflag = 0; SET_FLAG_FROM_TEST(vflag, (flag & SELECT), VFLAG_VERT_SELECTED); SET_FLAG_FROM_TEST(vflag, (v_idx == rdata->actvert && nu_id == rdata->actnu), VFLAG_VERT_ACTIVE); SET_FLAG_FROM_TEST(vflag, (nu_id == rdata->actnu), ACTIVE_NURB); + SET_FLAG_FROM_TEST(vflag, handle_point, BEZIER_HANDLE); /* handle color id */ - vflag |= col_id << 4; /* << 4 because of EVEN_U_BIT */ + vflag |= col_id << COLOR_SHIFT; return vflag; } @@ -704,7 +705,7 @@ static char bpoint_vflag_get(CurveRenderData *rdata, char flag, int v_idx, int n SET_FLAG_FROM_TEST(vflag, (v_idx == rdata->actvert && nu_id == rdata->actnu), VFLAG_VERT_ACTIVE); SET_FLAG_FROM_TEST(vflag, (nu_id == rdata->actnu), ACTIVE_NURB); SET_FLAG_FROM_TEST(vflag, ((u % 2) == 0), EVEN_U_BIT); - vflag |= COLOR_NURB_ULINE_ID << 4; /* << 4 because of EVEN_U_BIT */ + vflag |= COLOR_NURB_ULINE_ID << COLOR_SHIFT; return vflag; } @@ -760,7 +761,9 @@ static void curve_create_edit_data_and_handles(CurveRenderData *rdata, } if (elbp_verts) { + GPU_indexbuf_add_point_vert(elbp_verts, vbo_len_used + 0); GPU_indexbuf_add_point_vert(elbp_verts, vbo_len_used + 1); + GPU_indexbuf_add_point_vert(elbp_verts, vbo_len_used + 2); } if (elbp_lines) { GPU_indexbuf_add_line_verts(elbp_lines, vbo_len_used + 1, vbo_len_used + 0); @@ -768,9 +771,9 @@ static void curve_create_edit_data_and_handles(CurveRenderData *rdata, } if (vbo_data) { const char vflag[3] = { - beztriple_vflag_get(rdata, bezt->f1, bezt->h1, a, nu_id), - beztriple_vflag_get(rdata, bezt->f2, bezt->h1, a, nu_id), - beztriple_vflag_get(rdata, bezt->f3, bezt->h2, a, nu_id), + beztriple_vflag_get(rdata, bezt->f1, bezt->h1, a, nu_id, true), + beztriple_vflag_get(rdata, bezt->f2, bezt->h1, a, nu_id, false), + beztriple_vflag_get(rdata, bezt->f3, bezt->h2, a, nu_id, true), }; for (int j = 0; j < 3; j++) { GPU_vertbuf_attr_set(vbo_data, attr_id.data, vbo_len_used + j, &vflag[j]); @@ -859,15 +862,10 @@ GPUBatch *DRW_curve_batch_cache_get_edit_edges(Curve *cu) return DRW_batch_request(&cache->batch.edit_edges); } -GPUBatch *DRW_curve_batch_cache_get_edit_verts(Curve *cu, bool handles) +GPUBatch *DRW_curve_batch_cache_get_edit_verts(Curve *cu) { CurveBatchCache *cache = curve_batch_cache_get(cu); - if (handles) { - return DRW_batch_request(&cache->batch.edit_handles_verts); - } - else { - return DRW_batch_request(&cache->batch.edit_verts); - } + return DRW_batch_request(&cache->batch.edit_verts); } GPUBatch *DRW_curve_batch_cache_get_triangles_with_normals(struct Curve *cu) @@ -965,14 +963,10 @@ void DRW_curve_batch_cache_create_requested(Object *ob) DRW_vbo_request(cache->batch.edit_edges, &cache->edit.data); } if (DRW_batch_requested(cache->batch.edit_verts, GPU_PRIM_POINTS)) { - DRW_ibo_request(cache->batch.edit_verts, &cache->ibo.edit_verts_points); + DRW_ibo_request(cache->batch.edit_verts, &cache->ibo.edit_verts); DRW_vbo_request(cache->batch.edit_verts, &cache->edit.pos); DRW_vbo_request(cache->batch.edit_verts, &cache->edit.data); } - if (DRW_batch_requested(cache->batch.edit_handles_verts, GPU_PRIM_POINTS)) { - DRW_vbo_request(cache->batch.edit_handles_verts, &cache->edit.pos); - DRW_vbo_request(cache->batch.edit_handles_verts, &cache->edit.data); - } if (DRW_batch_requested(cache->batch.edit_normals, GPU_PRIM_LINES)) { DRW_vbo_request(cache->batch.edit_normals, &cache->edit.curves_nor); } @@ -1012,7 +1006,7 @@ void DRW_curve_batch_cache_create_requested(Object *ob) DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.data, CU_DATATYPE_OVERLAY); DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.curves_nor, CU_DATATYPE_NORMAL); DRW_ADD_FLAG_FROM_VBO_REQUEST(mr_flag, cache->edit.curves_weight, CU_DATATYPE_OVERLAY); - DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.edit_verts_points, CU_DATATYPE_OVERLAY); + DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.edit_verts, CU_DATATYPE_OVERLAY); DRW_ADD_FLAG_FROM_IBO_REQUEST(mr_flag, cache->ibo.edit_lines, CU_DATATYPE_OVERLAY); for (int i = 0; i < cache->mat_len; i++) { @@ -1065,13 +1059,9 @@ void DRW_curve_batch_cache_create_requested(Object *ob) } if (DRW_vbo_requested(cache->edit.pos) || DRW_vbo_requested(cache->edit.data) || - DRW_ibo_requested(cache->ibo.edit_verts_points) || - DRW_ibo_requested(cache->ibo.edit_lines)) { - curve_create_edit_data_and_handles(rdata, - cache->edit.pos, - cache->edit.data, - cache->ibo.edit_verts_points, - cache->ibo.edit_lines); + DRW_ibo_requested(cache->ibo.edit_verts) || DRW_ibo_requested(cache->ibo.edit_lines)) { + curve_create_edit_data_and_handles( + rdata, cache->edit.pos, cache->edit.data, cache->ibo.edit_verts, cache->ibo.edit_lines); } if (DRW_vbo_requested(cache->edit.curves_nor)) { curve_create_edit_curves_nor(rdata, cache->edit.curves_nor); diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c index 32c72f12948..262f4b78b95 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c @@ -381,7 +381,7 @@ static void dial_ghostarc_draw_with_helplines(const float angle_ofs, { /* Coordinate at which the arc drawing will be started. */ const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; - const float color_arc_inner[4] = {0.8f, 0.8f, 0.8f, 0.4f}; + const float color_arc_inner[4] = {0.8f, 0.8f, 0.8f, 0.2f}; dial_ghostarc_draw(angle_ofs, angle_delta, arc_inner_factor, color_arc_inner); float line_width = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_VALUE) ? 3.0f : 1.0f; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 8fb96ca0b76..48b54ddcea3 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -269,7 +269,7 @@ static void draw_azone_arrow(float x1, float y1, float x2, float y2, AZEdge edge GPU_blend(false); } -static void region_draw_azone_tab_arrow(AZone *az) +static void region_draw_azone_tab_arrow(ScrArea *area, ARegion *region, AZone *az) { GPU_blend(true); @@ -289,7 +289,9 @@ static void region_draw_azone_tab_arrow(AZone *az) break; } - float color[4] = {0.05f, 0.05f, 0.05f, 0.4f}; + /* Workaround for different color spaces between normal areas and the ones using GPUViewports. */ + float alpha = WM_region_use_viewport(area, region) ? 0.6f : 0.4f; + float color[4] = {0.05f, 0.05f, 0.05f, alpha}; UI_draw_roundbox_aa( true, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, color); @@ -330,7 +332,7 @@ static void region_draw_azones(ScrArea *area, ARegion *region) if (az->region) { /* only display tab or icons when the region is hidden */ if (az->region->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { - region_draw_azone_tab_arrow(az); + region_draw_azone_tab_arrow(area, region, az); } } } diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index 7a9be86624e..b575030778f 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -347,7 +347,7 @@ static void gizmo_get_axis_color(const int axis_idx, if (axis_idx >= MAN_AXIS_RANGE_ROT_START && axis_idx < MAN_AXIS_RANGE_ROT_END) { /* Never fade rotation rings. */ /* trackball rotation axis is a special case, we only draw a slight overlay */ - alpha_fac = (axis_idx == MAN_AXIS_ROT_T) ? 0.1f : 1.0f; + alpha_fac = (axis_idx == MAN_AXIS_ROT_T) ? 0.05f : 1.0f; } else { bool is_plane = false; diff --git a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl index 18f58d52f32..bdc87baf924 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl @@ -35,4 +35,6 @@ void main() if (butCo > 0.0) { fragColor.a = 1.0; } + + fragColor = blender_srgb_to_framebuffer_space(fragColor); } diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 219a6b7365a..ffa5bc15876 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -870,6 +870,8 @@ void WM_generic_callback_free(struct wmGenericCallback *callback); void WM_generic_user_data_free(struct wmGenericUserData *user_data); +bool WM_region_use_viewport(struct ScrArea *area, struct ARegion *region); + #ifdef WITH_XR_OPENXR /* wm_xr.c */ bool WM_xr_session_exists(const wmXrData *xr); diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 63ad2e446ea..a01ab1377c1 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -293,7 +293,7 @@ static bool wm_region_use_viewport_by_type(short space_type, short region_type) return (ELEM(space_type, SPACE_VIEW3D, SPACE_IMAGE) && region_type == RGN_TYPE_WINDOW); } -static bool wm_region_use_viewport(ScrArea *area, ARegion *region) +bool WM_region_use_viewport(ScrArea *area, ARegion *region) { return wm_region_use_viewport_by_type(area->spacetype, region->regiontype); } @@ -658,7 +658,7 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) LISTBASE_FOREACH (ARegion *, region, &area->regionbase) { if (region->visible && region->do_draw) { CTX_wm_region_set(C, region); - bool use_viewport = wm_region_use_viewport(area, region); + bool use_viewport = WM_region_use_viewport(area, region); if (stereo && wm_draw_region_stereo_set(bmain, area, region, STEREO_LEFT_ID)) { wm_draw_region_buffer_create(region, true, use_viewport); @@ -1042,7 +1042,7 @@ void WM_draw_region_free(ARegion *region, bool hide) void wm_draw_region_test(bContext *C, ScrArea *area, ARegion *region) { /* Function for redraw timer benchmark. */ - bool use_viewport = wm_region_use_viewport(area, region); + bool use_viewport = WM_region_use_viewport(area, region); wm_draw_region_buffer_create(region, false, use_viewport); wm_draw_region_bind(region, 0); ED_region_do_draw(C, region); |