From 8e87f04a55acd41c1940276068bfc343353a0dd4 Mon Sep 17 00:00:00 2001 From: Colin Marmond Date: Fri, 10 Feb 2023 09:05:36 +0100 Subject: [PATCH 1/7] Fix shading in Eevee when using the canvas option in the paint brush (sculpt mode). --- source/blender/editors/sculpt_paint/sculpt.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 10ce391c397..8edcb3d8b22 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -5379,15 +5379,16 @@ void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags) if ((update_flags & SCULPT_UPDATE_IMAGE) != 0) { ED_region_tag_redraw(region); - if (update_flags == SCULPT_UPDATE_IMAGE) { - /* Early exit when only need to update the images. We don't want to tag any geometry updates - * that would rebuilt the PBVH. */ - return; - } } DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); + if (update_flags == SCULPT_UPDATE_IMAGE) { + /* Early exit when only need to update the images. We don't want to tag any geometry updates + * that would rebuilt the PBVH. */ + return; + } + /* Only current viewport matters, slower update for all viewports will * be done in sculpt_flush_update_done. */ if (!BKE_sculptsession_use_pbvh_draw(ob, rv3d)) { -- 2.30.2 From e4ac205dba4c60a6ad203446671e602eaa5f6c6c Mon Sep 17 00:00:00 2001 From: Colin Marmond Date: Fri, 10 Feb 2023 14:20:09 +0100 Subject: [PATCH 2/7] Finer selection of the correction. --- source/blender/editors/sculpt_paint/sculpt.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 8edcb3d8b22..2dd51a0c234 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -5366,6 +5366,7 @@ void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags) ARegion *region = CTX_wm_region(C); MultiresModifierData *mmd = ss->multires.modifier; RegionView3D *rv3d = CTX_wm_region_view3d(C); + View3D *v3d = CTX_wm_view3d(C); Mesh *mesh = static_cast(ob->data); if (rv3d) { @@ -5379,16 +5380,19 @@ void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags) if ((update_flags & SCULPT_UPDATE_IMAGE) != 0) { ED_region_tag_redraw(region); + if (update_flags == SCULPT_UPDATE_IMAGE) { + if (ELEM(v3d->shading.type, OB_MATERIAL, OB_TEXTURE, OB_RENDER)) { + /* When multisampling is activated, this should prevent from ghosting */ + DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); + } + /* Early exit when only need to update the images. We don't want to tag any geometry updates + * that would rebuilt the PBVH. */ + return; + } } DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); - if (update_flags == SCULPT_UPDATE_IMAGE) { - /* Early exit when only need to update the images. We don't want to tag any geometry updates - * that would rebuilt the PBVH. */ - return; - } - /* Only current viewport matters, slower update for all viewports will * be done in sculpt_flush_update_done. */ if (!BKE_sculptsession_use_pbvh_draw(ob, rv3d)) { -- 2.30.2 From 6e7e0de09158546807499ff4978e92531dc521d8 Mon Sep 17 00:00:00 2001 From: Colin Marmond Date: Sat, 11 Feb 2023 08:21:51 +0100 Subject: [PATCH 3/7] Force 1 sample when painting strokes in sculpt mode instead of having all sample drawn. --- .../draw/engines/eevee/eevee_temporal_sampling.c | 3 ++- source/blender/editors/include/ED_screen.h | 1 + source/blender/editors/screen/area.c | 13 +++++++++++-- source/blender/editors/sculpt_paint/sculpt.cc | 6 +----- source/blender/makesdna/DNA_screen_types.h | 3 +++ 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c index 5644fc6f1f4..145fdd91b64 100644 --- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c +++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c @@ -254,7 +254,8 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data const DRWContextState *draw_ctx = DRW_context_state_get(); const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); - if ((scene_eval->eevee.taa_samples != 1) || DRW_state_is_image_render()) { + if (((scene_eval->eevee.taa_samples != 1) || DRW_state_is_image_render()) && + !(draw_ctx->region->do_draw & RGN_DRAW_SINGLE_SAMPLE)) { float persmat[4][4]; if (!DRW_state_is_image_render() && (scene_eval->eevee.flag & SCE_EEVEE_TAA_REPROJECTION)) { diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 6dfaab663f6..03bbde3fb74 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -71,6 +71,7 @@ void ED_region_update_rect(struct ARegion *region); */ void ED_region_floating_init(struct ARegion *region); void ED_region_tag_redraw(struct ARegion *region); +void ED_region_tag_redraw_force_single_sample(struct ARegion *region); void ED_region_tag_redraw_partial(struct ARegion *region, const struct rcti *rct, bool rebuild); void ED_region_tag_redraw_cursor(struct ARegion *region); void ED_region_tag_redraw_no_rebuild(struct ARegion *region); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index c3df23500d4..8ebd2632f75 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -658,12 +658,21 @@ void ED_region_tag_redraw(ARegion *region) * but python scripts can cause this to happen indirectly */ if (region && !(region->do_draw & RGN_DRAWING)) { /* zero region means full region redraw */ - region->do_draw &= ~(RGN_DRAW_PARTIAL | RGN_DRAW_NO_REBUILD | RGN_DRAW_EDITOR_OVERLAYS); + region->do_draw &= ~(RGN_DRAW_PARTIAL | RGN_DRAW_NO_REBUILD | RGN_DRAW_EDITOR_OVERLAYS | + RGN_DRAW_SINGLE_SAMPLE); region->do_draw |= RGN_DRAW; memset(®ion->drawrct, 0, sizeof(region->drawrct)); } } +void ED_region_tag_redraw_force_single_sample(ARegion *region) +{ + if (region && !(region->do_draw & RGN_DRAWING)) { + ED_region_tag_redraw(region); + region->do_draw |= RGN_DRAW_SINGLE_SAMPLE; + } +} + void ED_region_tag_redraw_cursor(ARegion *region) { if (region) { @@ -674,7 +683,7 @@ void ED_region_tag_redraw_cursor(ARegion *region) void ED_region_tag_redraw_no_rebuild(ARegion *region) { if (region && !(region->do_draw & (RGN_DRAWING | RGN_DRAW))) { - region->do_draw &= ~(RGN_DRAW_PARTIAL | RGN_DRAW_EDITOR_OVERLAYS); + region->do_draw &= ~(RGN_DRAW_PARTIAL | RGN_DRAW_EDITOR_OVERLAYS | RGN_DRAW_SINGLE_SAMPLE); region->do_draw |= RGN_DRAW_NO_REBUILD; memset(®ion->drawrct, 0, sizeof(region->drawrct)); } diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 2dd51a0c234..2e4ba607c55 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -5379,12 +5379,8 @@ void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags) } if ((update_flags & SCULPT_UPDATE_IMAGE) != 0) { - ED_region_tag_redraw(region); + ED_region_tag_redraw_force_single_sample(region); if (update_flags == SCULPT_UPDATE_IMAGE) { - if (ELEM(v3d->shading.type, OB_MATERIAL, OB_TEXTURE, OB_RENDER)) { - /* When multisampling is activated, this should prevent from ghosting */ - DEG_id_tag_update(&ob->id, ID_RECALC_SHADING); - } /* Early exit when only need to update the images. We don't want to tag any geometry updates * that would rebuilt the PBVH. */ return; diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 9872e30f0a2..00da5dbe71f 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -742,6 +742,9 @@ enum { /* Only editor overlays (currently gizmos only!) should be redrawn. */ RGN_DRAW_EDITOR_OVERLAYS = 32, + + /* Force single sample for some specific cases (sculpt paint tool stroke). */ + RGN_DRAW_SINGLE_SAMPLE = 64, }; #ifdef __cplusplus -- 2.30.2 From 3328982d27506c42c05818c71c5be115b0b6ac1b Mon Sep 17 00:00:00 2001 From: Colin Marmond Date: Sat, 11 Feb 2023 08:25:16 +0100 Subject: [PATCH 4/7] Cleaning --- source/blender/editors/sculpt_paint/sculpt.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 2e4ba607c55..2122dda9c4d 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -5366,7 +5366,6 @@ void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags) ARegion *region = CTX_wm_region(C); MultiresModifierData *mmd = ss->multires.modifier; RegionView3D *rv3d = CTX_wm_region_view3d(C); - View3D *v3d = CTX_wm_view3d(C); Mesh *mesh = static_cast(ob->data); if (rv3d) { -- 2.30.2 From f9dd57e4a3da27b194be49af6bc91566ac48d7be Mon Sep 17 00:00:00 2001 From: Colin Marmond Date: Sat, 11 Feb 2023 08:27:59 +0100 Subject: [PATCH 5/7] Strange thing --- release/datafiles/locale | 2 +- release/scripts/addons | 2 +- release/scripts/addons_contrib | 2 +- source/tools | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/release/datafiles/locale b/release/datafiles/locale index 4331c8e76c2..547a54b294f 160000 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 4331c8e76c2f42b9fd903716c333d6cdeaa5cebd +Subproject commit 547a54b294f32ee11bce73273c6f183d8b235f92 diff --git a/release/scripts/addons b/release/scripts/addons index b3f0ffc587d..78b0fc30b6b 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit b3f0ffc587d197b37eac9a1566d1d24b7bee7d9a +Subproject commit 78b0fc30b6b6e610ef897fc7d26e812da348f2ff diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index 14ab9273409..65ff08e325d 160000 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit 14ab9273409ea0231d08ba6e86fdc73d4e459e99 +Subproject commit 65ff08e325d54a58b47fb3219ec7dbf417f20f18 diff --git a/source/tools b/source/tools index e133fc08cd3..6a627cf37f0 160000 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit e133fc08cd3254bb3d3bd1345028c8486700bca4 +Subproject commit 6a627cf37f040f27175c430fb6c1a89cb4278297 -- 2.30.2 From 1bda091ddf017a8af4407971fe1c05fd3d3da019 Mon Sep 17 00:00:00 2001 From: Colin Marmond Date: Sat, 11 Feb 2023 08:36:12 +0100 Subject: [PATCH 6/7] Revert "Strange thing" This reverts commit f9dd57e4a3da27b194be49af6bc91566ac48d7be. --- release/datafiles/locale | 2 +- release/scripts/addons | 2 +- release/scripts/addons_contrib | 2 +- source/tools | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/release/datafiles/locale b/release/datafiles/locale index 547a54b294f..4331c8e76c2 160000 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit 547a54b294f32ee11bce73273c6f183d8b235f92 +Subproject commit 4331c8e76c2f42b9fd903716c333d6cdeaa5cebd diff --git a/release/scripts/addons b/release/scripts/addons index 78b0fc30b6b..b3f0ffc587d 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 78b0fc30b6b6e610ef897fc7d26e812da348f2ff +Subproject commit b3f0ffc587d197b37eac9a1566d1d24b7bee7d9a diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index 65ff08e325d..14ab9273409 160000 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit 65ff08e325d54a58b47fb3219ec7dbf417f20f18 +Subproject commit 14ab9273409ea0231d08ba6e86fdc73d4e459e99 diff --git a/source/tools b/source/tools index 6a627cf37f0..e133fc08cd3 160000 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit 6a627cf37f040f27175c430fb6c1a89cb4278297 +Subproject commit e133fc08cd3254bb3d3bd1345028c8486700bca4 -- 2.30.2 From 0ed5ab64fd8626a4f682854e22538f0d17ab9aff Mon Sep 17 00:00:00 2001 From: Colin Marmond Date: Tue, 28 Feb 2023 09:17:33 +0100 Subject: [PATCH 7/7] Correcting previous errors. This is now taking into account the RV3D_PAINTING flag which is far more consistent. --- .../draw/engines/eevee/eevee_temporal_sampling.c | 6 ++++-- source/blender/editors/include/ED_screen.h | 1 - source/blender/editors/screen/area.c | 13 ++----------- source/blender/editors/sculpt_paint/sculpt.cc | 2 +- source/blender/makesdna/DNA_screen_types.h | 3 --- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c index eccaf24f7ce..ae2d22cdafa 100644 --- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c +++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c @@ -253,9 +253,11 @@ int EEVEE_temporal_sampling_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data const DRWContextState *draw_ctx = DRW_context_state_get(); const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); + bool painting = false; + if (draw_ctx->rv3d) + painting = draw_ctx->rv3d->rflag & RV3D_PAINTING; - if (((scene_eval->eevee.taa_samples != 1) || DRW_state_is_image_render()) && - !(draw_ctx->region->do_draw & RGN_DRAW_SINGLE_SAMPLE)) { + if (((scene_eval->eevee.taa_samples != 1) || DRW_state_is_image_render()) && !painting) { float persmat[4][4]; if (!DRW_state_is_image_render() && (scene_eval->eevee.flag & SCE_EEVEE_TAA_REPROJECTION)) { diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h index 03bbde3fb74..6dfaab663f6 100644 --- a/source/blender/editors/include/ED_screen.h +++ b/source/blender/editors/include/ED_screen.h @@ -71,7 +71,6 @@ void ED_region_update_rect(struct ARegion *region); */ void ED_region_floating_init(struct ARegion *region); void ED_region_tag_redraw(struct ARegion *region); -void ED_region_tag_redraw_force_single_sample(struct ARegion *region); void ED_region_tag_redraw_partial(struct ARegion *region, const struct rcti *rct, bool rebuild); void ED_region_tag_redraw_cursor(struct ARegion *region); void ED_region_tag_redraw_no_rebuild(struct ARegion *region); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 0673bc86f95..574cefceb36 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -658,21 +658,12 @@ void ED_region_tag_redraw(ARegion *region) * but python scripts can cause this to happen indirectly */ if (region && !(region->do_draw & RGN_DRAWING)) { /* zero region means full region redraw */ - region->do_draw &= ~(RGN_DRAW_PARTIAL | RGN_DRAW_NO_REBUILD | RGN_DRAW_EDITOR_OVERLAYS | - RGN_DRAW_SINGLE_SAMPLE); + region->do_draw &= ~(RGN_DRAW_PARTIAL | RGN_DRAW_NO_REBUILD | RGN_DRAW_EDITOR_OVERLAYS); region->do_draw |= RGN_DRAW; memset(®ion->drawrct, 0, sizeof(region->drawrct)); } } -void ED_region_tag_redraw_force_single_sample(ARegion *region) -{ - if (region && !(region->do_draw & RGN_DRAWING)) { - ED_region_tag_redraw(region); - region->do_draw |= RGN_DRAW_SINGLE_SAMPLE; - } -} - void ED_region_tag_redraw_cursor(ARegion *region) { if (region) { @@ -683,7 +674,7 @@ void ED_region_tag_redraw_cursor(ARegion *region) void ED_region_tag_redraw_no_rebuild(ARegion *region) { if (region && !(region->do_draw & (RGN_DRAWING | RGN_DRAW))) { - region->do_draw &= ~(RGN_DRAW_PARTIAL | RGN_DRAW_EDITOR_OVERLAYS | RGN_DRAW_SINGLE_SAMPLE); + region->do_draw &= ~(RGN_DRAW_PARTIAL | RGN_DRAW_EDITOR_OVERLAYS); region->do_draw |= RGN_DRAW_NO_REBUILD; memset(®ion->drawrct, 0, sizeof(region->drawrct)); } diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 77875716427..6b5e2438068 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -5470,7 +5470,7 @@ void SCULPT_flush_update_step(bContext *C, SculptUpdateType update_flags) } if ((update_flags & SCULPT_UPDATE_IMAGE) != 0) { - ED_region_tag_redraw_force_single_sample(region); + ED_region_tag_redraw(region); if (update_flags == SCULPT_UPDATE_IMAGE) { /* Early exit when only need to update the images. We don't want to tag any geometry updates * that would rebuilt the PBVH. */ diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 00da5dbe71f..9872e30f0a2 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -742,9 +742,6 @@ enum { /* Only editor overlays (currently gizmos only!) should be redrawn. */ RGN_DRAW_EDITOR_OVERLAYS = 32, - - /* Force single sample for some specific cases (sculpt paint tool stroke). */ - RGN_DRAW_SINGLE_SAMPLE = 64, }; #ifdef __cplusplus -- 2.30.2