float D_GGX_TR(vec3 N, vec3 H, float a)
{
float a2 = a*a;
float NdotH = max(dot(N, H), 0.0);
float NdotH2 = NdotH*NdotH;
float nom = a2;
float denom = (NdotH2 * (a2 - 1.0) + 1.0);
denom = PI * denom * denom;
return nom / denom;
}
複製代碼
// Generalized-Trowbridge-Reitz distribution
float D_GTR1(float alpha, float dotNH)
{
float a2 = alpha * alpha;
float cos2th = dotNH * dotNH;
float den = (1.0 + (a2 - 1.0) * cos2th);
return (a2 - 1.0) / (PI * log(a2) * den);
}
float D_GTR2(float alpha, float dotNH)
{
float a2 = alpha * alpha;
float cos2th = dotNH * dotNH;
float den = (1.0 + (a2 - 1.0) * cos2th);
return a2 / (PI * den * den);
}
複製代碼
以及各項異性的版本:chrome
float D_GTR2_aniso(float dotHX, float dotHY, float dotNH, float ax, float ay)
{
float deno = dotHX * dotHX / (ax * ax) + dotHY * dotHY / (ay * ay) + dotNH * dotNH;
return 1.0 / (PI * ax * ay * deno * deno);
}
複製代碼