summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbrdf.cginc6
1 files 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"