[Bf-blender-cvs] [7d12d8956de] blender2.8: Sculpt: Move sculpt drawing to engines.
Clément Foucault
noreply at git.blender.org
Fri May 12 18:02:57 CEST 2017
Commit: 7d12d8956ded188f8d0a7c8589e715e8a2e33742
Author: Clément Foucault
Date: Fri May 12 17:54:14 2017 +0200
Branches: blender2.8
https://developer.blender.org/rB7d12d8956ded188f8d0a7c8589e715e8a2e33742
Sculpt: Move sculpt drawing to engines.
Only mask are handled by sculpt mode engine and are multiplied on top of the render.
There is room for improvement:
- Shaded meshes don't have correct tangents or uvs.
- Masks are in range 0.8 - 0.2 thus always darkening at least 20% the render.
- It only uses the first material slot of the mesh.
===================================================================
M source/blender/blenkernel/BKE_pbvh.h
M source/blender/blenkernel/intern/pbvh.c
M source/blender/draw/engines/clay/clay_engine.c
M source/blender/draw/engines/eevee/eevee_engine.c
M source/blender/draw/intern/DRW_render.h
M source/blender/draw/intern/draw_manager.c
M source/blender/draw/modes/sculpt_mode.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 53180713cf9..27c6814b959 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -358,6 +358,7 @@ bool BKE_pbvh_node_vert_update_check_any(PBVH *bvh, PBVHNode *node);
//void BKE_pbvh_node_BB_reset(PBVHNode *node);
//void BKE_pbvh_node_BB_expand(PBVHNode *node, float co[3]);
+bool pbvh_has_mask(PBVH *bvh);
void pbvh_show_diffuse_color_set(PBVH *bvh, bool show_diffuse_color);
#endif /* __BKE_PBVH_H__ */
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 69028a0c96c..33901d3c0d0 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -2117,22 +2117,22 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node,
vi->vmask = CustomData_get_layer(bvh->vdata, CD_PAINT_MASK);
}
-void pbvh_show_diffuse_color_set(PBVH *bvh, bool show_diffuse_color)
+bool pbvh_has_mask(PBVH *bvh)
{
- bool has_mask = false;
-
switch (bvh->type) {
case PBVH_GRIDS:
- has_mask = (bvh->gridkey.has_mask != 0);
- break;
+ return (bvh->gridkey.has_mask != 0);
case PBVH_FACES:
- has_mask = (bvh->vdata && CustomData_get_layer(bvh->vdata,
- CD_PAINT_MASK));
- break;
+ return (bvh->vdata && CustomData_get_layer(bvh->vdata,
+ CD_PAINT_MASK));
case PBVH_BMESH:
- has_mask = (bvh->bm && (CustomData_get_offset(&bvh->bm->vdata, CD_PAINT_MASK) != -1));
- break;
+ return (bvh->bm && (CustomData_get_offset(&bvh->bm->vdata, CD_PAINT_MASK) != -1));
}
- bvh->show_diffuse_color = !has_mask || show_diffuse_color;
+ return false;
+}
+
+void pbvh_show_diffuse_color_set(PBVH *bvh, bool show_diffuse_color)
+{
+ bvh->show_diffuse_color = !pbvh_has_mask(bvh) || show_diffuse_color;
}
diff --git a/source/blender/draw/engines/clay/clay_engine.c b/source/blender/draw/engines/clay/clay_engine.c
index 95ddb3cc6fa..f7cb606b7ae 100644
--- a/source/blender/draw/engines/clay/clay_engine.c
+++ b/source/blender/draw/engines/clay/clay_engine.c
@@ -746,17 +746,30 @@ static void CLAY_cache_populate(void *vedata, Object *ob)
if (!DRW_object_is_renderable(ob))
return;
+ bool sculpt_mode = ob->mode & OB_MODE_SCULPT;
+
struct Batch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
IDProperty *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
bool do_cull = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_backface_culling");
/* Depth Prepass */
- DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat);
+ if (sculpt_mode) {
+ DRW_shgroup_call_sculpt_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, ob, ob->obmat);
+ }
+ else {
+ DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat);
+ }
/* Shading */
clay_shgrp = CLAY_object_shgrp_get(vedata, ob, stl, psl);
- DRW_shgroup_call_add(clay_shgrp, geom, ob->obmat);
+
+ if (sculpt_mode) {
+ DRW_shgroup_call_sculpt_add(clay_shgrp, ob, ob->obmat);
+ }
+ else {
+ DRW_shgroup_call_add(clay_shgrp, geom, ob->obmat);
+ }
}
if (ob->type == OB_MESH) {
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index 8c6085f1a04..8ab07685c9d 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -552,18 +552,25 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
EEVEE_TextureList *txl = ((EEVEE_Data *)vedata)->txl;
EEVEE_PassList *psl = ((EEVEE_Data *)vedata)->psl;
+ bool sculpt_mode = ob->mode & OB_MODE_SCULPT;
+
struct Batch *geom = DRW_cache_object_surface_get(ob);
if (geom) {
IDProperty *ces_mode_ob = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_OBJECT, "");
const bool do_cull = BKE_collection_engine_property_value_get_bool(ces_mode_ob, "show_backface_culling");
/* Depth Prepass */
- DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat);
+ if (sculpt_mode) {
+ DRW_shgroup_call_sculpt_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, ob, ob->obmat);
+ }
+ else {
+ DRW_shgroup_call_add((do_cull) ? stl->g_data->depth_shgrp_cull : stl->g_data->depth_shgrp, geom, ob->obmat);
+ }
/* Get per-material split surface */
struct Batch **mat_geom = DRW_cache_object_surface_material_get(ob);
if (mat_geom) {
- for (int i = 0; i < MAX2(1, ob->totcol); ++i) {
+ for (int i = 0; i < MAX2(1, (sculpt_mode ? 1 : ob->totcol)); ++i) {
Material *ma = give_current_material(ob, i + 1);
if (ma == NULL)
@@ -583,10 +590,7 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
"#define MAX_CASCADE_NUM 4\n");
DRWShadingGroup *shgrp = DRW_shgroup_material_create(gpumat, psl->material_pass);
-
if (shgrp) {
- DRW_shgroup_call_add(shgrp, mat_geom[i], ob->obmat);
-
DRW_shgroup_uniform_block(shgrp, "light_block", stl->light_ubo);
DRW_shgroup_uniform_block(shgrp, "shadow_block", stl->shadow_ubo);
DRW_shgroup_uniform_int(shgrp, "light_count", &stl->lamps->num_light, 1);
@@ -596,6 +600,13 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
DRW_shgroup_uniform_texture(shgrp, "ltcMat", e_data.ltc_mat);
DRW_shgroup_uniform_texture(shgrp, "brdfLut", e_data.brdf_lut);
DRW_shgroup_uniform_texture(shgrp, "probeFiltered", txl->probe_pool);
+
+ if (sculpt_mode) {
+ DRW_shgroup_call_sculpt_add(shgrp, ob, ob->obmat);
+ }
+ else {
+ DRW_shgroup_call_add(shgrp, mat_geom[i], ob->obmat);
+ }
}
else {
/* Shader failed : pink color */
@@ -609,7 +620,13 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
DRW_shgroup_uniform_texture(stl->g_data->default_lit_grp, "ltcMat", e_data.ltc_mat);
DRW_shgroup_uniform_texture(stl->g_data->default_lit_grp, "brdfLut", e_data.brdf_lut);
DRW_shgroup_uniform_texture(stl->g_data->default_lit_grp, "probeFiltered", txl->probe_pool);
- DRW_shgroup_call_add(shgrp, mat_geom[i], ob->obmat);
+
+ if (sculpt_mode) {
+ DRW_shgroup_call_sculpt_add(shgrp, ob, ob->obmat);
+ }
+ else {
+ DRW_shgroup_call_add(shgrp, mat_geom[i], ob->obmat);
+ }
}
}
else {
@@ -620,9 +637,14 @@ static void EEVEE_cache_populate(void *vedata, Object *ob)
DRW_shgroup_uniform_texture(stl->g_data->default_lit_grp, "ltcMat", e_data.ltc_mat);
DRW_shgroup_uniform_texture(stl->g_data->default_lit_grp, "brdfLut", e_data.brdf_lut);
DRW_shgroup_uniform_texture(stl->g_data->default_lit_grp, "probeFiltered", txl->probe_pool);
- DRW_shgroup_call_add(shgrp, mat_geom[i], ob->obmat);
- }
+ if (sculpt_mode) {
+ DRW_shgroup_call_sculpt_add(shgrp, ob, ob->obmat);
+ }
+ else {
+ DRW_shgroup_call_add(shgrp, mat_geom[i], ob->obmat);
+ }
+ }
}
}
// GPUMaterial *gpumat = GPU_material_from_nodetree(struct bNodeTree *ntree, ListBase *gpumaterials, void *engine_type, int options)
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 8f1ee805584..652d79980e7 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -245,6 +245,7 @@ typedef enum {
DRW_STATE_STIPPLE_4 = (1 << 12),
DRW_STATE_BLEND = (1 << 13),
DRW_STATE_ADDITIVE = (1 << 14),
+ DRW_STATE_MULTIPLY = (1 << 15),
DRW_STATE_WRITE_STENCIL_SELECT = (1 << 27),
DRW_STATE_WRITE_STENCIL_ACTIVE = (1 << 28),
@@ -256,7 +257,6 @@ typedef enum {
DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass);
-DRWShadingGroup *DRW_shgroup_create_fn(struct GPUShader *shader, DRWPass *pass);
DRWShadingGroup *DRW_shgroup_material_create(struct GPUMaterial *material, DRWPass *pass);
DRWShadingGroup *DRW_shgroup_material_instance_create(struct GPUMaterial *material, DRWPass *pass, struct Batch *geom);
DRWShadingGroup *DRW_shgroup_instance_create(struct GPUShader *shader, DRWPass *pass, struct Batch *geom);
@@ -271,6 +271,7 @@ typedef void (DRWCallGenerateFn)(
void DRW_shgroup_free(struct DRWShadingGroup *shgroup);
void DRW_shgroup_call_add(DRWShadingGroup *shgroup, struct Batch *geom, float (*obmat)[4]);
+void DRW_shgroup_call_sculpt_add(DRWShadingGroup *shgroup, struct Object *ob, float (*obmat)[4]);
void DRW_shgroup_call_generate_add(
DRWShadingGroup *shgroup, DRWCallGenerateFn *geometry_fn, void *user_data, float (*obmat)[4]);
void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *attr[], unsigned int attr_len);
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 1d98fe94961..a6f6b14a1d7 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -34,6 +34,8 @@
#include "BKE_depsgraph.h"
#include "BKE_global.h"
+#include "BKE_pbvh.h"
+#include "BKE_paint.h"
#include "BLT_translation.h"
#include "BLF_api.h"
@@ -192,6 +194,7 @@ typedef struct DRWCall {
#ifdef USE_GPU_SELECT
int select_id;
#endif
+ int type;
float (*obmat)[4];
Batch *geometry;
} DRWCall;
@@ -201,6 +204,7 @@ typedef struct DRWCallGenerate {
#ifdef USE_GPU_SELECT
int select_id;
#endif
+ int type;
float (*obmat)[4];
DRWCallGenerateFn *geometry_fn;
@@ -236,14 +240,18 @@ struct DRWShadingGroup {
/* Used by DRWShadingGroup.type */
enum {
DRW_SHG_NORMAL,
- /* same as 'DRW_SHG_NORMAL' but use a callback to generate geometry */
- DRW_SHG_NORMAL_GENERATE,
DRW_SHG_POINT_BATCH,
DRW_SHG_LINE_BATCH,
DRW_SHG_TRIANGLE_BATCH,
DRW_SHG_INSTANCE,
};
+/* Used by DRWCall.type */
+enum {
+ DRW_CALL_SINGLE,
+ DRW_CALL_GENERATE,
+};
+
/* only 16 bits long */
enum {
STENCIL_SELECT = (1 << 0),
@@ -662,15 +670,6 @@ DRWShadingGroup *DRW_shgroup_create(struct GPUShader *shader, DRWPass *pass)
return shgroup;
}
-DRWShadingGroup *DRW_sh
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list