[Bf-blender-cvs] [4ca31474ef6] greasepencil-object: GPencil: Pass basic data to shaders for gradients (wip)
Antonioya
noreply at git.blender.org
Tue Mar 19 14:07:43 CET 2019
Commit: 4ca31474ef6a3876b651102310d673eee7f81326
Author: Antonioya
Date: Mon Mar 18 10:50:07 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB4ca31474ef6a3876b651102310d673eee7f81326
GPencil: Pass basic data to shaders for gradients (wip)
===================================================================
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_stroke_frag.glsl
===================================================================
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 2710ecc5e5b..1cb44105537 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -532,6 +532,11 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
stl->shgroups[id].caps_mode[1] = gps->caps[1];
DRW_shgroup_uniform_int(grp, "caps_mode", &stl->shgroups[id].caps_mode[0], 2);
+ stl->shgroups[id].gradient_f = gps->gradient_f;
+ copy_v2_v2(stl->shgroups[id].gradient_s, gps->gradient_s);
+ DRW_shgroup_uniform_float(grp, "gradient_f", &stl->shgroups[id].gradient_f, 1);
+ DRW_shgroup_uniform_vec2(grp, "gradient_s", stl->shgroups[id].gradient_s, 1);
+
/* viewport x-ray */
stl->shgroups[id].is_xray = (ob->dt == OB_WIRE) ? 1 : stl->storage->is_xray;
DRW_shgroup_uniform_int(grp, "viewport_xray", (const int *)&stl->shgroups[id].is_xray, 1);
@@ -565,6 +570,9 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
const int zero[2] = { 0, 0 };
DRW_shgroup_uniform_int(grp, "caps_mode", &zero[0], 2);
+ DRW_shgroup_uniform_float(grp, "gradient_f", &stl->storage->gradient_f, 1);
+ DRW_shgroup_uniform_vec2(grp, "gradient_s", stl->storage->gradient_s, 1);
+
/* viewport x-ray */
DRW_shgroup_uniform_int(grp, "viewport_xray", &stl->storage->is_xray, 1);
DRW_shgroup_uniform_int(grp, "shading_type", (const int *)&stl->storage->shade_render, 2);
@@ -1374,6 +1382,11 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
* i.e. tGPspoints NOT bGPDspoints
*/
short lthick = brush->size * obscale;
+
+ /* save gradient info */
+ stl->storage->gradient_f = brush->gpencil_settings->gradient_f;
+ copy_v2_v2(stl->storage->gradient_s, brush->gpencil_settings->gradient_s);
+
/* if only one point, don't need to draw buffer because the user has no time to see it */
if (gpd->runtime.sbuffer_size > 1) {
if ((gp_style) && (gp_style->mode == GP_STYLE_MODE_LINE)) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 860dd728805..7a5546646a4 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -120,6 +120,9 @@ typedef struct GPENCIL_shgroup {
float obj_scale;
int xray_mode;
+ float gradient_f;
+ float gradient_s[2];
+
/* color of the wireframe */
float wire_color[4];
/* shading type and mode */
@@ -164,6 +167,9 @@ typedef struct GPENCIL_Storage {
bool simplify_fx;
bool simplify_blend;
+ float gradient_f;
+ float gradient_s[2];
+
/* Render Matrices and data */
float persmat[4][4], persinv[4][4];
float viewmat[4][4], viewinv[4][4];
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
index 80fa899b13a..53ff8d1709a 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
@@ -1,6 +1,9 @@
uniform int color_type;
uniform sampler2D myTexture;
+uniform float gradient_f;
+uniform vec2 gradient_s;
+
in vec4 mColor;
in vec2 mTexCoord;
in vec2 uvfac;
@@ -54,6 +57,10 @@ void main()
fragColor.a = min(text_color.a * tColor.a, tColor.a);
}
+ /* gradient */
+ fragColor.a = gradient_f;
+
+
if(fragColor.a < 0.0035)
discard;
}
More information about the Bf-blender-cvs
mailing list