Commit: 781a282caada36734a87ddcf43dbed09eef45f25
Author: Antonioya
Date:   Mon Mar 18 11:04:31 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB781a282caada36734a87ddcf43dbed09eef45f25

GPencil: Pass gradient basic data to point shader

===================================================================

M       source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M       source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
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 1cb44105537..2ca3bd4ac74 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -619,7 +619,7 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
 /* create shading group for points */
 static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
         GPENCIL_e_data *e_data, GPENCIL_Data *vedata, DRWPass *pass, GPUShader 
*shader, Object *ob,
-        bGPdata *gpd, bGPDlayer *gpl,
+        bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps,
         MaterialGPencilStyle *gp_style, int id, bool onion,
         const float scale, const int shading_type[2])
 {
@@ -659,6 +659,11 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
                DRW_shgroup_uniform_int(grp, "mode", &stl->shgroups[id].mode, 
1);
                DRW_shgroup_uniform_float(grp, "pixfactor", &gpd->pixfactor, 1);
 
+               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);
@@ -692,6 +697,10 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
                else {
                        DRW_shgroup_uniform_float(grp, "pixfactor", 
&stl->storage->pixfactor, 1);
                }
+
+               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 */
                stl->shgroups[id].is_xray = ((ob) && (ob->dt == OB_WIRE)) ? 1 : 
stl->storage->is_xray;
                DRW_shgroup_uniform_int(grp, "viewport_xray", (const int 
*)&stl->shgroups[id].is_xray, 1);
@@ -1398,7 +1407,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data 
*e_data, void *vedata, T
                                else {
                                        stl->g_data->shgrps_drawing_stroke = 
DRW_gpencil_shgroup_point_create(
                                                e_data, vedata, 
psl->drawing_pass, e_data->gpencil_point_sh, NULL,
-                                               gpd, NULL, gp_style, -1,
+                                               gpd, NULL, NULL, gp_style, -1,
                                                false, 1.0f, (const int 
*)stl->storage->shade_render);
                                }
 
@@ -1595,7 +1604,7 @@ static void DRW_gpencil_shgroups_create(
 
                                shgrp = DRW_gpencil_shgroup_point_create(
                                        e_data, vedata, stroke_pass, 
e_data->gpencil_point_sh,
-                                       ob, gpd, gpl, gp_style, 
stl->storage->shgroup_id, elm->onion,
+                                       ob, gpd, gpl, gps, gp_style, 
stl->storage->shgroup_id, elm->onion,
                                        scale, cache_ob->shading_type);
 
                                DRW_shgroup_call_range_add(
diff --git 
a/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl 
b/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
index a1285029e4c..7e222311295 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl
@@ -2,6 +2,9 @@ uniform int color_type;
 uniform int mode;
 uniform sampler2D myTexture;
 
+uniform float gradient_f;
+uniform vec2 gradient_s;
+
 in vec4 mColor;
 in vec2 mTexCoord;
 out vec4 fragColor;
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 53ff8d1709a..32d53fa9992 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl
@@ -58,8 +58,9 @@ void main()
        }
 
        /* gradient */
-       fragColor.a = gradient_f;
-
+       if (mTexCoord.y > gradient_f) {
+               fragColor.a = gradient_f;
+       }
 
        if(fragColor.a < 0.0035)
                discard;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to