On 20-04-11 05:57, Patrick Scheibe wrote:
Hi,
I'm exporting 3d surfaces from Mathematica. This creates a large number of polygons where neighboring polygons have two equal vertex-points.
Following problem: Although no stroke is used for the polygons and the coordinates of neighboring polygons are exactly equal, theres a teeny tiny space visible between them.
One hack around is to scale every polygon to 100.01% so that it overlaps a bit, but this is no solution.
Does anyone have hint for me?
This is a very well known problem (and not limited to Inkscape btw). The problem lies in the way shapes are anti-aliased. At edges coverage information is encoded in the alpha channel, but this essentially only gives the percentage of the pixel covered, it has no directional information. When compositing Inkscape just uses the normal alpha compositing operator (which is more based on translucent objects than coverage): newAlpha = 1 - (1-fgAlpha)*(1-bgAlpha) So now suppose that two adjacent polygons both cover complementary halves of the pixel. Inkscape then essentially computes a result that still only covers 75% of the pixel, corresponding to the case that both polygons overlap a bit.
In the same vein as what you did, you can try enlarging shapes selectively, so that shapes overlap a bit, without the visible border moving (obviously this is laborious and only works when the shapes in question are opaque). Similarly, you can blur the shapes a bit, this can help mask the seams, but has obvious drawbacks.
Apart from doing what you did there are a few other ways around this. The most "elegant" solution is blending with a different mode. This is most easily done by looking at what Inkscape does for blending modes in layers and copying that, except that you should change the filter to use feComposite instead of feBlend, and I think you need to use operator="arithmetic" with k2 and k3 set to 1. This only works properly if no shapes (that need to be blended in this way) overlap. If you run into trouble with this, feel free to ask for help.
A simpler method (if you're exporting anyway) is to export at a very high resolution and then downsampling. This essentially just "averages out" the seams.
This is actually a pretty difficult problem to solve properly in a renderer. I know of some ways to solve it, but all require more storage and processing (although I could imagine some heuristics that would only require additional processing). If anyone has any suggestions, I'm all ears.