bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Fix UI border artifacts caused by incorrect blending

Open floppyhammer opened this issue 1 year ago • 6 comments
trafficstars

Fixes https://github.com/bevyengine/bevy/issues/12702.

floppyhammer avatar Mar 26 '24 03:03 floppyhammer

I'm not sure if this fix works, take the button example with a black background:

Before (main)
After (this PR)

I don't think these artifacts are desired.

chompaa avatar Mar 26 '24 18:03 chompaa

This solves my artifacts.

before Screenshot 2024-03-25 at 15 17 53
after Screenshot 2024-03-27 at 9 11 09

asafigan avatar Mar 27 '24 00:03 asafigan

I'm not sure if this fix works, take the button example with a black background:

Before (main) After (this PR) I don't think these artifacts are desired.

These artifacts are actually from the underlaying button image:

Before before
After after

This PR only makes them more obvious. I believe this is another issue we need to deal with (which may need a separate PR). I'll take a look.

floppyhammer avatar Mar 27 '24 03:03 floppyhammer

The artifacts brought up by @chompaa are due to how we draw borders. Given a rect, we extend the rect edge inwards to make the border, which has the exact same external edge as the rect (which we use to draw UiImage). We will have blending issue between the border and the UiImage background near these anti-aliased edges.

A possible solution to this is not to draw the UiImage in the full rect but in a smaller rect (which depends on the border width). This may require some changes to the prepare_uinodes function.

Anyways, this is a separate issue. And, with some further tests, this PR is good to go.

floppyhammer avatar Mar 27 '24 06:03 floppyhammer

Is there anything I can do to move this along? Like working on tests?

asafigan avatar Apr 25 '24 06:04 asafigan

@asafigan I'm not sure. We may need to run all the UI related examples to make sure this isn't causing other issues.

floppyhammer avatar Apr 25 '24 08:04 floppyhammer