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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-02 17:05:23 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-02 17:05:23 +0300
commit43e6bb85cee0802887eae9489a2bd73836daf41d (patch)
treeeaa106429af8341bf2123d7445fdab0af71b3dda /source/blender/draw/modes
parent7daeb1f9aee284d958abe87622b43c70c21af967 (diff)
parentffaf91b5fc03f91e1fc90bd2f1d5dc5aa75656ff (diff)
Merge 'master' into 'collada'
Diffstat (limited to 'source/blender/draw/modes')
-rw-r--r--source/blender/draw/modes/edit_armature_mode.c1
-rw-r--r--source/blender/draw/modes/edit_mesh_mode.c64
-rw-r--r--source/blender/draw/modes/edit_mesh_mode_text.c13
-rw-r--r--source/blender/draw/modes/edit_metaball_mode.c2
-rw-r--r--source/blender/draw/modes/object_mode.c47
-rw-r--r--source/blender/draw/modes/overlay_mode.c3
-rw-r--r--source/blender/draw/modes/paint_texture_mode.c2
-rw-r--r--source/blender/draw/modes/pose_mode.c16
-rw-r--r--source/blender/draw/modes/sculpt_mode.c12
-rw-r--r--source/blender/draw/modes/shaders/common_fxaa_lib.glsl8
-rw-r--r--source/blender/draw/modes/shaders/common_hair_lib.glsl4
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_common_lib.glsl36
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl12
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl31
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl14
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl23
-rw-r--r--source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl12
-rw-r--r--source/blender/draw/modes/shaders/object_grid_frag.glsl4
-rw-r--r--source/blender/draw/modes/shaders/particle_strand_vert.glsl4
-rw-r--r--source/blender/draw/modes/shaders/sculpt_mask_vert.glsl3
20 files changed, 222 insertions, 89 deletions
diff --git a/source/blender/draw/modes/edit_armature_mode.c b/source/blender/draw/modes/edit_armature_mode.c
index 12bf4982ffb..d1ef0d0e104 100644
--- a/source/blender/draw/modes/edit_armature_mode.c
+++ b/source/blender/draw/modes/edit_armature_mode.c
@@ -126,6 +126,7 @@ static void EDIT_ARMATURE_cache_populate(void *vedata, Object *ob)
.bone_envelope = psl->bone_envelope[ghost],
.bone_axes = psl->bone_axes,
.relationship_lines = psl->relationship[ghost],
+ .custom_shapes = NULL, /* Not needed in edit mode. */
};
DRW_shgroup_armature_edit(ob, passes, transp);
}
diff --git a/source/blender/draw/modes/edit_mesh_mode.c b/source/blender/draw/modes/edit_mesh_mode.c
index b3b6acf9b7d..ffe7fe5845c 100644
--- a/source/blender/draw/modes/edit_mesh_mode.c
+++ b/source/blender/draw/modes/edit_mesh_mode.c
@@ -55,6 +55,8 @@ extern char datatoc_edit_mesh_overlay_geom_glsl[];
extern char datatoc_edit_mesh_overlay_mix_frag_glsl[];
extern char datatoc_edit_mesh_overlay_facefill_vert_glsl[];
extern char datatoc_edit_mesh_overlay_facefill_frag_glsl[];
+extern char datatoc_edit_mesh_overlay_mesh_analysis_frag_glsl[];
+extern char datatoc_edit_mesh_overlay_mesh_analysis_vert_glsl[];
extern char datatoc_edit_normals_vert_glsl[];
extern char datatoc_edit_normals_geom_glsl[];
extern char datatoc_common_globals_lib_glsl[];
@@ -75,6 +77,7 @@ typedef struct EDIT_MESH_PassList {
struct DRWPass *edit_face_occluded;
struct DRWPass *mix_occlude;
struct DRWPass *facefill_occlude;
+ struct DRWPass *mesh_analysis_pass;
struct DRWPass *normals;
} EDIT_MESH_PassList;
@@ -115,6 +118,10 @@ typedef struct EDIT_MESH_Shaders {
GPUShader *normals_loop;
GPUShader *normals;
GPUShader *depth;
+
+ /* Mesh analysis shader */
+ GPUShader *mesh_analysis_face;
+ GPUShader *mesh_analysis_vertex;
} EDIT_MESH_Shaders;
/* *********** STATIC *********** */
@@ -149,6 +156,7 @@ typedef struct EDIT_MESH_PrivateData {
DRWShadingGroup *facedot_shgrp_in_front;
DRWShadingGroup *facefill_occluded_shgrp;
+ DRWShadingGroup *mesh_analysis_shgrp;
int data_mask[4];
int ghost_ob;
@@ -278,6 +286,22 @@ static void EDIT_MESH_engine_init(void *vedata)
.defs = (const char *[]){sh_cfg_data->def, NULL},
});
+ /* Mesh Analysis */
+ sh_data->mesh_analysis_face = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib,
+ datatoc_edit_mesh_overlay_mesh_analysis_vert_glsl,
+ NULL},
+ .frag = (const char *[]){datatoc_edit_mesh_overlay_mesh_analysis_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, "#define FACE_COLOR\n", NULL},
+ });
+ sh_data->mesh_analysis_vertex = GPU_shader_create_from_arrays({
+ .vert = (const char *[]){sh_cfg_data->lib,
+ datatoc_edit_mesh_overlay_mesh_analysis_vert_glsl,
+ NULL},
+ .frag = (const char *[]){datatoc_edit_mesh_overlay_mesh_analysis_frag_glsl, NULL},
+ .defs = (const char *[]){sh_cfg_data->def, "#define VERTEX_COLOR\n", NULL},
+ });
+
sh_data->depth = DRW_shader_create_3d_depth_only(draw_ctx->sh_cfg);
}
}
@@ -300,8 +324,6 @@ static DRWPass *edit_mesh_create_overlay_pass(float *face_alpha,
const bool select_vert = (tsettings->selectmode & SCE_SELECT_VERTEX) != 0;
const bool select_face = (tsettings->selectmode & SCE_SELECT_FACE) != 0;
const bool select_edge = (tsettings->selectmode & SCE_SELECT_EDGE) != 0;
- const bool show_wide_edge = select_edge &&
- !(draw_ctx->v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_DOT);
float winmat[4][4];
float viewdist = rv3d->dist;
@@ -336,8 +358,8 @@ static DRWPass *edit_mesh_create_overlay_pass(float *face_alpha,
DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);
DRW_shgroup_uniform_float(grp, "faceAlphaMod", face_alpha, 1);
DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1);
- DRW_shgroup_uniform_bool_copy(grp, "doEdges", do_edges);
DRW_shgroup_uniform_float_copy(grp, "ofs", 0.0f);
+ DRW_shgroup_uniform_bool_copy(grp, "selectFaces", select_face);
if (rv3d->rflag & RV3D_CLIPPING) {
DRW_shgroup_world_clip_planes_from_rv3d(grp, rv3d);
}
@@ -354,7 +376,8 @@ static DRWPass *edit_mesh_create_overlay_pass(float *face_alpha,
DRW_shgroup_uniform_ivec4(grp, "dataMask", data_mask, 1);
DRW_shgroup_uniform_bool_copy(grp, "doEdges", do_edges);
DRW_shgroup_uniform_float_copy(grp, "ofs", depth_ofs);
- DRW_shgroup_uniform_float_copy(grp, "edgeScale", show_wide_edge ? 1.75f : 1.0f);
+ DRW_shgroup_uniform_bool_copy(grp, "selectEdges", select_edge);
+
DRW_shgroup_state_enable(grp, DRW_STATE_OFFSET_NEGATIVE);
/* To match blender loop structure. */
DRW_shgroup_state_enable(grp, DRW_STATE_FIRST_VERTEX_CONVENTION);
@@ -422,9 +445,6 @@ static void EDIT_MESH_cache_init(void *vedata)
stl->g_data->do_faces = false;
stl->g_data->do_zbufclip = false;
}
- if ((tsettings->selectmode & SCE_SELECT_FACE) == 0) {
- stl->g_data->data_mask[0] &= ~VFLAG_FACE_ACTIVE;
- }
if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_SEAMS) == 0) {
stl->g_data->data_mask[1] &= ~VFLAG_EDGE_SEAM;
}
@@ -513,6 +533,18 @@ static void EDIT_MESH_cache_init(void *vedata)
}
}
+ {
+ /* Mesh Analysis Pass */
+ DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_BLEND;
+ psl->mesh_analysis_pass = DRW_pass_create("Mesh Analysis", state);
+ const bool is_vertex_color = scene->toolsettings->statvis.type == SCE_STATVIS_SHARP;
+ stl->g_data->mesh_analysis_shgrp = DRW_shgroup_create(
+ is_vertex_color ? sh_data->mesh_analysis_vertex : sh_data->mesh_analysis_face,
+ psl->mesh_analysis_pass);
+ if (rv3d->rflag & RV3D_CLIPPING) {
+ DRW_shgroup_world_clip_planes_from_rv3d(stl->g_data->mesh_analysis_shgrp, rv3d);
+ }
+ }
/* For in front option */
psl->edit_face_overlay_in_front = edit_mesh_create_overlay_pass(
&face_mod,
@@ -538,7 +570,8 @@ static void EDIT_MESH_cache_init(void *vedata)
&stl->g_data->vert_shgrp);
}
else {
- /* We render all wires with depth and opaque to a new fbo and blend the result based on depth values */
+ /* We render all wires with depth and opaque to a new fbo and blend the result based on depth
+ * values */
psl->edit_face_occluded = edit_mesh_create_overlay_pass(&zero,
stl->g_data->data_mask,
stl->g_data->do_edges,
@@ -632,6 +665,7 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
bool do_in_front = (ob->dtx & OB_DRAWXRAY) != 0;
bool do_occlude_wire = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_OCCLUDE_WIRE) != 0;
bool do_show_weight = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_WEIGHT) != 0;
+ bool do_show_mesh_analysis = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_STATVIS) != 0;
bool fnormals_do = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_NORMALS) != 0;
bool vnormals_do = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_VERT_NORMALS) != 0;
bool lnormals_do = (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_LOOP_NORMALS) != 0;
@@ -660,6 +694,19 @@ static void EDIT_MESH_cache_populate(void *vedata, Object *ob)
DRW_shgroup_call_add(g_data->fweights_shgrp, geom, ob->obmat);
}
+ if (do_show_mesh_analysis) {
+ Mesh *me = (Mesh *)ob->data;
+ BMEditMesh *embm = me->edit_mesh;
+ const bool is_original = embm->mesh_eval_final &&
+ (embm->mesh_eval_final->runtime.is_original == true);
+ if (is_original) {
+ geom = DRW_cache_mesh_surface_mesh_analysis_get(ob);
+ if (geom) {
+ DRW_shgroup_call_add(g_data->mesh_analysis_shgrp, geom, ob->obmat);
+ }
+ }
+ }
+
if (do_occlude_wire || do_in_front) {
geom = DRW_cache_mesh_surface_get(ob);
DRW_shgroup_call_add(do_in_front ? g_data->depth_shgrp_hidden_wire_in_front :
@@ -735,6 +782,7 @@ static void EDIT_MESH_draw_scene(void *vedata)
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
DRW_draw_pass(psl->weight_faces);
+ DRW_draw_pass(psl->mesh_analysis_pass);
DRW_draw_pass(psl->depth_hidden_wire);
diff --git a/source/blender/draw/modes/edit_mesh_mode_text.c b/source/blender/draw/modes/edit_mesh_mode_text.c
index 90396785eb3..f3630a77e9a 100644
--- a/source/blender/draw/modes/edit_mesh_mode_text.c
+++ b/source/blender/draw/modes/edit_mesh_mode_text.c
@@ -47,8 +47,8 @@ void DRW_edit_mesh_mode_text_measure_stats(ARegion *ar,
Object *ob,
const UnitSettings *unit)
{
- /* Do not use ascii when using non-default unit system, some unit chars are utf8 (micro, square, etc.).
- * See bug #36090.
+ /* Do not use ascii when using non-default unit system, some unit chars are utf8 (micro, square,
+ * etc.). See bug #36090.
*/
struct DRWTextStore *dt = DRW_text_cache_ensure();
const short txt_flag = DRW_TEXT_CACHE_GLOBALSPACE | (unit->system ? 0 : DRW_TEXT_CACHE_ASCII);
@@ -157,12 +157,12 @@ void DRW_edit_mesh_mode_text_measure_stats(ARegion *ar,
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
BMLoop *l_a, *l_b;
if (BM_edge_loop_pair(eed, &l_a, &l_b)) {
- /* draw selected edges, or edges next to selected verts while dragging */
+ /* Draw selected edges, or edges next to selected verts while dragging. */
if (BM_elem_flag_test(eed, BM_ELEM_SELECT) ||
(do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
BM_elem_flag_test(eed->v2, BM_ELEM_SELECT) ||
- /* special case, this is useful to show when verts connected to
- * this edge via a face are being transformed */
+ /* Special case, this is useful to show when verts connected
+ * to this edge via a face are being transformed. */
BM_elem_flag_test(l_a->next->next->v, BM_ELEM_SELECT) ||
BM_elem_flag_test(l_a->prev->v, BM_ELEM_SELECT) ||
BM_elem_flag_test(l_b->next->next->v, BM_ELEM_SELECT) ||
@@ -319,7 +319,8 @@ void DRW_edit_mesh_mode_text_measure_stats(ARegion *ar,
}
}
- /* This option is for mesh ops and addons debugging; only available in UI if Blender starts with --debug */
+ /* This option is for mesh ops and addons debugging; only available in UI if Blender starts with
+ * --debug */
if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_INDICES) {
int i;
diff --git a/source/blender/draw/modes/edit_metaball_mode.c b/source/blender/draw/modes/edit_metaball_mode.c
index 90c5676727f..aa7c6863423 100644
--- a/source/blender/draw/modes/edit_metaball_mode.c
+++ b/source/blender/draw/modes/edit_metaball_mode.c
@@ -126,7 +126,7 @@ static void EDIT_METABALL_cache_init(void *vedata)
/* Add geometry to shadingGroups. Execute for each objects */
static void EDIT_METABALL_cache_populate(void *vedata, Object *ob)
{
- //EDIT_METABALL_PassList *psl = ((EDIT_METABALL_Data *)vedata)->psl;
+ // EDIT_METABALL_PassList *psl = ((EDIT_METABALL_Data *)vedata)->psl;
EDIT_METABALL_StorageList *stl = ((EDIT_METABALL_Data *)vedata)->stl;
if (ob->type == OB_MBALL) {
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index ec49b4dbe51..ee2c660ca06 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -53,6 +53,8 @@
#include "BKE_particle.h"
#include "BKE_tracking.h"
+#include "BLI_ghash.h"
+
#include "ED_view3d.h"
#include "GPU_batch.h"
@@ -273,6 +275,8 @@ typedef struct OBJECT_PrivateData {
OBJECT_ShadingGroupList sgl;
OBJECT_ShadingGroupList sgl_ghost;
+ GHash *custom_shapes;
+
/* Outlines */
DRWShadingGroup *outlines_active;
DRWShadingGroup *outlines_select;
@@ -511,6 +515,7 @@ static void OBJECT_engine_init(void *vedata)
const bool show_axis_y = (v3d->gridflag & V3D_SHOW_Y) != 0;
const bool show_axis_z = (v3d->gridflag & V3D_SHOW_Z) != 0;
const bool show_floor = (v3d->gridflag & V3D_SHOW_FLOOR) != 0;
+ const bool show_ortho_grid = (v3d->gridflag & V3D_SHOW_ORTHO_GRID) != 0;
e_data.draw_grid = show_axis_x || show_axis_y || show_axis_z || show_floor;
DRW_viewport_matrix_get(winmat, DRW_MAT_WIN);
@@ -559,15 +564,15 @@ static void OBJECT_engine_init(void *vedata)
grid_res = viewdist / grid_scale;
if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) {
- e_data.draw_grid = true;
+ e_data.draw_grid = show_ortho_grid;
e_data.grid_flag = PLANE_YZ | SHOW_AXIS_Y | SHOW_AXIS_Z | SHOW_GRID | GRID_BACK;
}
else if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) {
- e_data.draw_grid = true;
+ e_data.draw_grid = show_ortho_grid;
e_data.grid_flag = PLANE_XY | SHOW_AXIS_X | SHOW_AXIS_Y | SHOW_GRID | GRID_BACK;
}
else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) {
- e_data.draw_grid = true;
+ e_data.draw_grid = show_ortho_grid;
e_data.grid_flag = PLANE_XZ | SHOW_AXIS_X | SHOW_AXIS_Z | SHOW_GRID | GRID_BACK;
}
else { /* RV3D_VIEW_USER */
@@ -948,7 +953,8 @@ static void DRW_shgroup_empty_image(OBJECT_Shaders *sh_data,
return;
}
- /* Calling 'BKE_image_get_size' may free the texture. Get the size from 'tex' instead, see: T59347 */
+ /* Calling 'BKE_image_get_size' may free the texture. Get the size from 'tex' instead,
+ * see: T59347 */
int size[2] = {0};
const bool use_alpha_blend = (ob->empty_image_flag & OB_EMPTY_IMAGE_USE_ALPHA_BLEND) != 0;
@@ -1039,6 +1045,8 @@ static void OBJECT_cache_init(void *vedata)
g_data->xray_enabled_and_not_wire = g_data->xray_enabled &&
draw_ctx->v3d->shading.type > OB_WIRE;
+ g_data->custom_shapes = BLI_ghash_ptr_new(__func__);
+
{
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
DRW_STATE_WIRE;
@@ -1494,7 +1502,7 @@ static void OBJECT_cache_init(void *vedata)
psl->ob_center = DRW_pass_create("Obj Center Pass", state);
outlineWidth = 1.0f * U.pixelsize;
- size = U.obcenter_dia * U.pixelsize + outlineWidth;
+ size = UI_GetThemeValuef(TH_OBCENTER_DIA) * U.pixelsize + outlineWidth;
GPUShader *sh = GPU_shader_get_builtin_shader_with_config(
GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA, draw_ctx->sh_cfg);
@@ -1853,8 +1861,10 @@ static void camera_view3d_stereoscopy_display_extra(OBJECT_ShadingGroupList *sgl
static float one = 1.0f;
float plane_mat[4][4], scale_mat[4][4];
float scale_factor[3] = {1.0f, 1.0f, 1.0f};
- float color_plane[2][4] = {{0.0f, 0.0f, 0.0f, v3d->stereo3d_convergence_alpha},
- {0.0f, 0.0f, 0.0f, 1.0f}};
+ float color_plane[2][4] = {
+ {0.0f, 0.0f, 0.0f, v3d->stereo3d_convergence_alpha},
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ };
const float height = convergence_plane[1][1] - convergence_plane[0][1];
const float width = convergence_plane[2][0] - convergence_plane[0][0];
@@ -1877,9 +1887,11 @@ static void camera_view3d_stereoscopy_display_extra(OBJECT_ShadingGroupList *sgl
/* Draw convergence volume. */
if (is_stereo3d_volume && !is_select) {
static float one = 1.0f;
- float color_volume[3][4] = {{0.0f, 1.0f, 1.0f, v3d->stereo3d_volume_alpha},
- {1.0f, 0.0f, 0.0f, v3d->stereo3d_volume_alpha},
- {0.0f, 0.0f, 0.0f, 1.0f}};
+ float color_volume[3][4] = {
+ {0.0f, 1.0f, 1.0f, v3d->stereo3d_volume_alpha},
+ {1.0f, 0.0f, 0.0f, v3d->stereo3d_volume_alpha},
+ {0.0f, 0.0f, 0.0f, 1.0f},
+ };
for (int eye = 0; eye < 2; eye++) {
float winmat[4][4], viewinv[4][4], viewmat[4][4], persmat[4][4], persinv[4][4];
@@ -3115,11 +3127,10 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
((DRW_object_is_renderable(ob) && (ob->dt > OB_WIRE)) ||
(ob->dt == OB_WIRE)));
const bool show_relations = ((draw_ctx->v3d->flag & V3D_HIDE_HELPLINES) == 0);
- const bool hide_object_extra = ((v3d->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) != 0 &&
- /* Show if this is the camera we're looking through
- * since it's useful for moving the camera. */
- (((rv3d->persp == RV3D_CAMOB) &&
- ((ID *)v3d->camera == ob->id.orig_id)) == 0));
+ const bool hide_object_extra =
+ ((v3d->overlay.flag & V3D_OVERLAY_HIDE_OBJECT_XTRAS) != 0 &&
+ /* Show if this is the camera we're looking through since it's useful for selecting. */
+ (((rv3d->persp == RV3D_CAMOB) && ((ID *)v3d->camera == ob->id.orig_id)) == 0));
if (do_outlines) {
if (!BKE_object_is_in_editmode(ob) &&
@@ -3284,6 +3295,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
.bone_envelope = sgl->bone_envelope,
.bone_axes = sgl->bone_axes,
.relationship_lines = NULL, /* Don't draw relationship lines */
+ .custom_shapes = stl->g_data->custom_shapes,
};
DRW_shgroup_armature_object(ob, view_layer, passes, is_wire);
}
@@ -3391,6 +3403,11 @@ static void OBJECT_cache_finish(void *vedata)
DRW_pass_sort_shgroup_z(stl->g_data->sgl.image_empties);
DRW_pass_sort_shgroup_z(stl->g_data->sgl_ghost.image_empties);
+
+ if (stl->g_data->custom_shapes) {
+ /* TODO(fclem): Do not free it for each frame but reuse it. Avoiding alloc cost. */
+ BLI_ghash_free(stl->g_data->custom_shapes, NULL, NULL);
+ }
}
static void OBJECT_draw_scene(void *vedata)
diff --git a/source/blender/draw/modes/overlay_mode.c b/source/blender/draw/modes/overlay_mode.c
index 4d583066f44..ed96b2a05bc 100644
--- a/source/blender/draw/modes/overlay_mode.c
+++ b/source/blender/draw/modes/overlay_mode.c
@@ -359,8 +359,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
if ((!pd->show_overlays) ||
(((ob != draw_ctx->object_edit) && !is_edit_mode) || has_edit_mesh_cage) ||
ob->type != OB_MESH) {
- const bool is_active = (ob == draw_ctx->obact);
- const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
+ const bool is_sculpt_mode = (ob->sculpt != NULL);
const bool all_wires = (ob->dtx & OB_DRAW_ALL_EDGES);
const bool is_wire = (ob->dt < OB_SOLID);
const bool use_coloring = (pd->show_overlays && !is_edit_mode && !is_sculpt_mode &&
diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c
index 84852ff7ab3..3e292f4e4bc 100644
--- a/source/blender/draw/modes/paint_texture_mode.c
+++ b/source/blender/draw/modes/paint_texture_mode.c
@@ -294,7 +294,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
const Mesh *me_orig = DEG_get_original_object(ob)->data;
Scene *scene = draw_ctx->scene;
const bool use_surface = draw_ctx->v3d->overlay.texture_paint_mode_opacity !=
- 0.0; //DRW_object_is_mode_shade(ob) == true;
+ 0.0; // DRW_object_is_mode_shade(ob) == true;
const bool use_material_slots = (scene->toolsettings->imapaint.mode ==
IMAGEPAINT_MODE_MATERIAL);
const bool use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
diff --git a/source/blender/draw/modes/pose_mode.c b/source/blender/draw/modes/pose_mode.c
index 5e3353414f5..a37901a1fa9 100644
--- a/source/blender/draw/modes/pose_mode.c
+++ b/source/blender/draw/modes/pose_mode.c
@@ -72,6 +72,7 @@ typedef struct POSE_Data {
typedef struct POSE_PrivateData {
DRWShadingGroup *bone_selection_shgrp;
DRWShadingGroup *bone_selection_invert_shgrp;
+ GHash *custom_shapes[2];
float blend_color[4];
float blend_color_invert[4];
bool transparent_bones;
@@ -139,6 +140,8 @@ static void POSE_cache_init(void *vedata)
state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
DRW_STATE_BLEND | DRW_STATE_WIRE;
psl->relationship[i] = DRW_pass_create("Bone Relationship Pass", state);
+
+ ppd->custom_shapes[i] = BLI_ghash_ptr_new(__func__);
}
{
@@ -213,6 +216,7 @@ static void POSE_cache_populate(void *vedata, Object *ob)
.bone_envelope = psl->bone_envelope[ghost],
.bone_axes = psl->bone_axes,
.relationship_lines = psl->relationship[ghost],
+ .custom_shapes = ppd->custom_shapes[transp],
};
DRW_shgroup_armature_pose(ob, passes, transp);
}
@@ -231,6 +235,16 @@ static void POSE_cache_populate(void *vedata, Object *ob)
}
}
+static void POSE_cache_finish(void *vedata)
+{
+ POSE_PrivateData *ppd = ((POSE_Data *)vedata)->stl->g_data;
+
+ /* TODO(fclem): Do not free it for each frame but reuse it. Avoiding alloc cost. */
+ for (int i = 0; i < 2; i++) {
+ BLI_ghash_free(ppd->custom_shapes[i], NULL, NULL);
+ }
+}
+
/**
* Return true if armature should be handled by the pose mode engine.
*/
@@ -323,7 +337,7 @@ DrawEngineType draw_engine_pose_type = {
&POSE_engine_free,
&POSE_cache_init,
&POSE_cache_populate,
- NULL,
+ &POSE_cache_finish,
NULL,
&POSE_draw_scene,
NULL,
diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c
index b25a8af795b..8adae0a4238 100644
--- a/source/blender/draw/modes/sculpt_mode.c
+++ b/source/blender/draw/modes/sculpt_mode.c
@@ -135,9 +135,15 @@ static void SCULPT_cache_init(void *vedata)
}
{
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ View3D *v3d = draw_ctx->v3d;
+
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_MULTIPLY;
psl->pass = DRW_pass_create("Sculpt Pass", state);
- stl->g_data->group_smooth = DRW_shgroup_create(e_data.shader_smooth, psl->pass);
+
+ DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.shader_smooth, psl->pass);
+ DRW_shgroup_uniform_float(shgrp, "maskOpacity", &v3d->overlay.sculpt_mode_mask_opacity, 1);
+ stl->g_data->group_smooth = shgrp;
}
}
@@ -155,6 +161,7 @@ static void sculpt_draw_mask_cb(DRWShadingGroup *shgroup,
false,
false,
true,
+ false,
(void (*)(void *, struct GPUBatch *))draw_fn,
shgroup);
}
@@ -193,7 +200,8 @@ static void SCULPT_cache_populate(void *vedata, Object *ob)
sculpt_update_pbvh_normals(ob);
/* XXX, needed for dyntopo-undo (which clears).
- * probably depsgraph should handlle? in 2.7x getting derived-mesh does this (mesh_build_data) */
+ * probably depsgraph should handlle? in 2.7x
+ * getting derived-mesh does this (mesh_build_data). */
if (ob->sculpt->pbvh == NULL) {
/* create PBVH immediately (would be created on the fly too,
* but this avoids waiting on first stroke) */
diff --git a/source/blender/draw/modes/shaders/common_fxaa_lib.glsl b/source/blender/draw/modes/shaders/common_fxaa_lib.glsl
index dcb7c0ba7f2..d9e78855dc9 100644
--- a/source/blender/draw/modes/shaders/common_fxaa_lib.glsl
+++ b/source/blender/draw/modes/shaders/common_fxaa_lib.glsl
@@ -674,7 +674,7 @@ vec4 FxaaPixelShader(
posP.x += offNP.x * FXAA_QUALITY__P10;
if (!doneP)
posP.y += offNP.y * FXAA_QUALITY__P10;
- /*--------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------*/
# if (FXAA_QUALITY__PS > 11)
if (doneNP) {
if (!doneN)
@@ -696,7 +696,7 @@ vec4 FxaaPixelShader(
posP.x += offNP.x * FXAA_QUALITY__P11;
if (!doneP)
posP.y += offNP.y * FXAA_QUALITY__P11;
- /*--------------------------------------------------------------------------*/
+ /*-----------------------------------------------------------------------*/
# if (FXAA_QUALITY__PS > 12)
if (doneNP) {
if (!doneN)
@@ -718,10 +718,10 @@ vec4 FxaaPixelShader(
posP.x += offNP.x * FXAA_QUALITY__P12;
if (!doneP)
posP.y += offNP.y * FXAA_QUALITY__P12;
- /*--------------------------------------------------------------------------*/
+ /*-----------------------------------------------------------------------*/
}
# endif
- /*--------------------------------------------------------------------------*/
+ /*-------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
diff --git a/source/blender/draw/modes/shaders/common_hair_lib.glsl b/source/blender/draw/modes/shaders/common_hair_lib.glsl
index 02254908232..1c0a31c59fd 100644
--- a/source/blender/draw/modes/shaders/common_hair_lib.glsl
+++ b/source/blender/draw/modes/shaders/common_hair_lib.glsl
@@ -38,8 +38,8 @@ uniform usamplerBuffer hairStrandBuffer; /* R32UI */
uniform usamplerBuffer hairStrandSegBuffer; /* R16UI */
/* Not used, use one buffer per uv layer */
-//uniform samplerBuffer hairUVBuffer; /* RG32F */
-//uniform samplerBuffer hairColBuffer; /* RGBA16 linear color */
+// uniform samplerBuffer hairUVBuffer; /* RG32F */
+// uniform samplerBuffer hairColBuffer; /* RGBA16 linear color */
/* -- Subdivision stage -- */
/**
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_common_lib.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_common_lib.glsl
index ffabfd3fcee..7d4cba66933 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_common_lib.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_common_lib.glsl
@@ -1,5 +1,7 @@
uniform bool doEdges = true;
+uniform bool selectFaces = true;
+uniform bool selectEdges = true;
vec4 EDIT_MESH_edge_color_outer(int edge_flag, int face_flag, float crease, float bweight)
{
@@ -15,16 +17,21 @@ vec4 EDIT_MESH_edge_color_outer(int edge_flag, int face_flag, float crease, floa
vec4 EDIT_MESH_edge_color_inner(int edge_flag)
{
vec4 color = colorWireEdit;
- color = ((edge_flag & EDGE_SELECTED) != 0) ? colorEdgeSelect : color;
- color = ((edge_flag & EDGE_ACTIVE) != 0) ? colorEditMeshActive : color;
+ vec4 color_select = (selectEdges) ? colorEdgeSelect : colorFaceSelect;
+ color = (doEdges && ((edge_flag & EDGE_SELECTED) != 0)) ? color_select : color;
+ color = (doEdges && ((edge_flag & EDGE_ACTIVE) != 0)) ? colorEditMeshActive : color;
+
+ float non_edge_select_alpha = (selectFaces && (edge_flag & EDGE_SELECTED) != 0) ? 0.75 : 0.4;
+ color.a = (selectEdges) ? 1.0 : non_edge_select_alpha;
return color;
}
vec4 EDIT_MESH_edge_vertex_color(int vertex_flag)
{
vec4 color = colorWireEdit;
- color = (doEdges && (vertex_flag & (VERT_ACTIVE | VERT_SELECTED)) != 0) ? colorEdgeSelect :
- color;
+ vec4 color_select = (selectEdges) ? colorEdgeSelect : colorFaceSelect;
+ color = (doEdges && (vertex_flag & (VERT_ACTIVE | VERT_SELECTED)) != 0) ? color_select : color;
+ color.a = (selectEdges) ? 1.0 : 0.4;
return color;
}
@@ -43,18 +50,15 @@ vec4 EDIT_MESH_vertex_color(int vertex_flag)
vec4 EDIT_MESH_face_color(int face_flag)
{
- if ((face_flag & FACE_ACTIVE) != 0) {
- return mix(colorFaceSelect, colorEditMeshActive, 0.5);
- }
- else if ((face_flag & FACE_SELECTED) != 0) {
- return colorFaceSelect;
- }
- else if ((face_flag & FACE_FREESTYLE) != 0) {
- return colorFaceFreestyle;
- }
- else {
- return colorFace;
- }
+ vec4 color = colorFace;
+ vec4 color_active = mix(colorFaceSelect, colorEditMeshActive, 0.5);
+ color = ((face_flag & FACE_FREESTYLE) != 0) ? colorFaceFreestyle : color;
+ color = ((face_flag & FACE_SELECTED) != 0) ? colorFaceSelect : color;
+ color = ((face_flag & FACE_ACTIVE) != 0) ? color_active : color;
+ color.a *= ((face_flag & (FACE_FREESTYLE | FACE_SELECTED | FACE_ACTIVE)) == 0 || selectFaces) ?
+ 1.0 :
+ 0.5;
+ return color;
}
vec4 EDIT_MESH_facedot_color(float facedot_flag)
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
index 3418732afc2..7fe3cea8a42 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_frag.glsl
@@ -5,15 +5,13 @@
* We want to know how much a pixel is covered by a line.
* We replace the square pixel with acircle of the same area and try to find the intersection area.
* The area we search is the circular segment. https://en.wikipedia.org/wiki/Circular_segment
- * The formula for the area uses inverse trig function and is quite complexe.
- * Instead, we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
+ * The formula for the area uses inverse trig function and is quite complexe. Instead,
+ * we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
*/
#define DISC_RADIUS (M_1_SQRTPI * 1.05)
#define GRID_LINE_SMOOTH_START (0.5 - DISC_RADIUS)
#define GRID_LINE_SMOOTH_END (0.5 + DISC_RADIUS)
-uniform float edgeScale;
-
flat in vec4 finalColorOuter_f;
in vec4 finalColor_f;
noperspective in float edgeCoord_f;
@@ -22,8 +20,8 @@ out vec4 FragColor;
void main()
{
- float dist = abs(edgeCoord_f) - max(sizeEdge * edgeScale - 0.5, 0.0);
- float dist_outer = dist - max(sizeEdge * edgeScale, 1.0);
+ float dist = abs(edgeCoord_f) - max(sizeEdge - 0.5, 0.0);
+ float dist_outer = dist - max(sizeEdge, 1.0);
#ifdef USE_SMOOTH_WIRE
float mix_w = smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist);
float mix_w_outer = smoothstep(GRID_LINE_SMOOTH_START, GRID_LINE_SMOOTH_END, dist_outer);
@@ -31,6 +29,8 @@ void main()
float mix_w = step(0.5, dist);
float mix_w_outer = step(0.5, dist_outer);
#endif
+ /* Line color & alpha. */
FragColor = mix(finalColorOuter_f, finalColor_f, 1.0 - mix_w * finalColorOuter_f.a);
+ /* Line edges shape. */
FragColor.a *= 1.0 - (finalColorOuter_f.a > 0.0 ? mix_w_outer : mix_w);
}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl
index 6e59de12260..047bd1dccc6 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_geom.glsl
@@ -4,7 +4,6 @@ layout(triangle_strip, max_vertices = 4) out;
uniform vec2 viewportSize;
uniform vec2 viewportSizeInv;
-uniform float edgeScale;
in vec4 finalColor[2];
in vec4 finalColorOuter[2];
@@ -14,14 +13,16 @@ flat out vec4 finalColorOuter_f;
out vec4 finalColor_f;
noperspective out float edgeCoord_f;
-void do_vertex(const int i, vec4 pos, float coord, vec2 offset)
+void do_vertex(vec4 color, vec4 pos, float coord, vec2 offset)
{
- finalColor_f = (selectOveride[0] == 0) ? finalColor[i] : finalColor[0];
+ finalColor_f = color;
edgeCoord_f = coord;
gl_Position = pos;
/* Multiply offset by 2 because gl_Position range is [-1..1]. */
gl_Position.xy += offset * 2.0 * pos.w;
-#ifdef USE_WORLD_CLIP_PLANES
+ /* Correct but fails due to an AMD compiler bug, see: T62792.
+ * Do inline instead. */
+#if 0
world_clip_planes_set_clip_distance(gl_in[i].gl_ClipDistance);
#endif
EmitVertex();
@@ -57,9 +58,9 @@ void main()
line = abs(line) * viewportSize;
finalColorOuter_f = finalColorOuter[0];
- float half_size = sizeEdge * edgeScale;
+ float half_size = sizeEdge;
/* Enlarge edge for flag display. */
- half_size += (finalColorOuter_f.a > 0.0) ? max(sizeEdge * edgeScale, 1.0) : 0.0;
+ half_size += (finalColorOuter_f.a > 0.0) ? max(sizeEdge, 1.0) : 0.0;
#ifdef USE_SMOOTH_WIRE
/* Add 1 px for AA */
@@ -71,10 +72,20 @@ void main()
bool horizontal = line.x > line.y;
edge_ofs = (horizontal) ? edge_ofs.zyz : edge_ofs.xzz;
- do_vertex(0, pos0, half_size, edge_ofs.xy);
- do_vertex(0, pos0, -half_size, -edge_ofs.xy);
- do_vertex(1, pos1, half_size, edge_ofs.xy);
- do_vertex(1, pos1, -half_size, -edge_ofs.xy);
+#ifdef USE_WORLD_CLIP_PLANES
+ /* Due to an AMD glitch, this line was moved out of the `do_vertex`
+ * function (see T62792). */
+ world_clip_planes_set_clip_distance(gl_in[0].gl_ClipDistance);
+#endif
+ do_vertex(finalColor[0], pos0, half_size, edge_ofs.xy);
+ do_vertex(finalColor[0], pos0, -half_size, -edge_ofs.xy);
+
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_set_clip_distance(gl_in[1].gl_ClipDistance);
+#endif
+ vec4 final_color = (selectOveride[0] == 0) ? finalColor[1] : finalColor[0];
+ do_vertex(final_color, pos1, half_size, edge_ofs.xy);
+ do_vertex(final_color, pos1, -half_size, -edge_ofs.xy);
EndPrimitive();
}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl
new file mode 100644
index 00000000000..8581453e810
--- /dev/null
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_frag.glsl
@@ -0,0 +1,14 @@
+out vec4 fragColor;
+
+#ifdef FACE_COLOR
+flat in vec4 weightColor;
+#endif
+
+#ifdef VERTEX_COLOR
+in vec4 weightColor;
+#endif
+
+void main()
+{
+ fragColor = weightColor;
+}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl
new file mode 100644
index 00000000000..94d8d2e701c
--- /dev/null
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_mesh_analysis_vert.glsl
@@ -0,0 +1,23 @@
+uniform mat4 ModelViewProjectionMatrix;
+uniform mat4 ModelMatrix;
+
+in vec3 pos;
+in vec4 weight_color;
+
+#ifdef FACE_COLOR
+flat out vec4 weightColor;
+#endif
+
+#ifdef VERTEX_COLOR
+out vec4 weightColor;
+#endif
+
+void main()
+{
+ gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
+ weightColor = vec4(weight_color.rgb, 1.0);
+
+#ifdef USE_WORLD_CLIP_PLANES
+ world_clip_planes_calc_clip_distance((ModelMatrix * vec4(pos, 1.0)).xyz);
+#endif
+}
diff --git a/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
index 8c54470cd5a..d700e69fb57 100644
--- a/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
+++ b/source/blender/draw/modes/shaders/edit_mesh_overlay_vert.glsl
@@ -74,21 +74,15 @@ void main()
#endif
-#if !defined(FACE) && !defined(EDGE_DECORATION)
+#if !defined(FACE)
/* Facing based color blend */
vec4 vpos = ModelViewMatrix * vec4(pos, 1.0);
vec3 view_normal = normalize(NormalMatrix * vnor + 1e-4);
vec3 view_vec = (ProjectionMatrix[3][3] == 0.0) ? normalize(vpos.xyz) : vec3(0.0, 0.0, 1.0);
float facing = dot(view_vec, view_normal);
- facing = 1.0 - abs(facing) * 0.3;
-
- finalColor = mix(colorEditMeshMiddle, finalColor, facing);
- finalColor.a = 1.0;
+ facing = 1.0 - abs(facing) * 0.2;
-# if defined(EDGE) && !defined(FLAT)
- /* Hack to blend color in pixel shader in case of overide. */
- finalColor.a = facing;
-# endif
+ finalColor.rgb = mix(colorEditMeshMiddle.rgb, finalColor.rgb, facing);
#endif
diff --git a/source/blender/draw/modes/shaders/object_grid_frag.glsl b/source/blender/draw/modes/shaders/object_grid_frag.glsl
index 841b4a95b21..df2cfe7be82 100644
--- a/source/blender/draw/modes/shaders/object_grid_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_grid_frag.glsl
@@ -40,8 +40,8 @@ uniform int gridFlag;
* We want to know how much a pixel is covered by a line.
* We replace the square pixel with acircle of the same area and try to find the intersection area.
* The area we search is the circular segment. https://en.wikipedia.org/wiki/Circular_segment
- * The formula for the area uses inverse trig function and is quite complexe.
- * Instead, we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
+ * The formula for the area uses inverse trig function and is quite complexe. Instead,
+ * we approximate it by using the smoothstep function and a 1.05 factor to the disc radius.
*/
#define DISC_RADIUS (M_1_SQRTPI * 1.05)
#define GRID_LINE_SMOOTH_START (0.5 - DISC_RADIUS)
diff --git a/source/blender/draw/modes/shaders/particle_strand_vert.glsl b/source/blender/draw/modes/shaders/particle_strand_vert.glsl
index 745499800e5..6dac6d6b980 100644
--- a/source/blender/draw/modes/shaders/particle_strand_vert.glsl
+++ b/source/blender/draw/modes/shaders/particle_strand_vert.glsl
@@ -45,14 +45,12 @@ vec3 weight_to_rgb(float weight)
return r_rgb;
}
-#define DECOMPRESS_RANGE 1.0039
-
void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
#ifdef USE_WEIGHT
- finalColor = vec4(weight_to_rgb(color * DECOMPRESS_RANGE), 1.0);
+ finalColor = vec4(weight_to_rgb(color), 1.0);
#else
finalColor = mix(colorWire, colorEdgeSelect, color);
#endif
diff --git a/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl b/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl
index 5ae97ec5cb9..e5e34fee57e 100644
--- a/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl
+++ b/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl
@@ -1,5 +1,6 @@
uniform mat4 ModelViewProjectionMatrix;
+uniform float maskOpacity;
in vec3 pos;
in float msk;
@@ -10,6 +11,6 @@ void main()
{
gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0);
- float mask = 1.0 - msk * 0.75;
+ float mask = 1.0 - (msk * maskOpacity);
finalColor = vec4(mask, mask, mask, 1.0);
}