Commit: cd9c1c10e88c3fd1a028cdf2a711b4df234fbf17
Author: Antonioya
Date:   Sat Mar 2 13:58:59 2019 +0100
Branches: master
https://developer.blender.org/rBcd9c1c10e88c3fd1a028cdf2a711b4df234fbf17

GPencil: Fix Display Textures in Solid mode

There was a bug when selected Solid mode with Material or Texture mode. The 
textures were not visible.

Now, the mode is passed to shaders to decide if use the solid color or the 
result texture color. The mode is passed using an array with shading type and 
mode.

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

M       source/blender/draw/engines/gpencil/gpencil_cache_utils.c
M       source/blender/draw/engines/gpencil/gpencil_draw_utils.c
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
M       source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.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_cache_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
index f57ec5e974f..cf3025302ef 100644
--- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c
@@ -85,11 +85,11 @@ tGPencilObjectCache *gpencil_object_cache_add(
 
        /* save wire mode (object mode is always primary option) */
        if (ob->dt == OB_WIRE) {
-               cache_elem->shading_type = (int)OB_WIRE;
+               cache_elem->shading_type[0] = (int)OB_WIRE;
        }
        else {
                if (v3d) {
-                       cache_elem->shading_type = (int)v3d->shading.type;
+                       cache_elem->shading_type[0] = (int)v3d->shading.type;
                }
        }
 
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c 
b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 873b660ef53..3b2d5ec0825 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -268,11 +268,11 @@ static void set_wireframe_color(Object *ob, bGPDlayer 
*gpl, View3D *v3d,
 
        /* wire color */
        if ((v3d) && (id > -1)) {
-               const char type = (stl->shgroups[id].shading_type == OB_WIRE) ?
+               const char type = (stl->shgroups[id].shading_type[0] == 
OB_WIRE) ?
                                                        
v3d->shading.wire_color_type :
                                                        v3d->shading.color_type;
                /* if fill and wire, use background color */
-               if ((is_fill) && (stl->shgroups[id].shading_type == OB_WIRE)) {
+               if ((is_fill) && (stl->shgroups[id].shading_type[0] == 
OB_WIRE)) {
                        if (v3d->shading.background_type == 
V3D_SHADING_BACKGROUND_THEME) {
                                UI_GetThemeColor4fv(TH_BACK, 
stl->shgroups[id].wire_color);
                                stl->shgroups[id].wire_color[3] = 1.0f;
@@ -296,7 +296,7 @@ static void set_wireframe_color(Object *ob, bGPDlayer *gpl, 
View3D *v3d,
                switch (type) {
                        case V3D_SHADING_SINGLE_COLOR:
                        {
-                               if (stl->shgroups[id].shading_type == OB_WIRE) {
+                               if (stl->shgroups[id].shading_type[0] == 
OB_WIRE) {
                                        UI_GetThemeColor4fv(TH_WIRE, color);
                                }
                                else {
@@ -348,7 +348,7 @@ static void set_wireframe_color(Object *ob, bGPDlayer *gpl, 
View3D *v3d,
 static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(
         GPENCIL_e_data *e_data, GPENCIL_Data *vedata, DRWPass *pass,
         GPUShader *shader, Object *ob, bGPdata *gpd, bGPDlayer *gpl,
-        MaterialGPencilStyle *gp_style, int id, int shading_type)
+        MaterialGPencilStyle *gp_style, int id, int shading_type[2])
 {
        GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
        const DRWContextState *draw_ctx = DRW_context_state_get();
@@ -416,8 +416,14 @@ static DRWShadingGroup *DRW_gpencil_shgroup_fill_create(
        DRW_shgroup_uniform_int(grp, "viewport_xray", &stl->storage->is_xray, 
1);
 
        /* shading type */
-       stl->shgroups[id].shading_type = GPENCIL_USE_SOLID(stl) ? 
(int)OB_RENDER : shading_type;
-       DRW_shgroup_uniform_int(grp, "shading_type", 
&stl->shgroups[id].shading_type, 1);
+       stl->shgroups[id].shading_type[0] = GPENCIL_USE_SOLID(stl) ? 
(int)OB_RENDER : shading_type[0];
+       if (v3d) {
+               stl->shgroups[id].shading_type[1] = 
(stl->shgroups[id].shading_type[0] == OB_WIRE) ?
+                                                                               
        v3d->shading.wire_color_type :
+                                                                               
        v3d->shading.color_type;
+       }
+
+       DRW_shgroup_uniform_int(grp, "shading_type", 
&stl->shgroups[id].shading_type[0], 2);
 
        /* wire color */
        set_wireframe_color(ob, gpl, v3d, stl, gp_style, id, true);
@@ -475,7 +481,7 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
         GPENCIL_e_data *e_data, GPENCIL_Data *vedata, DRWPass *pass, GPUShader 
*shader, Object *ob,
         bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps,
         MaterialGPencilStyle *gp_style, int id,
-        bool onion, const float scale, int shading_type)
+        bool onion, const float scale, const int shading_type[2])
 {
        GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
        const float *viewport_size = DRW_viewport_size_get();
@@ -519,8 +525,13 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
                /* viewport x-ray */
                DRW_shgroup_uniform_int(grp, "viewport_xray", 
&stl->storage->is_xray, 1);
 
-               stl->shgroups[id].shading_type = (GPENCIL_USE_SOLID(stl) || 
onion) ? (int)OB_RENDER : shading_type;
-               DRW_shgroup_uniform_int(grp, "shading_type", 
&stl->shgroups[id].shading_type, 1);
+               stl->shgroups[id].shading_type[0] = (GPENCIL_USE_SOLID(stl) || 
onion) ? (int)OB_RENDER : shading_type[0];
+               if (v3d) {
+                       stl->shgroups[id].shading_type[1] = 
(stl->shgroups[id].shading_type[0] == OB_WIRE) ?
+                                                                               
                v3d->shading.wire_color_type :
+                                                                               
                v3d->shading.color_type;
+               }
+               DRW_shgroup_uniform_int(grp, "shading_type", 
&stl->shgroups[id].shading_type[0], 2);
 
                /* wire color */
                set_wireframe_color(ob, gpl, v3d, stl, gp_style, id, false);
@@ -545,8 +556,8 @@ DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
                /* viewport x-ray */
                DRW_shgroup_uniform_int(grp, "viewport_xray", 
&stl->storage->is_xray, 1);
 
-               stl->shgroups[id].shading_type = (int)OB_RENDER;
-               DRW_shgroup_uniform_int(grp, "shading_type", 
&stl->shgroups[id].shading_type, 1);
+               stl->shgroups[id].shading_type[0] = (int)OB_RENDER;
+               DRW_shgroup_uniform_int(grp, "shading_type", 
&stl->shgroups[id].shading_type[0], 2);
        }
 
        if ((gpd) && (id > -1)) {
@@ -591,7 +602,7 @@ 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,
         MaterialGPencilStyle *gp_style, int id, bool onion,
-        const float scale, int shading_type)
+        const float scale, const int shading_type[2])
 {
        GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
        const float *viewport_size = DRW_viewport_size_get();
@@ -632,8 +643,13 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
                /* viewport x-ray */
                DRW_shgroup_uniform_int(grp, "viewport_xray", 
&stl->storage->is_xray, 1);
 
-               stl->shgroups[id].shading_type = (GPENCIL_USE_SOLID(stl) || 
onion) ? (int)OB_RENDER : shading_type;
-               DRW_shgroup_uniform_int(grp, "shading_type", 
&stl->shgroups[id].shading_type, 1);
+               stl->shgroups[id].shading_type[0] = (GPENCIL_USE_SOLID(stl) || 
onion) ? (int)OB_RENDER : shading_type[0];
+               if (v3d) {
+                       stl->shgroups[id].shading_type[1] = 
(stl->shgroups[id].shading_type[0] == OB_WIRE) ?
+                                                                               
                v3d->shading.wire_color_type :
+                                                                               
                v3d->shading.color_type;
+               }
+               DRW_shgroup_uniform_int(grp, "shading_type", 
&stl->shgroups[id].shading_type[0], 2);
 
                /* wire color */
                set_wireframe_color(ob, gpl, v3d, stl, gp_style, id, false);
@@ -658,8 +674,8 @@ static DRWShadingGroup *DRW_gpencil_shgroup_point_create(
                /* viewport x-ray */
                DRW_shgroup_uniform_int(grp, "viewport_xray", 
&stl->storage->is_xray, 1);
 
-               stl->shgroups[id].shading_type = (int)OB_RENDER;
-               DRW_shgroup_uniform_int(grp, "shading_type", 
&stl->shgroups[id].shading_type, 1);
+               stl->shgroups[id].shading_type[0] = (int)OB_RENDER;
+               DRW_shgroup_uniform_int(grp, "shading_type", 
&stl->shgroups[id].shading_type[0], 2);
        }
 
        if (gpd) {
@@ -1318,7 +1334,7 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data 
*e_data, void *vedata, T
        bGPdata *gpd = (bGPdata *)DEG_get_original_id(&gpd_eval->id);
 
        MaterialGPencilStyle *gp_style = NULL;
-
+       const int shade_render[2] = { OB_RENDER, 0 };
        float obscale = mat4_to_scale(ob->obmat);
 
        /* use the brush material */
@@ -1346,12 +1362,12 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data 
*e_data, void *vedata, T
                                if ((gp_style) && (gp_style->mode == 
GP_STYLE_MODE_LINE)) {
                                        stl->g_data->shgrps_drawing_stroke = 
DRW_gpencil_shgroup_stroke_create(
                                                e_data, vedata, 
psl->drawing_pass, e_data->gpencil_stroke_sh, NULL,
-                                               gpd, NULL, NULL, gp_style, -1, 
false, 1.0f, (int)OB_RENDER);
+                                               gpd, NULL, NULL, gp_style, -1, 
false, 1.0f, shade_render);
                                }
                                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, false, 
1.0f, (int)OB_RENDER);
+                                               gpd, NULL, gp_style, -1, false, 
1.0f, shade_render);
                                }
 
                                /* clean previous version of the batch */
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c 
b/source/blender/draw/engines/gpencil/gpencil_engine.c
index d5d5c1e604d..74b3e7a6f4f 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -558,7 +558,7 @@ static void gpencil_add_draw_data(void *vedata, Object *ob)
        /* FX passses */
        cache_ob->has_fx = false;
        if ((!stl->storage->simplify_fx) &&
-           (!ELEM(cache_ob->shading_type, OB_WIRE, OB_SOLID)) &&
+           (!ELEM(cache_ob->shading_type[0], OB_WIRE, OB_SOLID)) &&
            (BKE_shaderfx_has_gpencil(ob)))
        {
                cache_ob->has_fx = true;
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h 
b/source/blender/draw/engines/gpencil/gpencil_engine.h
index 1b92f599246..0c917b038a4 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -93,7 +93,7 @@ typedef struct tGPencilObjectCache {
        float scale;
 
        /* shading type */
-       int shading_type;
+       int shading_type[2];
 
        /* GPU data size */
        int tot_vertex;
@@ -121,8 +121,8 @@ typedef struct GPENCIL_shgroup {
 
        /* color of the wireframe */
        float wire_color[4];
-       /* shading type */
-       int shading_type;
+       /* shading type and mode */
+       int shading_type[2];
 } GPENCIL_shgroup;
 
 typedef struct GPENCIL_Storage {
@@ -380,7 +380,7 @@ struct DRWShadingGroup *DRW_gpencil_shgroup_stroke_create(
         struct Object *ob, struct bGPdata *gpd,
         struct bGPDlayer *gpl, struct bGPDstroke *gps,
         struct MaterialGPencilStyle *gp_style, int id, bool onion,
-        const float scale, int shading_type);
+        const float scale, const int shading_type[2]);
 void DRW_gpencil_populate_datablock(
         struct GPENCIL_e_data *e_data, void *vedata,
         struct Object *ob, struct tGPencilObjectCache *cache_ob);
diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c 
b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
index 4b03075abc3..e4819f48eb1 100644
--- a/

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to