diff options
| author | yum <yum.food.vr@gmail.com> | 2026-03-16 15:59:51 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-03-16 15:59:51 -0700 |
| commit | 1a35d85c623569dd2e61b821bfe3a7f03f99343f (patch) | |
| tree | c4c6ec2e8ff448b3cb5c0abef8dd232aba69b3b6 | |
| parent | 7bfc0ecde84604abf8974ec2ffd1e9b0efb84bea (diff) | |
Add (cheap) hacks to minimize flashy specular highlights
| -rwxr-xr-x | brdf.cginc | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -39,8 +39,10 @@ float3 F_Schlick(float LoH, float3 f0, float f90) { // tan^2(theta) = sin^2(theta) / cos^2(theta) // = (1 - cos^2(theta)) / cos^2(theta) // = -1 + 1 / cos^2(theta) +// The `max(1e-4, _)` and `min(4096, _)` are hand picked to minimize the issue +// of bloom making specular highlights flash as the camera moves. float D_GGX(float roughness, float NoH) { - float r2 = roughness * roughness; + float r2 = max(1e-4, roughness * roughness); float NoH2 = NoH * NoH; float NoH4 = NoH2 * NoH2; @@ -48,7 +50,7 @@ float D_GGX(float roughness, float NoH) { float r2_plus_k = r2 + k; float denom = NoH4 * r2_plus_k * r2_plus_k; - return r2 / denom; + return min(4096, r2 / denom); } // Hammon "PBR Diffuse Lighting for GGX+Smith Microsurfaces" |
