EEVEE Next: Ambient Occlusion #108398

Merged
Miguel Pozo merged 29 commits from pragma37/blender:pull-eevee-next-ao into main 2023-06-30 19:37:37 +02:00
4 changed files with 15 additions and 27 deletions
Showing only changes of commit 5f7a76ced1 - Show all commits

View File

@ -168,10 +168,7 @@ class RENDER_PT_eevee_next_ambient_occlusion(RenderButtonsPanel, Panel):
layout.active = props.use_gtao
col = layout.column()
col.prop(props, "gtao_distance")
col.prop(props, "gtao_factor")
col.prop(props, "gtao_quality")
col.prop(props, "use_gtao_bent_normals")
col.prop(props, "use_gtao_bounce")
class RENDER_PT_eevee_motion_blur(RenderButtonsPanel, Panel):

View File

@ -49,10 +49,7 @@ void AmbientOcclusion::init()
}
data_.distance = scene->eevee.gtao_distance;
data_.factor = std::max(1e-4f, scene->eevee.gtao_factor);
data_.quality = scene->eevee.gtao_quality;
pragma37 marked this conversation as resolved Outdated

Remove that. We don't want that in the new implementation. Same for the UI parameter and the code.

This was a NPR parameter that was ported from the old AO implementation and has no meaning in the PBR world. It is a hindrance to a better PBR integration of the AO.

Remove that. We don't want that in the new implementation. Same for the UI parameter and the code. This was a NPR parameter that was ported from the old AO implementation and has no meaning in the PBR world. It is a hindrance to a better PBR integration of the AO.
data_.use_bent_normals = scene->eevee.flag & SCE_EEVEE_GTAO_BENT_NORMALS;
data_.bounce_factor = (scene->eevee.flag & SCE_EEVEE_GTAO_BOUNCE) ? 1.0f : 0.0f;
data_.push_update();
pragma37 marked this conversation as resolved Outdated

Remove also that parameter. Bent normals will be used by default.

Remove also that parameter. Bent normals will be used by default.
pragma37 marked this conversation as resolved Outdated

Also remove.

Also remove.

View File

@ -914,13 +914,9 @@ BLI_STATIC_ASSERT_ALIGN(RayTracingData, 16)
struct AOData {
pragma37 marked this conversation as resolved Outdated

Do not use AO as abreviation in either typenames or members name.

Do not use AO as abreviation in either typenames or members name.
bool1 enabled;
bool1 use_bent_normals;
float distance;
float factor;
float bounce_factor;
float quality;
int _pad0;
int _pad1;
};
BLI_STATIC_ASSERT_ALIGN(AOData, 16)

View File

@ -26,6 +26,8 @@ float cone_cosine(float r)
*/
#define NO_OCCLUSION_DATA OcclusionData(vec4(M_PI, -M_PI, M_PI, -M_PI), 1.0)
pragma37 marked this conversation as resolved Outdated

Prefer a function that returns an empty occlusion data.

Prefer a function that returns an empty occlusion data.
#define AO_BENT_NORMALS true
#define AO_MULTI_BOUNCE true
struct OcclusionData {
/* 4 horizons angles, one in each direction around the view vector to form a cross pattern. */
@ -231,11 +233,11 @@ void occlusion_eval(OcclusionData data,
visibility = saturate(dot(N, Ng) * 0.5 + 0.5);
visibility = min(visibility, data.custom_occlusion);
if (!ao_buf.use_bent_normals) {
bent_normal = N;
if (AO_BENT_NORMALS) {
bent_normal = safe_normalize(N + Ng);
}
else {
bent_normal = safe_normalize(N + Ng);
bent_normal = N;
}
return;
}
@ -297,21 +299,21 @@ void occlusion_eval(OcclusionData data,
visibility = min(visibility, data.custom_occlusion);
if (!ao_buf.use_bent_normals) {
bent_normal = N;
}
else {
if (AO_BENT_NORMALS) {
/* NOTE: using pow(visibility, 6.0) produces NaN (see #87369). */
float tmp = saturate(pow6(visibility));
bent_normal = normalize(mix(bent_normal, N, tmp));
}
else {
bent_normal = N;
}
}
/* Multibounce approximation base on surface albedo.
* Page 78 in the .pdf version. */
float gtao_multibounce(float visibility, vec3 albedo)
{
if (ao_buf.bounce_factor == 0.0) {
if (!AO_MULTI_BOUNCE) {
return visibility;
}
@ -332,9 +334,8 @@ float diffuse_occlusion(OcclusionData data, ivec2 texel, vec3 V, vec3 N, vec3 Ng
float unused_error;
float visibility;
occlusion_eval(data, texel, V, N, Ng, 0.0, visibility, unused_error, unused);
/* Scale by user factor */
visibility = occlusion_pow(saturate(visibility), ao_buf.factor);
return visibility;
return saturate(visibility);
}
float diffuse_occlusion(
@ -345,9 +346,8 @@ float diffuse_occlusion(
occlusion_eval(data, texel, V, N, Ng, 0.0, visibility, unused_error, bent_normal);
visibility = gtao_multibounce(visibility, albedo);
/* Scale by user factor */
visibility = occlusion_pow(saturate(visibility), ao_buf.factor);
return visibility;
return saturate(visibility);
}
/**
@ -409,7 +409,5 @@ float specular_occlusion(
float tmp = saturate(pow8(visibility));
visibility = mix(specular_occlusion, 1.0, tmp);
/* Scale by user factor */
visibility = occlusion_pow(saturate(visibility), ao_buf.factor);
return visibility;
return saturate(visibility);
}