diff options
| author | yum <yum.food.vr@gmail.com> | 2025-03-31 21:50:39 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-03-31 21:50:39 -0700 |
| commit | 2dfd6322587eb095a5a4f7b22d70e1abcc14d5e3 (patch) | |
| tree | 76b6f84628e07c722b74ce58b34e70d672e9541d /yum_brdf.cginc | |
| parent | 3f1915bbd0e6176e625c484cf24a460cc88bfeac (diff) | |
Overhaul wrapped lighting
Now:
* k=0 -> lambertian
* k=0.5 -> half lambertian
* k=1.0 -> flat
All three points should be energy conserving, but I haven't done the
actual analysis yet.
Diffstat (limited to 'yum_brdf.cginc')
| -rw-r--r-- | yum_brdf.cginc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/yum_brdf.cginc b/yum_brdf.cginc index 9bc01bf..8b0d659 100644 --- a/yum_brdf.cginc +++ b/yum_brdf.cginc @@ -68,7 +68,7 @@ float4 YumBRDF(v2f i, const YumLighting light, YumPbr pbr) { // Use a proper diffuse BRDF term instead of raw albedo
float3 Fd = pbr.albedo / PI;
Fd *= light.attenuation;
-
+
#if defined(_MATERIAL_TYPE_CLOTH_SUBSURFACE)
// Energy conservative wrap diffuse for subsurface scattering
float wrap_diffuse = saturate((NoL + 0.5) / 2.25);
@@ -76,15 +76,15 @@ float4 YumBRDF(v2f i, const YumLighting light, YumPbr pbr) { // Apply subsurface color
Fd *= saturate(_Cloth_Subsurface_Color + NoL);
#endif
-
+
// Cloth specular BRDF
float3 Fr = specularLobe(pbr, 0.04, h, LoH, NoH, NoV, NoL_wrapped_s);
-
+
#if defined(_MATERIAL_TYPE_CLOTH_SUBSURFACE)
// No need to multiply by NoL when using subsurface scattering
- direct_cloth = (Fd + Fr * NoL) * light.direct * _Cloth_Direct_Multiplier;
+ direct_cloth = (Fd + Fr * NoL_wrapped_d) * light.direct * _Cloth_Direct_Multiplier;
#else
- direct_cloth = (Fd + Fr) * NoL * light.direct * _Cloth_Direct_Multiplier;
+ direct_cloth = (Fd + Fr) * NoL_wrapped_d * light.direct * _Cloth_Direct_Multiplier;
#endif
}
#endif
@@ -105,7 +105,7 @@ float4 YumBRDF(v2f i, const YumLighting light, YumPbr pbr) { float3 Fd = pbr.albedo / PI;
Fd *= (1.0 - pbr.metallic) * light.attenuation;
float3 Fr = specularLobe(pbr, f0, h, LoH, NoH, NoV, NoL_wrapped_s);
-
+
float3 color = Fd * NoL_wrapped_d + Fr * energy_compensation * NoL_wrapped_s;
direct_standard = color * light.direct;
}
|
