Smear brush destroys alpha #46560

Closed
opened 2015-10-21 22:33:40 +02:00 by Keith Boshoff · 14 comments
Member

When texture painting in the UV editor, the Smear brush doesn't smear the Alpha channel, it paints it like a regular brush.

Test 1:

  • Create a blank texture with 0 alpha.
  • Draw a spot with the TexDraw brush.

With the Smear tool selected, smear the spot.

Test 2:

  • Create a blank texture with 0 alpha
  • With the Smear tool selected, paint on the image.

Tested in Blender 2.76 Official.

Thanks.

When texture painting in the UV editor, the Smear brush doesn't smear the Alpha channel, it paints it like a regular brush. Test 1: - Create a blank texture with 0 alpha. - Draw a spot with the TexDraw brush. # With the Smear tool selected, smear the spot. Test 2: - Create a blank texture with 0 alpha - With the Smear tool selected, paint on the image. Tested in Blender 2.76 Official. Thanks.
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'
Author
Member

Added subscriber: @Wahooney

Added subscriber: @Wahooney

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Contributor

Added subscriber: @Marcelo-Mutzbauer

Added subscriber: @Marcelo-Mutzbauer
Contributor

This seems to solve it
P281: Smear Alpha

diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index c5a066e..0e5a1ba 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -994,7 +994,7 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short tile)
 		IMB_rectblend(ibufb, ibufb, ibuf, NULL, NULL, NULL, 0, region- [x].destx, region- [x].desty,
 		              region- [x].destx, region- [x].desty,
 		              region- [x].srcx, region- [x].srcy,
-		              region- [x].width, region- [x].height, IMB_BLEND_COPY_RGB, false);
+		              region- [x].width, region- [x].height, IMB_BLEND_COPY, false);
 }
 
 static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos)
This seems to solve it [P281: Smear Alpha](https://archive.blender.org/developer/P281.txt) ```diff diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index c5a066e..0e5a1ba 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -994,7 +994,7 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short tile) IMB_rectblend(ibufb, ibufb, ibuf, NULL, NULL, NULL, 0, region- [x].destx, region- [x].desty, region- [x].destx, region- [x].desty, region- [x].srcx, region- [x].srcy, - region- [x].width, region- [x].height, IMB_BLEND_COPY_RGB, false); + region- [x].width, region- [x].height, IMB_BLEND_COPY, false); } static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos) ```

@Marcelo-Mutzbauer, I tried this too and while it gives improved results, its still overriding the alpha, you can't for eg, smear a 50% alpha region (while maintaining the 50% alpha).

@Marcelo-Mutzbauer, I tried this too and while it gives improved results, its still overriding the alpha, you can't for eg, smear a 50% alpha region (while maintaining the 50% alpha).

Added subscriber: @gwentiv

Added subscriber: @gwentiv

Tried it as well, and it seems to me that "soften" behaves the same way.

Tried it as well, and it seems to me that "soften" behaves the same way.

Added subscriber: @Sergey

Added subscriber: @Sergey

@campbellabrton, this is because of smear buffer will be mixed together with original image, and current blend_color_mix_byte() will lift the alpha up.

Guess we want some sort of "leak" of alpha between smear buffer and original one, so we can smear opaque reigons into transparent ones. Real quick test:

P379: Smear Alpha Mix

diff --git a/source/blender/blenlib/intern/math_color_blend_inline.c b/source/blender/blenlib/intern/math_color_blend_inline.c
index 048ab71..68835ed 100644
--- a/source/blender/blenlib/intern/math_color_blend_inline.c
+++ b/source/blender/blenlib/intern/math_color_blend_inline.c
@@ -68,7 +68,7 @@ MINLINE void blend_color_mix_byte(unsigned char dst- [x], const unsigned char src1
 		dst- [x] = (unsigned char)divide_round_i(tmp- [x], tmp[3]);
 		dst- [x] = (unsigned char)divide_round_i(tmp- [x], tmp[3]);
 		dst- [x] = (unsigned char)divide_round_i(tmp- [x], tmp[3]);
-		dst- [x] = (unsigned char)divide_round_i(tmp- [x], 255);
+		dst- [x] = max_ii(src1- [x], (((int)src1- [x] + src2- [x]) / 2));
 	}
 	else {
 		/* no op */
diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c
index 9474a46..83fa148 100644
--- a/source/blender/editors/sculpt_paint/paint_image_2d.c
+++ b/source/blender/editors/sculpt_paint/paint_image_2d.c
@@ -995,7 +995,7 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short tile)
 		IMB_rectblend(ibufb, ibufb, ibuf, NULL, NULL, NULL, 0, region- [x].destx, region- [x].desty,
 		              region- [x].destx, region- [x].desty,
 		              region- [x].srcx, region- [x].srcy,
-		              region- [x].width, region- [x].height, IMB_BLEND_COPY_RGB, false);
+		              region- [x].width, region- [x].height, IMB_BLEND_COPY, false);
 }
 
 static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos)

