Fixe bug in pbr

This commit is contained in:
2026-02-19 19:08:41 +09:00
parent b41ea60c02
commit 5183e73ca0
12 changed files with 155 additions and 94 deletions

View File

@@ -35,6 +35,17 @@ float ggx_g_smith(float n_dot_v, float n_dot_l, float roughness)
return ggx_g1(n_dot_v, roughness) * ggx_g1(n_dot_l, roughness);
}
float ggx_visibility(float n_dot_v, float n_dot_l, float roughness)
{
float alpha = roughness * roughness;
float alpha2 = alpha * alpha;
float ggx_v = n_dot_l * sqrtf(alpha2 + (1.0f - alpha2) * n_dot_v * n_dot_v);
float ggx_l = n_dot_v * sqrtf(alpha2 + (1.0f - alpha2) * n_dot_l * n_dot_l);
return 0.5f / fmaxf(ggx_v + ggx_l, FLT_EPSILON);
}
vec3s ggx_sample_vndf(vec3s n, vec3s v, float roughness, float u1, float u2)
{
// Build local frame around n.