EEVEE-Next: Add Volume Probe > Blending Size setting #118342

Closed
Miguel Pozo wants to merge 3 commits from pragma37/blender:pull-eevee-grid-blending-setting into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
9 changed files with 28 additions and 7 deletions
Showing only changes of commit da6f42da3b - Show all commits

View File

@ -104,6 +104,7 @@ class DATA_PT_lightprobe_eevee_next(DataButtonsPanel, Panel):
col.separator()
col.prop(probe, "intensity")
col.prop(probe, "grid_blending_size")
col.separator()

View File

@ -29,7 +29,7 @@ extern "C" {
/* Blender file format version. */
#define BLENDER_FILE_VERSION BLENDER_VERSION
#define BLENDER_FILE_SUBVERSION 3
#define BLENDER_FILE_SUBVERSION 4
/* Minimum Blender version that supports reading file written with the current
* version. Older Blender versions will test this and cancel loading the file, showing a warning to

View File

@ -2938,6 +2938,12 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
FOREACH_NODETREE_END;
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 402, 4)) {
LISTBASE_FOREACH (LightProbe *, probe, &bmain->lightprobes) {
probe->grid_blending_size = 1.0f;
}
}
/**
* Always bump subversion in BKE_blender_version.h when adding versioning
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.

View File

@ -92,6 +92,8 @@ void LightProbeModule::sync_volume(const Object *ob, ObjectHandle &handle)
grid.view_bias = lightprobe->grid_view_bias;
grid.facing_bias = lightprobe->grid_facing_bias;
grid.blending_size = lightprobe->grid_blending_size;
grid.validity_threshold = lightprobe->grid_validity_threshold;
grid.dilation_threshold = lightprobe->grid_dilation_threshold;
grid.dilation_radius = lightprobe->grid_dilation_radius;

View File

@ -1218,7 +1218,7 @@ struct VolumeProbeData {
float normal_bias;
float view_bias;
float facing_bias;
int _pad1;
float blending_size;
};
BLI_STATIC_ASSERT_ALIGN(VolumeProbeData, 16)

View File

@ -150,7 +150,7 @@ SphericalHarmonicL1 lightprobe_irradiance_sample(
index = i;
#ifdef IRRADIANCE_GRID_SAMPLING
float distance_to_border = reduce_min(min(lP, vec3(grids_infos_buf[i].grid_size) - lP));
if (distance_to_border < random) {
if (distance_to_border < grids_infos_buf[i].blending_size * random) {
/* Remap random to the remaining interval. */
random = (random - distance_to_border) / (1.0 - distance_to_border);
/* Try to sample another grid to get smooth transitions at borders. */

View File

@ -20,6 +20,7 @@
.grid_resolution_x = 4, \
.grid_resolution_y = 4, \
.grid_resolution_z = 4, \
.grid_blending_size = 1.0f, \
.grid_bake_samples = 2048, \
.grid_surface_bias = 0.05, \
.grid_escape_bias = 0.1, \

View File

@ -54,6 +54,8 @@ typedef struct LightProbe {
int grid_resolution_x;
int grid_resolution_y;
int grid_resolution_z;
/** Irradiance grid blending. */
float grid_blending_size;
/** Irradiance grid: number of directions to evaluate light transfer in. */
int grid_bake_samples;
/** Irradiance grid: Virtual offset parameters. */
@ -75,12 +77,11 @@ typedef struct LightProbe {
/** Surface element density for scene surface cache. In surfel per unit distance. */
float surfel_density;
/** Object visibility group, inclusive or exclusive. */
struct Collection *visibility_grp;
/** LIGHTPROBE_FLAG_SHOW_DATA display size. */
float data_display_size;
char _pad1[4];
/** Object visibility group, inclusive or exclusive. */
struct Collection *visibility_grp;
} LightProbe;
/* Probe->type */

View File

@ -160,6 +160,16 @@ static void rna_def_lightprobe(BlenderRNA *brna)
prop, "Resolution Z", "Number of samples along the z axis of the volume");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
prop = RNA_def_property(srna, "grid_blending_size", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_ui_range(prop, 0.0f, 8.0f, 1, 2);
RNA_def_property_ui_text(
prop,
"Blending Size",
"Number of voxels to blend at the grid bounds (avoids harsh cutoffs, but "
"may introduce external bleeding)");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, "rna_LightProbe_recalc");
prop = RNA_def_property(srna, "grid_normal_bias", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_ui_text(prop,
"Normal Bias",