4 ms·
> For degree-two/quadratics there are a series of coordinate transforms that you can do which conveniently map all curves to one UV coordinate space; degree-thr
by delhanty 5y ago
> For degree-two/quadratics there are a series of coordinate transforms that you can do which conveniently map all curves to one UV coordinate space; degree-three/cubics require a lot more attention in order to render correctly. If I remember correctly Mozilla Pathfinder does this[2].
That's interesting! Do you have any references (or links to sample fragment shader code) for that quadratic case coordinate transformation?
- Jasper_ 5y agoThis is basically "all parabolas are linear transformations of one parabola", and the details can be found in Loop-Blinn.
- delhanty 5y agoThank you - sounds pretty straightforward. I found a reference on HN for anyone else following along: > In 2005 Loop & Blinn [0] found a method to decide if a sample / pixel is inside or outside a bezier curve (independently of other samples, thus possible in a fragment shader) using only a few multiplications and one subtraction per sample. - Integral quadratic curve: One multiplication - Rational quadratic curve: Two multiplications - Integral cubic curve: Three multiplications - Rational cubic curve: Four multiplications https://www.microsoft.com/en-us/research/wp-content/uploads/2005/01/p1000-loop.pdf https://www.microsoft.com/en-us/research/wp-content/uploads/... https://news.ycombinator.com/item?id=26463464 https://news.ycombinator.com/item?id=26463464
- kmeisthax 5y agoNVIDIA put out a book with Bezier rendering algorithms in it: https://developer.nvidia.com/gpugems/gpugems3/part-iv-image-effects/chapter-25-rendering-vector-art-gpu https://developer.nvidia.com/gpugems/gpugems3/part-iv-image-... which is itself derived from a paper whose name I don't remember. Basically, all quadratic Bezier curves are just linear transformations[0] of the curve u^2 - v. The fragment shader just evaluates that one equation to draw the curve, and texture mapping does all the rest. As long as you're careful to ensure that your fill surface polygon actually makes sense, you get back out perfectly-rendered Beziers at any zoom factor or angle. [0] Scale/shear/rotate - all the things you can do by matrix multiplication against a vector. Notably, not including translations; though GPUs just so happen to use a coordinate system that allows linear translations if you follow some conventions.
- delhanty 5y agoThank you - I appreciate the link. > from a paper whose name I don't remember. I guess it's the Loop-Blinn paper from my reply to the other reply. Resolution Independent Curve Rendering using Programmable Graphics Hardware https://www.microsoft.com/en-us/research/wp-content/uploads/2005/01/p1000-loop.pdf https://www.microsoft.com/en-us/research/wp-content/uploads/...