VSE shading mode ignores Grease Pencil Vertex colors #86956

Closed
opened 2021-03-26 09:06:41 +01:00 by Ivan Cappiello · 21 comments
Member

System Information
Operating system: Darwin-20.3.0-x86_64-i386-64bit 64 Bits
Graphics card: AMD Radeon Pro 5500M OpenGL Engine ATI Technologies Inc. 4.1 ATI-4.2.15

Blender Version
Broken: version: 2.92.0, branch: master, commit date: 2021-02-24 16:25, hash: 02948a2cab
Worked: N.A.

Short description of error
If a blender scene is added in the VSE, the shading mode is respected for 3D objects vertex colors but not for GP objects

Exact steps for others to reproduce the error
Open the attached blender file and switch between the "3D" scene and "EDIT" scene. In the 3d viewport of 3D scene both the cube and the grease pencil stroke are shaded correctly, in the VSE EDIT scene the cube shows the correct vertex colors and the GP is flat shaded without colors.
Side Note: using the "override scene settings" and forcing the workbench engine on the EDIT scene to respect vertex color and flat shade, makes no difference.

LINKED_GP_VSE_SCENE.blend

3Dview.png
VSE.png
GP_issue_VSE.mov

**System Information** Operating system: Darwin-20.3.0-x86_64-i386-64bit 64 Bits Graphics card: AMD Radeon Pro 5500M OpenGL Engine ATI Technologies Inc. 4.1 ATI-4.2.15 **Blender Version** Broken: version: 2.92.0, branch: master, commit date: 2021-02-24 16:25, hash: `02948a2cab` Worked: N.A. **Short description of error** If a blender scene is added in the VSE, the shading mode is respected for 3D objects vertex colors but not for GP objects **Exact steps for others to reproduce the error** Open the attached blender file and switch between the "3D" scene and "EDIT" scene. In the 3d viewport of 3D scene both the cube and the grease pencil stroke are shaded correctly, in the VSE EDIT scene the cube shows the correct vertex colors and the GP is flat shaded without colors. Side Note: using the "override scene settings" and forcing the workbench engine on the EDIT scene to respect vertex color and flat shade, makes no difference. [LINKED_GP_VSE_SCENE.blend](https://archive.blender.org/developer/F9910358/LINKED_GP_VSE_SCENE.blend) ![3Dview.png](https://archive.blender.org/developer/F9910282/3Dview.png) ![VSE.png](https://archive.blender.org/developer/F9910285/VSE.png) [GP_issue_VSE.mov](https://archive.blender.org/developer/F9910273/GP_issue_VSE.mov)
Author
Member

Added subscriber: @icappiello

Added subscriber: @icappiello
Author
Member

Added subscribers: @Jeroen-Bakker, @antoniov

Added subscribers: @Jeroen-Bakker, @antoniov
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

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

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

To make sure we are all on the same page (and speed up the triaging/fixing process), please always provide the example .blend file where this happens.

To make sure we are all on the same page (and speed up the triaging/fixing process), please always provide the example .blend file where this happens.
Author
Member

In #86956#1136627, @lichtwerk wrote:
To make sure we are all on the same page (and speed up the triaging/fixing process), please always provide the example .blend file where this happens.

@lichtwerk Sorry! The blend upload failed. should be fixed now.

> In #86956#1136627, @lichtwerk wrote: > To make sure we are all on the same page (and speed up the triaging/fixing process), please always provide the example .blend file where this happens. @lichtwerk Sorry! The blend upload failed. should be fixed now.
Author
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: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

I can confirm.
The Grease Pencil object, which should be green, is white in the VSE.

I can confirm. The Grease Pencil object, which should be green, is white in the VSE.
Jeroen Bakker self-assigned this 2021-05-20 09:22:24 +02:00
Member

Will assign this issue to me to investigate next week. Not sure about the cause and not really familiar GP code base.

Will assign this issue to me to investigate next week. Not sure about the cause and not really familiar GP code base.

@Jeroen-Bakker Let me know if you need my help.

@Jeroen-Bakker Let me know if you need my help.

My guess is the problem looks related to how the shading Solid mode is used in the Linked scene. In the original, the shading is Solid->Vertex, but in the linked, it looks Solid->Singleand it's not using the original scene setup.

My guess is the problem looks related to how the shading Solid mode is used in the Linked scene. In the original, the shading is `Solid->Vertex`, but in the linked, it looks `Solid->Single`and it's not using the original scene setup.

This issue was referenced by baa7a53974

This issue was referenced by baa7a5397486f6fad9e8e8ffc4852776940c4392

This issue was referenced by a20ef4207d

This issue was referenced by a20ef4207d46a28c869f8953c5ecf0f5b7af1984
Member

Narrowing down the issue is in a parameter used in the vertex shader. the finalColorAdd uses 1.0.
Seems like vertexColorOpacity contains an incorrect value (0 in stead of 1).

this is read from pd->vertex_paint_opacity which uses draw_ctx->v3d->overlay.gpencil_vertex_paint_opacity.

This property isn't set when performing opengl rendering.

Finally...
root cause there is no known default for gpencil_vertex_paint_opacity.

Code is really confusing.
is_render in grease pencil means that it shading is in render mode. We cannot add exceptions there when rendering images as that would also intervene with viewport rendering where it is not expected.

although the comments says something else...

/* If we are rendering for final render (F12). */
  bool is_render;
  const bool override_vertcol = (pd->v3d_color_type != -1);
  const bool is_vert_col_mode = (pd->v3d_color_type == V3D_SHADING_VERTEX_COLOR) ||
                                GPENCIL_VERTEX_MODE(gpd) || pd->is_render;
  float vert_col_opacity = (override_vertcol) ?
                               (is_vert_col_mode ? pd->vertex_paint_opacity : 0.0f) :
                               pd->is_render ? gpl->vertex_paint_opacity :
                                               pd->vertex_paint_opacity;

Added a hack...

Narrowing down the issue is in a parameter used in the vertex shader. the finalColorAdd uses 1.0. Seems like vertexColorOpacity contains an incorrect value (0 in stead of 1). this is read from `pd->vertex_paint_opacity` which uses draw_ctx->v3d->overlay.gpencil_vertex_paint_opacity. This property isn't set when performing opengl rendering. Finally... root cause there is no known default for gpencil_vertex_paint_opacity. Code is really confusing. is_render in grease pencil means that it shading is in render mode. We cannot add exceptions there when rendering images as that would also intervene with viewport rendering where it is not expected. although the comments says something else... ``` /* If we are rendering for final render (F12). */ bool is_render; ``` ``` const bool override_vertcol = (pd->v3d_color_type != -1); const bool is_vert_col_mode = (pd->v3d_color_type == V3D_SHADING_VERTEX_COLOR) || GPENCIL_VERTEX_MODE(gpd) || pd->is_render; float vert_col_opacity = (override_vertcol) ? (is_vert_col_mode ? pd->vertex_paint_opacity : 0.0f) : pd->is_render ? gpl->vertex_paint_opacity : pd->vertex_paint_opacity; ``` Added a hack...
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Member

@antoniov please check my solution. It shows a design flaw in the grease pencil drawing. Question remains when to use which opacity setting. Current implementation might not match what users expect.

@antoniov please check my solution. It shows a design flaw in the grease pencil drawing. Question remains when to use which opacity setting. Current implementation might not match what users expect.

@Jeroen-Bakker I will check.

@Jeroen-Bakker I will check.

@Jeroen-Bakker It looks your fix is correct. The root cause is the versioning code is not fixing this value for some reason:

/* Init default Grease Pencil Vertex paint mix factor for Viewport. */
if (!DNA_struct_elem_find(
fd->filesdna, "View3DOverlay", "float", "gpencil_vertex_paint_opacity")) {
LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
v3d->overlay.gpencil_vertex_paint_opacity = 1.0f;
}
}
}
}
}````


