diff options
| author | yum <yum.food.vr@gmail.com> | 2026-03-03 18:24:18 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-03-03 18:24:18 -0800 |
| commit | e28c2aa1eaf537276e5667b23d8d35b001200d31 (patch) | |
| tree | a25e6339c8e80065c478aa5319f5b8b9eeb9e06d | |
| parent | 23014acf1bd834744018425e7aeba314a10e12f9 (diff) | |
Fix reflection dir, matching filament
| -rwxr-xr-x | brdf.cginc | 3 | ||||
| -rwxr-xr-x | lighting.cginc | 4 |
2 files changed, 4 insertions, 3 deletions
@@ -70,6 +70,7 @@ float4 brdf(Pbr pbr, LightData data) { float3 specular = 0; float3 diffuse = 0; + // TODO parameterize float f0 = 0.04f; const float f90 = 1.0f; @@ -94,7 +95,7 @@ float4 brdf(Pbr pbr, LightData data) { dfg = float3(1, 1, 1); } float3 f0_color = lerp(f0, pbr.albedo.xyz, pbr.metallic); - float3 energy_comp = 1.0f + f0_color * (1.0f / dfg.xxx - 1.0f); + float3 energy_comp = 1.0f + f0_color * (1.0f / (dfg.xxx + dfg.yyy) - 1.0f); #if defined(_CLEARCOAT) const float cc_f0 = 0.04f; diff --git a/lighting.cginc b/lighting.cginc index f5957b8..1f3afe6 100755 --- a/lighting.cginc +++ b/lighting.cginc @@ -299,7 +299,7 @@ void GetLighting(v2f i, Pbr pbr, out LightData data) { data.direct.color = lightColorIntensity.rgb * getShadowAttenuation(i); // Indirect lighting - float3 reflect_dir = reflect(data.common.V, pbr.normal); + float3 reflect_dir = reflect(-data.common.V, pbr.normal); float3 dominant_dir = getSpecularDominantDirection(pbr.normal, reflect_dir, pbr.roughness); data.indirect.dir = normalize(dominant_dir); @@ -317,7 +317,7 @@ void GetLighting(v2f i, Pbr pbr, out LightData data) { data.indirect.double_LoV = saturate(2.0f * indirect_LoV * indirect_LoV - 1.0f); data.indirect.diffuse = getIndirectDiffuse(i, pbr, data); - data.indirect.specular = getIndirectSpecular(i, pbr.roughness_perceptual, view_dir, -data.indirect.dir); + data.indirect.specular = getIndirectSpecular(i, pbr.roughness_perceptual, view_dir, data.indirect.dir); data.common.spec_ao = getSpecularAO(i, pbr, data, reflect_dir); |
