Merge pull request #59123 from Snowapril/fix-nan-specular-highlight
Fix `D_GGX` code which can cause `divide-by-zero`
This commit is contained in:
commit
000ff82071
@ -1,9 +1,9 @@
|
|||||||
// Functions related to lighting
|
// Functions related to lighting
|
||||||
|
|
||||||
float D_GGX(float cos_theta_m, float alpha) {
|
float D_GGX(float cos_theta_m, float alpha) {
|
||||||
float alpha2 = alpha * alpha;
|
float a = cos_theta_m * alpha;
|
||||||
float d = 1.0 + (alpha2 - 1.0) * cos_theta_m * cos_theta_m;
|
float k = alpha / (1.0 - cos_theta_m * cos_theta_m + a * a);
|
||||||
return alpha2 / (M_PI * d * d);
|
return k * k * (1.0 / M_PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
// From Earl Hammon, Jr. "PBR Diffuse Lighting for GGX+Smith Microsurfaces" https://www.gdcvault.com/play/1024478/PBR-Diffuse-Lighting-for-GGX
|
// From Earl Hammon, Jr. "PBR Diffuse Lighting for GGX+Smith Microsurfaces" https://www.gdcvault.com/play/1024478/PBR-Diffuse-Lighting-for-GGX
|
||||||
|
Loading…
Reference in New Issue
Block a user