GPv3: SVG export corrupted #126606

Closed
opened 2024-08-21 16:37:41 +02:00 by Antonio Vazquez · 8 comments

System Information
Operating system: Windows-10-10.0.22621-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2080 Ti/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 552.12

Blender Version
Broken: version: 4.3.0 Alpha, branch: main (modified), commit date: 2024-08-21 13:20, hash: 08d5eb8f9cba
Worked: 4.2

Short description of error
When you export a demo file, the result is totally wrong.

Exact steps for others to reproduce the error

  1. Download Cowboy demo file
  2. Open file
  3. Select cowboy characted and try to export in SVG for Selected or Visible object.
**System Information** Operating system: Windows-10-10.0.22621-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 2080 Ti/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 552.12 **Blender Version** Broken: version: 4.3.0 Alpha, branch: main (modified), commit date: 2024-08-21 13:20, hash: `08d5eb8f9cba` Worked: 4.2 **Short description of error** When you export a demo file, the result is totally wrong. **Exact steps for others to reproduce the error** 1) Download Cowboy demo file 2) Open file 3) Select cowboy characted and try to export in SVG for Selected or Visible object.
Antonio Vazquez added the
Severity
Normal
Type
Bug
Status
Needs Triage
labels 2024-08-21 16:37:42 +02:00
Antonio Vazquez added this to the Grease Pencil project 2024-08-21 16:37:42 +02:00
Pratik Borhade added
Module
Grease Pencil
Status
Confirmed
and removed
Status
Needs Triage
labels 2024-08-22 08:10:00 +02:00
Member
@LukasTonne ^ :)
Lukas Tönne self-assigned this 2024-08-22 11:16:44 +02:00
Member

The SVG export is looking good for this file with the fix above.

PDF export, however, looks bad because of the materials used here: A number of materials have both Stroke and Fill color, but with Fill alpha set to zero. That makes these strokes invisible in the viewport and in SVG they also render transparent. PDF does not support transparency, so all these strokes show up with weird extra triangles. This is not really a bug but a limitation of the GP renderer and the PDF format:
image

The SVG export is looking good for this file with the fix above. PDF export, however, looks bad because of the materials used here: A number of materials have both Stroke and Fill color, but with Fill alpha set to zero. That makes these strokes invisible in the viewport and in SVG they also render transparent. PDF does not support transparency, so all these strokes show up with weird extra triangles. This is not really a bug but a limitation of the GP renderer and the PDF format: <img width="920" alt="image" src="attachments/4e9a457d-47cb-4475-b1b9-b4653f081030">
267 KiB
Author
Member

There is something I am missing. If the GPv3 Render Engine is the same and the materials are the same as in GPv2 and in GPv2 the exporter is able to do it, why can't it be done in GPv3? The PDF exporter is very important for transferring animation to other software and for creating scene documentation.

There is something I am missing. If the GPv3 Render Engine is the same and the materials are the same as in GPv2 and in GPv2 the exporter is able to do it, why can't it be done in GPv3? The PDF exporter is very important for transferring animation to other software and for creating scene documentation.
Member

What is GP supposed to do with a material that it cannot render properly in pdf?

What is GP supposed to do with a material that it cannot render properly in pdf?
Author
Member

Why you can't? This is my question. The same file exported in GPv2 using Blender 4.2,1.

image

Why you can't? This is my question. The same file exported in GPv2 using Blender 4.2,1. ![image](/attachments/5c9c8ec9-a2db-414e-9a4d-b7a8913e9f4c)
Author
Member

Here you have how set transparency. You need create a HPDF_ExtGState

