PaintMode: Full Shading Boolean => Slider

There was a Full Shading bool that was shared across the WP, VP and TP
modes. This commit makes some changes:

- Replace the bool with a factor. This gives the user more control on
the visibility.
- Also draw it on top of the Material and Rendered mode so the user can
control what he needs. In certain cases you don't want to see the final
rendered material, but the actual texture.
- Removed the skipping of objects when in paint modes. As now the paint
modes are blended.
This commit is contained in:
Jeroen Bakker 2018-06-22 10:37:38 +02:00
parent c517778a8b
commit f3501a00e2
Notes: blender-bot 2023-02-14 05:50:03 +01:00
Referenced by issue #55570, TexturePaintMode: polishing
15 changed files with 87 additions and 68 deletions

View File

@ -4021,12 +4021,20 @@ class VIEW3D_PT_overlay_paint(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
bl_parent_id = 'VIEW3D_PT_overlay'
bl_label = "Paint"
bl_label = ""
@classmethod
def poll(cls, context):
return context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}
def draw_header(self, context):
layout = self.layout
layout.label(text={
"PAINT_TEXTURE": "Texture Paint",
"PAINT_VERTEX": "Vertex Paint",
"PAINT_WEIGHT": "Weight Paint",
}[context.mode])
def draw(self, context):
layout = self.layout
view = context.space_data
@ -4036,11 +4044,16 @@ class VIEW3D_PT_overlay_paint(Panel):
col = layout.column()
col.active = display_all
col.prop(overlay, {
"PAINT_TEXTURE": "texture_paint_mode_opacity",
"PAINT_VERTEX": "vertex_paint_mode_opacity",
"PAINT_WEIGHT": "weight_paint_mode_opacity",
}[context.mode], text="Opacity")
if context.mode in {'PAINT_WEIGHT', 'PAINT_VERTEX'}:
col.prop(overlay, "show_paint_wire")
col.prop(view, "show_mode_shade_override")
class VIEW3D_PT_quad_view(Panel):
bl_space_type = 'VIEW_3D'

View File

@ -1508,4 +1508,23 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
{
if (!DNA_struct_elem_find(fd->filesdna, "View3DOverlay", "float", "texture_paint_mode_opacity")) {
for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
if (sl->spacetype == SPACE_VIEW3D) {
View3D *v3d = (View3D *)sl;
float alpha = v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE? 0.0f: 0.8f;
v3d->overlay.texture_paint_mode_opacity = alpha;
v3d->overlay.vertex_paint_mode_opacity = alpha;
v3d->overlay.weight_paint_mode_opacity = alpha;
}
}
}
}
}
}
}

View File

@ -128,15 +128,8 @@ static void eevee_cache_populate(void *vedata, Object *ob)
EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_active = (ob == draw_ctx->obact);
bool cast_shadow = false;
if (is_active) {
if (DRW_object_is_mode_shade(ob) == true) {
return;
}
}
if (ob->base_flag & BASE_VISIBLED) {
EEVEE_hair_cache_populate(vedata, sldata, ob, &cast_shadow);
}

View File

