Commit: c8859d8f66c6e0f4697c64ad3057f0992ff0ff78
Author: Clément Foucault
Date:   Fri Jun 22 20:19:48 2018 +0200
Branches: temp-eeveelightcache
https://developer.blender.org/rBc8859d8f66c6e0f4697c64ad3057f0992ff0ff78

Eevee: LightCache: Add UI to control visibility of the lighcache data

For the moment we use a per scene setting for that. We could move it to be
per viewport (as an overlay).

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

M       release/scripts/startup/bl_ui/properties_render.py
M       source/blender/blenkernel/intern/scene.c
M       source/blender/blenloader/intern/versioning_280.c
M       source/blender/draw/engines/eevee/eevee_lightprobes.c
M       
source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
M       source/blender/makesdna/DNA_scene_types.h
M       source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/properties_render.py 
b/release/scripts/startup/bl_ui/properties_render.py
index b03439682ac..4d2b8fd2163 100644
--- a/release/scripts/startup/bl_ui/properties_render.py
+++ b/release/scripts/startup/bl_ui/properties_render.py
@@ -721,6 +721,23 @@ class 
RENDER_PT_eevee_indirect_lighting(RenderButtonsPanel, Panel):
         col.prop(props, "gi_cubemap_resolution")
         col.prop(props, "gi_visibility_resolution")
 
+        layout.use_property_split = False
+        row = layout.row(align=True)
+        row.label("Cubemap Display")
+        row.prop(props, "gi_cubemap_draw_size", text="Size")
+        if props.gi_show_cubemaps :
+            row.prop(props, "gi_show_cubemaps", text="", toggle=True, 
icon='HIDE_OFF')
+        else:
+            row.prop(props, "gi_show_cubemaps", text="", toggle=True, 
icon='HIDE_ON')
+
+        row = layout.row(align=True)
+        row.label("Irradiance Display")
+        row.prop(props, "gi_irradiance_draw_size", text="Size")
+        if props.gi_show_irradiance :
+            row.prop(props, "gi_show_irradiance", text="", toggle=True, 
icon='HIDE_OFF')
+        else:
+            row.prop(props, "gi_show_irradiance", text="", toggle=True, 
icon='HIDE_ON')
+
 
 class RENDER_PT_eevee_film(RenderButtonsPanel, Panel):
     bl_label = "Film"
diff --git a/source/blender/blenkernel/intern/scene.c 
b/source/blender/blenkernel/intern/scene.c
index ee0b6b75e3a..14b816c47f3 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -825,6 +825,8 @@ void BKE_scene_init(Scene *sce)
        sce->eevee.gi_diffuse_bounces = 3;
        sce->eevee.gi_cubemap_resolution = 512;
        sce->eevee.gi_visibility_resolution = 32;
+       sce->eevee.gi_cubemap_draw_size = 0.2f;
+       sce->eevee.gi_irradiance_draw_size = 1.0f;
 
        sce->eevee.taa_samples = 16;
        sce->eevee.taa_render_samples = 64;
diff --git a/source/blender/blenloader/intern/versioning_280.c 
b/source/blender/blenloader/intern/versioning_280.c
index 53e9ada214b..122405a9067 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -1526,5 +1526,11 @@ void blo_do_versions_280(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
                        }
                }
 
+               if (!DNA_struct_elem_find(fd->filesdna, "SceneEEVEE", "float", 
"gi_cubemap_draw_size")) {
+                       for (Scene *scene = bmain->scene.first; scene; scene = 
scene->id.next) {
+                               scene->eevee.gi_irradiance_draw_size = 0.2f;
+                               scene->eevee.gi_cubemap_draw_size = 1.0f;
+                       }
+               }
        }
 }
diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c 
b/source/blender/draw/engines/eevee/eevee_lightprobes.c
index 07e318537ff..7520b8e0e7c 100644
--- a/source/blender/draw/engines/eevee/eevee_lightprobes.c
+++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c
@@ -371,6 +371,8 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData 
*sldata, EEVEE_Data *vedat
        EEVEE_StorageList *stl = vedata->stl;
        EEVEE_LightProbesInfo *pinfo = sldata->probes;
        EEVEE_LightCache *lcache = stl->g_data->light_cache;
+       const DRWContextState *draw_ctx = DRW_context_state_get();
+       const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph);
 
        {
                psl->probe_background = DRW_pass_create("World Probe Background 
Pass", DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL);
@@ -423,30 +425,34 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData 
*sldata, EEVEE_Data *vedat
                psl->probe_display = DRW_pass_create("LightProbe Display", 
state);
 
                /* Cube Display */
-               int cube_count = GPU_texture_layers(lcache->cube_tx) - 1; /* 
don't count the world. */
-               DRWShadingGroup *grp = 
DRW_shgroup_empty_tri_batch_create(e_data.probe_cube_display_sh,
-                                                                         
psl->probe_display, cube_count * 2);
-               DRW_shgroup_uniform_texture_ref(grp, "probeCubes", 
&lcache->cube_tx);
-               DRW_shgroup_uniform_block(grp, "probe_block", 
sldata->probe_ubo);
-               DRW_shgroup_uniform_block(grp, "common_block", 
sldata->common_ubo);
-               DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", 
DRW_viewport_screenvecs_get(), 2);
-               DRW_shgroup_uniform_float_copy(grp, "sphere_size", 0.2f); /* 
TODO param */
+               if (scene_eval->eevee.flag & SCE_EEVEE_SHOW_CUBEMAPS) {
+                       int cube_count = GPU_texture_layers(lcache->cube_tx) - 
1; /* don't count the world. */
+                       DRWShadingGroup *grp = 
DRW_shgroup_empty_tri_batch_create(e_data.probe_cube_display_sh,
+                                                                               
  psl->probe_display, cube_count * 2);
+                       DRW_shgroup_uniform_texture_ref(grp, "probeCubes", 
&lcache->cube_tx);
+                       DRW_shgroup_uniform_block(grp, "probe_block", 
sldata->probe_ubo);
+                       DRW_shgroup_uniform_block(grp, "common_block", 
sldata->common_ubo);
+                       DRW_shgroup_uniform_vec3(grp, "screen_vecs[0]", 
DRW_viewport_screenvecs_get(), 2);
+                       DRW_shgroup_uniform_float_copy(grp, "sphere_size", 
scene_eval->eevee.gi_cubemap_draw_size * 0.5f);
+               }
 
                /* Grid Display */
-               EEVEE_LightGrid *egrid = lcache->grid_data + 1;
-               for (int p = 1; p < lcache->grid_count; ++p, egrid++) {
-                       DRWShadingGroup *shgrp = 
DRW_shgroup_create(e_data.probe_grid_display_sh, psl->probe_display);
-                       DRW_shgroup_uniform_int(shgrp, "offset", 
&egrid->offset, 1);
-                       DRW_shgroup_uniform_ivec3(shgrp, "grid_resolution", 
egrid->resolution, 1);
-                       DRW_shgroup_uniform_vec3(shgrp, "corner", 
egrid->corner, 1);
-                       DRW_shgroup_uniform_vec3(shgrp, "increment_x", 
egrid->increment_x, 1);
-                       DRW_shgroup_uniform_vec3(shgrp, "increment_y", 
egrid->increment_y, 1);
-                       DRW_shgroup_uniform_vec3(shgrp, "increment_z", 
egrid->increment_z, 1);
-                       DRW_shgroup_uniform_vec3(shgrp, "screen_vecs[0]", 
DRW_viewport_screenvecs_get(), 2);
-                       DRW_shgroup_uniform_texture_ref(shgrp, 
"irradianceGrid", &lcache->grid_tx);
-                       DRW_shgroup_uniform_float_copy(shgrp, "sphere_size", 
1.0f); /* TODO param */
-                       int tri_count = egrid->resolution[0] * 
egrid->resolution[1] * egrid->resolution[2] * 2;
-                       DRW_shgroup_call_procedural_triangles_add(shgrp, 
tri_count, NULL);
+               if (scene_eval->eevee.flag & SCE_EEVEE_SHOW_IRRADIANCE) {
+                       EEVEE_LightGrid *egrid = lcache->grid_data + 1;
+                       for (int p = 1; p < lcache->grid_count; ++p, egrid++) {
+                               DRWShadingGroup *shgrp = 
DRW_shgroup_create(e_data.probe_grid_display_sh, psl->probe_display);
+                               DRW_shgroup_uniform_int(shgrp, "offset", 
&egrid->offset, 1);
+                               DRW_shgroup_uniform_ivec3(shgrp, 
"grid_resolution", egrid->resolution, 1);
+                               DRW_shgroup_uniform_vec3(shgrp, "corner", 
egrid->corner, 1);
+                               DRW_shgroup_uniform_vec3(shgrp, "increment_x", 
egrid->increment_x, 1);
+                               DRW_shgroup_uniform_vec3(shgrp, "increment_y", 
egrid->increment_y, 1);
+                               DRW_shgroup_uniform_vec3(shgrp, "increment_z", 
egrid->increment_z, 1);
+                               DRW_shgroup_uniform_vec3(shgrp, 
"screen_vecs[0]", DRW_viewport_screenvecs_get(), 2);
+                               DRW_shgroup_uniform_texture_ref(shgrp, 
"irradianceGrid", &lcache->grid_tx);
+                               DRW_shgroup_uniform_float_copy(shgrp, 
"sphere_size", scene_eval->eevee.gi_irradiance_draw_size * 0.5f);
+                               int tri_count = egrid->resolution[0] * 
egrid->resolution[1] * egrid->resolution[2] * 2;
+                               
DRW_shgroup_call_procedural_triangles_add(shgrp, tri_count, NULL);
+                       }
                }
 
                /* Planar Display */
@@ -455,7 +461,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData 
*sldata, EEVEE_Data *vedat
                    {"probe_mat", DRW_ATTRIB_FLOAT, 16},
                });
 
