[Bf-blender-cvs] [1b287230a46] master: Viewport Shading: StudioLight Intensity

Jeroen Bakker noreply at git.blender.org
Fri Sep 6 08:35:52 CEST 2019


Commit: 1b287230a46d98f7cdfe6cbfd6c86e43c7e14968
Author: Jeroen Bakker
Date:   Wed Sep 4 16:22:47 2019 +0200
Branches: master
https://developer.blender.org/rB1b287230a46d98f7cdfe6cbfd6c86e43c7e14968

Viewport Shading: StudioLight Intensity

Add option to change the Intensity of the HDRI in the 3d viewport. This works for both EEVEE and Cycles

Reviewed By: brecht, fclem

Differential Revision: https://developer.blender.org/D5674

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

M	intern/cycles/blender/addon/ui.py
M	intern/cycles/blender/blender_shader.cpp
M	intern/cycles/blender/blender_viewport.cpp
M	intern/cycles/blender/blender_viewport.h
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenkernel/intern/screen.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/draw/engines/eevee/eevee_lookdev.c
M	source/blender/draw/engines/eevee/eevee_private.h
M	source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
M	source/blender/makesdna/DNA_view3d_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 6f2794531fd..0af59411c5c 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -2086,6 +2086,7 @@ class CYCLES_VIEW3D_PT_shading_lighting(Panel):
             split = layout.split(factor=0.9)
             col = split.column()
             col.prop(shading, "studiolight_rotate_z", text="Rotation")
+            col.prop(shading, "studiolight_intensity")
             col.prop(shading, "studiolight_background_alpha")
 
 
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index f5a76002eb6..de04cc7714a 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -1347,6 +1347,14 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
       texture_environment->filename = new_viewport_parameters.studiolight_path;
       graph->add(texture_environment);
 
+      MixNode *mix_intensity = new MixNode();
+      mix_intensity->type = NODE_MIX_MUL;
+      mix_intensity->fac = 1.0f;
+      mix_intensity->color2 = make_float3(new_viewport_parameters.studiolight_intensity,
+                                          new_viewport_parameters.studiolight_intensity,
+                                          new_viewport_parameters.studiolight_intensity);
+      graph->add(mix_intensity);
+
       TextureCoordinateNode *texture_coordinate = new TextureCoordinateNode();
       graph->add(texture_coordinate);
 
@@ -1359,10 +1367,10 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
 
       graph->connect(texture_coordinate->output("Generated"),
                      texture_environment->input("Vector"));
+      graph->connect(texture_environment->output("Color"), mix_intensity->input("Color1"));
       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"),
+      graph->connect(mix_intensity->output("Color"), mix_scene_with_background->input("Color1"));
+      graph->connect(mix_intensity->output("Color"),
                      mix_background_with_environment->input("Color2"));
       graph->connect(mix_background_with_environment->output("Color"),
                      mix_scene_with_background->input("Color2"));
diff --git a/intern/cycles/blender/blender_viewport.cpp b/intern/cycles/blender/blender_viewport.cpp
index 7af509aab09..93dd8faa450 100644
--- a/intern/cycles/blender/blender_viewport.cpp
+++ b/intern/cycles/blender/blender_viewport.cpp
@@ -21,6 +21,7 @@ BlenderViewportParameters::BlenderViewportParameters()
     : use_scene_world(true),
       use_scene_lights(true),
       studiolight_rotate_z(0.0f),
