[Bf-blender-cvs] [68d1f091583] master: Shading Modes: Material and Render Preview

Jeroen Bakker noreply at git.blender.org
Wed Sep 4 15:58:36 CEST 2019


Commit: 68d1f091583168dce4e52d3c7378b9b0359e903a
Author: Jeroen Bakker
Date:   Tue Aug 27 15:47:30 2019 +0200
Branches: master
https://developer.blender.org/rB68d1f091583168dce4e52d3c7378b9b0359e903a

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

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

M	intern/cycles/blender/CMakeLists.txt
M	intern/cycles/blender/addon/ui.py
M	intern/cycles/blender/blender_object.cpp
M	intern/cycles/blender/blender_session.cpp
M	intern/cycles/blender/blender_shader.cpp
M	intern/cycles/blender/blender_sync.cpp
M	intern/cycles/blender/blender_sync.h
A	intern/cycles/blender/blender_viewport.cpp
A	intern/cycles/blender/blender_viewport.h
M	release/scripts/startup/bl_ui/properties_material.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/intern/screen.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/draw/engines/eevee/eevee_private.h
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/makesdna/DNA_view3d_types.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/windowmanager/intern/wm_init_exit.c

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

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.st

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list