[Bf-blender-cvs] [2bf333b35dd] blender2.8: Workbench: studiolight

Jeroen Bakker noreply at git.blender.org
Thu May 3 15:33:39 CEST 2018


Commit: 2bf333b35dda46e9ec870b4aeec431562284eaf8
Author: Jeroen Bakker
Date:   Thu May 3 15:31:03 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB2bf333b35dda46e9ec870b4aeec431562284eaf8

Workbench: studiolight

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/draw/CMakeLists.txt
M	source/blender/draw/DRW_engine.h
M	source/blender/draw/engines/workbench/workbench_engine.c
M	source/blender/draw/engines/workbench/workbench_materials.c
M	source/blender/draw/engines/workbench/workbench_private.h
A	source/blender/draw/engines/workbench/workbench_studiolight.c
M	source/blender/editors/include/UI_icons.h
M	source/blender/editors/interface/CMakeLists.txt
M	source/blender/editors/interface/interface_icons.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 077af19da8c..5b06f512abe 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3545,38 +3545,17 @@ class VIEW3D_PT_shading(Panel):
         col.prop(shading, "type", expand=True)
 
         if shading.type == 'SOLID':
+            col.separator()
+            col.row().prop(shading, "single_color_mode", expand=True)
+
             col.separator()
             col.row().prop(shading, "light", expand=True)
+            if shading.light == 'STUDIO':
+                col.row().template_icon_view(shading, "studiolight")
 
             col.separator()
-            col.row().prop(shading, "single_color_mode", expand=True)
             col.prop(shading, "show_object_overlap")
 
