Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2019-03-02 15:58:59 +0300
committerAntonioya <blendergit@gmail.com>2019-03-02 15:59:18 +0300
commitcd9c1c10e88c3fd1a028cdf2a711b4df234fbf17 (patch)
tree76a0e2cd49b639e16dc93d15c9ffb07f8b27dded /source/blender/draw
parent10d41e48b8abd6f60f3dc379a8a0b5b5eb4889b4 (diff)
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.
Diffstat (limited to 'source/blender/draw')
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_cache_utils.c4
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_draw_utils.c54
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.c2
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_engine.h8
-rw-r--r--source/blender/draw/engines/gpencil/gpencil_shader_fx.c2
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl23
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl17
-rw-r--r--source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl17
8 files changed, 76 insertions, 51 deletions
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/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
+++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c
@@ -746,7 +746,7 @@ void DRW_gpencil_fx_prepare(
tGPencilObjectCache *cache_ob)
{
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
- const bool wiremode = (bool)(cache_ob->shading_type == OB_WIRE);
+ const bool wiremode = (bool)(cache_ob->shading_type[0] == OB_WIRE);
int ob_idx = cache_ob->idx;
diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
index 78fbb21a552..b35970780a4 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl
@@ -22,7 +22,7 @@ uniform sampler2D myTexture;
uniform int texture_clamp;
uniform int viewport_xray;
-uniform int shading_type;
+uniform int shading_type[2];
uniform vec4 wire_color;
/* keep this list synchronized with list in gpencil_draw_utils.c */
@@ -43,6 +43,9 @@ uniform vec4 wire_color;
#define OB_WIRE 2
#define OB_SOLID 3
+#define V3D_SHADING_MATERIAL_COLOR 0
+#define V3D_SHADING_TEXTURE_COLOR 3
+
in vec4 finalColor;
in vec2 texCoord_interp;
out vec4 fragColor;
@@ -92,7 +95,7 @@ void main()
vec4 chesscolor;
/* wireframe with x-ray discard */
- if ((viewport_xray == 1) && (shading_type == OB_WIRE)) {
+ if ((viewport_xray == 1) && (shading_type[0] == OB_WIRE)) {
discard;
}
@@ -168,18 +171,18 @@ void main()
}
/* if wireframe override colors */
- if (shading_type == OB_WIRE) {
+ if (shading_type[0] == OB_WIRE) {
fragColor = wire_color;
}
- /* solid with x-ray discard */
- if (shading_type == OB_SOLID) {
- if (viewport_xray == 1) {
- /* use 50% of color */
- fragColor = vec4(wire_color.rgb, wire_color.a * 0.5);
- }
- else {
+
+ /* for solid override color */
+ if (shading_type[0] == OB_SOLID) {
+ if ((shading_type[1] != V3D_SHADING_MATERIAL_COLOR) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR)) {
fragColor = wire_color;
}
+ if (viewport_xray == 1) {
+ fragColor.a *= 0.5;
+ }
}
}
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 20ca2cf9c2f..b367d15f1f9 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl
@@ -6,7 +6,7 @@ uniform int keep_size;
uniform float objscale;
uniform float pixfactor;
uniform int viewport_xray;
-uniform int shading_type;
+uniform int shading_type[2];
uniform vec4 wire_color;
in vec3 pos;
@@ -23,6 +23,9 @@ out vec2 finaluvdata;
#define OB_WIRE 2
#define OB_SOLID 3
+#define V3D_SHADING_MATERIAL_COLOR 0
+#define V3D_SHADING_TEXTURE_COLOR 3
+
float defaultpixsize = pixsize * (1000.0 / pixfactor);
void main()
@@ -39,18 +42,18 @@ void main()
}
/* for wireframe override size and color */
- if (shading_type == OB_WIRE) {
+ if (shading_type[0] == OB_WIRE) {
finalThickness = 2.0;
finalColor = wire_color;
}
/* for solid override color */
- if (shading_type == OB_SOLID) {
- if (viewport_xray == 1) {
- finalColor = vec4(wire_color.rgb, wire_color.a * 0.5);
- }
- else {
+ if (shading_type[0] == OB_SOLID) {
+ if ((shading_type[1] != V3D_SHADING_MATERIAL_COLOR) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR)) {
finalColor = wire_color;
}
+ if (viewport_xray == 1) {
+ finalColor.a *= 0.5;
+ }
}
finaluvdata = uvdata;
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 f58f5a3c051..3c6768dd483 100644
--- a/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
+++ b/source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl
@@ -6,7 +6,7 @@ uniform int keep_size;
uniform float objscale;
uniform float pixfactor;
uniform int viewport_xray;
-uniform int shading_type;
+uniform int shading_type[2];
uniform vec4 wire_color;
in vec3 pos;
@@ -23,6 +23,9 @@ out vec2 finaluvdata;
#define OB_WIRE 2
#define OB_SOLID 3
+#define V3D_SHADING_MATERIAL_COLOR 0
+#define V3D_SHADING_TEXTURE_COLOR 3
+
float defaultpixsize = pixsize * (1000.0 / pixfactor);
void main(void)
@@ -39,18 +42,18 @@ void main(void)
}
/* for wireframe override size and color */
- if (shading_type == OB_WIRE) {
+ if (shading_type[0] == OB_WIRE) {
finalThickness = 1.0;
finalColor = wire_color;
}
/* for solid override color */
- if (shading_type == OB_SOLID) {
- if (viewport_xray == 1) {
- finalColor = vec4(wire_color.rgb, wire_color.a * 0.5);
- }
- else {
+ if (shading_type[0] == OB_SOLID) {
+ if ((shading_type[1] != V3D_SHADING_MATERIAL_COLOR) && (shading_type[1] != V3D_SHADING_TEXTURE_COLOR)) {
finalColor = wire_color;
}
+ if (viewport_xray == 1) {
+ finalColor.a *= 0.5;
+ }
}
finaluvdata = uvdata;