w3c / svgwg

SVG Working Group specifications
Other
711 stars 133 forks source link

Mesh Patch in SVG2 is not C1 smooth at edge #377

Open wada314 opened 6 years ago

wada314 commented 6 years ago

Hello everyone, Sorry if this is already discussed topic.

While reading the svg2 spec about the mesh; https://svgwg.org/svg2-draft/pservers.html#MeshPatchPainting I noticed that the definition is different with the definitions of "Gradient Mesh" I read in some papers before:

Paper 1: Image vectorization using optimized gradient meshes https://dl.acm.org/citation.cfm?id=1276391 https://www.cct.lsu.edu/~fharhad/ganbatte/siggraph2007/CD2/content/papers/011-sun.pdf // Note: There's typo in the 4x4 matrix C defined in this paper... please refer to the following paper instead.

Paper 2: Automatic and topology-preserving gradient mesh generation for image vectorization https://dl.acm.org/citation.cfm?id=1531391 http://orca.cf.ac.uk/27764/1/ImageVectorization.pdf

And I believe Adobe Illustrator is also using this "Gradient Mesh" definition, not the current SVG2 definition.

The problem of the current SVG2's mesh definition is that C1 smoothness is not guaranteed on the edge. For example, at a point (u, 0) (somewhere in the top edge of the mesh), the v-direction differential value is depending on the value of 2 bottom corners & its knots. OTOH, in the "Gradient Mesh", v-direction differential at (u, 0) is consist of only 2 top corners & knots values. This assures the adjacent patches are C1 continuous as long as they are sharing corners & knots.

Does someone know why SVG2 is using the current definition instead of the Gradient Mesh?

thanks,

AmeliaBR commented 6 years ago

The current spec was mostly written by @Tavmjong. He has written up some details about the issues with smooth continuation between patches on his blog, with the resolution (bicubic interpolation) described here.

wada314 commented 6 years ago

Thanks Amelia! I take a look at it from now.

wada314 commented 6 years ago

I read the articles.

IMHO, SVG is spec not only for rendering the vector graphics but has strong support to edit it, so it might be a small problem if a gradient mesh patch in Adobe Illustrator is converted into subpatches in SVG. Then it will be difficult to edit it in Inkscape or other editing software. And I don't think the definition using cubic-spline interpolation is considerably complex compared to the bi-linear one. (Please notify me if the bi-linear one has any useful property where the cubic-spline does not have; Maybe I'm missing some)

Otherwise, it looks reasonable decision. Anyway when rasterizing the patch it is subdivided into small subpatches so the rasterizing cost won't be much different. The SVG file size will increase by these subdivided patches, but the file size is not a big problem I believe.

boggydigital commented 6 years ago

Not blocking updated 2.0 CR publication - assigning 2.1 WD milestone