-            if shading.light == 'STUDIO':
-                # TODO: don't store these settings in the scene
-                scene = context.scene
-                props = scene.layer_properties['BLENDER_WORKBENCH']
-
-                col.separator()
-
-                sub = col.column()
-                sub.label(text="Left/Right:")
-                row = sub.row(align=True)
-                row.prop(props, "diffuse_light_x_neg", text="")
-                row.prop(props, "diffuse_light_x_pos", text="")
-
-                sub = col.column()
-                sub.label(text="Up/Down:")
-                row = sub.row(align=True)
-                row.prop(props, "diffuse_light_y_neg", text="")
-                row.prop(props, "diffuse_light_y_pos", text="")
-
-                sub = col.column()
-                sub.label(text="Front/Back:")
-                row = sub.row(align=True)
-                row.prop(props, "diffuse_light_z_neg", text="")
-                row.prop(props, "diffuse_light_z_pos", text="")
-
 
 class VIEW3D_PT_overlay(Panel):
     bl_space_type = 'VIEW_3D'
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index 0db397433e5..9dadabad4b0 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -107,6 +107,7 @@ set(SRC
 	engines/eevee/eevee_volumes.c
 	engines/workbench/workbench_engine.c
 	engines/workbench/workbench_materials.c
+	engines/workbench/workbench_studiolight.c
 	engines/workbench/solid_mode.c
 	engines/external/external_engine.c
 
diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index e300bcad8bf..22dc116d4a6 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -142,4 +142,5 @@ void DRW_opengl_context_disable(void);
 
 void DRW_deferred_shader_remove(struct GPUMaterial *mat);
 
+unsigned int *WORKBENCH_generate_studiolight_preview(int studiolight_id, int icon_size);
 #endif /* __DRW_ENGINE_H__ */
diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c
index d4d14125116..f758918d577 100644
--- a/source/blender/draw/engines/workbench/workbench_engine.c
+++ b/source/blender/draw/engines/workbench/workbench_engine.c
@@ -58,20 +58,7 @@ static void workbench_view_layer_settings_create(RenderEngine *UNUSED(engine), I
 	BLI_assert(props &&
 	           props->type == IDP_GROUP &&
 	           props->subtype == IDP_GROUP_SUB_ENGINE_RENDER);
-
-	const float diffuse_x_pos[3] = {1.0,  0.8,   0.6};
-	const float diffuse_x_neg[3] = {1.0,  0.6,   0.6};
-	const float diffuse_y_pos[3] = {0.9,  0.9,   1.0};
-	const float diffuse_y_neg[3] = {0.05, 0.025, 0.025};
-	const float diffuse_z_pos[3] = {0.8,  0.8,   0.75};
-	const float diffuse_z_neg[3] = {1.0,  0.95,  0.8};
-
-	BKE_collection_engine_property_add_float_array(props, "diffuse_light_x_pos", diffuse_x_pos, 3);
-	BKE_collection_engine_property_add_float_array(props, "diffuse_light_x_neg", diffuse_x_neg, 3);
-	BKE_collection_engine_property_add_float_array(props, "diffuse_light_y_pos", diffuse_y_pos, 3);
-	BKE_collection_engine_property_add_float_array(props, "diffuse_light_y_neg", diffuse_y_neg, 3);
-	BKE_collection_engine_property_add_float_array(props, "diffuse_light_z_pos", diffuse_z_pos, 3);
-	BKE_collection_engine_property_add_float_array(props, "diffuse_light_z_neg", diffuse_z_neg, 3);
+	UNUSED_VARS_NDEBUG(props);
 }
 
 /* Note: currently unused, we may want to register so we can see this when debugging the view. */
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c
index b095890f873..69d983b96c7 100644
--- a/source/blender/draw/engines/workbench/workbench_materials.c
+++ b/source/blender/draw/engines/workbench/workbench_materials.c
@@ -257,10 +257,6 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
 	WORKBENCH_PrivateData *wpd = stl->g_data;
 	DefaultTextureList *dtxl = DRW_viewport_texture_list_get();
 	DRWShadingGroup *grp;
-	const DRWContextState *draw_ctx = DRW_context_state_get();
-	ViewLayer *view_layer = draw_ctx->view_layer;
-	IDProperty *props = BKE_view_layer_engine_evaluated_get(view_layer, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_WORKBENCH);
-
 	const DRWContextState *DCS = DRW_context_state_get();
 
 	wpd->material_hash = BLI_ghash_ptr_new(__func__);
@@ -269,10 +265,12 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
 	if (v3d) {
 		wpd->drawtype_lighting = v3d->drawtype_lighting;
 		wpd->drawtype_options = v3d->drawtype_options;
+		wpd->drawtype_studiolight = v3d->drawtype_studiolight;
 	}
 	else {
 		wpd->drawtype_lighting = V3D_LIGHTING_STUDIO;
 		wpd->drawtype_options = 0;
+		wpd->drawtype_studiolight = 0;
 	}
 
 	select_deferred_shaders(wpd);
@@ -281,12 +279,7 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata)
 		WORKBENCH_UBO_World *wd = &wpd->world_data;
 		UI_GetThemeColor3fv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_LOW_GRAD:TH_HIGH_GRAD, wd->background_color_low);
 		UI_GetThemeColor3fv(TH_HIGH_GRAD, wd->background_color_high);
-		copy_v3_v3(wd->diffuse_light_x_pos, BKE_collection_engine_property_value_get_float_array(props, "diffuse_light_x_pos"));
-		copy_v3_v3(wd->diffuse_light_x_neg, BKE_collection_engine_property_value_get_float_array(props, "diffuse_light_x_neg"));
-		copy_v3_v3(wd->diffuse_light_y_pos, BKE_collection_engine_property_value_get_float_array(props, "diffuse_light_y_pos"));
-		copy_v3_v3(wd->diffuse_light_y_neg, BKE_collection_engine_property_value_get_float_array(props, "diffuse_light_y_neg"));
-		copy_v3_v3(wd->diffuse_light_z_pos, BKE_collection_engine_property_value_get_float_array(props, "diffuse_light_z_pos"));
-		copy_v3_v3(wd->diffuse_light_z_neg, BKE_collection_engine_property_value_get_float_array(props, "diffuse_light_z_neg"));
+		studiolight_update_world(wpd->drawtype_studiolight, wd);
 
 		psl->composite_pass = DRW_pass_create("Composite", DRW_STATE_WRITE_COLOR);
 		grp = DRW_shgroup_create(wpd->composite_sh, psl->composite_pass);
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h
index d94cce6e880..1f66fb31095 100644
--- a/source/blender/draw/engines/workbench/workbench_private.h
+++ b/source/blender/draw/engines/workbench/workbench_private.h
@@ -73,6 +73,7 @@ typedef struct WORKBENCH_PrivateData {
 	struct GPUShader *composite_sh;
 	short drawtype_lighting;
 	short drawtype_options;
+	short drawtype_studiolight;
 	struct GPUUniformBuffer *world_ubo;
 	WORKBENCH_UBO_World world_data;
 } WORKBENCH_PrivateData; /* Transient data */