@ -17,7 +17,7 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Mate
copy_v4_v4(data->material_data.specular_color, default_specular_color);
data->material_data.roughness = 0.5f;
if (DRW_object_is_paint_mode(ob) || color_type == V3D_SHADING_SINGLE_COLOR) {
if (color_type == V3D_SHADING_SINGLE_COLOR) {
copy_v3_v3(data->material_data.diffuse_color, wpd->shading.single_color);
}
else if (color_type == V3D_SHADING_RANDOM_COLOR) {

View File

@ -475,8 +475,6 @@ void DRW_lamp_engine_data_free(struct LampEngineData *led);
bool DRW_object_is_renderable(struct Object *ob);
bool DRW_check_object_visible_within_active_context(struct Object *ob);
bool DRW_object_is_flat_normal(const struct Object *ob);
int DRW_object_is_mode_shade(const struct Object *ob);
int DRW_object_is_paint_mode(const struct Object *ob);
bool DRW_check_psys_visible_within_active_context(struct Object *object, struct ParticleSystem *psys);

View File

@ -187,39 +187,6 @@ bool DRW_object_is_flat_normal(const 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);
UNUSED_VARS_NDEBUG(ob);
if ((DST.draw_ctx.object_mode & OB_MODE_EDIT) == 0) {
if ((DST.draw_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) > 0) {
if (ELEM(DST.draw_ctx.v3d->drawtype, OB_MATERIAL, OB_RENDER)) {
return false;
}
else if ((DST.draw_ctx.v3d->flag2 & V3D_SHOW_MODE_SHADE_OVERRIDE) == 0) {
return true;
}
else {
return false;
}
}
}
return -1;
}
int DRW_object_is_paint_mode(const Object *ob)
{
if (ob == DST.draw_ctx.obact) {
if ((DST.draw_ctx.object_mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) > 0) {
return true;
}
}
return false;
}
bool DRW_check_psys_visible_within_active_context(
Object *object,
struct ParticleSystem *psys)

View File

@ -194,8 +194,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
{
/* Create a pass */
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL |
DRW_STATE_MULTIPLY | DRW_STATE_WIRE;
DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND;
psl->image_faces = DRW_pass_create("Image Color Pass", state);
stl->g_data->shgroup_fallback = DRW_shgroup_create(e_data.fallback_sh, psl->image_faces);
@ -227,6 +226,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
if (tex) {
DRWShadingGroup *grp = DRW_shgroup_create(e_data.image_sh, psl->image_faces);
DRW_shgroup_uniform_texture(grp, "image", tex);
DRW_shgroup_uniform_float(grp, "alpha", &draw_ctx->v3d->overlay.texture_paint_mode_opacity, 1);
stl->g_data->shgroup_image_array[i] = grp;
}
else {
@ -242,6 +242,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
if (tex) {
DRWShadingGroup *grp = DRW_shgroup_create(e_data.image_sh, psl->image_faces);
DRW_shgroup_uniform_texture(grp, "image", tex);
DRW_shgroup_uniform_float(grp, "alpha", &draw_ctx->v3d->overlay.texture_paint_mode_opacity, 1);
stl->g_data->shgroup_image_array[0] = grp;
}
else {
@ -285,7 +286,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
/* Get geometry cache */
const Mesh *me = ob->data;
Scene *scene = draw_ctx->scene;
const bool use_surface = DRW_object_is_mode_shade(ob) == true;
const bool use_surface = draw_ctx->v3d->overlay.texture_paint_mode_opacity != 0.0; //DRW_object_is_mode_shade(ob) == true;
const bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL);
bool ok = false;

View File

@ -101,6 +101,8 @@ static void PAINT_VERTEX_cache_init(void *vedata)
{
PAINT_VERTEX_PassList *psl = ((PAINT_VERTEX_Data *)vedata)->psl;
PAINT_VERTEX_StorageList *stl = ((PAINT_VERTEX_Data *)vedata)->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
const View3D *v3d = draw_ctx->v3d;
if (!stl->g_data) {
/* Alloc transient pointers */
@ -111,9 +113,10 @@ static void PAINT_VERTEX_cache_init(void *vedata)
/* Create a pass */
psl->vcolor_faces = DRW_pass_create(
"Vert Color Pass",
DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_MULTIPLY);
DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND);
stl->g_data->fvcolor_shgrp = DRW_shgroup_create(e_data.vcolor_face_shader, psl->vcolor_faces);
DRW_shgroup_uniform_float(stl->g_data->fvcolor_shgrp, "alpha", &v3d->overlay.vertex_paint_mode_opacity, 1);
}
{
@ -145,7 +148,7 @@ static void PAINT_VERTEX_cache_populate(void *vedata, Object *ob)
if ((ob->type == OB_MESH) && (ob == draw_ctx->obact)) {
const Mesh *me = ob->data;
const bool use_wire = (v3d->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0;
const bool use_surface = DRW_object_is_mode_shade(ob) == true;
const bool use_surface = v3d->overlay.vertex_paint_mode_opacity != 0.0f;
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
struct Gwn_Batch *geom;

View File

@ -123,6 +123,8 @@ static void PAINT_WEIGHT_cache_init(void *vedata)
{
PAINT_WEIGHT_PassList *psl = ((PAINT_WEIGHT_Data *)vedata)->psl;
PAINT_WEIGHT_StorageList *stl = ((PAINT_WEIGHT_Data *)vedata)->stl;
const DRWContextState *draw_ctx = DRW_context_state_get();
const View3D *v3d = draw_ctx->v3d;
if (!stl->g_data) {
/* Alloc transient pointers */
@ -133,15 +135,14 @@ static void PAINT_WEIGHT_cache_init(void *vedata)
/* Create a pass */
psl->weight_faces = DRW_pass_create(
"Weight Pass",
DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_MULTIPLY);
DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND);
stl->g_data->fweights_shgrp = DRW_shgroup_create(e_data.weight_face_shader, psl->weight_faces);
static float light[3] = {-0.3f, 0.5f, 1.0f};
static float alpha = 1.0f;
static float world_light = 1.0f;
DRW_shgroup_uniform_vec3(stl->g_data->fweights_shgrp, "light", light, 1);
DRW_shgroup_uniform_float(stl->g_data->fweights_shgrp, "alpha", &alpha, 1);
DRW_shgroup_uniform_float(stl->g_data->fweights_shgrp, "alpha", &v3d->overlay.weight_paint_mode_opacity, 1);
DRW_shgroup_uniform_float(stl->g_data->fweights_shgrp, "global", &world_light, 1);
}
@ -182,7 +183,7 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob)
if ((ob->type == OB_MESH) && (ob == draw_ctx->obact)) {
const Mesh *me = ob->data;
const bool use_wire = (v3d->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE) != 0;
const bool use_surface = DRW_object_is_mode_shade(ob) == true;
const bool use_surface = v3d->overlay.weight_paint_mode_opacity != 0.0f;
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
struct Gwn_Batch *geom;

View File

@ -3,9 +3,9 @@ in vec2 uv_interp;
out vec4 fragColor;
uniform sampler2D image;
uniform float alpha = 1.0;
void main()
{
fragColor = texture(image, uv_interp);
fragColor = vec4(texture(image, uv_interp).rgb, alpha);
}

View File

@ -2,7 +2,7 @@
in vec3 finalColor;
out vec4 fragColor;
uniform float alpha = 1.0;
vec3 linear_to_srgb_attrib(vec3 c) {
c = max(c, vec3(0.0));
vec3 c1 = c * 12.92;
@ -13,5 +13,5 @@ vec3 linear_to_srgb_attrib(vec3 c) {
void main()
{
fragColor.rgb = linear_to_srgb_attrib(finalColor);
fragColor.a = 1.0;
fragColor.a = alpha;
}

View File

@ -18,7 +18,5 @@ void main()
const vec4 colSel = vec4(1.0, 1.0, 1.0, 1.0);
#endif
const vec4 colUnsel = vec4(0.5, 0.5, 0.5, 1.0);
fragColor = bool(finalFlag & VERTEX_SELECTED) ? colSel : colUnsel;
fragColor = bool(finalFlag & VERTEX_SELECTED) ? colSel : colorWire;
}

View File

@ -335,6 +335,9 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene)
v3d->overlay.flag = V3D_OVERLAY_LOOK_DEV;
v3d->overlay.wireframe_threshold = 0.5f;
v3d->overlay.bone_selection_alpha = 0.5f;
v3d->overlay.texture_paint_mode_opacity = 0.8;
v3d->overlay.weight_paint_mode_opacity = 0.8;
v3d->overlay.vertex_paint_mode_opacity = 0.8;
v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR;

View File

@ -167,12 +167,19 @@ typedef struct View3DOverlay {
/* Paint mode settings */
int paint_flag;
/* Alpha for texture, weight, vertex paint overlay */
float texture_paint_mode_opacity;
float vertex_paint_mode_opacity;
float weight_paint_mode_opacity;
/* Armature edit/pose mode settings */
int arm_flag;
float bone_selection_alpha;
/* Other settings */
float wireframe_threshold;
int pad;
} View3DOverlay;
/* 3D ViewPort Struct */
@ -331,7 +338,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_SHOW_MODE_SHADE_OVERRIDE (1 << 15)
#define V3D_SHOW_MODE_SHADE_OVERRIDE (1 << 15) /* XXX: DNA deprecated */
/* View3d->flag3 (short) */

View File

@ -2716,6 +2716,27 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "overlay.arm_flag", V3D_OVERLAY_ARM_TRANSP_BONES);
RNA_def_property_ui_text(prop, "Transparent Bones", "Display bones as transparent");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "texture_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.texture_paint_mode_opacity");
RNA_def_property_float_default(prop, 0.8f);
RNA_def_property_ui_text(prop, "Texture Opacity", "Opacity of the texture paint mode overlay");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "vertex_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.vertex_paint_mode_opacity");
RNA_def_property_float_default(prop, 0.8f);
RNA_def_property_ui_text(prop, "Vertex Paint Opacity", "Opacity of the vertex paint mode overlay");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "weight_paint_mode_opacity", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_sdna(prop, NULL, "overlay.weight_paint_mode_opacity");
RNA_def_property_float_default(prop, 0.8f);
RNA_def_property_ui_text(prop, "Weight Paint Opacity", "Opacity of the weight paint mode overlay");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
}
static void rna_def_space_view3d(BlenderRNA *brna)
@ -2853,11 +2874,6 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Textured Solid", "Display face-assigned textures in solid view");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
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);
RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_OCCLUDE_WIRE);
RNA_def_property_ui_text(prop, "Hidden Wire", "Use hidden wireframe display");