Incorrect import of SVG paths #92713
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#92713
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Blender Version
Broken: version: 3.1.0 Alpha
Worked: Never
Addon Information
Name: Scalable Vector Graphics (SVG) 1.1 format ()
Author: JM Soler, Sergey Sharybin
Short description of error
Hi everyone,
Developing simple-icons-blender add-on, I've noted that some SVG paths are not imported correctly.
I've done a comparison against Inkscape in the next video. In the row at the top there are the Blender representation of SVGs loaded with
import_svg
addon, in the row at the bottom there are PNGs converted from original SVGs with Inkscape included as plane materials.failed-slugs.mp4
Note that these icons are created with common vector graphics programs, manually reviewed using the browser (on Github) and other vector graphics programs, and their paths have been linted, so I'm sure that this is a bug in Blender.
List of badly rendered icons:
Exact steps for others to reproduce the error
Changed status from 'Needs Triage' to: 'Confirmed'
Added subscriber: @mondeja
Added subscriber: @discostu
Is this related to the fact that many SVGs import at a very small scale?
Added subscriber: @jenkm
@mondeja - one or two svg examples and one screenshot are enough.
The issue here is that the svg path is not closed.
I would say that Blender imports the file correctly (as it is) and the svg itself is incorrect.
For example, this svg, is completely broken:
Changed status from 'Confirmed' to: 'Needs Triage'
@jenkm I think the confusion for the users here is that most other software seems to be more forgiving for incorrect svgs. I tried, Illustrator, Sketch, a web browser, and Affinity Designer and they each rendered the Angular svg as expected. I wonder if there could be an import option to correct svgs such as closing open paths.
The other thing I've noticed with importing SVGs is they come in very very small and the user is required to scale them up 80x or more. In looking at the source code I see that it only scales if the width and height have units in this list:
In my experience SVGs never specify unit. I wonder if they could default to pt?
Thanks for the feedback @jenkm, but I think that your answer does not conform with the SVG specification. In "Specifying fill paint: the ‘fill’ property" the specification says:
So there is no need to close the subpath explicitly with a closepath (
z
/Z
) command to define the fill behaviour, it only affects at howstroke-linecap
andstroke-linejoin
properties are applied. In The "closepath" command, the specification points that:Blender is differing here from the specification compared with other softwares.
Added subscriber: @Sergey
Of course you are right that svg supports such a thing and it works in other programs. I basically meant that Blender is not a vector editor, it just converts svg into its own format, which works differently, i.e. not all svg features can be supported. It is often necessary to prepare files specifically before importing them into another program.
This can probably be fixed/improved, perhaps @Sergey can comment on this.
Blender's SVG addon implements a rather small subset of SVG 1.1 specification. Styling is very limited (i.e. filters and such are ignored). The tessellation is Relying on the way how 2D curves are tessellated. Think best description would be: main goal is to get paths into Blender, and final look of non-trivial images is not considered to be a priority. Making a good/proper SVG importer is a big project on its own, not something we had capacitance for.
That't the viewbox handling code. Weirdly, its unit is derived from document height.
Having paths with points without unit should be possible, although it is not impossible there is a mistake somewhere in the way we calculate transform.
I'm not sure why wrong scale would cause bad icon. To me there is a difference between icon being wrong size and icon missing its elements. Or is it because some of the parts of icon are scaled wrongly, making them invisible?
Top make the report manageable we need a simple SVG file which indicates specific problem. If there is a simple SVG demonstrating wrong scale or wrong path shape we can look into it.
Changed status from 'Needs Triage' to: 'Confirmed'
Added subscriber: @Lin-Hsu
D16143 can fix some broken paths, like the following PeerTube icon.
But some icons are still incomplete due to other issues, like the following NVIDIA icon.
With D16143 committed, I rechecked all the badly rendered icons that Álvaro listed.
There are 3 images for each icon: Blender rendering, CairoSVG rendering, abs(diff).
The number is the MSE of the pixels with alpha !=0 and alpha != 1 in both renderings. These pixels are borders which are all that matters for such icons.
Icons with MSE > 0.0004 are treated as broken and are framed with red.
Please note that the sets of broken icons are different for the 2 resolutions, though the counts are the same.
I'll try to fix the remaining issues...
With D16198, more icons are fixed.