@@ -113,4 +114,7 @@ void workbench_materials_cache_init(WORKBENCH_Data *vedata);
 void workbench_materials_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob);
 void workbench_materials_cache_finish(WORKBENCH_Data *vedata);
 
+/* workbench_studiolight.c */
+void studiolight_update_world(int studio_light, WORKBENCH_UBO_World* wd);
+
 #endif
diff --git a/source/blender/draw/engines/workbench/workbench_studiolight.c b/source/blender/draw/engines/workbench/workbench_studiolight.c
new file mode 100644
index 00000000000..f93a7341212
--- /dev/null
+++ b/source/blender/draw/engines/workbench/workbench_studiolight.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2016, Blender Foundation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Institute
+ *
+ */
+
+/** \file workbench_studiolight.h
+ *  \ingroup draw_engine
+ */
+ #include "DRW_engine.h"
+#include "workbench_private.h"
+
+#include "BLI_math.h"
+
+
+#define STUDIOLIGHT_X_POS 0
+#define STUDIOLIGHT_X_NEG 1
+#define STUDIOLIGHT_Y_POS 2
+#define STUDIOLIGHT_Y_NEG 3
+#define STUDIOLIGHT_Z_POS 4
+#define STUDIOLIGHT_Z_NEG 5
+
+const float studiolights[][6][3] = {
+	{
+		{1.0,  0.8,   0.6}, 
+		{1.0,  0.6,   0.6},
+		{0.9,  0.9,   1.0},
+		{0.05, 0.025, 0.025},
+		{0.8,  0.8,   0.75},
+		{1.0,  0.95,  0.8},
+	},
+	{
+		{0.0, 0.0, 0.0}, 
+		{0.0, 0.0, 0.0}, 
+		{0.0, 0.0, 0.0}, 
+		{0.0, 0.0, 0.0}, 
+		{0.8, 0.8, 1.0}, 
+		{0.0, 0.0, 0.0}, 
+	},
+	{
+		{0.4, 0.3, 0.8}, 
+		{0.4, 0.3, 0.8}, 
+		{0.8, 0.8, 0.2}, 
+		{0.0, 0.0, 0.0}, 
+		{0.4, 0.4, 0.8}, 
+		{0.0, 0.0, 0.0}, 
+	},
+	{
+		{0.2, 0.2, 0.0}, 
+		{0.8, 0.2, 0.0}, 
+		{0.8, 0.2, 0.0}, 
+		{0.2, 0.2, 0.0}, 
+		{0.8, 0.6, 0.4}, 
+		{0.0, 0.0, 0.0}, 
+	},
+	{
+		{0.8, 0.2, 0.0}, 
+		{0.8, 0.2, 0.0}, 
+		{0.8, 0.6, 0.0}, 
+		{0.2, 0.2, 0.0}, 
+		{1.0, 0.5, 0.0}, 
+		{0.0, 0.0, 0.0}, 
+	},
+};
+
+void studiolight_update_world(int studio_light, WORKBENCH_UBO_World* wd) {
+	copy_v3_v3(wd->diffuse_light_x_pos, studiolights[studio_light][STUDIOLIGHT_X_POS]);
+	cop

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list