-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error in vertex calculation #22
Comments
This must be related to miter limit which isn't supported in vg-renderer (see Readme) Inkscape (and all proper vector graphics renderers) support miter limit which will convert thin long miters into bevel joints. vg-renderer doesn't support miter limit in order to simplify stroke calculations. It was a decision I made very early and never got back into fixing it. I don't really know how much such calculations will affect runtime performance. Unfortunately, I cannot think of an easy way to fix this, other than rewriting all stroker functions in a way to include this kind of checks and convert the problematic stoke corners into bevels. EDIT: Added link to stroke-miterlimit SVG attribute. Not supporting miter limit in vg-renderer is the same as setting the limit to a large value in all other renderers. You can check this by altering stroke-miterlimit in your SVG file and viewing it in your browser. See example in the linked MDN page. |
Thanks for the answer. But it seems to me that the problem is not only miter limit. I have attached some images for a better understanding of the problem. In the turquoise rectangles, I have highlighted the problem areas. As the kMaxExtrusionScale ratio increases, there are fewer errors. However, on smaller scales, kMaxExtrusionScale has to be done more in order to achieve acceptable quality. It seems that kMaxExtrusionScale should not be constant. What do you think on this? |
Even path fills suffer from the same problem as strokes without a miter limit when using AA. This is because the same algorithm is used for calculating AA fringes. Fringes as half-width strokes around a filled path. See https://github.com/jdryg/vg-renderer/blob/master/src/stroker.cpp#L867 kMaxExtrusionScale is a hack to limit the amount of extrusion of those problematic cases. The correct way to handle it is to dynamically limit the extrusion and convert those corners into bevels, even for the AA fringes. Problem with dynamically produced bevels is that the amount of vertices isn't known beforehand so extra allocations are necessary inside the inner loop as well as extra checks. Hope that makes sense. You can check this is due to AA if you disable AA in all the problematic cases you shown above. A polygon fill without AA doesn't introduce any more vertices than those produced by the path tesselation. AA on the other hand produces extra vertices around the polygon with an alpha value of 0 in order to smoothly fade the edges. |
I tried to make a minimal example to demonstrate the problem.
Let's take a bezier curve made in inkscape:
If I try render with vg I see what:
Code:
Also the problem is easy to reproduce it to output svg on a small scale (0.1f or less) with AA enabled:
In an imperial way, I tried to change the kMaxExtrusionScale parameter here:
vg-renderer/src/stroker.cpp
Line 45 in 4f1bfa7
The text was updated successfully, but these errors were encountered: