[Bf-blender-cvs] [3f762dd7640] blender2.8-workbench: Workbench: clean up the viewport shading code
Jeroen Bakker
noreply at git.blender.org
Tue Apr 17 22:14:37 CEST 2018
Commit: 3f762dd76409a285bc0f40df0ff8a6bae6d065b0
Author: Jeroen Bakker
Date: Tue Apr 17 22:11:56 2018 +0200
Branches: blender2.8-workbench
https://developer.blender.org/rB3f762dd76409a285bc0f40df0ff8a6bae6d065b0
Workbench: clean up the viewport shading code
- added the drawtype_solid, drawtype_wireframe, drawtype_texture to
View3D
- enabled workbench panels for important render engines
- merged workbench_materials to solid_flat_mode. All draw modes will get
its own fast implementation in the workbench
===================================================================
M release/scripts/startup/bl_ui/properties_collection.py
M release/scripts/startup/bl_ui/properties_render.py
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/draw/CMakeLists.txt
R100 source/blender/draw/engines/workbench/shaders/solid_frag.glsl source/blender/draw/engines/workbench/shaders/solid_flat_frag.glsl
M source/blender/draw/engines/workbench/solid_flat_mode.c
D source/blender/draw/engines/workbench/workbench_materials_solid.c
M source/blender/draw/intern/draw_manager.c
M source/blender/makesdna/DNA_object_types.h
M source/blender/makesdna/DNA_view3d_types.h
M source/blender/makesrna/intern/rna_space.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_collection.py b/release/scripts/startup/bl_ui/properties_collection.py
index cced6262be5..60f06b57f3c 100644
--- a/release/scripts/startup/bl_ui/properties_collection.py
+++ b/release/scripts/startup/bl_ui/properties_collection.py
@@ -87,12 +87,7 @@ class COLLECTION_PT_clay_settings(CollectionButtonsPanel, Panel):
class COLLECTION_PT_workbench_settings(CollectionButtonsPanel, Panel):
- bl_label = "Render Settings"
- COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
-
- @classmethod
- def poll(cls, context):
- return context.view_render.engine in cls.COMPAT_ENGINES
+ bl_label = "Workbench Settings"
def draw(self, context):
layout = self.layout
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py
index 11b71d6cb24..6ba49627579 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -913,8 +913,8 @@ class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
class RENDER_PT_workbench_collection_settings(RenderButtonsPanel, Panel):
- bl_label = "Workbench Collection Settings"
- COMPAT_ENGINES = {'BLENDER_WORKBENCH'}
+ bl_label = "Workbench Settings"
+ COMPAT_ENGINES = {'BLENDER_WORKBENCH', 'BLENDER_EEVEE', 'CYCLES'}
def draw(self, context):
layout = self.layout
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 4a24beb36c1..48d0451632a 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -46,7 +46,10 @@ class VIEW3D_HT_header(Header):
# Contains buttons like Mode, Pivot, Manipulator, Layer, Mesh Select Mode...
row = layout
layout.template_header_3D()
- row.prop(view, "viewport_shade")
+ row.prop(view, "viewport_shade", text="", icon_only=True)
+
+ if view.viewport_shade == "SOLID":
+ row.prop(view, "viewport_shade_solid", text="")
if obj:
mode = obj.mode
diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt
index b22c97e352c..9fae5a6c3af 100644
--- a/source/blender/draw/CMakeLists.txt
+++ b/source/blender/draw/CMakeLists.txt
@@ -104,7 +104,6 @@ set(SRC
engines/eevee/eevee_subsurface.c
engines/eevee/eevee_temporal_sampling.c
engines/eevee/eevee_volumes.c
- engines/workbench/workbench_materials_solid.c
engines/workbench/workbench_engine.c
engines/workbench/solid_flat_mode.c
engines/external/external_engine.c
@@ -206,7 +205,7 @@ data_to_c_simple(engines/eevee/shaders/volumetric_resolve_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/volumetric_scatter_frag.glsl SRC)
data_to_c_simple(engines/eevee/shaders/volumetric_integration_frag.glsl SRC)
-data_to_c_simple(engines/workbench/shaders/solid_frag.glsl SRC)
+data_to_c_simple(engines/workbench/shaders/solid_flat_frag.glsl SRC)
data_to_c_simple(engines/workbench/shaders/workbench_vert.glsl SRC)
data_to_c_simple(modes/shaders/common_globals_lib.glsl SRC)
diff --git a/source/blender/draw/engines/workbench/shaders/solid_frag.glsl b/source/blender/draw/engines/workbench/shaders/solid_flat_frag.glsl
similarity index 100%
rename from source/blender/draw/engines/workbench/shaders/solid_frag.glsl
rename to source/blender/draw/engines/workbench/shaders/solid_flat_frag.glsl
diff --git a/source/blender/draw/engines/workbench/solid_flat_mode.c b/source/blender/draw/engines/workbench/solid_flat_mode.c
index 79f1fbd170d..e8d2c61152e 100644
--- a/source/blender/draw/engines/workbench/solid_flat_mode.c
+++ b/source/blender/draw/engines/workbench/solid_flat_mode.c
@@ -19,7 +19,7 @@
*
*/
-/** \file workbench_engine.c
+/** \file solid_flat_mode.c
* \ingroup draw_engine
*
* Simple engine for drawing color and/or depth.
@@ -28,49 +28,112 @@
#include "DRW_render.h"
-#include "BKE_icons.h"
-#include "BKE_idprop.h"
-#include "BKE_main.h"
-
#include "GPU_shader.h"
-#include "workbench_engine.h"
#include "workbench_private.h"
/* Shaders */
-#define WORKBENCH_ENGINE "BLENDER_WORKBENCH"
+extern char datatoc_solid_flat_frag_glsl[];
+extern char datatoc_workbench_vert_glsl[];
+
+/* *********** STATIC *********** */
+static struct {
+ struct GPUShader *depth_sh;
+
+ /* Shading Pass */
+ struct GPUShader *solid_sh;
+
+} e_data = {NULL};
/* Functions */
-static void workbench_engine_init(void *UNUSED(vedata))
+static void workbench_solid_flat_engine_init(void *UNUSED(vedata))
{
- workbench_solid_materials_init();
+ if (!e_data.depth_sh) {
+ /* Depth pass */
+ e_data.depth_sh = DRW_shader_create_3D_depth_only();
+
+ /* Shading pass */
+ e_data.solid_sh = DRW_shader_create(
+ datatoc_workbench_vert_glsl, NULL, datatoc_solid_flat_frag_glsl, "\n");
+ }
}
-static void workbench_cache_init(void *vedata)
+static void workbench_solid_flat_cache_init(void *vedata)
{
- workbench_solid_materials_cache_init((WORKBENCH_Data *)vedata);
+
+ WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
+ WORKBENCH_PassList *psl = data->psl;
+ WORKBENCH_StorageList *stl = data->stl;
+
+ if (!stl->g_data) {
+ /* Alloc transient pointers */
+ stl->g_data = MEM_mallocN(sizeof(*stl->g_data), __func__);
+ }
+
+ /* Depth Pass */
+ {
+ int state = DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS;
+ psl->depth_pass = DRW_pass_create("Depth Pass", state);
+ stl->g_data->depth_shgrp = DRW_shgroup_create(e_data.depth_sh, psl->depth_pass);
+ }
+
+ /* Solid Pass */
+ {
+ int state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL;
+ psl->solid_pass = DRW_pass_create("Solid Pass", state);
+ }
+
+ /* Flat Lighting Pass */
+ {
+ int state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL;
+ psl->lighting_pass = DRW_pass_create("Lighting Pass", state);
+ }
}
-static void workbench_cache_populate(void *vedata, Object *ob)
+static void workbench_solid_flat_cache_populate(void *vedata, Object *ob)
{
- workbench_solid_materials_cache_populate((WORKBENCH_Data *)vedata, ob);
+ WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
+
+ WORKBENCH_PassList *psl = data->psl;
+ WORKBENCH_StorageList *stl = data->stl;
+
+ IDProperty *props = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_NONE, RE_engine_id_BLENDER_WORKBENCH);
+ const float* color = BKE_collection_engine_property_value_get_float_array(props, "object_color");
+
+ if (!DRW_object_is_renderable(ob))
+ return;
+
+ struct Gwn_Batch *geom = DRW_cache_object_surface_get(ob);
+ DRWShadingGroup *grp;
+ if (geom) {
+ /* Depth */
+ DRW_shgroup_call_add(stl->g_data->depth_shgrp, geom, ob->obmat);
+
+ /* Solid */
+ grp = DRW_shgroup_create(e_data.solid_sh, psl->solid_pass);
+ DRW_shgroup_uniform_vec3(grp, "color", color, 1);
+ DRW_shgroup_call_add(grp, geom, ob->obmat);
+ }
}
-static void workbench_cache_finish(void *vedata)
+static void workbench_solid_flat_cache_finish(void *UNUSED(vedata))
{
- workbench_solid_materials_cache_finish((WORKBENCH_Data *)vedata);
}
-static void workbench_draw_scene(void *vedata)
+static void workbench_solid_flat_draw_scene(void *vedata)
{
- workbench_solid_materials_draw_scene((WORKBENCH_Data *)vedata);
+ WORKBENCH_Data * data = (WORKBENCH_Data *)vedata;
+ WORKBENCH_PassList *psl = ((WORKBENCH_Data *)vedata)->psl;
+
+ DRW_draw_pass(psl->depth_pass);
+ DRW_draw_pass(psl->solid_pass);
}
-static void workbench_engine_free(void)
+static void workbench_solid_flat_engine_free(void)
{
- workbench_solid_materials_free();
+ DRW_SHADER_FREE_SAFE(e_data.solid_sh);
}
static const DrawEngineDataSize workbench_data_size = DRW_VIEWPORT_DATA_SIZE(WORKBENCH_Data);
@@ -79,17 +142,14 @@ DrawEngineType draw_engine_workbench_solid_flat = {
NULL, NULL,
N_("Workbench"),
&workbench_data_size,
- &workbench_engine_init,
- &workbench_engine_free,
- &workbench_cache_init,
- &workbench_cache_populate,
- &workbench_cache_finish,
+ &workbench_solid_flat_engine_init,
+ &workbench_solid_flat_engine_free,
+ &workbench_solid_flat_cache_init,
+ &workbench_solid_flat_cache_populate,
+ &workbench_solid_flat_cache_finish,
NULL,
- &workbench_draw_scene,
+ &workbench_solid_flat_draw_scene,
NULL,
NULL,
NULL,
};
-
-
-#undef WORKBENCH_ENGINE
diff --git a/source/blender/draw/engines/workbench/workbench_materials_solid.c b/source/blender/draw/engines/workbench/workbench_materials_solid.c
deleted file mode 100644
index 6fb26609e90..00000000000
--- a/source/blender/draw/engines/workbench/workbench_materials_solid.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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_materials.c
- * \ingroup draw_engine
- */
-
-#include "workbench_private.h"
-#include "GPU_shader.h"
-
-extern char datatoc_solid_frag_glsl[];
-extern char datatoc_flat_lighting_frag_glsl[];
-extern char datatoc_workbench_vert_glsl[];
-
-/* *********** STATIC *********** */
-static struct {
- struct GPUShader *depth_sh;
-
- /* Shading Pass */
- struct GPUShader *solid_sh;
-
-} e_data = {NULL};
-
-
-void workbench_solid_materials_init() {
- if (!e_data.depth_sh) {
- /* Depth pass */
- e_data.depth_sh = DRW_shader_create_3D_depth_only();
-
- /* Shading pass */
- e_data.solid_sh = DRW_shader_create(
- datatoc_workbench_vert_glsl, NULL, datatoc_solid_frag_glsl, "\n");
- }
-}
-
-void workbench_solid_materials_cache_init(WORKBENCH_Data* vedata)
-{
- WORKBENCH_PassList *psl
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list