-
-
Notifications
You must be signed in to change notification settings - Fork 639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize the arcTo
function to use gl.LINES
#1178
Comments
With this last commit, we conclude for now a series of update and improvements to our WebGL renderer that started with version 14.4, and aimed to improve the API and improve performances drastically. This includes :
As you can see in the table below, we got now up to 81% performance improvements when drawing primitives, and up to 50% improvements when drawing sprites. With the latter now allowing to claim that melonJS can draw 15'000 sprites per frame at 60fps.
Of course there are still room for improvements. Looking at the complete benchmark here, there are still some room to improve primitive drawing especially for circle fill operations. But as far as batching is concerned here we are good enough. Moving further definitely will require using a proper shader to draw primitive. But in my opinion, unless your game is purely based on drawing thousands of full circle all over the screen, a shader might not be really necessary with the level of performance we have today. but hey, if anyone is up to the task and want to contribute, please do ! :) |
Currently, batch drawing is only enabled for shapes using
gl.LINES
as draw mode. Reason being that when batching primitives that use gl.LINE_LOOP or gl.LINE_STRIP it produces "artefacts" with lines being added between the different shapes corresponding starting point and end point.To fix batch drawing for Circle/Ellipse and RoundedRect,
arcTo
should be rewritten in a way where we only usegl.LINES
. Problem being that it then generates a huge amount of data (since it literally double the amount of vertices, and therefore ends up being a performance killer as well).Best approach ultimately, would be to use a shader to draw both ellipse and rounded rectangle
For reference here is a quick benchmark that compare rectangle and circle stroke performances:
As a final note, performances are only dropping when drawing more than 2500 circles per frame.
The text was updated successfully, but these errors were encountered: