From c8c4b2e7cf58e7813bebf80e43426e3b32bf1ff0 Mon Sep 17 00:00:00 2001 From: yum Date: Tue, 11 Nov 2025 19:59:29 -0800 Subject: more tweaks - direct specular matches filament more closely --- brdf.cginc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'brdf.cginc') diff --git a/brdf.cginc b/brdf.cginc index 70bca86..a12c256 100644 --- a/brdf.cginc +++ b/brdf.cginc @@ -47,12 +47,9 @@ float D_GGX(float roughness, float NoH) { float k = rcp(NoH2) - 1; float r2_plus_k = r2 + k; - // Not sure why, but not using the factor of PI here makes the specular match - // the Unity standard much more closely. Maybe the author was just folding - // the 4.0 (historically used to be a PI) into the GGX calculation? float denom = NoH4 * r2_plus_k * r2_plus_k; - return r2 / denom; + return r2 / (denom * PI); } // Hammon "PBR Diffuse Lighting for GGX+Smith Microsurfaces" @@ -208,10 +205,11 @@ float4 brdf(Pbr pbr, LightData data) { direct_specular *= data.direct.color * data.direct.NoL; direct_specular *= energy_comp; direct_specular *= layer_attenuation; + direct_specular *= PI; direct_specular = max(0, direct_specular); specular += direct_specular; - float Fd = Fd_OrenNayar(pbr.roughness, data.common.NoV, data.direct.NoL, data.direct.LoV) / PI; + float Fd = Fd_OrenNayar(pbr.roughness, data.common.NoV, data.direct.NoL, data.direct.LoV); float3 direct_diffuse = Fd * (1.0f - pbr.metallic) * pbr.albedo.xyz * data.direct.color; direct_diffuse *= layer_attenuation; direct_diffuse = max(0, direct_diffuse); -- cgit v1.2.3