Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorJeroen Bakker <j.bakker@atmind.nl>2019-08-27 16:47:30 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2019-09-04 16:57:00 +0300
commit68d1f091583168dce4e52d3c7378b9b0359e903a (patch)
tree07adc7e5f8f353f4bab9f8cdd6f4fd783a13767c /intern
parentd3ab930c880e3a15cd7cd46355663e60119f6bde (diff)
Shading Modes: Material and Render Preview
This change implements the basics as described in {T68312} for the shading modes. * LookDev shading mode is renamed to Material Preview. It always uses Eevee as renderer, and is intended to provide a fast material preview suitable for texture painting, and texture and material setup. * Rendered shading gains "Use Scene Lights" and "Use Scene World" options similar to current Material Preview. These will be enabled by default. When Use Scene World is turned off, HDRIs will be used for lighting instead. These options are available for EEVEE and Cycles. * Renderers will be able to customize the shading settings panel and add additional settings. Reviewed By: brecht, fclem Differential Revision: https://developer.blender.org/D5612
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/blender/CMakeLists.txt2
-rw-r--r--intern/cycles/blender/addon/ui.py40
-rw-r--r--intern/cycles/blender/blender_object.cpp21
-rw-r--r--intern/cycles/blender/blender_session.cpp2
-rw-r--r--intern/cycles/blender/blender_shader.cpp58
-rw-r--r--intern/cycles/blender/blender_sync.cpp13
-rw-r--r--intern/cycles/blender/blender_sync.h15
-rw-r--r--intern/cycles/blender/blender_viewport.cpp59
-rw-r--r--intern/cycles/blender/blender_viewport.h47
9 files changed, 235 insertions, 22 deletions
diff --git a/intern/cycles/blender/CMakeLists.txt b/intern/cycles/blender/CMakeLists.txt
index 9658c7b4a62..66d955768a3 100644
--- a/intern/cycles/blender/CMakeLists.txt
+++ b/intern/cycles/blender/CMakeLists.txt
@@ -29,6 +29,7 @@ set(SRC
blender_shader.cpp
blender_sync.cpp
blender_texture.cpp
+ blender_viewport.cpp
CCL_api.h
blender_object_cull.h
@@ -36,6 +37,7 @@ set(SRC
blender_session.h
blender_texture.h
blender_util.h
+ blender_viewport.h
)
set(LIB
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index b072d9e583e..6f2794531fd 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -2050,6 +2050,45 @@ class CYCLES_RENDER_PT_simplify_culling(CyclesButtonsPanel, Panel):
sub.prop(cscene, "distance_cull_margin", text="Distance")
+class CYCLES_VIEW3D_PT_shading_lighting(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "Lighting"
+ bl_parent_id = 'VIEW3D_PT_shading'
+ COMPAT_ENGINES = {'CYCLES'}
+
+ @classmethod
+ def poll(cls, context):
+ return (context.engine in cls.COMPAT_ENGINES
+ and context.space_data.shading.type == 'RENDERED')
+
+ def draw(self, context):
+ layout = self.layout
+ col = layout.column()
+ split = col.split(factor=0.9)
+
+ shading = context.space_data.shading
+ col.prop(shading, "use_scene_lights_render")
+ col.prop(shading, "use_scene_world_render")
+
+ if not shading.use_scene_world_render:
+ col = layout.column()
+ split = col.split(factor=0.9)
+
+ col = split.column()
+ sub = col.row()
+ sub.scale_y = 0.6
+ sub.template_icon_view(shading, "studio_light", scale_popup=3)
+
+ col = split.column()
+ col.operator("preferences.studiolight_show", emboss=False, text="", icon='PREFERENCES')
+
+ split = layout.split(factor=0.9)
+ col = split.column()
+ col.prop(shading, "studiolight_rotate_z", text="Rotation")
+ col.prop(shading, "studiolight_background_alpha")
+
+
def draw_device(self, context):
scene = context.scene
layout = self.layout
@@ -2131,6 +2170,7 @@ classes = (
CYCLES_RENDER_PT_simplify_viewport,
CYCLES_RENDER_PT_simplify_render,
CYCLES_RENDER_PT_simplify_culling,
+ CYCLES_VIEW3D_PT_shading_lighting,
CYCLES_RENDER_PT_motion_blur,
CYCLES_RENDER_PT_motion_blur_curve,
CYCLES_RENDER_PT_film,
diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp
index b670922ac88..b0599546244 100644
--- a/intern/cycles/blender/blender_object.cpp
+++ b/intern/cycles/blender/blender_object.cpp
@@ -239,7 +239,7 @@ void BlenderSync::sync_light(BL::Object &b_parent,
light->tag_update(scene);
}
-void BlenderSync::sync_background_light(bool use_portal)
+void BlenderSync::sync_background_light(BL::SpaceView3D &b_v3d, bool use_portal)
{
BL::World b_world = b_scene.world();
@@ -283,6 +283,7 @@ void BlenderSync::sync_background_light(bool use_portal)
world_map = b_world.ptr.data;
world_recalc = false;
+ viewport_parameters = BlenderViewportParameters(b_v3d);
}
/* Object */
@@ -293,6 +294,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
float motion_time,
bool show_self,
bool show_particles,
+ bool show_lights,
BlenderObjectCulling &culling,
bool *use_portal)
{
@@ -311,6 +313,10 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
/* light is handled separately */
if (!motion && object_is_light(b_ob)) {
+ if (!show_lights) {
+ return NULL;
+ }
+
/* TODO: don't use lights for excluded layers used as mask layer,
* when dynamic overrides are back. */
#if 0
@@ -507,7 +513,9 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph,
/* Object Loop */
-void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph, float motion_time)
+void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph,
+ BL::SpaceView3D &b_v3d,
+ float motion_time)
{
/* layer data */
bool motion = motion_time != 0.0f;
@@ -530,6 +538,7 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph, float motion_time)
/* object loop */
bool cancel = false;
bool use_portal = false;
+ const bool show_lights = BlenderViewportParameters(b_v3d).use_scene_lights;
BL::ViewLayer b_view_layer = b_depsgraph.view_layer_eval();
@@ -555,6 +564,7 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph, float motion_time)
motion_time,
show_self,
show_particles,
+ show_lights,
culling,
&use_portal);
}
@@ -565,7 +575,7 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph, float motion_time)
progress.set_sync_status("");
if (!cancel && !motion) {
- sync_background_light(use_portal);
+ sync_background_light(b_v3d, use_portal);
/* handle removed data and modified pointers */
if (light_map.post_sync())
@@ -584,6 +594,7 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph, float motion_time)
void BlenderSync::sync_motion(BL::RenderSettings &b_render,
BL::Depsgraph &b_depsgraph,
+ BL::SpaceView3D &b_v3d,
BL::Object &b_override,
int width,
int height,
@@ -621,7 +632,7 @@ void BlenderSync::sync_motion(BL::RenderSettings &b_render,
b_engine.frame_set(frame, subframe);
python_thread_state_save(python_thread_state);
sync_camera_motion(b_render, b_cam, width, height, 0.0f);
- sync_objects(b_depsgraph, 0.0f);
+ sync_objects(b_depsgraph, b_v3d, 0.0f);
}
/* always sample these times for camera motion */
@@ -657,7 +668,7 @@ void BlenderSync::sync_motion(BL::RenderSettings &b_render,
}
/* sync object */
- sync_objects(b_depsgraph, relative_time);
+ sync_objects(b_depsgraph, b_v3d, relative_time);
}
/* we need to set the python thread state again because this
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp
index 8923450c469..1f0816a6edb 100644
--- a/intern/cycles/blender/blender_session.cpp
+++ b/intern/cycles/blender/blender_session.cpp
@@ -861,7 +861,7 @@ void BlenderSession::synchronize(BL::Depsgraph &b_depsgraph_)
/* copy recalc flags, outside of mutex so we can decide to do the real
* synchronization at a later time to not block on running updates */
- sync->sync_recalc(b_depsgraph_);
+ sync->sync_recalc(b_depsgraph_, b_v3d);
/* don't do synchronization if on pause */
if (session_pause) {
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 720f521c589..ca51482c98e 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -1314,19 +1314,23 @@ void BlenderSync::sync_materials(BL::Depsgraph &b_depsgraph, bool update_all)
/* Sync World */
-void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, bool update_all)
+void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, bool update_all)
{
Background *background = scene->background;
Background prevbackground = *background;
BL::World b_world = b_scene.world();
- if (world_recalc || update_all || b_world.ptr.data != world_map) {
+ BlenderViewportParameters new_viewport_parameters(b_v3d);
+
+ if (world_recalc || update_all || b_world.ptr.data != world_map ||
+ viewport_parameters.modified(new_viewport_parameters)) {
Shader *shader = scene->default_background;
ShaderGraph *graph = new ShaderGraph();
/* create nodes */
- if (b_world && b_world.use_nodes() && b_world.node_tree()) {
+ if (new_viewport_parameters.use_scene_world && b_world && b_world.use_nodes() &&
+ b_world.node_tree()) {
BL::ShaderNodeTree b_ntree(b_world.node_tree());
add_nodes(scene, b_engine, b_data, b_depsgraph, b_scene, graph, b_ntree);
@@ -1337,7 +1341,7 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, bool update_all)
shader->volume_sampling_method = get_volume_sampling(cworld);
shader->volume_interpolation_method = get_volume_interpolation(cworld);
}
- else if (b_world) {
+ else if (new_viewport_parameters.use_scene_world && b_world) {
BackgroundNode *background = new BackgroundNode();
background->color = get_float3(b_world.color());
graph->add(background);
@@ -1345,6 +1349,45 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, bool update_all)
ShaderNode *out = graph->output();
graph->connect(background->output("Background"), out->input("Surface"));
}
+ else if (!new_viewport_parameters.use_scene_world) {
+ BackgroundNode *background = new BackgroundNode();
+ graph->add(background);
+
+ LightPathNode *light_path = new LightPathNode();
+ graph->add(light_path);
+
+ MixNode *mix_scene_with_background = new MixNode();
+ mix_scene_with_background->color2 = get_float3(b_world.color());
+ graph->add(mix_scene_with_background);
+
+ EnvironmentTextureNode *texture_environment = new EnvironmentTextureNode();
+ texture_environment->tex_mapping.type = TextureMapping::VECTOR;
+ texture_environment->tex_mapping.rotation[2] = new_viewport_parameters.studiolight_rotate_z;
+ texture_environment->filename = new_viewport_parameters.studiolight_path;
+ graph->add(texture_environment);
+
+ TextureCoordinateNode *texture_coordinate = new TextureCoordinateNode();
+ graph->add(texture_coordinate);
+
+ MixNode *mix_background_with_environment = new MixNode();
+ mix_background_with_environment->fac = new_viewport_parameters.studiolight_background_alpha;
+ mix_background_with_environment->color1 = get_float3(b_world.color());
+ graph->add(mix_background_with_environment);
+
+ ShaderNode *out = graph->output();
+
+ graph->connect(texture_coordinate->output("Generated"),
+ texture_environment->input("Vector"));
+ graph->connect(light_path->output("Is Camera Ray"), mix_scene_with_background->input("Fac"));
+ graph->connect(texture_environment->output("Color"),
+ mix_scene_with_background->input("Color1"));
+ graph->connect(texture_environment->output("Color"),
+ mix_background_with_environment->input("Color2"));
+ graph->connect(mix_background_with_environment->output("Color"),
+ mix_scene_with_background->input("Color2"));
+ graph->connect(mix_scene_with_background->output("Color"), background->input("Color"));
+ graph->connect(background->output("Background"), out->input("Surface"));
+ }
if (b_world) {
/* AO */
@@ -1389,7 +1432,8 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, bool update_all)
background->transparent_roughness_threshold = 0.0f;
}
- background->use_shader = view_layer.use_background_shader;
+ background->use_shader = view_layer.use_background_shader |
+ viewport_parameters.custom_viewport_parameters();
background->use_ao = background->use_ao && view_layer.use_background_ao;
if (background->modified(prevbackground))
@@ -1439,7 +1483,7 @@ void BlenderSync::sync_lights(BL::Depsgraph &b_depsgraph, bool update_all)
}
}
-void BlenderSync::sync_shaders(BL::Depsgraph &b_depsgraph)
+void BlenderSync::sync_shaders(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d)
{
/* for auto refresh images */
bool auto_refresh_update = false;
@@ -1452,7 +1496,7 @@ void BlenderSync::sync_shaders(BL::Depsgraph &b_depsgraph)
shader_map.pre_sync();
- sync_world(b_depsgraph, auto_refresh_update);
+ sync_world(b_depsgraph, b_v3d, auto_refresh_update);
sync_lights(b_depsgraph, auto_refresh_update);
sync_materials(b_depsgraph, auto_refresh_update);
}
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index aec21887088..e50d96cf345 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -80,7 +80,7 @@ BlenderSync::~BlenderSync()
/* Sync */
-void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph)
+void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d)
{
/* Sync recalc flags from blender to cycles. Actual update is done separate,
* so we can do it later on if doing it immediate is not suitable. */
@@ -175,6 +175,11 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph)
}
}
+ BlenderViewportParameters new_viewport_parameters(b_v3d);
+ if (viewport_parameters.modified(new_viewport_parameters)) {
+ world_recalc = true;
+ }
+
/* Updates shader with object dependency if objects changed. */
if (has_updated_objects) {
if (scene->default_background->has_object_dependency) {
@@ -202,7 +207,7 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render,
sync_view_layer(b_v3d, b_view_layer);
sync_integrator();
sync_film();
- sync_shaders(b_depsgraph);
+ sync_shaders(b_depsgraph, b_v3d);
sync_images();
sync_curve_settings();
@@ -210,9 +215,9 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render,
if (scene->need_motion() == Scene::MOTION_PASS || scene->need_motion() == Scene::MOTION_NONE ||
scene->camera->motion_position == Camera::MOTION_POSITION_CENTER) {
- sync_objects(b_depsgraph);
+ sync_objects(b_depsgraph, b_v3d);
}
- sync_motion(b_render, b_depsgraph, b_override, width, height, python_thread_state);
+ sync_motion(b_render, b_depsgraph, b_v3d, b_override, width, height, python_thread_state);
mesh_synced.clear();
diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h
index 00afceebde3..c6c7b7549cf 100644
--- a/intern/cycles/blender/blender_sync.h
+++ b/intern/cycles/blender/blender_sync.h
@@ -23,6 +23,7 @@
#include "RNA_blender_cpp.h"
#include "blender/blender_util.h"
+#include "blender/blender_viewport.h"
#include "render/scene.h"
#include "render/session.h"
@@ -36,6 +37,7 @@ CCL_NAMESPACE_BEGIN
class Background;
class BlenderObjectCulling;
+class BlenderViewportParameters;
class Camera;
class Film;
class Light;
@@ -59,7 +61,7 @@ class BlenderSync {
~BlenderSync();
/* sync */
- void sync_recalc(BL::Depsgraph &b_depsgraph);
+ void sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d);
void sync_data(BL::RenderSettings &b_render,
BL::Depsgraph &b_depsgraph,
BL::SpaceView3D &b_v3d,
@@ -106,17 +108,18 @@ class BlenderSync {
/* sync */
void sync_lights(BL::Depsgraph &b_depsgraph, bool update_all);
void sync_materials(BL::Depsgraph &b_depsgraph, bool update_all);
- void sync_objects(BL::Depsgraph &b_depsgraph, float motion_time = 0.0f);
+ void sync_objects(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, float motion_time = 0.0f);
void sync_motion(BL::RenderSettings &b_render,
BL::Depsgraph &b_depsgraph,
+ BL::SpaceView3D &b_v3d,
BL::Object &b_override,
int width,
int height,
void **python_thread_state);
void sync_film();
void sync_view();
- void sync_world(BL::Depsgraph &b_depsgraph, bool update_all);
- void sync_shaders(BL::Depsgraph &b_depsgraph);
+ void sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, bool update_all);
+ void sync_shaders(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d);
void sync_curve_settings();
void sync_nodes(Shader *shader, BL::ShaderNodeTree &b_ntree);
@@ -134,6 +137,7 @@ class BlenderSync {
float motion_time,
bool show_self,
bool show_particles,
+ bool show_lights,
BlenderObjectCulling &culling,
bool *use_portal);
void sync_light(BL::Object &b_parent,
@@ -143,7 +147,7 @@ class BlenderSync {
int random_id,
Transform &tfm,
bool *use_portal);
- void sync_background_light(bool use_portal);
+ void sync_background_light(BL::SpaceView3D &b_v3d, bool use_portal);
void sync_mesh_motion(BL::Depsgraph &b_depsgraph,
BL::Object &b_ob,
Object *object,
@@ -183,6 +187,7 @@ class BlenderSync {
set<float> motion_times;
void *world_map;
bool world_recalc;
+ BlenderViewportParameters viewport_parameters;
Scene *scene;
bool preview;
diff --git a/intern/cycles/blender/blender_viewport.cpp b/intern/cycles/blender/blender_viewport.cpp
new file mode 100644
index 00000000000..7af509aab09
--- /dev/null
+++ b/intern/cycles/blender/blender_viewport.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2019 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "blender_viewport.h"
+
+CCL_NAMESPACE_BEGIN
+
+BlenderViewportParameters::BlenderViewportParameters()
+ : use_scene_world(true),
+ use_scene_lights(true),
+ studiolight_rotate_z(0.0f),
+ studiolight_background_alpha(1.0f),
+ studiolight_path(ustring())
+{
+}
+
+BlenderViewportParameters::BlenderViewportParameters(BL::SpaceView3D &b_v3d)
+ : BlenderViewportParameters()
+{
+ /* We only copy the parameters if we are in look dev mode. otherwise
+ * defaults are being used. These defaults mimic normal render settings */
+ if (b_v3d && b_v3d.shading().type() == BL::View3DShading::type_RENDERED) {
+ use_scene_world = b_v3d.shading().use_scene_world_render();
+ use_scene_lights = b_v3d.shading().use_scene_lights_render();
+ if (!use_scene_world) {
+ studiolight_rotate_z = b_v3d.shading().studiolight_rotate_z();
+ studiolight_background_alpha = b_v3d.shading().studiolight_background_alpha();
+ studiolight_path = b_v3d.shading().selected_studio_light().path();
+ }
+ }
+}
+
+/* Check if two instances are different. */
+const bool BlenderViewportParameters::modified(const BlenderViewportParameters &other) const
+{
+ return use_scene_world != other.use_scene_world || use_scene_lights != other.use_scene_lights ||
+ studiolight_rotate_z != other.studiolight_rotate_z ||
+ studiolight_background_alpha != other.studiolight_background_alpha ||
+ studiolight_path != other.studiolight_path;
+}
+
+const bool BlenderViewportParameters::custom_viewport_parameters() const
+{
+ return !(use_scene_world && use_scene_lights);
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/blender/blender_viewport.h b/intern/cycles/blender/blender_viewport.h
new file mode 100644
index 00000000000..bb0d7d7f314
--- /dev/null
+++ b/intern/cycles/blender/blender_viewport.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2019 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __BLENDER_VIEWPORT_H__
+#define __BLENDER_VIEWPORT_H__
+
+#include "MEM_guardedalloc.h"
+#include "RNA_types.h"
+#include "RNA_access.h"
+#include "RNA_blender_cpp.h"
+
+#include "util/util_param.h"
+
+CCL_NAMESPACE_BEGIN
+
+class BlenderViewportParameters {
+ private:
+ bool use_scene_world;
+ bool use_scene_lights;
+ float studiolight_rotate_z;
+ float studiolight_background_alpha;
+ ustring studiolight_path;
+
+ BlenderViewportParameters();
+ BlenderViewportParameters(BL::SpaceView3D &b_v3d);
+
+ const bool modified(const BlenderViewportParameters &other) const;
+ const bool custom_viewport_parameters() const;
+ friend class BlenderSync;
+};
+
+CCL_NAMESPACE_END
+
+#endif \ No newline at end of file