Fix T87541 EEVEE: AO causes black outline around objects and NaN pixels
It seems the pow result is unstable on some implementations. Also avoid undefined behavior by clamping aoFactor to strict positive values.
This commit is contained in:
parent
db0b1cab1f
commit
27cfc1ea11
Notes:
blender-bot
2023-02-14 09:24:53 +01:00
Referenced by issue #87541, AO in Eevee causes black outline around objects and hot pixel artificets,
|
@ -61,7 +61,7 @@ int EEVEE_occlusion_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
|
|||
const int fs_size[2] = {(int)viewport_size[0], (int)viewport_size[1]};
|
||||
|
||||
common_data->ao_dist = scene_eval->eevee.gtao_distance;
|
||||
common_data->ao_factor = scene_eval->eevee.gtao_factor;
|
||||
common_data->ao_factor = max_ff(1e-4f, scene_eval->eevee.gtao_factor);
|
||||
common_data->ao_quality = scene_eval->eevee.gtao_quality;
|
||||
|
||||
if (scene_eval->eevee.flag & SCE_EEVEE_GTAO_ENABLED) {
|
||||
|
|
|
@ -386,7 +386,8 @@ float specular_occlusion(
|
|||
float specular_solid_angle = spherical_cap_intersection(M_PI_2, spec_angle, cone_nor_dist);
|
||||
float specular_occlusion = isect_solid_angle / specular_solid_angle;
|
||||
/* Mix because it is unstable in unoccluded areas. */
|
||||
visibility = mix(specular_occlusion, 1.0, pow(visibility, 8.0));
|
||||
float tmp = saturate(pow8(visibility));
|
||||
visibility = mix(specular_occlusion, 1.0, tmp);
|
||||
|
||||
/* Scale by user factor */
|
||||
visibility = pow(saturate(visibility), aoFactor);
|
||||
|
|
|
@ -91,6 +91,8 @@ vec2 sqr(vec2 a) { return a * a; }
|
|||
vec3 sqr(vec3 a) { return a * a; }
|
||||
vec4 sqr(vec4 a) { return a * a; }
|
||||
|
||||
float pow8(float x) { return sqr(sqr(sqr(x))); }
|
||||
|
||||
float len_squared(vec3 a) { return dot(a, a); }
|
||||
float len_squared(vec2 a) { return dot(a, a); }
|
||||
|
||||
|
|
Loading…
Reference in New Issue