[Bf-blender-cvs] [cbbf8bbbb4f] blender2.8: Workbench: XFlip Matcap per 3D View

Jeroen Bakker noreply at git.blender.org
Fri Jun 8 16:15:12 CEST 2018


Commit: cbbf8bbbb4fac21d5148201d45053e4f85ed778f
Author: Jeroen Bakker
Date:   Fri Jun 8 16:12:25 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBcbbf8bbbb4fac21d5148201d45053e4f85ed778f

Workbench: XFlip Matcap per 3D View

Note: Icons are not yet updated.

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
M	source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
M	source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
M	source/blender/draw/engines/workbench/workbench_data.c
M	source/blender/draw/engines/workbench/workbench_deferred.c
M	source/blender/draw/engines/workbench/workbench_private.h
M	source/blender/editors/space_view3d/view3d_header.c
M	source/blender/editors/space_view3d/view3d_intern.h
M	source/blender/editors/space_view3d/view3d_ops.c
M	source/blender/makesdna/DNA_view3d_types.h

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 6c16b14886a..3a8fb3ce2f0 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3520,14 +3520,16 @@ class VIEW3D_PT_shading(Panel):
             if shading.light == 'STUDIO':
                 row = col.row()
                 row.template_icon_view(shading, "studio_light")
-                op = row.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='ZOOMIN')
+                row.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='ZOOMIN')
                 if shading.studio_light_orientation == 'WORLD':
                     col.row().prop(shading, "studiolight_rot_z")
 
             elif shading.light == 'MATCAP':
                 row = col.row()
                 row.template_icon_view(shading, "matcap")
-                op = row.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='ZOOMIN')
+                sub = row.column()
+                sub.operator('VIEW3D_OT_toggle_matcap_flip', emboss=False, text="", icon='ARROW_LEFTRIGHT')
+                sub.operator('wm.studiolight_userpref_show', emboss=False, text="", icon='ZOOMIN')
 
         if shading.type == 'SOLID':
             col.separator()
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
index 8d648ce7d7b..f67d2ff6745 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_data_lib.glsl
@@ -16,12 +16,12 @@ struct WorldData {
 	vec4 light_direction_vs;
 	LightData lights[3];
 	int num_lights;
-	int pad[3];
+	int matcap_orientation;
+	int pad[2];
 };
 
 struct MaterialData {
 	vec4 diffuse_color;
 	vec4 specular_color;
 	float roughness;
-	int matcap_texture_index;
 };
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
index 9116e2e7ef5..e5ee272e7fd 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
@@ -62,7 +62,11 @@ void main()
 #endif
 
 #ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL
-	diffuse_color = texture(matcapImage, normal_viewport.xy / 2.0 + 0.5);
+	vec2 matcap_uv = normal_viewport.xy / 2.0 + 0.5;
+	if (world_data.matcap_orientation != 0) {
+		matcap_uv.x = 1.0 - matcap_uv.x;
+	}
+	diffuse_color = texture(matcapImage, matcap_uv);
 #endif
 
 #ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
index d33ef9a0abb..200850e3036 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl
@@ -43,7 +43,8 @@ void main()
 #ifdef OB_SOLID
 	diffuseColor = vec4(material_data.diffuse_color.rgb, 0.0);
 #  ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL
-	specularColor = vec4(material_data.diffuse_color.rgb, material_data.matcap_texture_index);
+
+	specularColor = vec4(material_data.diffuse_color.rgb, 0.0);
 #  endif
 #endif /* OB_SOLID */
 
diff --git a/source/blender/draw/engines/workbench/workbench_data.c b/source/blender/draw/engines/workbench/workbench_data.c
index 3a4bb1db749..df0a2bf4684 100644
--- a/source/blender/draw/engines/workbench/workbench_data.c
+++ b/source/blender/draw/engines/workbench/workbench_data.c
@@ -35,6 +35,7 @@ void workbench_private_data_init(WORKBENCH_PrivateData *wpd)
 	wpd->shadow_multiplier = 1.0 - wpd->shading.shadow_intensity;
 
 	WORKBENCH_UBO_World *wd = &wpd->world_data;
+	wd->matcap_orientation = (wpd->shading.flag & V3D_SHADING_MATCAP_FLIP_X) > 0;
 
 	if ((v3d->flag3 & V3D_SHOW_WORLD) &&
 	    (scene->world != NULL))
diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c
index 428e5d4f7c8..c4fa82d39b7 100644
--- a/source/blender/draw/engines/workbench/workbench_deferred.c
+++ b/source/blender/draw/engines/workbench/workbench_deferred.c
@@ -464,7 +464,7 @@ static void workbench_composite_uniforms(WORKBENCH_PrivateData *wpd, DRWShadingG
 
 	if (STUDIOLIGHT_ORIENTATION_VIEWNORMAL_ENABLED(wpd)) {
 		BKE_studiolight_ensure_flag(wpd->studio_light, STUDIOLIGHT_EQUIRECTANGULAR_RADIANCE_GPUTEXTURE);
-		DRW_shgroup_uniform_texture(grp, "matcapImage", wpd->studio_light->equirectangular_radiance_gputexture);
+		DRW_shgroup_uniform_texture(grp, "matcapImage", wpd->studio_light->equirectangular_radiance_gputexture);		DRW_shgroup_uniform_texture(grp, "matcapImage", wpd->studio_light->equirectangular_radiance_gputexture);
 	}
 
 	workbench_material_set_normal_world_matrix(grp, wpd, e_data.normal_world_matrix);
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index 758cc2be826..9c5f97729bf 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -128,7 +128,8 @@ typedef struct WORKBENCH_UBO_World {
 	float light_direction_vs[4];
 	WORKBENCH_UBO_Light lights[3];
 	int num_lights;
-	int pad[3];
+	int matcap_orientation;
+	int pad[2];
 } WORKBENCH_UBO_World;
 BLI_STATIC_ASSERT_ALIGN(WORKBENCH_UBO_World, 16)
 
@@ -136,8 +137,7 @@ typedef struct WORKBENCH_UBO_Material {
 	float diffuse_color[4];
 	float specular_color[4];
 	float roughness;
-	int matcap_texture_index;
-	float pad[2];
+	float pad[3];
 } WORKBENCH_UBO_Material;
 BLI_STATIC_ASSERT_ALIGN(WORKBENCH_UBO_Material, 16)
 
diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c
index 5f07bb0fc3d..4f81fa7585c 100644
--- a/source/blender/editors/space_view3d/view3d_header.c
+++ b/source/blender/editors/space_view3d/view3d_header.c
@@ -259,6 +259,33 @@ void VIEW3D_OT_toggle_xray_draw_option(wmOperatorType *ot)
 
 /** \} */
 
+/* -------------------------------------------------------------------- */
+/** \name Toggle Bone selection Overlay Operator
+ * \{ */
+
+static int toggle_matcap_flip(bContext *C, wmOperator *UNUSED(op))
+{
+	View3D *v3d = CTX_wm_view3d(C);
+	v3d->shading.flag ^= V3D_SHADING_MATCAP_FLIP_X;
+	ED_view3d_shade_update(CTX_data_main(C), v3d, CTX_wm_area(C));
+	WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
+	return OPERATOR_FINISHED;
+}
+
+void VIEW3D_OT_toggle_matcap_flip(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "Flip MatCap";
+	ot->description = "Flip MatCap";
+	ot->idname = "VIEW3D_OT_toggle_matcap_flip";
+
+	/* api callbacks */
+	ot->exec = toggle_matcap_flip;
+	// ot->poll = toggle_show_xray_poll;
+}
+
+/** \} */
+
 
 static void do_view3d_header_buttons(bContext *C, void *UNUSED(arg), int event)
 {
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 4b1c7986b6e..017b31a0bf2 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -66,6 +66,7 @@ enum {
 /* view3d_header.c */
 void VIEW3D_OT_layers(struct wmOperatorType *ot);
 void VIEW3D_OT_toggle_xray_draw_option(struct wmOperatorType *ot);
+void VIEW3D_OT_toggle_matcap_flip(struct wmOperatorType *ot);
 
 /* view3d_ops.c */
 void view3d_operatortypes(void);
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index ad386d89d17..b3211ed1108 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -223,6 +223,7 @@ void view3d_operatortypes(void)
 
 	WM_operatortype_append(VIEW3D_OT_toggle_render);
 	WM_operatortype_append(VIEW3D_OT_toggle_xray_draw_option);
+	WM_operatortype_append(VIEW3D_OT_toggle_matcap_flip);
 
 	WM_operatortype_append(VIEW3D_OT_ruler_add);
 
diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h
index b1bf7c3692c..9794a1efbf5 100644
--- a/source/blender/makesdna/DNA_view3d_types.h
+++ b/source/blender/makesdna/DNA_view3d_types.h
@@ -352,6 +352,7 @@ enum {
 	V3D_SHADING_SCENE_LIGHT         = (1 << 3),
 	V3D_SHADING_SPECULAR_HIGHLIGHT  = (1 << 4),
 	V3D_SHADING_CAVITY              = (1 << 5),
+	V3D_SHADING_MATCAP_FLIP_X       = (1 << 6),
 };
 
 /* View3DShading->single_color_type */



More information about the Bf-blender-cvs mailing list