4 ms·
> I’m particularly interested in the rendering quality. Shouldn't the rendering be done using oversampling? E.g. instead of 100x100, you render on 400x400, the
by amelius 8y ago
> I’m particularly interested in the rendering quality.
Shouldn't the rendering be done using oversampling? E.g. instead of 100x100, you render on 400x400, then scale back down to 100x100 to get the best result.
One of the problems is that anti-aliasing creates pixels which are half-on, e.g. at the edge of a line or polygon. Now if multiple edges meet near a certain pixel, then rendering the polygon(s) will touch a "half-on" pixel several times, and as a result it may receive the wrong opacity.
- raphlinus 8y agoIt is true that is more correct (see https://github.com/pcwalton/pathfinder/issues/142 https://github.com/pcwalton/pathfinder/issues/142). But my motivation is much more user interface than document rendering, so it's quite reasonable to tell the UI designers, "don't do that," especially if the flip side is butter-smooth performance.
- amelius 8y agoBut UI designers are not always in complete control, e.g. if screen resolutions are different for different users.
- pcwalton 8y agoIn practice, if you avoid coincident edges, you're fine. Font rasterizers have been using analytic AA for a long time without problems. In theory, the lack of knowledge of render resolution makes that a concern, but in practice it's not too much of an issue.
- raphlinus 8y agoAgreed, and there are some deep issues, for example the rendering of very thin strokes which is quite dependent on resolution. Also keep in mind that the 4x4 oversampling you mentioned does not give nice smooth edges. I'm working on font editing, so the quality and smoothness of the line, to most accurately represent the shape without artifacts, is paramount.
- pcwalton 8y agoAs far as I know, you basically get to choose two of antialiasing quality, correctness, and performance. The viable antialiasing options for vectors are: 1. Supersampling/multisampling. This is what you suggested. This provides correctness with coincident edges, but 256xAA (what analytic AA gives you) is far too slow and memory intensive to be practical if you supersample. In general practical implementations of MSAA/SSAA are limited to 16xAA or so, which is a noticeable drop in quality and in fact is still pretty slow relative to a high-quality implementation of analytic AA. 2. Analytic antialiasing. This has problems with coincident edges, but in most cases the effects are minimal. The performance and quality are excellent if implemented properly. I generally think that analytic AA is the right tradeoff for most applications. Subtle rendering problems on coincident edges are usually a small price to pay for the excellent results, and designers can work around those issues when they come up. A 100% theoretically correct rasterizer can't exist anyway, because of floating point/fixed point precision issues among other reasons.
- amelius 8y agoInteresting, this is new for me. Is it true that for analytic AA you'd have to consider the rendered objects all at once, instead of just rendering one after the other?
- pcwalton 8y agoUsually with analytic AA you just use Porter-Duff blending, because rendering all the objects simultaneously doesn't buy you much except for performance (which is why piet-metal does it that way). For supersampling AA you can render all the objects at once, like Flash did, and this does improve rendering quality around coincident edges. Oddly (in my opinion), some rasterizers such as Skia's use supersampling for individual paths and Porter-Duff blending when overlaying different paths on top of one another. This means that you don't have seams between subpaths of the same path, but different paths can have seams on coincident edges. I don't like this tradeoff personally, because it has a lot of the downsides of analytic AA without the benefit of antialiasing quality, but for better or worse this approach is widely used.
- Rusky 8y agoThis (and its optimized cousin MSAA) has a huge performance and bandwidth cost relative to its quality increase. It fixes conflation on shared edges (the problem you describe) but 16x supersampling only gives you 16 possible opacities to work with for antialiased edges. The analytic approach taken here and by Pathfinder gets to use all 256 possible opacities, and uses less bandwidth than supersampling, but has conflation artifacts. To match that with supersampling you'd need to scale from 100x100 to 1600x1600. Because of this most renderers also have the conflation problem (try it in your browser with an SVG), so a lot of content in the wild works around it. There are other approaches that are low-bandwidth and solve the conflation problem, but at the cost of higher GPU requirements or higher complexity. For example, http://w3.impa.br/~diego/projects/GanEtAl14/ http://w3.impa.br/~diego/projects/GanEtAl14/ or http://hhoppe.com/proj/ravg/ http://hhoppe.com/proj/ravg/.