Schmavery / reprocessing

ReasonML graphics library inspired by Processing
https://schmavery.github.io/reprocessing/
MIT License
682 stars 24 forks source link

ellipse rendering is mad expensive & has aliasing artifacts #24

Closed jaredly closed 7 years ago

jaredly commented 7 years ago

I think we only need 2 triangles & the proper shader, instead of making an ellipse out of a ton of triangles. using 2 triangles & a shader will also give us antialiasing I think?

Schmavery commented 7 years ago

We had been going with the approach of drawing everything with triangles in order to be able to more easily batch multiple calls, but at some point it's possible we might have to come up with some new strategy.

This issue is mostly captured by #18 I think.

Schmavery commented 7 years ago

I'd been meaning to first try some sort of multisampling approach to AA and see if we can reduce the number of triangles/ellipse while still maintaining the same smoothness. The math that decides how many triangles to draw per ellipse is currently not very optimized.

Schmavery commented 7 years ago

A couple more things to note:

  1. Currently with stroke enabled, drawing ellipses will also draw a line around them which is currently even more expensive than the ellipse itself. This could be improved in some cases by simply drawing a slightly larger ellipse before drawing the actual ellipse but I hadn't had a chance to go back and fix this yet.
  2. I've been doing some experimentation with the number of triangles used to draw an ellipse, and it seems to be possible to get away with 1/8 of the triangles we're currently drawing and still get some good results. I suspect we can do a fair bit of tweaking here.
jaredly commented 7 years ago

yeah we'll have to see what it looks like w/ AA enabled

Schmavery commented 7 years ago

I just divided the number of triangles by 8, does it make any difference on your end?

jaredly commented 7 years ago

it seems to be working fine - I haven't done rigorous benchmarking, but for a few hundred ellipses I'm getting reasonable framerate

Schmavery commented 7 years ago

Alright, cool. Let's keep an eye on this. There might be one or two things we can do to tweak common cases to be faster.