summaryrefslogtreecommitdiffstats
path: root/brdf.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-11-11 19:59:29 -0800
committeryum <yum.food.vr@gmail.com>2025-11-11 20:02:22 -0800
commitc8c4b2e7cf58e7813bebf80e43426e3b32bf1ff0 (patch)
tree0f5326798627b6cc3c938e4995cbb47d2097853f /brdf.cginc
parentc88f634f9bfcb51cd116fc73147f44a0273d43a9 (diff)
more tweaks - direct specular matches filament more closely
Diffstat (limited to 'brdf.cginc')
-rw-r--r--brdf.cginc8
1 files changed, 3 insertions, 5 deletions
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);