-               grp = DRW_shgroup_instance_create(
+               DRWShadingGroup *grp = DRW_shgroup_instance_create(
                        e_data.probe_planar_display_sh,
                        psl->probe_display,
                        DRW_cache_quad_get(),
diff --git 
a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl 
b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
index 4c77430ddf9..7a92b55e530 100644
--- 
a/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
+++ 
b/source/blender/draw/engines/eevee/shaders/lightprobe_grid_display_vert.glsl
@@ -42,7 +42,7 @@ void main()
 
        quadCoord = pos[vert_id];
        vec3 screen_pos = screen_vecs[0] * quadCoord.x + screen_vecs[1] * 
quadCoord.y;
-       ws_cell_location += screen_pos * 0.02 * sphere_size;
+       ws_cell_location += screen_pos * sphere_size;
 
        gl_Position = ViewProjectionMatrix * vec4(ws_cell_location , 1.0);
        gl_Position.z += 0.0001; /* Small bias to let the icon draw without 
zfighting */
diff --git a/source/blender/makesdna/DNA_scene_types.h 
b/source/blender/makesdna/DNA_scene_types.h
index a813286677c..e7b25792445 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1386,6 +1386,9 @@ typedef struct SceneEEVEE {
        int gi_cubemap_resolution;
        int gi_visibility_resolution;
 
+       float gi_cubemap_draw_size;
+       float gi_irradiance_draw_size;
+
        int taa_samples;
        int taa_render_samples;
        int sss_samples;
@@ -2094,6 +2097,8 @@ enum {
        SCE_EEVEE_SSR_ENABLED                   = (1 << 14),
        SCE_EEVEE_SSR_REFRACTION                = (1 << 15),
        SCE_EEVEE_SSR_HALF_RESOLUTION   = (1 << 16),
+       SCE_EEVEE_SHOW_IRRADIANCE               = (1 << 17),
+       SCE_EEVEE_SHOW_CUBEMAPS                 = (1 << 18),
 };
 
 /* SceneEEVEE->shadow_method */
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 4b0c955d51a..06d725eddef 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -5792,6 +5792,28 @@ static void rna_def_scene_eevee(BlenderRNA *brna)
                                       "Size of the shadow map applied to each 
irradiance sample");
        RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
 
+       prop = RNA_def_property(srna, "gi_show_irradiance", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", 
SCE_EEVEE_SHOW_IRRADIANCE);
+       RNA_def_property_boolean_default(prop, 0);
+       RNA_def_property_ui_text(prop, "Show Irradiance Cache", "Display 
irradiance samples in the viewport");
+       RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
+
+       prop = RNA_def_property(srna, "gi_show_cubemaps", PROP_BOOLEAN, 
PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", 
SCE_EEVEE_SHOW_CUBEMAPS);
+       RNA_def_property_boolean_default(prop, 0);
+       RNA_def_property_ui_text(prop, "Show Cubemap Cache", "Display captured 
cubema

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to