[Bf-blender-cvs] [f3501a00e24] blender2.8: PaintMode: Full Shading Boolean => Slider

Jeroen Bakker noreply at git.blender.org
Fri Jun 22 10:44:52 CEST 2018


Commit: f3501a00e249bc4a7212be1f443704066dd43482
Author: Jeroen Bakker
Date:   Fri Jun 22 10:37:38 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBf3501a00e249bc4a7212be1f443704066dd43482

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.

===================================================================

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/draw/engines/eevee/eevee_engine.c
M	source/blender/draw/engines/workbench/workbench_materials.c
M	source/blender/draw/intern/DRW_render.h
M	source/blender/draw/intern/draw_manager.c
M	source/blender/draw/modes/paint_texture_mode.c
M	source/blender/draw/modes/paint_vertex_mode.c
M	source/blender/draw/modes/paint_weight_mode.c
M	source/blender/draw/modes/shaders/paint_texture_frag.glsl
M	source/blender/draw/modes/shaders/paint_vertex_frag.glsl
M	source/blender/draw/modes/shaders/paint_wire_frag.glsl
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/makesdna/DNA_view3d_types.h
M	source/blender/makesrna/intern/rna_space.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 2aaeba653fb..dda52a98299 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -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'
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index dd5deb0fb89..53e9ada214b 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -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;
+						}
+					}
+				}
+			}
+		}
+
+	}
 }
diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c
index d7c6684f086..f4958a1a080 100644
--- a/source/blender/draw/engines/eevee/eevee_engine.c
+++ b/source/blender/draw/engines/eevee/eevee_engine.c
@@ -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);
 	}
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index 56da31aa5f1..a8c677b4070 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -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) {
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index f79a2405c3f..d6187e32036 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -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);
 
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 52c8ca1f6fb..7a6771ae058 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -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)
diff --git a/source/blender/draw/modes/paint_texture_mode.c b/source/blender/draw/modes/paint_texture_mode.c
index bd8a1c71a6a..85cff28b313 100644
--- a/source/blender/draw/modes/paint_texture_mode.c
+++ b/source/blender/draw/modes/paint_texture_mode.c
@@ -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;
 
diff --git a/source/blender/draw/modes/paint_vertex_mode.c b/source/blender/draw/modes/paint_vertex_mode.c
index d335e0a4d70..9cf6ea52d33 100644
--- a/source/blender/draw/modes/paint_vertex_mode.c
+++ b/source/blender/draw/modes/paint_vertex_mode.c
@@ -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;
 
diff --git a/source/blender/draw/modes/paint_weight_mode.c b/source/blender/draw/modes/paint_weight_mode.c
index 13ef42d8622..2b510a9a4c9 100644
--- a/source/blender/draw/modes/paint_weight_mode.c
+++ b/source/blender/draw/modes/paint_weight_mode.c
@@ -123,6 +123,8 @@ static void PAINT_WEIGHT_cache_init(void

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list