[Bf-blender-cvs] [d78a6369ad7] tmp-drw-callbatching: GPencil: Use custom obmat instead of common_view_lib
Clément Foucault
noreply at git.blender.org
Sat Aug 17 14:50:46 CEST 2019
Commit: d78a6369ad7a0b79e27cdb5501c17ecc0810b26b
Author: Clément Foucault
Date: Sat Jun 22 12:21:08 2019 +0200
Branches: tmp-drw-callbatching
https://developer.blender.org/rBd78a6369ad7a0b79e27cdb5501c17ecc0810b26b
GPencil: Use custom obmat instead of common_view_lib
===================================================================
M source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
M source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_vert.glsl
M source/blender/draw/engines/gpencil/shaders/gpencil_fill_vert.glsl
M source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
M source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 2892d0dbbaa..835c875d71d 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -359,6 +359,7 @@ static DRWShadingGroup *gpencil_shgroup_fill_create(GPENCIL_Data *vedata,
DRWPass *pass,
GPUShader *shader,
Object *ob,
+ float (*obmat)[4],
bGPdata *gpd,
bGPDlayer *gpl,
MaterialGPencilStyle *gp_style,
@@ -372,6 +373,8 @@ static DRWShadingGroup *gpencil_shgroup_fill_create(GPENCIL_Data *vedata,
/* e_data.gpencil_fill_sh */
DRWShadingGroup *grp = DRW_shgroup_create(shader, pass);
+ DRW_shgroup_uniform_mat4(grp, "gpModelMatrix", obmat);
+
DRW_shgroup_uniform_vec4(grp, "color2", gp_style->mix_rgba, 1);
/* set style type */
@@ -499,6 +502,7 @@ DRWShadingGroup *gpencil_shgroup_stroke_create(GPENCIL_Data *vedata,
DRWPass *pass,
GPUShader *shader,
Object *ob,
+ float (*obmat)[4],
bGPdata *gpd,
bGPDlayer *gpl,
bGPDstroke *gps,
@@ -520,6 +524,8 @@ DRWShadingGroup *gpencil_shgroup_stroke_create(GPENCIL_Data *vedata,
DRW_shgroup_uniform_float(grp, "pixsize", stl->storage->pixsize, 1);
+ DRW_shgroup_uniform_mat4(grp, "gpModelMatrix", obmat);
+
/* avoid wrong values */
if ((gpd) && (gpd->pixfactor == 0.0f)) {
gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
@@ -650,6 +656,7 @@ static DRWShadingGroup *gpencil_shgroup_point_create(GPENCIL_Data *vedata,
DRWPass *pass,
GPUShader *shader,
Object *ob,
+ float (*obmat)[4],
bGPdata *gpd,
bGPDlayer *gpl,
bGPDstroke *gps,
@@ -670,6 +677,8 @@ static DRWShadingGroup *gpencil_shgroup_point_create(GPENCIL_Data *vedata,
DRW_shgroup_uniform_vec2(grp, "Viewport", viewport_size, 1);
DRW_shgroup_uniform_float(grp, "pixsize", stl->storage->pixsize, 1);
+ DRW_shgroup_uniform_mat4(grp, "gpModelMatrix", obmat);
+
/* avoid wrong values */
if ((gpd) && (gpd->pixfactor == 0.0f)) {
gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
@@ -1506,6 +1515,9 @@ void gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data,
copy_v2_v2(stl->storage->gradient_s, brush->gpencil_settings->gradient_s);
stl->storage->alignment_mode = (gp_style) ? gp_style->alignment_mode : GP_STYLE_FOLLOW_PATH;
+ float unit_mat[4][4];
+ unit_m4(unit_mat);
+
/* if only one point, don't need to draw buffer because the user has no time to see it */
if (gpd->runtime.sbuffer_used > 1) {
if ((gp_style) && (gp_style->mode == GP_STYLE_MODE_LINE)) {
@@ -1514,6 +1526,7 @@ void gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data,
psl->drawing_pass,
e_data->gpencil_stroke_sh,
NULL,
+ unit_mat,
gpd,
NULL,
NULL,
@@ -1538,6 +1551,7 @@ void gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data,
psl->drawing_pass,
e_data->gpencil_point_sh,
NULL,
+ unit_mat,
gpd,
NULL,
NULL,
@@ -1718,6 +1732,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data,
stroke_pass,
e_data->gpencil_stroke_sh,
ob,
+ obmat,
gpd,
gpl,
gps,
@@ -1752,6 +1767,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data,
stroke_pass,
e_data->gpencil_point_sh,
ob,
+ obmat,
gpd,
gpl,
gps,
@@ -1780,6 +1796,7 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data,
stroke_pass,
e_data->gpencil_fill_sh,
ob,
+ obmat,
gpd,
gpl,
gp_style,
@@ -1801,6 +1818,9 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data,
case eGpencilBatchGroupType_Edit: {
if (stl->g_data->shgrps_edit_point) {
const int len = elm->vertex_idx - start_edit;
+
+ shgrp = DRW_shgroup_create_sub(stl->g_data->shgrps_edit_point);
+ DRW_shgroup_uniform_mat4(shgrp, "gpModelMatrix", obmat);
/* use always the same group */
DRW_shgroup_call_range_obmat(
stl->g_data->shgrps_edit_point, cache->b_edit.batch, obmat, start_edit, len);
@@ -1812,6 +1832,9 @@ static void gpencil_shgroups_create(GPENCIL_e_data *e_data,
case eGpencilBatchGroupType_Edlin: {
if (stl->g_data->shgrps_edit_line) {
const int len = elm->vertex_idx - start_edlin;
+
+ shgrp = DRW_shgroup_create_sub(stl->g_data->shgrps_edit_line);
+ DRW_shgroup_uniform_mat4(shgrp, "gpModelMatrix", obmat);
/* use always the same group */
DRW_shgroup_call_range_obmat(
stl->g_data->shgrps_edit_line, cache->b_edlin.batch, obmat, start_edlin, len);
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index bc83136fece..3a61521aed6 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -401,6 +401,7 @@ struct DRWShadingGroup *gpencil_shgroup_stroke_create(struct GPENCIL_Data *vedat
struct DRWPass *pass,
struct GPUShader *shader,
struct Object *ob,
+ float (*obmat)[4],
struct bGPdata *gpd,
struct bGPDlayer *gpl,
struct bGPDstroke *gps,
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_vert.glsl
index a1cfb2ae4ae..f75322f90e2 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_vert.glsl
@@ -1,4 +1,6 @@
+uniform mat4 gpModelMatrix;
+
in vec3 pos;
in vec4 color;
in float size;
@@ -8,7 +10,7 @@ out float finalThickness;
void main()
{
- gl_Position = point_object_to_ndc(pos);
+ gl_Position = point_world_to_ndc((gpModelMatrix * vec4(pos, 1.0)).xyz);
finalColor = color;
finalThickness = size;
}
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_vert.glsl
index eb452f4c660..263dc570423 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_vert.glsl
@@ -1,4 +1,6 @@
+uniform mat4 gpModelMatrix;
+
in vec3 pos;
in vec4 color;
in vec2 texCoord;
@@ -8,7 +10,7 @@ out vec2 texCoord_interp;
void main(void)
{
- gl_Position = point_object_to_ndc(pos);
+ gl_Position = point_world_to_ndc((gpModelMatrix * vec4(pos, 1.0)).xyz);
finalColor = color;
texCoord_interp = texCoord;
}
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
index ef8b361373f..87963c66858 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
@@ -6,6 +6,7 @@ uniform float pixfactor;
uniform int viewport_xray;
uniform int shading_type[2];
uniform vec4 wire_color;
+uniform mat4 gpModelMatrix;
in vec3 pos;
in vec4 color;
@@ -30,8 +31,8 @@ float defaultpixsize = pixsize * (1000.0 / pixfactor);
void main()
{
- gl_Position = point_object_to_ndc(pos);
- finalprev_pos = point_object_to_ndc(prev_pos);
+ gl_Position = point_world_to_ndc((gpModelMatrix * vec4(pos, 1.0)).xyz);
+ finalprev_pos = point_world_to_ndc((gpModelMatrix * vec4(prev_pos, 1.0)).xyz);
finalColor = color;
if (keep_size == TRUE) {
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
index c7089f357f9..582b9a7f249 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
@@ -6,6 +6,7 @@ uniform float
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list