From 1a35d85c623569dd2e61b821bfe3a7f03f99343f Mon Sep 17 00:00:00 2001 From: yum Date: Mon, 16 Mar 2026 15:59:51 -0700 Subject: Add (cheap) hacks to minimize flashy specular highlights --- brdf.cginc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/brdf.cginc b/brdf.cginc index cdf09fd..45d350e 100755 --- a/brdf.cginc +++ b/brdf.cginc @@ -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" -- cgit v1.2.3