void GpencilExporterPDF::color_set(bGPDlayer *gpl, const bool do_fill)
{
  const float fill_opacity = fill_color_[3] * gpl->opacity;
  const float stroke_opacity = stroke_color_[3] * stroke_average_opacity_get() * gpl->opacity;
  const bool need_state = (do_fill && fill_opacity < 1.0f) || (stroke_opacity < 1.0f);

  HPDF_Page_GSave(page_);
  HPDF_ExtGState gstate = (need_state) ? HPDF_CreateExtGState(pdf_) : nullptr;

  float3 col;
  if (do_fill) {
    interp_v3_v3v3(col, fill_color_, gpl->tintcolor, gpl->tintcolor[3]);
    linearrgb_to_srgb_v3_v3(col, col);
    col = math::clamp(col, 0.0f, 1.0f);
    HPDF_Page_SetRGBFill(page_, col[0], col[1], col[2]);
    if (gstate) {
      HPDF_ExtGState_SetAlphaFill(gstate, clamp_f(fill_opacity, 0.0f, 1.0f));
    }
  }
  else {
    interp_v3_v3v3(col, stroke_color_, gpl->tintcolor, gpl->tintcolor[3]);
    linearrgb_to_srgb_v3_v3(col, col);
    col = math::clamp(col, 0.0f, 1.0f);

    HPDF_Page_SetRGBFill(page_, col[0], col[1], col[2]);
    HPDF_Page_SetRGBStroke(page_, col[0], col[1], col[2]);
    if (gstate) {
      HPDF_ExtGState_SetAlphaFill(gstate, clamp_f(stroke_opacity, 0.0f, 1.0f));
      HPDF_ExtGState_SetAlphaStroke(gstate, clamp_f(stroke_opacity, 0.0f, 1.0f));
    }
  }
  if (gstate) {
    HPDF_Page_SetExtGState(page_, gstate);
  }
}
Here you have how set transparency. You need create a HPDF_ExtGState ``` void GpencilExporterPDF::color_set(bGPDlayer *gpl, const bool do_fill) { const float fill_opacity = fill_color_[3] * gpl->opacity; const float stroke_opacity = stroke_color_[3] * stroke_average_opacity_get() * gpl->opacity; const bool need_state = (do_fill && fill_opacity < 1.0f) || (stroke_opacity < 1.0f); HPDF_Page_GSave(page_); HPDF_ExtGState gstate = (need_state) ? HPDF_CreateExtGState(pdf_) : nullptr; float3 col; if (do_fill) { interp_v3_v3v3(col, fill_color_, gpl->tintcolor, gpl->tintcolor[3]); linearrgb_to_srgb_v3_v3(col, col); col = math::clamp(col, 0.0f, 1.0f); HPDF_Page_SetRGBFill(page_, col[0], col[1], col[2]); if (gstate) { HPDF_ExtGState_SetAlphaFill(gstate, clamp_f(fill_opacity, 0.0f, 1.0f)); } } else { interp_v3_v3v3(col, stroke_color_, gpl->tintcolor, gpl->tintcolor[3]); linearrgb_to_srgb_v3_v3(col, col); col = math::clamp(col, 0.0f, 1.0f); HPDF_Page_SetRGBFill(page_, col[0], col[1], col[2]); HPDF_Page_SetRGBStroke(page_, col[0], col[1], col[2]); if (gstate) { HPDF_ExtGState_SetAlphaFill(gstate, clamp_f(stroke_opacity, 0.0f, 1.0f)); HPDF_ExtGState_SetAlphaStroke(gstate, clamp_f(stroke_opacity, 0.0f, 1.0f)); } } if (gstate) { HPDF_Page_SetExtGState(page_, gstate); } } ```
Member

@antoniov thanks for the hint, it was in fact setting the opacity, but ignoring the color alpha. PDF export should be ok now.

@antoniov thanks for the hint, it was in fact setting the opacity, but ignoring the color alpha. PDF export should be ok now.
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2024-08-23 17:51:47 +02:00
Author
Member

@LukasTonne Checked! The export is correct now. Thanks for fixing!

I have found a different bug with the selected frames and open a new report: #126702

@LukasTonne Checked! The export is correct now. Thanks for fixing! I have found a different bug with the selected frames and open a new report: https://projects.blender.org/blender/blender/issues/126702
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
3 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#126606
No description provided.