But, anyway, the real fix is what you did adding a default value of 1.0 to this value. Thanks for catch up this bug ;-)
@Jeroen-Bakker It looks your fix is correct. The root cause is the versioning code is not fixing this value for some reason: ```if (!MAIN_VERSION_ATLEAST(bmain, 283, 7)) { ``` /* Init default Grease Pencil Vertex paint mix factor for Viewport. */ if (!DNA_struct_elem_find( fd->filesdna, "View3DOverlay", "float", "gpencil_vertex_paint_opacity")) { LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) { LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; v3d->overlay.gpencil_vertex_paint_opacity = 1.0f; } } } } }```` ``` But, anyway, the real fix is what you did adding a default value of 1.0 to this value. Thanks for catch up this bug ;-)
Member

When overriding in a scene you don't have the overlay options. previously when creating a new 3d view the defaults were not set. But that is not related to this issue. I just fixed it as I came across it.

The second commit is the hacky fix. Personally I find this part of the code/design does not communicate when which vertex paint opacity should be used, there are just to many exceptions.

When overriding in a scene you don't have the overlay options. previously when creating a new 3d view the defaults were not set. But that is not related to this issue. I just fixed it as I came across it. The second commit is the hacky fix. Personally I find this part of the code/design does not communicate when which vertex paint opacity should be used, there are just to many exceptions.
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
6 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#86956
No description provided.