faiface/pixel

IMDraw is unaffected by SetSmooth or MSAA

Opened this issue · 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

Looking through the canvas code, I'm not sure if SetSmooth would have an effect on this... this might be fixed with #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.

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

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

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).

Shaders or an intermediary is your best bet I think