Fix #103244: ghosting in Eevee with sculpt paint brush and canvas #104557

Open
Colin Marmond wants to merge 9 commits from Kdaf/blender:fix-103244-sculpt-lighting-using-paint-brush-on-image into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 10 additions and 6 deletions
Showing only changes of commit e4ac205dba - Show all commits

View File

@ -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<Mesh *>(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)) {
Kdaf marked this conversation as resolved
Review

I see what you're doing and why you have chosen this solution. I did have something else in mind to fix this, what doesn't need re-evaluating materials, shaders etc.

When the user is painting (Paint model operator is active) eevee should only use a single sample.
When the user finishes the stroke the rest of the samples can be calculated.

The ghosting effect appears as previous samples might have different colors. Blending multiple samples together leads to the ghosting. By just drawing a single sample we can make sure ghosting isn't working.

Although the final result is the same, I expect it to be lighter on the painting pipeline and improves the performance when using larger textures and complexer shaders.

We should prototype the other approach and see which one would be better in terms of performance and maintencance.

I see what you're doing and why you have chosen this solution. I did have something else in mind to fix this, what doesn't need re-evaluating materials, shaders etc. When the user is painting (Paint model operator is active) eevee should only use a single sample. When the user finishes the stroke the rest of the samples can be calculated. The ghosting effect appears as previous samples might have different colors. Blending multiple samples together leads to the ghosting. By just drawing a single sample we can make sure ghosting isn't working. Although the final result is the same, I expect it to be lighter on the painting pipeline and improves the performance when using larger textures and complexer shaders. We should prototype the other approach and see which one would be better in terms of performance and maintencance.
/* 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)) {