[Bf-blender-cvs] [f9023f51963] greasepencil-refactor: GPencil: Replace hardcoded factor by definition
Antonio Vazquez
noreply at git.blender.org
Wed Dec 18 10:54:53 CET 2019
Commit: f9023f519635611e97244713937677ee0a2b53fb
Author: Antonio Vazquez
Date: Wed Dec 18 10:54:44 2019 +0100
Branches: greasepencil-refactor
https://developer.blender.org/rBf9023f519635611e97244713937677ee0a2b53fb
GPencil: Replace hardcoded factor by definition
===================================================================
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
M source/blender/draw/engines/gpencil/gpencil_shader_fx.c
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index fe62d9ac824..85b125d0783 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -822,7 +822,7 @@ static void gp_layer_cache_populate(bGPDlayer *gpl,
float object_scale = mat4_to_scale(iter->ob->obmat);
/* Negate thickness sign to tag that strokes are in screen space.
* Convert to world units (by default, 1 meter = 2000 px). */
- float thickness_scale = (is_screenspace) ? -1.0f : (gpd->pixfactor / 2000.0f);
+ float thickness_scale = (is_screenspace) ? -1.0f : (gpd->pixfactor / GPENCIL_PIXEL_FACTOR);
struct GPUShader *sh = GPENCIL_shader_geometry_get(&en_data);
iter->grp = DRW_shgroup_create(sh, tgp_layer->geom_ps);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index a88181a32b7..8c5393a40d0 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -44,6 +44,9 @@ struct GPUVertFormat;
#define GPENCIL_MAX_SHGROUPS 65536
#define GPENCIL_GROUPS_BLOCK_SIZE 1024
+/* used to convert pixel scale. */
+#define GPENCIL_PIXEL_FACTOR 2000.0f
+
/* used to expand VBOs. Size has a big impact in the speed */
#define GPENCIL_VBO_BLOCK_SIZE 128
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index e11549c7968..16917593242 100644
--- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -1142,7 +1142,7 @@ static void gpencil_vfx_pixelize(PixelShaderFxData *fx, Object *ob, gpIterVfxDat
add_v2_fl(ob_center, 0.5f);
/* Modify by distance to camera and object scale. */
- float world_pixel_scale = 1.0f / 2000.0f;
+ float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR;
float scale = mat4_to_scale(ob->obmat);
mul_v2_fl(pixel_size, (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w);
@@ -1198,7 +1198,7 @@ static void gpencil_vfx_shadow(ShadowShaderFxData *fx, Object *ob, gpIterVfxData
mul_v3_fl(rot_center, 1.0f / w);
/* Modify by distance to camera and object scale. */
- float world_pixel_scale = 1.0f / 2000.0f;
+ float world_pixel_scale = 1.0f / GPENCIL_PIXEL_FACTOR;
float scale = mat4_to_scale(ob->obmat);
float distance_factor = (world_pixel_scale * scale * winmat[1][1] * vp_size[1]) / w;
mul_v2_fl(offset, distance_factor);
@@ -1392,4 +1392,4 @@ void gpencil_vfx_cache_populate(GPENCIL_Data *vedata, Object *ob, GPENCIL_tObjec
DRW_shgroup_uniform_int_copy(grp, "isFirstPass", false);
DRW_shgroup_call_procedural_triangles(grp, NULL, 1);
}
-}
\ No newline at end of file
+}
More information about the Bf-blender-cvs
mailing list