EEVEE-Next: Scene Reflection Probe Resolution

This PR reuses the scene specific reflection probe resolution for all
reflection light probes in the scene. The target is to have a automatic
detection for the resolution. But as long as we don't have a mechanism
for detection it is better to not introduce a new UI element that will
be removed within the foreseen future.

This setting is currently used by EEVEE and EEVEE-Next. EEVEE supports
resolutions upto 4096px. This will be clamped to 2048 when using
EEVEE-Next.

The motivation for this is that EEVEE-Next will soon replace
EEVEE and 4096 can then be removed from the choices that the user can
made. Adding as separate option could need synchronization, and that
option would also be temporary as it will be removed by the resolution
detection mechanism.

Pull Request: https://projects.blender.org/blender/blender/pulls/113491
This commit is contained in:
Jeroen Bakker
2023-10-10 14:50:17 +02:00
parent 57fc3d48b8
commit 25a1cea8e2
9 changed files with 34 additions and 44 deletions

View File

@@ -1160,12 +1160,6 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
}
/* Set default bake resolution. */
if (!DNA_struct_member_exists(fd->filesdna, "LightProbe", "int", "resolution")) {
LISTBASE_FOREACH (LightProbe *, lightprobe, &bmain->lightprobes) {
lightprobe->resolution = LIGHT_PROBE_RESOLUTION_1024;
}
}
if (!DNA_struct_member_exists(fd->filesdna, "World", "int", "probe_resolution")) {
LISTBASE_FOREACH (World *, world, &bmain->worlds) {
world->probe_resolution = LIGHT_PROBE_RESOLUTION_1024;

View File

@@ -141,6 +141,25 @@ void ReflectionProbeModule::sync_world_lookdev()
}
}
eLightProbeResolution ReflectionProbeModule::reflection_probe_resolution() const
{
switch (instance_.scene->eevee.gi_cubemap_resolution) {
case 64:
return LIGHT_PROBE_RESOLUTION_64;
case 128:
return LIGHT_PROBE_RESOLUTION_128;
case 256:
return LIGHT_PROBE_RESOLUTION_256;
case 512:
return LIGHT_PROBE_RESOLUTION_512;
case 1024:
return LIGHT_PROBE_RESOLUTION_1024;
default:
return LIGHT_PROBE_RESOLUTION_2048;
}
return LIGHT_PROBE_RESOLUTION_2048;
}
void ReflectionProbeModule::sync_object(Object *ob, ObjectHandle &ob_handle)
{
const ::LightProbe *light_probe = (::LightProbe *)ob->data;
@@ -148,8 +167,7 @@ void ReflectionProbeModule::sync_object(Object *ob, ObjectHandle &ob_handle)
return;
}
const bool is_dirty = ob_handle.recalc != 0;
int subdivision = layer_subdivision_for(
max_resolution_, static_cast<eLightProbeResolution>(light_probe->resolution));
int subdivision = layer_subdivision_for(max_resolution_, reflection_probe_resolution());
ReflectionProbe &probe = find_or_insert(ob_handle, subdivision);
probe.do_render |= is_dirty;
probe.is_probe_used = true;

View File

@@ -163,6 +163,8 @@ class ReflectionProbeModule {
bool has_only_world_probe() const;
eLightProbeResolution reflection_probe_resolution() const;
/* Capture View requires access to the cube-maps texture for frame-buffer configuration. */
friend class CaptureView;
/* Instance requires access to #update_probes_this_sample_ */

View File

@@ -42,7 +42,6 @@
.intensity = 1.0f, \
.flag = LIGHTPROBE_FLAG_SHOW_INFLUENCE, \
.grid_flag = LIGHTPROBE_GRID_CAPTURE_INDIRECT | LIGHTPROBE_GRID_CAPTURE_EMISSION, \
.resolution = LIGHT_PROBE_RESOLUTION_1024, \
}
/** \} */

View File

@@ -67,7 +67,7 @@ typedef struct LightProbe {
/** Irradiance grid: Dilation. */
float grid_dilation_threshold;
float grid_dilation_radius;
char _pad1[4];
/** Light intensity clamp. */
float grid_clamp_direct;
float grid_clamp_indirect;
@@ -75,26 +75,10 @@ typedef struct LightProbe {
/** Surface element density for scene surface cache. In surfel per unit distance. */
float surfel_density;
/**
* Resolution of the cube light probe when baked to a texture.
* Contains `eLightProbeResolution`.
*/
int resolution;
/** Object visibility group, inclusive or exclusive. */
struct Collection *visibility_grp;
} LightProbe;
/* LightProbe->resolution, World->probe_resolution. */
typedef enum eLightProbeResolution {
LIGHT_PROBE_RESOLUTION_64 = 6,
LIGHT_PROBE_RESOLUTION_128 = 7,
LIGHT_PROBE_RESOLUTION_256 = 8,
LIGHT_PROBE_RESOLUTION_512 = 9,
LIGHT_PROBE_RESOLUTION_1024 = 10,
LIGHT_PROBE_RESOLUTION_2048 = 11,
} eLightProbeResolution;
/* Probe->type */
enum {
LIGHTPROBE_TYPE_CUBE = 0,

View File

@@ -116,3 +116,13 @@ enum {
*/
WO_DS_SHOW_TEXS = 1 << 2,
};
/** #World::probe_resolution. */
typedef enum eLightProbeResolution {
LIGHT_PROBE_RESOLUTION_64 = 6,
LIGHT_PROBE_RESOLUTION_128 = 7,
LIGHT_PROBE_RESOLUTION_256 = 8,
LIGHT_PROBE_RESOLUTION_512 = 9,
LIGHT_PROBE_RESOLUTION_1024 = 10,
LIGHT_PROBE_RESOLUTION_2048 = 11,
} eLightProbeResolution;

View File

@@ -57,16 +57,6 @@ static EnumPropertyItem lightprobe_type_items[] = {
{0, nullptr, 0, nullptr, nullptr},
};
static EnumPropertyItem lightprobe_resolution_items[] = {
{LIGHT_PROBE_RESOLUTION_64, "64", 0, "64", ""},
{LIGHT_PROBE_RESOLUTION_128, "128", 0, "128", ""},
{LIGHT_PROBE_RESOLUTION_256, "256", 0, "256", ""},
{LIGHT_PROBE_RESOLUTION_512, "512", 0, "512", ""},
{LIGHT_PROBE_RESOLUTION_1024, "1024", 0, "1024", ""},
{LIGHT_PROBE_RESOLUTION_2048, "2048", 0, "2048", ""},
{0, nullptr, 0, nullptr, nullptr},
};
static void rna_def_lightprobe(BlenderRNA *brna)
{
StructRNA *srna;
@@ -296,12 +286,6 @@ static void rna_def_lightprobe(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Visibility Blur", "Filter size of the visibility blur");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
prop = RNA_def_property(srna, "resolution", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, nullptr, "resolution");
RNA_def_property_enum_items(prop, lightprobe_resolution_items);
RNA_def_property_ui_text(prop, "Resolution", "Resolution when baked to a texture");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
prop = RNA_def_property(srna, "intensity", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, nullptr, "intensity");
RNA_def_property_range(prop, 0.0f, FLT_MAX);