[Bf-blender-cvs] [6e23433c1a7] master: EEVEE: Lookdev: Add support for partially blurred background

Clément Foucault noreply at git.blender.org
Tue Feb 25 13:28:14 CET 2020


Commit: 6e23433c1a747660d582bfe0d15179a9c7bed51c
Author: Clément Foucault
Date:   Tue Feb 25 13:25:49 2020 +0100
Branches: master
https://developer.blender.org/rB6e23433c1a747660d582bfe0d15179a9c7bed51c

EEVEE: Lookdev: Add support for partially blurred background

This is using the GGX probe as background. This has the drawback of
having the resolution choosed in the indirect lighting setting.
The blurring is not really high-quality.

The pros is that it has a simple implementation and is fast to evaluate.

This patch also fades the background alpha to make overlay engine draw the
default background color in the correct color space. Removing one colorspace
hack.

Reviewed By: jbakker

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

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/draw/engines/eevee/eevee_lightprobes.c
M	source/blender/draw/engines/eevee/eevee_lookdev.c
M	source/blender/draw/engines/eevee/eevee_materials.c
M	source/blender/draw/engines/eevee/eevee_private.h
M	source/blender/draw/engines/eevee/eevee_shaders.c
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/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 5ca6bbb20b7..e92490bcbdc 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -5415,6 +5415,7 @@ class VIEW3D_PT_shading_lighting(Panel):
                 col.prop(shading, "studiolight_rotate_z", text="Rotation")
                 col.prop(shading, "studiolight_intensity")
                 col.prop(shading, "studiolight_background_alpha")
+                col.prop(shading, "studiolight_background_blur")
                 col = split.column()  # to align properly with above
 
         elif shading.type == 'RENDERED':
@@ -5438,6 +5439,7 @@ class VIEW3D_PT_shading_lighting(Panel):
                 col.prop(shading, "studiolight_rotate_z", text="Rotation")
                 col.prop(shading, "studiolight_intensity")
                 col.prop(shading, "studiolight_background_alpha")
+                col.prop(shading, "studiolight_background_blur")
                 col = split.column()  # to align properly with above
 
 
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index a24165713aa..d34c15161fb 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -4498,5 +4498,19 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
         }
       }
     }
+
+    /* Add Lookdev blur property. */
+    if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "studiolight_blur")) {
+      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_blur = 0.5f;
+            }
+          }
+        }
+      }
+    }
   }
 }
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 52902d84b7e..5e6c11833d3 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -343,7 +343,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
     const float *col = G_draw.block.colorBackground;
 
     /* LookDev */
-    EEVEE_lookdev_cache_init(vedata, &grp, psl->probe_background, 1.0f, wo, pinfo);
+    EEVEE_lookdev_cache_init(vedata, sldata, &grp, psl->probe_background, wo, pinfo);
     /* END */
     if (!grp && wo) {
       col = &wo->horr;
diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c
index 55a35087684..e89ef7142ee 100644
--- a/source/blender/draw/engines/eevee/eevee_lookdev.c
+++ b/source/blender/draw/engines/eevee/eevee_lookdev.c
@@ -57,9 +57,9 @@ static void eevee_lookdev_lightcache_delete(EEVEE_Data *vedata)
 }
 
 void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
-                              DRWShadingGroup **grp,
+                              EEVEE_ViewLayerData *sldata,
+                              DRWShadingGroup **r_grp,
                               DRWPass *pass,
