summaryrefslogtreecommitdiffstats
path: root/brdf.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2026-02-23 16:56:44 -0800
committeryum <yum.food.vr@gmail.com>2026-02-23 16:56:44 -0800
commita4d1ade709ee0f16383698809004763bdc798002 (patch)
treee001347dfc7466ba4427d205477b6a4aeff9d520 /brdf.cginc
parentf57d761e414774081740b489b748cbfe60c11c1f (diff)
Drop cloth for now
Diffstat (limited to 'brdf.cginc')
-rwxr-xr-xbrdf.cginc82
1 files changed, 0 insertions, 82 deletions
diff --git a/brdf.cginc b/brdf.cginc
index d064823..bd44b3f 100755
--- a/brdf.cginc
+++ b/brdf.cginc
@@ -66,67 +66,6 @@ float G_GGXSmith(float roughness, float NoL, float NoV) {
return rcp(denom);
}
-#if defined(_CLOTH_SHEEN)
-// Estevez "Production Friendly Microfacet Sheen BRDF"
-// Equation 2.
-// The original equation is:
-// (2 + 1/r) * sin^(1-r)(theta) / (2 pi)
-// Recall that:
-// cos^2(theta) + sin^2(theta) = 1
-// So:
-// sin^2(theta) = 1 - cos^2(theta)
-// sin(theta) = (1 - cos^2(theta)) ^ (1/2)
-// sin^k(theta) = (1 - cos^2(theta)) ^ (k/2)
-float D_Cloth(float roughness, float NoH) {
- float r_rcp = rcp(roughness);
- return (2.0f + r_rcp) * pow(1.0f - NoH * NoH, r_rcp * 0.5f) / TAU;
-}
-
-float G_Cloth_L(float x, float a, float b, float c, float d, float e) {
- return a / (1.0f + b * pow(x, c)) + d * x + e;
-}
-
-// Estevez "Production Friendly Microfacet Sheen BRDF"
-// Equations 3 and 4.
-float G_Cloth(float roughness, float LoH) {
- // Table 1
- float a0 = 25.3245f;
- float a1 = 21.5473f;
- float b0 = 3.32435f;
- float b1 = 3.82987f;
- float c0 = 0.16801f;
- float c1 = 0.19823f;
- float d0 = -1.27393f;
- float d1 = -1.97760f;
- float e0 = -4.85967f;
- float e1 = -4.32054f;
- float one_minus_r = 1.0f - roughness;
- float one_minus_r_sq = one_minus_r * one_minus_r;
- float one_minus_LoH = 1.0f - LoH;
-
- float lambda;
- [branch]
- if (LoH < 0.5f) {
- float L0 = G_Cloth_L(LoH, a0, b0, c0, d0, e0);
- float L1 = G_Cloth_L(LoH, a1, b1, c1, d1, e1);
- float L = lerp(L0, L1, one_minus_r_sq);
- lambda = exp(L);
- } else {
- float L_05_0 = G_Cloth_L(0.5f, a0, b0, c0, d0, e0);
- float L_05_1 = G_Cloth_L(0.5f, a1, b1, c1, d1, e1);
- float L_05 = lerp(L_05_0, L_05_1, one_minus_r_sq);
-
- float L_LoH_0 = G_Cloth_L(one_minus_LoH, a0, b0, c0, d0, e0);
- float L_LoH_1 = G_Cloth_L(one_minus_LoH, a1, b1, c1, d1, e1);
- float L_LoH = lerp(L_LoH_0, L_LoH_1, one_minus_r_sq);
-
- lambda = exp(2.0f * L_05 - L_LoH);
- }
- // Apply terminator softening (equation 4).
- return pow(lambda, 1.0f + 2.0f * pow(one_minus_LoH, 8));
-}
-#endif
-
float4 brdf(Pbr pbr, LightData data) {
float3 specular = 0;
float3 diffuse = 0;
@@ -192,17 +131,6 @@ float4 brdf(Pbr pbr, LightData data) {
layer_attenuation *= saturate(1.0f - Fcc * pbr.cc_strength);
#endif
-#if defined(_CLOTH_SHEEN)
- float cl_f0 = 0.04f;
- float Fcl = 1;
- float Dcl = D_Cloth(pbr.roughness, data.direct.NoH);
- float Gcl = G_Cloth(pbr.roughness, data.direct.LoH);
- float DFGcl = Fcl * Dcl * Gcl;
- float3 direct_specular_cl = DFGcl * data.direct.color * pbr.cl_strength * pbr.cl_color * data.direct.NoL;
- direct_specular_cl = max(0, direct_specular_cl);
- specular += direct_specular_cl;
-#endif
-
float3 F = F_Schlick(data.direct.LoH, f0_color, f90);
float D = D_GGX(pbr.roughness, data.direct.NoH);
float G = G_GGXSmith(pbr.roughness, data.direct.NoL, data.common.NoV);
@@ -238,16 +166,6 @@ float4 brdf(Pbr pbr, LightData data) {
remainder = saturate(remainder - indirect_specular_cc);
#endif
-#if defined(_CLOTH_SHEEN)
- float DFGcl = _Cloth_Sheen_DFG_LUT.Sample(bilinear_clamp_s, dfg_uv).r;
- float3 indirect_specular_cl = DFGcl * data.indirect.specular * pbr.cl_strength * pbr.cl_color;
- specular += indirect_specular_cl * remainder;
- // Energy conservation for cloth is tricky with IBL.
- // A simple approximation is to use the Fresnel of the sheen layer.
- float Fcl = F_Schlick(data.common.NoV, 0.04, 1.0);
- remainder -= Fcl * pbr.cl_strength;
-#endif
-
// Standard split-sum IBL
float3 f0_spec = lerp(f0, pbr.albedo.xyz, pbr.metallic);
float3 ibl_specular_reflectance = lerp(dfg.xxx, dfg.yyy, f0_spec);