Eevee: Fix NaN
This was surely cause by float overflow. Limit roughness in this case to limit the brdf intensity. Also compute VH faster. Add a sanitizer to the SSR pass for investigating where NANs come from. Play with the roughness until you see where the black pixel is / comes from.
This commit is contained in:
parent
a8e1a7ba6d
commit
0665f58a57
|
@ -85,6 +85,7 @@ float direct_diffuse_unit_disc(vec3 N, vec3 L)
|
|||
/* ----------- GGx ------------ */
|
||||
vec3 direct_ggx_point(vec3 N, vec3 V, vec4 l_vector, float roughness, vec3 f0)
|
||||
{
|
||||
roughness = max(1e-3, roughness);
|
||||
float dist = l_vector.w;
|
||||
vec3 L = l_vector.xyz / dist;
|
||||
float bsdf = bsdf_ggx(N, L, V, roughness);
|
||||
|
@ -97,8 +98,9 @@ vec3 direct_ggx_point(vec3 N, vec3 V, vec4 l_vector, float roughness, vec3 f0)
|
|||
|
||||
vec3 direct_ggx_sun(LightData ld, vec3 N, vec3 V, float roughness, vec3 f0)
|
||||
{
|
||||
roughness = max(1e-3, roughness);
|
||||
float bsdf = bsdf_ggx(N, -ld.l_forward, V, roughness);
|
||||
float VH = max(dot(V, normalize(V - ld.l_forward)), 0.0);
|
||||
float VH = dot(V, -ld.l_forward) * 0.5 + 0.5;
|
||||
return F_schlick(f0, VH) * bsdf;
|
||||
}
|
||||
|
||||
|
|
|
@ -270,7 +270,7 @@ vec4 get_ssr_sample(
|
|||
mask = min(mask, screen_border_mask(ref_uvs));
|
||||
mask *= float(has_hit);
|
||||
|
||||
float hit_dist = length(hit_vec);
|
||||
float hit_dist = max(1e-8, length(hit_vec));
|
||||
vec3 L = hit_vec / hit_dist;
|
||||
|
||||
float cone_footprint = hit_dist * cone_tan;
|
||||
|
@ -306,6 +306,10 @@ vec4 get_ssr_sample(
|
|||
/* Do not add light if ray has failed. */
|
||||
sample *= float(has_hit);
|
||||
|
||||
#if 0 /* Enable to see where NANs come from. */
|
||||
sample = (any(isnan(sample))) ? vec3(0.0) : sample;
|
||||
#endif
|
||||
|
||||
return vec4(sample, mask) * weight;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue