GPencil: SVG exporter generates wrong stroke thickness #103061

Closed
opened 2022-12-09 10:39:32 +01:00 by Robert S · 17 comments

System Information
Operating system: Windows-10-10.0.19044-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 526.86

Blender Version
Broken: version: 3.3.1, branch: master, commit date: 2022-10-04 18:35, hash: b292cfe5a9
Worked: (newest version of Blender that worked as expected)

Short description of error
SVG seems to allays export a single thickness, while in the Blend file there's different thicknesses.

World space lineart apparently attempts to emulate the shrinking line width of the camera angle by exporting each segment with a different line weight. This makes post processing in Illustrator/Designer/Inkscape near impossible.

Screen space lineart should then instead produce a constant line width according to the displayed line thickness. Unfortunately, with screen space on, that seems to get ignored on SVG export.

Exact steps for others to reproduce the error

  1. Open the attached example
  2. Export as SVG
  3. Open SVG

image.png

image.png

lineart.blend

**System Information** Operating system: Windows-10-10.0.19044-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3090/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 526.86 **Blender Version** Broken: version: 3.3.1, branch: master, commit date: 2022-10-04 18:35, hash: `b292cfe5a9` Worked: (newest version of Blender that worked as expected) **Short description of error** SVG seems to allays export a single thickness, while in the Blend file there's different thicknesses. World space lineart apparently attempts to emulate the shrinking line width of the camera angle by exporting each segment with a different line weight. This makes post processing in Illustrator/Designer/Inkscape near impossible. Screen space lineart should then instead produce a constant line width according to the displayed line thickness. Unfortunately, with screen space on, that seems to get ignored on SVG export. **Exact steps for others to reproduce the error** 1. Open the attached example 2. Export as SVG 3. Open SVG ![image.png](https://archive.blender.org/developer/F14046424/image.png) ![image.png](https://archive.blender.org/developer/F14046426/image.png) [lineart.blend](https://archive.blender.org/developer/F14046565/lineart.blend)
Author

Added subscriber: @RobertS

Added subscriber: @RobertS
Member

Added subscriber: @OmarEmaraDev

Added subscriber: @OmarEmaraDev
Member

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'
Member

I can't reproduce that, all lines have constant thickness for me. Can you attach the svg itself?

<polyline stroke="#000000" stroke-opacity="1" fill="none" stroke-linecap="round" stroke-width="2" points="..." />
<polyline stroke="#000000" stroke-opacity="1" fill="none" stroke-linecap="round" stroke-width="2" points="..." />
<polyline stroke="#000000" stroke-opacity="1" fill="none" stroke-linecap="round" stroke-width="2" points="..." />
I can't reproduce that, all lines have constant thickness for me. Can you attach the svg itself? ``` <polyline stroke="#000000" stroke-opacity="1" fill="none" stroke-linecap="round" stroke-width="2" points="..." /> <polyline stroke="#000000" stroke-opacity="1" fill="none" stroke-linecap="round" stroke-width="2" points="..." /> <polyline stroke="#000000" stroke-opacity="1" fill="none" stroke-linecap="round" stroke-width="2" points="..." /> ```
Author

I think you misunderstood. The bug IS that the SVG has a single thickness, while in the Blend file there's two different thicknesses.

I think you misunderstood. The bug IS that the SVG has a single thickness, while in the Blend file there's two different thicknesses.
Member

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'

Added subscriber: @mano-wii

Added subscriber: @mano-wii

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Changed status from 'Needs Triage' to: 'Needs Developer To Reproduce'

Thickness is in pixels, and thus depends on the resolution of the final image.
It is a subject of discussion. See for example #100595 (Line Art Thickness doesn't consider Render Resolution Percentage)

But I can notice that the thicknesses are always "normalized" even with the option "Normalize" in the export settings disabled.

This happens because apparently BKE_gpencil_stroke_is_pressure_constant() always returns true.
{https://developer.blender.org/diffusion/B/browse/master/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc$204-205}

I don't know if this is intentional. This seems to make the Normalize option useless.

Thickness is in pixels, and thus depends on the resolution of the final image. It is a subject of discussion. See for example #100595 (Line Art Thickness doesn't consider Render Resolution Percentage) But I can notice that the thicknesses are always "normalized" even with the option "Normalize" in the export settings disabled. This happens because apparently `BKE_gpencil_stroke_is_pressure_constant()` always returns `true`. {https://developer.blender.org/diffusion/B/browse/master/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc$204-205} I don't know if this is intentional. This seems to make the Normalize option useless.
Germano Cavalcante changed title from Lineart doesn't export line weights in screen space to SVG to Exporter 'Grease Pencil as SVG' always normalize stroke thickness 2022-12-12 17:33:39 +01:00

Added subscriber: @antoniov

Added subscriber: @antoniov

@mano-wii The normalization is done if all points of the stroke have the same pressure. This is done because the PDF export lib can handle a maximum number of thickness change and the export function tries to reduce the thickness changes. (SVG export works similar to PDF) If the pressure is equal in all points, then thickness is equal for all strokes, so I don't see a problem in the export itself, but the generated stroke... maybe LineArt is doing something to simulate the pressure change but without changing the pressure.

@mano-wii The normalization is done if all points of the stroke have the same pressure. This is done because the PDF export lib can handle a maximum number of thickness change and the export function tries to reduce the thickness changes. (SVG export works similar to PDF) If the pressure is equal in all points, then thickness is equal for all strokes, so I don't see a problem in the export itself, but the generated stroke... maybe LineArt is doing something to simulate the pressure change but without changing the pressure.

Anyway, I will take a look.

Anyway, I will take a look.
Antonio Vazquez self-assigned this 2022-12-12 23:18:48 +01:00

I have been testing and the scene contains 3 strokes with all points with same pressure, so the auto-normalization is correct. What I have seen is that the thickness of the strokes is 2 or 5 pixels and this is a very thin lines, so when you export the precission of the calculations to determine the thickness gets in all cases 2...if you add a Thickness modifier on top of the Lineart, you will see that all is working in SVG and PDF.

Note: I applied the Lineart modifer and separete the strokes to make easy the debug.

image.png

image.png

image.png

I have been testing and the scene contains 3 strokes with all points with same pressure, so the auto-normalization is correct. What I have seen is that the thickness of the strokes is 2 or 5 pixels and this is a very thin lines, so when you export the precission of the calculations to determine the thickness gets in all cases 2...if you add a Thickness modifier on top of the Lineart, you will see that all is working in SVG and PDF. Note: I applied the Lineart modifer and separete the strokes to make easy the debug. ![image.png](https://archive.blender.org/developer/F14054712/image.png) ![image.png](https://archive.blender.org/developer/F14054714/image.png) ![image.png](https://archive.blender.org/developer/F14054717/image.png)

@RobertS What is the resolution of your screen?

@RobertS What is the resolution of your screen?

This issue was referenced by 94e7e83cd9

This issue was referenced by 94e7e83cd997170d42ddb1155814b8eda127a104

This issue was referenced by 85a743e08b

This issue was referenced by 85a743e08bfcaa321c7f0e7ced6bf9003a359888

Changed status from 'Needs Developer To Reproduce' to: 'Resolved'

Changed status from 'Needs Developer To Reproduce' to: 'Resolved'
Antonio Vazquez changed title from Exporter 'Grease Pencil as SVG' always normalize stroke thickness to GPencil: SVG exporter generates wrong stroke thickness 2022-12-13 11:42:23 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
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
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#103061
No description provided.