To create an ellipse/circle/donut in gpu with antialiasing for better performance
Is your feature request related to a problem? Please describe. Current, ellipse/circle/donut graphics aren't anti-aliased. The anti-aliased versions are recently done through smooth versions. So, to have anti-aliasing we have to change the current graphics instructions to the smooth versions. Also, all the calculations are done on cpu side which could have been easily implemented on gpu side with shaders having anti-aliasing.
Describe the solution you'd like The current ellipse/circle graphics instruction uses triangle meshes and calculates the points cpu side. Though the implementation is optimised (to my knowledge) but as the points are being calculated cpu side we will always have a bottleneck when rendering large amount of circles. Also, as the rendering is done by triangle meshes we suffer from approximation defects and the resulting shape is not gonna be an actual circle/ellipse/donut. To counter this we need high number of triangles , which the current implementation does. But on zoom, or on high dpi surfaces, the artifacts might be visible. So, I propose that we can further optimize the implementation by making the rendering gpu side using a fragment shader for drawing a circle. The shader can have input transformation matrices to make it ellipse and an input variable called thickness which can be translated to thickness of the donut, if a donut is to be made. Moreover, the shader will have built in anti-aliasing based on smoothstep or linear interpolation glsl functions. This will make the rendering completely gpu side which will translate into better performance. The pure gpu implementation can be added as a feature alongside the current cpu implementation. The gpu implementation will only be based on vertex shader and fragment shader, no geometry shader would be needed.
So, if permitted, I can help in changing the shader and graphics code to have the anti-aliasing in-built with gpu implementation thereby improving the performance.
Hi, @misl6 any suggestions on this , contrary, I can start working on a pr for this.
I have opened this https://github.com/kivy/kivy/issues/8559 as an overall measure to tackle this issue too.
@Samael-TLB: To my inexpert eyes, these look like duplicates. Could you explain what belongs in one issue versus the other, please?
Yes surely, @Julian-O. So this issue is mainly to target the entire drawing of the circle/ellipse gpu side. The current implementation calculates the points on the cpu side, which is what this issue tries to point out and subsequently will try to eliminate with a pr. As a side effect of the methodology that I plan to use for this, the resulting circle/ellipse shall have anti-aliasing free of cost. The issue #8559 is directed towards mainly to improve the anti-aliasing implementation in kivy. The current implementation uses smooth lines which are not well subjected for images apart from other issues mentioned in my issue post. If we can do that before solving this issue, then the implementation of this issue is very simplified. And if what I'm envisioning is correct, not only for ellipse/circle but for all other regular primitives too we can have the performative gpu implementations subsequently.