EEVEE-Next: Add jittering in fast GI bitmask angle

This avoids banding artifacts caused by the finite bitmask
using for Fast GI / Ambient Occlusion.

Fix #116032
This commit is contained in:
Clément Foucault
2024-05-29 15:49:42 +02:00
parent 40e036b63e
commit 204f56e59d
5 changed files with 21 additions and 17 deletions

View File

@@ -134,9 +134,9 @@ void Sampling::step()
data_.dimensions[SAMPLING_RAYTRACE_X] = r[0];
}
{
double2 r, offset = {0, 0};
uint2 primes = {5, 7};
BLI_halton_2d(primes, offset, sample_ + 1, r);
double3 r, offset = {0, 0, 0};
uint3 primes = {5, 7, 3};
BLI_halton_3d(primes, offset, sample_ + 1, r);
data_.dimensions[SAMPLING_LENS_U] = r[0];
data_.dimensions[SAMPLING_LENS_V] = r[1];
/* TODO de-correlate. */
@@ -145,6 +145,7 @@ void Sampling::step()
/* TODO de-correlate. */
data_.dimensions[SAMPLING_AO_U] = r[0];
data_.dimensions[SAMPLING_AO_V] = r[1];
data_.dimensions[SAMPLING_AO_W] = r[2];
/* TODO de-correlate. */
data_.dimensions[SAMPLING_CURVES_U] = r[0];
}

View File

@@ -250,20 +250,21 @@ enum eSamplingDimension : uint32_t {
SAMPLING_RAYTRACE_X = 18u,
SAMPLING_AO_U = 19u,
SAMPLING_AO_V = 20u,
SAMPLING_CURVES_U = 21u,
SAMPLING_VOLUME_U = 22u,
SAMPLING_VOLUME_V = 23u,
SAMPLING_VOLUME_W = 24u,
SAMPLING_SHADOW_I = 25u,
SAMPLING_SHADOW_J = 26u,
SAMPLING_SHADOW_K = 27u,
SAMPLING_AO_W = 21u,
SAMPLING_CURVES_U = 22u,
SAMPLING_VOLUME_U = 23u,
SAMPLING_VOLUME_V = 24u,
SAMPLING_VOLUME_W = 25u,
SAMPLING_SHADOW_I = 26u,
SAMPLING_SHADOW_J = 27u,
SAMPLING_SHADOW_K = 28u,
};
/**
* IMPORTANT: Make sure the array can contain all sampling dimensions.
* Also note that it needs to be multiple of 4.
*/
#define SAMPLING_DIMENSION_COUNT 28
#define SAMPLING_DIMENSION_COUNT 32
/* NOTE(@fclem): Needs to be used in #StorageBuffer because of arrays of scalar. */
struct SamplingData {

View File

@@ -26,10 +26,10 @@ void main()
vec3 N = imageLoad(in_normal_img, ivec3(texel, in_normal_img_layer_index)).xyz;
vec3 vN = drw_normal_world_to_view(N);
vec2 noise;
vec3 noise;
noise.x = interlieved_gradient_noise(vec2(texel), 3.0, 0.0);
noise.y = utility_tx_fetch(utility_tx, vec2(texel), UTIL_BLUE_NOISE_LAYER).r;
noise = fract(noise + sampling_rng_2D_get(SAMPLING_AO_U));
noise.yz = utility_tx_fetch(utility_tx, vec2(texel), UTIL_BLUE_NOISE_LAYER).rg;
noise = fract(noise + sampling_rng_3D_get(SAMPLING_AO_U));
HorizonScanResult scan = horizon_scan_eval(vP,
vN,

View File

@@ -43,8 +43,8 @@ void main()
vec3 vP = drw_point_screen_to_view(vec3(uv, depth));
vec3 vN = horizon_scan_sample_normal(uv);
vec2 noise = utility_tx_fetch(utility_tx, vec2(texel), UTIL_BLUE_NOISE_LAYER).rg;
noise = fract(noise + sampling_rng_2D_get(SAMPLING_AO_U));
vec3 noise = utility_tx_fetch(utility_tx, vec2(texel), UTIL_BLUE_NOISE_LAYER).rgb;
noise = fract(noise + sampling_rng_3D_get(SAMPLING_AO_U));
HorizonScanResult scan = horizon_scan_eval(vP,
vN,

View File

@@ -65,7 +65,7 @@ struct HorizonScanResult {
*/
HorizonScanResult horizon_scan_eval(vec3 vP,
vec3 vN,
vec2 noise,
vec3 noise,
vec2 pixel_size,
float search_distance,
float thickness_near,
@@ -112,6 +112,8 @@ HorizonScanResult horizon_scan_eval(vec3 vP,
horizon_scan_projected_normal_to_plane_angle_and_length(vN, vV, vT, vB, vN_length, vN_angle);
vN_angle += (noise.z - 0.5) * (M_PI / 32.0) * angle_bias;
SphericalHarmonicL1 sh_slice = spherical_harmonics_L1_new();
float weight_slice;