[cairo] Re: Avoiding seams
mental at rydia.net
mental at rydia.net
Mon Dec 12 15:49:04 PST 2005
Quoting TimothÃ©e Lecomte <timothee.lecomte at ens.fr>:
> So SATURATE is not the best solution. I think that drawing at a
> higher resolution has the same last problem, unless I draw
> everything on the higher-resolution context.
You'd need to draw everything which needs to meet cleanly on that
same context, yes.
> I have followed with great interest the discussion between
> MenTaLguY and Bill Spitzak about a possible new entry in the API.
> I am not convinced at all by "aliased_lineto"
> or "aliased_curveto". It implies to detect which sides of the
> polygons need to be aliased to avoid seams, and it's not simple
> at all !
It's actually a rehashing of a very old discussion. It isn't just a
problem for drawing e.g. adjoining triagles for
perspective-projected surfaces, but really a general issue which
affects any renderer which tries to approximate coverage via the
alpha channel for intermediate rendering steps.
"star and ring" cairo
and you'll find the original thread, along with the star-and-ring
test case I devised to show off the issue.
> Moreover, I want antialiased separations between my polygons, as
> they are of different colors.
Ahh, good catch. I'd overlooked that shortcoming.
> Do you have any other ideas ?
Maybe two-sided fills. But that's not really any easier to work
with than the aliased_lineto business, even if it did allow
The only apparent solutions involve FSAA, which as far as I know
involves one of two families of techniques:
- oversampling (render at higher resolution w/o antialiasing)
- geometric (e.g. build a BSP tree of the entire scene and
rasterize in a single pass)
There are a couple other interesting ways of "cheating" -- for
example, the AGG renderer dialates paths slightly so they overlap.
However, that approach only manages to avoid seams if the shapes
involved are all fully opaque.
As far as I can tell, the Macromedia Flash renderer uses
oversampling. I don't know what Xara uses, but it'll be
open-sourced soon. I suspect it also oversamples.
For what it's worth, I originally became aware of the issue with
Inkscape's current renderer (livarot). Designers complaining
loudly about seams between their precisely aligned shapes. Livarot
isn't cairo-based, but uses the same approach to partial coverage
approximation. libart too.
I've got a nasty feeling that OSS renderers have been pursuing a
dead end in this regard. It's a 90% solution that doesn't seem to
admit a 10% fix.
More information about the cairo