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:
authorCampbell Barton <ideasman42@gmail.com>2017-07-12 17:27:06 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-07-12 18:59:44 +0300
commitb4988d01cbe9c850a365604967bd3a5e03fc9a72 (patch)
tree147a8bb95d09b9c1fd0efef6c4d09d34df85783e
parent95a7a0a06ebc7c88bc56c90bb4edfeef302694b7 (diff)
DwM: Option to use final material over mode shading
Support using full material shading in sculpt & paint modes mode. Access 'Full Shading' from the display panel when in paint modes.
-rw-r--r--release/scripts/startup/bl_ui/space_view3d.py3
-rw-r--r--source/blender/blenkernel/BKE_mesh.h1
-rw-r--r--source/blender/blenkernel/intern/paint.c3
-rw-r--r--source/blender/draw/engines/clay/clay_engine.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_engine.c2
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c21
-rw-r--r--source/blender/draw/intern/DRW_render.h3
-rw-r--r--source/blender/draw/intern/draw_cache.c8
-rw-r--r--source/blender/draw/intern/draw_cache.h2
-rw-r--r--source/blender/draw/intern/draw_cache_impl.h2
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c34
-rw-r--r--source/blender/draw/intern/draw_manager.c32
-rw-r--r--source/blender/draw/modes/paint_texture_mode.c9
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c3
-rw-r--r--source/blender/makesdna/DNA_view3d_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_space.c6
16 files changed, 109 insertions, 24 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index b3792686fc4..cac7066f762 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3266,6 +3266,9 @@ class VIEW3D_PT_view3d_display(Panel):
col.prop(view, "show_only_render")
col.prop(view, "show_world")
+ if context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE', 'SCULPT'}:
+ col.prop(view, "show_mode_shade_override")
+
col = layout.column()
display_all = not view.show_only_render
col.active = display_all
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index e6893dca928..9a94b9513f4 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -407,6 +407,7 @@ enum {
BKE_MESH_BATCH_DIRTY_SELECT,
BKE_MESH_BATCH_DIRTY_NOCHECK,
BKE_MESH_BATCH_DIRTY_SHADING,
+ BKE_MESH_BATCH_DIRTY_SCULPT_COORDS,
};
void BKE_mesh_batch_cache_dirty(struct Mesh *me, int mode);
void BKE_mesh_batch_cache_free(struct Mesh *me);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 00efa4aa732..c798a1587ee 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -929,6 +929,9 @@ void BKE_sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob,
}
}
}
+
+ /* 2.8x - avoid full mesh update! */
+ BKE_mesh_batch_cache_dirty(me, BKE_MESH_BATCH_DIRTY_SCULPT_COORDS);
}
int BKE_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd)
diff --git a/source/blender/draw/engines/clay/clay_engine.c b/source/blender/draw/engines/clay/clay_engine.c
index 00cc93a9db2..61edc7fa318 100644
--- a/source/blender/draw/engines/clay/clay_engine.c
+++ b/source/blender/draw/engines/clay/clay_engine.c
@@ -771,7 +771,7 @@ static void CLAY_cache_populate(void *vedata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_active = (ob == draw_ctx->obact);
if (is_active) {
- if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
+ if (DRW_object_is_mode_shade(ob) == true) {
return;
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index dd45d87b6e1..1f178fb1302 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -86,7 +86,7 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_active = (ob == draw_ctx->obact);
if (is_active) {
- if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
+ if (DRW_object_is_mode_shade(ob) == true) {
return;
}
}
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 57015e8a582..8b94ffb34c3 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -27,6 +27,7 @@
#include "DNA_world_types.h"
#include "DNA_modifier_types.h"
+#include "DNA_view3d_types.h"
#include "BLI_dynstr.h"
#include "BLI_ghash.h"
@@ -719,7 +720,7 @@ void EEVEE_materials_cache_init(EEVEE_Data *vedata)
}
#define ADD_SHGROUP_CALL(shgrp, ob, geom) do { \
- if (is_sculpt_mode) { \
+ if (is_sculpt_mode_draw) { \
DRW_shgroup_call_sculpt_add(shgrp, ob, ob->obmat); \
} \
else { \
@@ -927,11 +928,12 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sl
const bool do_cull = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_backface_culling");
const bool is_active = (ob == draw_ctx->obact);
const bool is_sculpt_mode = is_active && (ob->mode & OB_MODE_SCULPT) != 0;
+ const bool is_sculpt_mode_draw = is_sculpt_mode && (draw_ctx->v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE) == 0;
const bool is_default_mode_shader = is_sculpt_mode;
/* First get materials for this mesh. */
if (ELEM(ob->type, OB_MESH)) {
- const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol));
+ const int materials_len = MAX2(1, (is_sculpt_mode_draw ? 1 : ob->totcol));
struct DRWShadingGroup **shgrp_array = BLI_array_alloca(shgrp_array, materials_len);
struct DRWShadingGroup **shgrp_depth_array = BLI_array_alloca(shgrp_depth_array, materials_len);
@@ -943,13 +945,20 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sl
bool use_flat_nor = false;
if (is_default_mode_shader) {
- if (is_sculpt_mode) {
+ if (is_sculpt_mode_draw) {
use_flat_nor = DRW_object_is_flat_normal(ob);
}
}
for (int i = 0; i < materials_len; ++i) {
- Material *ma = give_current_material(ob, i + 1);
+ Material *ma;
+
+ if (is_sculpt_mode_draw) {
+ ma = NULL;
+ }
+ else {
+ ma = give_current_material(ob, i + 1);
+ }
gpumat_array[i] = NULL;
gpumat_depth_array[i] = NULL;
@@ -980,6 +989,10 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_SceneLayerData *sl
}
}
+ if (is_sculpt_mode && is_sculpt_mode_draw == false) {
+ DRW_cache_mesh_sculpt_coords_ensure(ob);
+ }
+
/* Get per-material split surface */
struct Gwn_Batch **mat_geom = DRW_cache_object_surface_material_get(ob, gpumat_array, materials_len);
if (mat_geom) {
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 51145b15237..ee1e14f8898 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -356,7 +356,8 @@ void DRW_lamp_engine_data_free(struct LampEngineData *led);
/* Settings */
bool DRW_object_is_renderable(struct Object *ob);
-bool DRW_object_is_flat_normal(struct Object *ob);
+bool DRW_object_is_flat_normal(const struct Object *ob);
+int DRW_object_is_mode_shade(const struct Object *ob);
/* Draw commands */
void DRW_draw_pass(DRWPass *pass);
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index b62559fdb0e..c0338de3d54 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -2287,6 +2287,14 @@ Gwn_Batch *DRW_cache_mesh_verts_weight_overlay_get(Object *ob)
return DRW_mesh_batch_cache_get_weight_overlay_verts(me);
}
+void DRW_cache_mesh_sculpt_coords_ensure(Object *ob)
+{
+ BLI_assert(ob->type == OB_MESH);
+
+ Mesh *me = ob->data;
+ DRW_mesh_cache_sculpt_coords_ensure(me);
+}
+
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index 21fa652778b..ac7062b3cc8 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -125,6 +125,8 @@ struct Gwn_Batch **DRW_cache_mesh_surface_shaded_get(
struct Gwn_Batch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob);
+void DRW_cache_mesh_sculpt_coords_ensure(struct Object *ob);
+
/* Curve */
struct Gwn_Batch *DRW_cache_curve_surface_get(struct Object *ob);
struct Gwn_Batch *DRW_cache_curve_surface_verts_get(struct Object *ob);
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 9328f6f6314..f8feeb37b82 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -96,6 +96,8 @@ struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_edges_nor(struct Mesh *
struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_loose_verts(struct Mesh *me);
struct Gwn_Batch *DRW_mesh_batch_cache_get_overlay_facedots(struct Mesh *me);
+void DRW_mesh_cache_sculpt_coords_ensure(struct Mesh *me);
+
/* Particles */
struct Gwn_Batch *DRW_particles_batch_cache_get_hair(struct ParticleSystem *psys, struct ModifierData *md);
struct Gwn_Batch *DRW_particles_batch_cache_get_dots(struct ParticleSystem *psys);
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index ae0e62809bb..f48d739f11b 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -1494,6 +1494,9 @@ typedef struct MeshBatchCache {
int vert_len;
int mat_len;
bool is_editmode;
+
+ /* XXX, only keep for as long as sculpt mode uses shaded drawing. */
+ bool is_sculpt_points_tag;
} MeshBatchCache;
/* Gwn_Batch cache management. */
@@ -1603,6 +1606,9 @@ void DRW_mesh_batch_cache_dirty(Mesh *me, int mode)
* and not free the entire cache. */
cache->is_really_dirty = true;
break;
+ case BKE_MESH_BATCH_DIRTY_SCULPT_COORDS:
+ cache->is_sculpt_points_tag = true;
+ break;
default:
BLI_assert(0);
}
@@ -3433,6 +3439,34 @@ Gwn_Batch *DRW_mesh_batch_cache_get_weight_overlay_verts(Mesh *me)
return cache->overlay_weight_verts;
}
+/**
+ * Needed for when we draw with shaded data.
+ */
+void DRW_mesh_cache_sculpt_coords_ensure(Mesh *me)
+{
+ if (me->batch_cache) {
+ MeshBatchCache *cache = mesh_batch_cache_get(me);
+ if (cache && cache->pos_with_normals && cache->is_sculpt_points_tag) {
+
+ const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY;
+ MeshRenderData *rdata = mesh_render_data_create(me, datatype);
+
+ Gwn_VertBuf *pos_with_normals = cache->pos_with_normals;
+ cache->pos_with_normals = NULL;
+ GWN_vertbuf_clear(pos_with_normals);
+ Gwn_VertBuf *vbo = mesh_batch_cache_get_tri_pos_and_normals(rdata, cache);
+ *pos_with_normals = *vbo;
+ GWN_vertformat_copy(&pos_with_normals->format, &vbo->format);
+
+ free(vbo);
+ cache->pos_with_normals = pos_with_normals;
+
+ mesh_render_data_free(rdata);
+ }
+ cache->is_sculpt_points_tag = false;
+ }
+}
+
/** \} */
#undef MESH_RENDER_FUNCTION
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 812280319e9..b93b7e21df2 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2045,11 +2045,10 @@ bool DRW_object_is_renderable(Object *ob)
return true;
}
-
-bool DRW_object_is_flat_normal(Object *ob)
+bool DRW_object_is_flat_normal(const Object *ob)
{
if (ob->type == OB_MESH) {
- Mesh *me = ob->data;
+ const Mesh *me = ob->data;
if (me->mpoly && me->mpoly[0].flag & ME_SMOOTH) {
return false;
}
@@ -2057,6 +2056,26 @@ bool DRW_object_is_flat_normal(Object *ob)
return true;
}
+
+/**
+ * Return true if the object has its own draw mode.
+ * Caller must check this is active */
+int DRW_object_is_mode_shade(const Object *ob)
+{
+ BLI_assert(ob == DST.draw_ctx.obact);
+ if ((ob->mode & OB_MODE_EDIT) == 0) {
+ if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) {
+ if ((DST.draw_ctx.v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE) == 0) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ }
+ }
+ return -1;
+}
+
/** \} */
@@ -2811,12 +2830,15 @@ static void DRW_engines_enable_external(void)
static void DRW_engines_enable(const Scene *scene, SceneLayer *sl)
{
- const int mode = CTX_data_mode_enum_ex(scene->obedit, OBACT_NEW);
+ Object *obact = OBACT_NEW;
+ const int mode = CTX_data_mode_enum_ex(scene->obedit, obact);
DRW_engines_enable_from_engine(scene);
if (DRW_state_draw_support()) {
DRW_engines_enable_from_object_mode();
- DRW_engines_enable_from_mode(mode);
+ if ((obact == NULL) || (DRW_object_is_mode_shade(obact) != false)) {
+ DRW_engines_enable_from_mode(mode);
+ }
}
}
diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c
index 795b0bae02b..ae6ee12ee7d 100644
--- a/source/blender/draw/modes/paint_texture_mode.c
+++ b/source/blender/draw/modes/paint_texture_mode.c
@@ -178,8 +178,7 @@ static void PAINT_TEXTURE_engine_init(void *vedata)
e_data.face_overlay_shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
}
}
-#include "BKE_global.h"
-#include "BKE_main.h"
+
/* Here init all passes and shading groups
* Assume that all Passes are NULL */
static void PAINT_TEXTURE_cache_init(void *vedata)
@@ -199,12 +198,6 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
DRW_STATE_BLEND | DRW_STATE_WIRE;
psl->image_faces = DRW_pass_create("Image Color Pass", state);
- /* Create a shadingGroup using a function in draw_common.c or custom one */
- /*
- * stl->g_data->group = shgroup_dynlines_uniform_color(psl->pass, ts.colorWire);
- * -- or --
- * stl->g_data->group = DRW_shgroup_create(e_data.custom_shader, psl->pass);
- */
stl->g_data->shgroup_fallback = DRW_shgroup_create(e_data.fallback_sh, psl->image_faces);
/* Uniforms need a pointer to it's value so be sure it's accessible at
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index b8e2724f786..9be196d1561 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4642,6 +4642,9 @@ static void sculpt_flush_update(bContext *C)
ED_region_tag_redraw_partial(ar, &r);
}
}
+
+ /* 2.8x - avoid full mesh update! */
+ BKE_mesh_batch_cache_dirty(ob->data, BKE_MESH_BATCH_DIRTY_SCULPT_COORDS);
}
/* Returns whether the mouse/stylus is over the mesh (1)
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index 22bb3cd5add..6a9b979596b 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -324,7 +324,7 @@ typedef struct View3D {
#define V3D_SOLID_MATCAP (1 << 12) /* user flag */
#define V3D_SHOW_SOLID_MATCAP (1 << 13) /* runtime flag */
#define V3D_OCCLUDE_WIRE (1 << 14)
-#define V3D_SHADELESS_TEX (1 << 15)
+#define V3D_SHOW_MODE_SHADE_OVERRIDE (1 << 15)
/* View3d->flag3 (short) */
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 2af13103805..a16380e70e9 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -2621,9 +2621,9 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Backface Culling", "Use back face culling to hide the back side of faces");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
- prop = RNA_def_property(srna, "show_textured_shadeless", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHADELESS_TEX);
- RNA_def_property_ui_text(prop, "Shadeless", "Show shadeless texture without lighting in textured draw mode");
+ prop = RNA_def_property(srna, "show_mode_shade_override", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_MODE_SHADE_OVERRIDE);
+ RNA_def_property_ui_text(prop, "Full Shading", "Use full shading for mode drawing (to view final result)");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_occlude_wire", PROP_BOOLEAN, PROP_NONE);