pixel icon indicating copy to clipboard operation
pixel copied to clipboard

IMDraw is unaffected by SetSmooth or MSAA

Open NabeelAhmed1721 opened this issue 3 years ago • 5 comments

  • Is there a reason why IMDraw shapes tend to have jagged edges?
  • Is there a way to solve this?

win.SetSmooth(true) doesn't seem to work.

Example:

Screen Shot 2020-10-24 at 2 11 41 PM

NabeelAhmed1721 avatar Oct 24 '20 18:10 NabeelAhmed1721

Looking through the canvas code, I'm not sure if SetSmooth would have an effect on this... this might be fixed with https://github.com/faiface/pixel/pull/285 however, but I would have to test it. If you want to try, you can clone a PR using git fetch origin pull/285/HEAD; git checkout -b antialias FETCH_HEAD.

dusk125 avatar Jun 22 '21 12:06 dusk125

May I ask if there is an update on this issue?

trisub avatar Apr 17 '22 14:04 trisub

My assumption is that this is the correct behavior. This is most likely caused by the resolution of your window and not caused. Is this problem still present even after #285 was merged @trisub

cebarks avatar Apr 18 '22 07:04 cebarks

I just checked with pixel v0.11.0-beta and it doesn't seem to make a difference. When I draw polygons or circles (on an IMDraw) there is no antialias at all which looks kinda ugly. I tried with window.SetSmooth(true) and also by setting the property SampleMSAA on the WindowConfig struct itself to different values. Sadly, both without any effect on the shapes.

However, I when draw to an intermediary canvas and do some matrix transformations (other than just translating, i.e. rotating or scaling) and then draw that canvas to the window, there is some antialiasing (when using window.SetSmooth(true)). So I could essentially draw my shapes slightly bigger and then just scale them down to get the same shape but with antialiasing. This workaround is kinda ugly though. Maybe I could look into shaders? Still, I would love if it worked automatically (without even having to set up an intermediary canvas).

trisub avatar Apr 18 '22 20:04 trisub

Shaders or an intermediary is your best bet I think

cebarks avatar Apr 18 '22 20:04 cebarks