Page MenuHome

VSE shading mode ignores Grease Pencil Vertex colors
Closed, ResolvedPublicBUG

Description

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: rB02948a2cab44
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.



Event Timeline

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Needs Information from User.Mar 26 2021, 10:11 AM

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.

@Philipp Oeser (lichtwerk) Sorry! The blend upload failed. should be fixed now.

Ivan Cappiello (icappiello) changed the task status from Needs Information from User to Needs Triage.Mar 31 2021, 9:01 AM
Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Confirmed.Apr 1 2021, 10:47 PM
Germano Cavalcante (mano-wii) changed the subtype of this task from "Report" to "Bug".

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

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

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.

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...

@Antonio Vazquez (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 (jbakker) 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 ;-)

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.