+      studiolight_intensity(1.0f),
       studiolight_background_alpha(1.0f),
       studiolight_path(ustring())
 {
@@ -36,6 +37,7 @@ BlenderViewportParameters::BlenderViewportParameters(BL::SpaceView3D &b_v3d)
     use_scene_lights = b_v3d.shading().use_scene_lights_render();
     if (!use_scene_world) {
       studiolight_rotate_z = b_v3d.shading().studiolight_rotate_z();
+      studiolight_intensity = b_v3d.shading().studiolight_intensity();
       studiolight_background_alpha = b_v3d.shading().studiolight_background_alpha();
       studiolight_path = b_v3d.shading().selected_studio_light().path();
     }
@@ -47,6 +49,7 @@ const bool BlenderViewportParameters::modified(const BlenderViewportParameters &
 {
   return use_scene_world != other.use_scene_world || use_scene_lights != other.use_scene_lights ||
          studiolight_rotate_z != other.studiolight_rotate_z ||
+         studiolight_intensity != other.studiolight_intensity ||
          studiolight_background_alpha != other.studiolight_background_alpha ||
          studiolight_path != other.studiolight_path;
 }
diff --git a/intern/cycles/blender/blender_viewport.h b/intern/cycles/blender/blender_viewport.h
index bb0d7d7f314..10e89f16e7b 100644
--- a/intern/cycles/blender/blender_viewport.h
+++ b/intern/cycles/blender/blender_viewport.h
@@ -31,6 +31,7 @@ class BlenderViewportParameters {
   bool use_scene_world;
   bool use_scene_lights;
   float studiolight_rotate_z;
+  float studiolight_intensity;
   float studiolight_background_alpha;
   ustring studiolight_path;
 
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 7d9f84d69a2..89de137df76 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -5131,6 +5131,7 @@ class VIEW3D_PT_shading_lighting(Panel):
                 split = layout.split(factor=0.9)
                 col = split.column()
                 col.prop(shading, "studiolight_rotate_z", text="Rotation")
+                col.prop(shading, "studiolight_intensity")
                 col.prop(shading, "studiolight_background_alpha")
                 col = split.column()  # to align properly with above
 
@@ -5153,6 +5154,7 @@ class VIEW3D_PT_shading_lighting(Panel):
                 split = layout.split(factor=0.9)
                 col = split.column()
                 col.prop(shading, "studiolight_rotate_z", text="Rotation")
+                col.prop(shading, "studiolight_intensity")
                 col.prop(shading, "studiolight_background_alpha")
                 col = split.column()  # to align properly with above
 
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 4837fa8639e..9f049b61b5a 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -869,6 +869,7 @@ void BKE_screen_view3d_shading_init(View3DShading *shading)
   shading->curvature_valley_factor = 1.0f;
   copy_v3_fl(shading->single_color, 0.8f);
   copy_v3_fl(shading->background_color, 0.05f);
+  shading->studiolight_intensity = 1.0f;
 }
 
 /* magic zoom calculation, no idea what
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index 0d108704b4e..ca00e7cc62f 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -3767,7 +3767,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
 
   {
     /* Versioning code until next subversion bump goes here. */
-
     for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
       for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
         for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
@@ -3820,5 +3819,19 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
         }
       }
     }
+
+    /* Added studiolight intensity */
+    if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "studiolight_intensity")) {
+      for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
+        for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+          for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+            if (sl->spacetype == SPACE_VIEW3D) {
+              View3D *v3d = (View3D *)sl;
+              v3d->shading.studiolight_intensity = 1.0f;
+            }
+          }
+        }
+      }
+    }
   }
 }
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index f52fcf31267..94d61a81fcc 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -151,6 +151,9 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
           stl->g_data->studiolight_matrix, 'Z', v3d->shading.studiolight_rot_z);
       DRW_shgroup_uniform_mat3(*grp, "StudioLightMatrix", stl->g_data->studiolight_matrix);
       DRW_shgroup_uniform_float_copy(*grp, "backgroundAlpha", background_alpha);
+      DRW_shgroup_uniform_float(
+          *grp, "studioLightIntensity", &v3d->shading.studiolight_intensity, 1);
+
       DRW_shgroup_uniform_vec3(*grp, "color", background_color, 1);
       DRW_shgroup_call(*grp, geom, NULL);
       if (!pinfo) {
@@ -170,12 +173,14 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
       /* Do we need to recalc the lightprobes? */
       if (g_data->studiolight_index != sl->index ||
           g_data->studiolight_rot_z != v3d->shading.studiolight_rot_z ||
+          g_data->studiolight_intensity != v3d->shading.studiolight_intensity ||
           g_data->studiolight_cubemap_res != scene->eevee.gi_cubemap_resolution ||
           g_data->studiolight_glossy_clamp != scene->eevee.gi_glossy_clamp ||
           g_data->studiolight_filter_quality != scene->eevee.gi_filter_quality) {
         stl->lookdev_lightcache->flag |= LIGHTCACHE_UPDATE_WORLD;
         g_data->studiolight_index = sl->index;
         g_data->studiolight_rot_z = v3d->shading.studiolight_rot_z;
+        g_data->studiolight_intensity = v3d->shading.studiolight_intensity;
         g_data->studiolight_cubemap_res = scene->eevee.gi_cubemap_resolution;
         g_data->studiolight_glossy_clamp = scene->eevee.gi_glossy_clamp;
         g_data->studiolight_filter_quality = scene->eevee.gi_filter_quality;
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index 28a8983cfee..f4f40d40de6 100644
--- a/source/blender/draw/engines/eevee/eevee_private.h
+++ b/source/blender/draw/engines/eevee/eevee_private.h
@@ -789,6 +789,7 @@ typedef struct EEVEE_PrivateData {
   /* LookDev Settings */
   int studiolight_index;
   float studiolight_rot_z;
+  float studiolight_intensity;
   int studiolight_cubemap_res;
   float studiolight_glossy_clamp;
   float studiolight_filter_quality;
diff --git a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl b/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
index 70466479a29..41e103609f3 100644
--- a/source/blender/draw/engines/eevee/shaders/default_world_frag.glsl
+++ b/source/blender/draw/engi

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list