diff options
| -rw-r--r-- | brdf.cginc | 8 | ||||
| -rw-r--r-- | lighting.cginc | 2 |
2 files changed, 4 insertions, 6 deletions
@@ -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); diff --git a/lighting.cginc b/lighting.cginc index d6ca4de..8d51cda 100644 --- a/lighting.cginc +++ b/lighting.cginc @@ -185,7 +185,7 @@ void GetLighting(v2f i, Pbr pbr, out LightData data) { data.direct.double_LoV = saturate(2.0f * direct_LoV * direct_LoV - 1.0f); float4 lightColorIntensity = getDirectLightColorIntensity(); - data.direct.color = lightColorIntensity.rgb * lightColorIntensity.w * getShadowAttenuation(i); + data.direct.color = lightColorIntensity.rgb * getShadowAttenuation(i); // Indirect lighting float3 reflect_dir = -reflect(data.common.V, pbr.normal); |