-                              float background_alpha,
                               World *UNUSED(world),
                               EEVEE_LightProbesInfo *pinfo)
 {
@@ -69,8 +69,11 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
   EEVEE_PrivateData *g_data = stl->g_data;
   const DRWContextState *draw_ctx = DRW_context_state_get();
   View3D *v3d = draw_ctx->v3d;
+  View3DShading *shading = &v3d->shading;
   Scene *scene = draw_ctx->scene;
 
+  const bool probe_render = pinfo != NULL;
+
   effects->lookdev_view = NULL;
 
   if (LOOK_DEV_OVERLAY_ENABLED(v3d)) {
@@ -95,12 +98,11 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
   }
 
   if (LOOK_DEV_STUDIO_LIGHT_ENABLED(v3d)) {
-    StudioLight *sl = BKE_studiolight_find(v3d->shading.lookdev_light,
+    StudioLight *sl = BKE_studiolight_find(shading->lookdev_light,
                                            STUDIOLIGHT_ORIENTATIONS_MATERIAL_MODE);
     if (sl && (sl->flag & STUDIOLIGHT_TYPE_WORLD)) {
-      GPUShader *shader = EEVEE_shaders_default_studiolight_sh_get();
-      struct GPUBatch *geom = DRW_cache_fullscreen_quad_get();
-      GPUTexture *tex = NULL;
+      GPUShader *shader = probe_render ? EEVEE_shaders_default_studiolight_sh_get() :
+                                         EEVEE_shaders_background_studiolight_sh_get();
 
       /* If one of the component is missing we start from scratch. */
       if ((stl->lookdev_grid_data == NULL) || (stl->lookdev_cube_data == NULL) ||
@@ -138,49 +140,45 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
         txl->lookdev_cube_tx = stl->lookdev_lightcache->cube_tx.tex;
       }
 
-      stl->g_data->light_cache = stl->lookdev_lightcache;
-
-      static float background_color[4];
-      UI_GetThemeColor4fv(TH_BACK, background_color);
-      /* XXX: Really quick conversion to avoid washed out background.
-       * Needs to be addressed properly (color managed using ocio). */
-      srgb_to_linearrgb_v4(background_color, background_color);
-
-      *grp = DRW_shgroup_create(shader, pass);
-      axis_angle_to_mat3_single(
-          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) {
+      g_data->light_cache = stl->lookdev_lightcache;
+
+      DRWShadingGroup *grp = *r_grp = DRW_shgroup_create(shader, pass);
+      axis_angle_to_mat3_single(g_data->studiolight_matrix, 'Z', shading->studiolight_rot_z);
+      DRW_shgroup_uniform_mat3(grp, "StudioLightMatrix", g_data->studiolight_matrix);
+
+      if (probe_render) {
+        DRW_shgroup_uniform_float_copy(
+            grp, "studioLightIntensity", shading->studiolight_intensity);
+        BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE);
+        DRW_shgroup_uniform_texture(grp, "image", sl->equirect_radiance_gputexture);
         /* Do not fadeout when doing probe rendering, only when drawing the background */
-        DRW_shgroup_uniform_float(
-            *grp, "studioLightBackground", &v3d->shading.studiolight_background, 1);
-        BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECT_IRRADIANCE_GPUTEXTURE);
-        tex = sl->equirect_irradiance_gputexture;
+        DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", 1.0f);
       }
       else {
-        DRW_shgroup_uniform_float_copy(*grp, "studioLightBackground", 1.0f);
-        BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EQUIRECT_RADIANCE_GPUTEXTURE);
-        tex = sl->equirect_radiance_gputexture;
+        float background_alpha = g_data->background_alpha * shading->studiolight_background;
+        float studiolight_blur = powf(shading->studiolight_blur, 2.5f);
+        DRW_shgroup_uniform_float_copy(grp, "backgroundAlpha", background_alpha);
+        DRW_shgroup_uniform_float_copy(grp, "studioLightBlur", studiolight_blur);
+        DRW_shgroup_uniform_texture(grp, "probeCubes", txl->lookdev_cube_tx);
+        DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
+        DRW_shgroup_uniform_block(grp, "grid_block", sldata->grid_ubo);
+        DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
+        DRW_shgroup_uniform_block(grp, "common_block", sldata->common_ubo);
       }
-      DRW_shgroup_uniform_texture(*grp, "image", tex);
+
+      DRW_shgroup_call(grp, DRW_cache_fullscreen_quad_get(), NULL);
 
       /* 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_rot_z != shading->studiolight_rot_z ||
+          g_data->studiolight_intensity != 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_rot_z = shading->studiolight_rot_z;
+        g_data->studiolight_intensity = 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_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index 3c793ca0693..0c9efeb0a16 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -1158,8 +1158,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
 
     const float *col = G_draw.block.colorBackground;
 
-    EEVEE_lookdev_cache_init(
-        vedata, &grp, psl->background_pass, stl->g_data->background_alpha, wo, NULL);
+    EEVEE_lookdev_cache_init(vedata, sldata, &grp, psl->background_pass, wo, NULL);
 
     if (!grp && wo) {
       col = &wo->horr;
diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h
index dfe3dc5a538..a2ed0a16d89 100644
--- a/source/blen

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list