Fix: EEVEE-Next: Discrepancy in GGX pdf and eval function

This commit is contained in:
Clément Foucault
2024-05-20 19:24:32 +02:00
parent f9f7f25e8d
commit 8d4576d165
2 changed files with 4 additions and 6 deletions

View File

@@ -23,12 +23,10 @@ float sample_pdf_ggx_refract_ex(
}
/* All inputs must be in tangent space. */
float sample_pdf_ggx_refract(vec3 Vt, vec3 Lt, float alpha, float ior, bool is_second_event)
float sample_pdf_ggx_refract(vec3 Vt, vec3 Lt, float alpha, float ior)
{
/* Inverse of `refract(-V, H, 1.0 / ior)` with `Lt * ior + Vt` equivalent to `Lt + Vt / ior`. */
vec3 Ht = normalize(-(Lt * ior + Vt));
/* FIXME(fclem): Why is this necessary? */
Ht = is_second_event ? -Ht : Ht;
vec3 Ht = normalize(ior * Lt + Vt);
Ht = (ior < 1.0) ? Ht : -Ht;
float NH = Ht.z;
float NV = Vt.z;
float VH = dot(Vt, Ht);

View File

@@ -50,7 +50,7 @@ float pdf_eval(ClosureUndetermined cl, vec3 L, vec3 V, float thickness)
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID: {
float ior = to_closure_refraction(cl).ior;
float roughness = max(BSDF_ROUGHNESS_THRESHOLD, to_closure_refraction(cl).roughness);
return sample_pdf_ggx_refract(Vt, Lt, square(roughness), ior, thickness != 0.0);
return sample_pdf_ggx_refract(Vt, Lt, square(roughness), ior);
}
}
/* TODO(fclem): Assert. */