From 7cefd01aaf2e2741f8a79df7060ddf18d811c6bc Mon Sep 17 00:00:00 2001 From: Chris Clyne Date: Wed, 18 Jan 2023 22:44:56 +0000 Subject: [PATCH] GooEngine: Enable GP screenspace thickness slider for all modes. --- scripts/startup/bl_ui/properties_data_gpencil.py | 1 - source/blender/draw/engines/gpencil/gpencil_cache_utils.c | 2 +- source/blender/draw/engines/overlay/overlay_outline.cc | 2 +- source/blender/draw/intern/shaders/common_gpencil_lib.glsl | 3 ++- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/startup/bl_ui/properties_data_gpencil.py b/scripts/startup/bl_ui/properties_data_gpencil.py index 9d95332a901..078aa583dc0 100644 --- a/scripts/startup/bl_ui/properties_data_gpencil.py +++ b/scripts/startup/bl_ui/properties_data_gpencil.py @@ -365,7 +365,6 @@ class DATA_PT_gpencil_strokes(DataButtonsPanel, Panel): col = layout.column(align=True) col.prop(gpd, "stroke_thickness_space") sub = col.column() - sub.active = gpd.stroke_thickness_space == 'WORLDSPACE' sub.prop(gpd, "pixel_factor", text="Thickness Scale") col.prop(gpd, "edit_curve_resolution") diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c index 4616fc48473..1895280a4aa 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c @@ -274,7 +274,7 @@ GPENCIL_tLayer *gpencil_layer_cache_add(GPENCIL_PrivateData *pd, pd->vertex_paint_opacity); /* Negate thickness sign to tag that strokes are in screen space. * Convert to world units (by default, 1 meter = 2000 pixels). */ - float thickness_scale = (is_screenspace) ? -1.0f : (gpd->pixfactor / GPENCIL_PIXEL_FACTOR); + float thickness_scale = (is_screenspace) ? -gpd->pixfactor : (gpd->pixfactor / GPENCIL_PIXEL_FACTOR); float layer_opacity = gpencil_layer_final_opacity_get(pd, ob, gpl); float layer_tint[4]; float layer_alpha; diff --git a/source/blender/draw/engines/overlay/overlay_outline.cc b/source/blender/draw/engines/overlay/overlay_outline.cc index 4fdbb33c0fa..0308d387fe4 100644 --- a/source/blender/draw/engines/overlay/overlay_outline.cc +++ b/source/blender/draw/engines/overlay/overlay_outline.cc @@ -191,7 +191,7 @@ static void gpencil_layer_cache_populate(bGPDlayer *gpl, float object_scale = mat4_to_scale(iter->ob->object_to_world); /* Negate thickness sign to tag that strokes are in screen space. * Convert to world units (by default, 1 meter = 2000 pixels). */ - float thickness_scale = (is_screenspace) ? -1.0f : (gpd->pixfactor / 2000.0f); + float thickness_scale = (is_screenspace) ? -gpd->pixfactor : (gpd->pixfactor / 2000.0f); GPUVertBuf *position_tx = DRW_cache_gpencil_position_buffer_get(iter->ob, iter->cfra); GPUVertBuf *color_tx = DRW_cache_gpencil_color_buffer_get(iter->ob, iter->cfra); diff --git a/source/blender/draw/intern/shaders/common_gpencil_lib.glsl b/source/blender/draw/intern/shaders/common_gpencil_lib.glsl index f48c355835a..62bfdfb6126 100644 --- a/source/blender/draw/intern/shaders/common_gpencil_lib.glsl +++ b/source/blender/draw/intern/shaders/common_gpencil_lib.glsl @@ -69,7 +69,8 @@ float gpencil_stroke_thickness_modulate(float thickness, vec4 ndc_pos, vec4 view if (gpThicknessIsScreenSpace) { /* Multiply offset by view Z so that offset is constant in screenspace. * (e.i: does not change with the distance to camera) */ - thickness *= ndc_pos.w; + thickness *= ndc_pos.w * + -gpThicknessWorldScale; // Multiply by positive world scale (default 1.0). } else { /* World space point size. */