Warning: colors are probably incorrectly unpremulled here.

If we want to go this way we can create some special mix blend for this.

@campbellabrton, this is because of smear buffer will be mixed together with original image, and current `blend_color_mix_byte()` will lift the alpha up. Guess we want some sort of "leak" of alpha between smear buffer and original one, so we can smear opaque reigons into transparent ones. Real quick test: [P379: Smear Alpha Mix](https://archive.blender.org/developer/P379.txt) ``` diff --git a/source/blender/blenlib/intern/math_color_blend_inline.c b/source/blender/blenlib/intern/math_color_blend_inline.c index 048ab71..68835ed 100644 --- a/source/blender/blenlib/intern/math_color_blend_inline.c +++ b/source/blender/blenlib/intern/math_color_blend_inline.c @@ -68,7 +68,7 @@ MINLINE void blend_color_mix_byte(unsigned char dst- [x], const unsigned char src1 dst- [x] = (unsigned char)divide_round_i(tmp- [x], tmp[3]); dst- [x] = (unsigned char)divide_round_i(tmp- [x], tmp[3]); dst- [x] = (unsigned char)divide_round_i(tmp- [x], tmp[3]); - dst- [x] = (unsigned char)divide_round_i(tmp- [x], 255); + dst- [x] = max_ii(src1- [x], (((int)src1- [x] + src2- [x]) / 2)); } else { /* no op */ diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 9474a46..83fa148 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -995,7 +995,7 @@ static void paint_2d_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos, short tile) IMB_rectblend(ibufb, ibufb, ibuf, NULL, NULL, NULL, 0, region- [x].destx, region- [x].desty, region- [x].destx, region- [x].desty, region- [x].srcx, region- [x].srcy, - region- [x].width, region- [x].height, IMB_BLEND_COPY_RGB, false); + region- [x].width, region- [x].height, IMB_BLEND_COPY, false); } static ImBuf *paint_2d_lift_clone(ImBuf *ibuf, ImBuf *ibufb, int *pos) ``` Warning: colors are probably incorrectly unpremulled here. If we want to go this way we can create some special mix blend for this.
Bastien Montagne was assigned by Aaron Carlisle 2016-09-04 20:33:44 +02:00
Bastien Montagne removed their assignment 2016-09-05 09:52:54 +02:00

Added subscribers: @Blendify, @mont29

Added subscribers: @Blendify, @mont29

@Blendify I’d like to know why me? Last guy working on this was @Sergey afaict, and texture painting is not especially my area?

@Blendify I’d like to know why me? Last guy working on this was @Sergey afaict, and texture painting is not especially my area?

This issue was referenced by 0d4fd7528f

This issue was referenced by 0d4fd7528f9bfdf88eb3623b1e1e6cdf749b397d

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
8 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#46560
No description provided.