From 42dbd067eb455d4b67d6ae8c57f1cbe4ec7dccfa Mon Sep 17 00:00:00 2001 From: yum Date: Fri, 8 Aug 2025 19:28:27 -0700 Subject: Optimize sh9 implementation Saves ~20 instructions (572 -> 552). --- brdf.cginc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'brdf.cginc') diff --git a/brdf.cginc b/brdf.cginc index 12f2770..5a24307 100644 --- a/brdf.cginc +++ b/brdf.cginc @@ -55,6 +55,7 @@ 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: @@ -113,6 +114,7 @@ float G_Cloth(float roughness, float 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; @@ -134,7 +136,7 @@ float4 brdf(Pbr pbr, LightData data) { #endif // Direct - if (true) { + { float remainder = 1.0f; #if defined(_CLEARCOAT) @@ -180,7 +182,7 @@ float4 brdf(Pbr pbr, LightData data) { // Indirect #if defined(FORWARD_BASE_PASS) - if (true) { + { float remainder = 1.0f; float2 dfg_uv = float2(data.common.NoV, pbr.roughness); @@ -212,7 +214,7 @@ float4 brdf(Pbr pbr, LightData data) { // For energy conservation with the diffuse term, we use the view-dependent Fresnel. float3 F = F_Schlick(data.common.NoV, f0_spec, 1.0f); remainder *= (1.0f - F); - + // Diffuse is Lambertian, which is pre-integrated into the SH diffuse probe float3 indirect_diffuse = pbr.albedo.xyz * data.indirect.diffuse * remainder * (1.0 - pbr.metallic); diffuse += indirect_diffuse; -- cgit v1.2.3