Myth: Vector graphics on GPU is hard because GPUs only know how to draw triangles, not curves. In fact, anyone who has touched a pixel shader in Unity can make a GPU draw a filled circle…
-
Show this thread
-
Rather, vector graphics on GPU is hard because GPUs don’t know how to draw filled *polygons*. That’s because fill rules are inherently sequential: whether a pixel is filled depends on every pixel before it in the scanline.
2 replies 5 retweets 43 likesShow this thread -
Replying to @pcwalton
(Signed) distance fields are a different way of approaching this. Fill a pixel where distance is negative, small distances are used for anti aliasing by eg making the edges fade to transparency. They have different problems though, not a panacea :)
2 replies 1 retweet 2 likes -
Replying to @Atrix256
Yeah, I addressed SDF in the next tweet: drawing the SDF is essentially equivalent to drawing paths on CPU.
1 reply 0 retweets 1 like -
Replying to @pcwalton
Oh sorry i was talking about continuous SDFs, like not made into a texture. A pixel is able to take a discrete sample of the continuous SDF and reconstruct.
1 reply 0 retweets 1 like -
Replying to @Atrix256
Oh, you mean something like constructing a voronoi diagram for edges and encoding distance to edge in each voronoi region?
1 reply 0 retweets 0 likes -
Replying to @pcwalton
Like mathematically defining some 2d shapes, possibly doing domain distortion (modify x values in strange ways), using modulus to repeat the shapes, and operations to combine the influence of multiple distance fields. Its not good for drawing text, but lemme grab a shadertoy rq.
2 replies 0 retweets 2 likes -
Replying to @Atrix256
Ah, I see, that’s cool! Not really relevant for <canvas>/SVG/text which are all about beziergon meshes though
1 reply 0 retweets 0 likes -
This looks relevant: https://www.shadertoy.com/view/Mlj3zD Compute SDF from bezier, evaluate per pixel.
2 replies 0 retweets 2 likes -
(1) This is exactly my point: drawing curves on GPU is easy. It’s drawing *polygons* (or beziergons) that is hard. (2) There’s a much more efficient way to draw cubic beziers, as shown by Taubin, “Distance approximations for rasterizing implicit curves” 1994
1 reply 0 retweets 6 likes
(That paper is the basis of Loop/Blinn, and I use the technique to draw elliptical border radii in Firefox/WebRender. I should blog about it)
-
-
Not saying that this is going to be more efficient, it's just a different approach that's neat, but you can do analytic SDFs polygons too (see https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm …).
2 replies 0 retweets 1 like -
It’s not actually a different approach if you squint—Massively Parallel Vector Graphics is kind of the same idea. But generating the analytic SDF for arbitrary beziergons requires that you compute the winding numbers. No free lunch :)
1 reply 0 retweets 0 likes - 2 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.