Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Implement QQuickItem with antialiasing for custom triangle object

$
0
0
What kind of hardware are you running on? Depending on what your target is, turning on multisampling might not be a bad choice, and that gives you antialiasing for free. On many embedded chips, you have cheap 4x multisampling. On most desktop chips, you have more expensive 8-16x multisampling, but on a chip with a proper graphics card, it isn’t a problem. Intel chips, especially the older ones, will struggle, if it is supported at all. If you want to implement per-vertex antialiasing, you would need to create a QSGGeometryNode. If you add just the triangle, it will be aliased. To get antialiasing you need to add more vertices along the exterior of the triangle which fade the interior color to transparent. You could do that with a QSGGeometryNode using 6 vertices and indices making up 7 triangles (1 for the interior and 2 for each antialiasing edge). A trivial implementation could use geometry of QSGGeometry::ColoredPoint2D combined with QSGVertexColorMaterial, where interior vertices get alpha=1 and exterior vertices get alpha=0. If you want to antialiasing edge adapt based on scale factor you would need to implement your own material and take the scale factor of the matrix into account in the vertex shader and change the width of the exterior based on that. Good Luck :)

Viewing all articles
Browse latest Browse all 4972

Trending Articles