diff options
| -rw-r--r-- | 2ner.cginc | 1 | ||||
| -rw-r--r-- | 2ner.shader | 1 | ||||
| -rw-r--r-- | globals.cginc | 6 | ||||
| -rw-r--r-- | yum_brdf.cginc | 37 | ||||
| -rw-r--r-- | yum_lighting.cginc | 7 |
5 files changed, 8 insertions, 44 deletions
@@ -397,6 +397,7 @@ float4 frag(v2f i, uint facing : SV_IsFrontFace #if defined(FORWARD_BASE_PASS) || defined(FORWARD_ADD_PASS) || defined(OUTLINE_PASS) || defined(EXTRA_STENCIL_COLOR_PASS)
YumLighting l = GetYumLighting(i, pbr);
+ //return float4(l.occlusion, l.occlusion, l.occlusion, 1);
#if defined(FORWARD_BASE_PASS) || defined(FORWARD_ADD_PASS)
applyMatcapsAndRimLighting(i, pbr, l);
diff --git a/2ner.shader b/2ner.shader index e812c52..3dffe34 100644 --- a/2ner.shader +++ b/2ner.shader @@ -1948,6 +1948,7 @@ Shader "yum_food/2ner" [HideInInspector] m_FilamentStuff("Filament stuff", Float) = 0 [NonModifiableTextureData]_DFG("DFG", 2D) = "white" {} [ThryWideEnum(Water, 0.02, Skin, 0.028, Eyes, 0.025, Hair, 0.046, Teeth, 0.058, Fabric, 0.05, Stone, 0.045, Plastic, 0.045, Glass, 0.06, Gemstone, 0.07, Diamond, 0.18)]_reflectance("Reflectance", Float) = 0.028 + _ExposureOcclusion("Exposure Occlusion", Float) = 1 [Helpbox]_reflectance_help("Values are documented in the filament whitepaper here https://google.github.io/filament/Filament.html#toc4.8.3.2", Float) = 1 //ifex _Material_Type_Cloth_Enabled==0 [HideInInspector] m_start_Material_Type_Cloth("Cloth", Float) = 0 diff --git a/globals.cginc b/globals.cginc index 3688378..8c11d15 100644 --- a/globals.cginc +++ b/globals.cginc @@ -3,10 +3,6 @@ #include "features.cginc"
-// Filamented global variables
-half _ExposureOcclusion;
-half _LightmapSpecularMaxSmoothness;
-
#if defined(USING_BAKERY_VERTEXLM)
float bakeryLightmapMode;
#endif
@@ -113,6 +109,8 @@ float _Spherical_Harmonics; float _reflectance;
float _specularAntiAliasingVariance;
float _specularAntiAliasingThreshold;
+float _ExposureOcclusion;
+float _LightmapSpecularMaxSmoothness;
#if defined(_METALLICS)
float _Smoothness;
diff --git a/yum_brdf.cginc b/yum_brdf.cginc index 0b4b3b1..6a4b5e5 100644 --- a/yum_brdf.cginc +++ b/yum_brdf.cginc @@ -151,7 +151,7 @@ float4 YumBRDF(v2f i, const YumLighting light, YumPbr pbr) { // Compute specular ambient occlusion float diffuseAO = pbr.ao; - float specularAO = computeSpecularAO(NoV, diffuseAO, pbr.roughness); + float specularAO = computeSpecularAO(NoV, diffuseAO * light.occlusion, pbr.roughness); float3 specularSingleBounceAO = singleBounceAO(specularAO) * energy_compensation; float3 Fd = pbr.albedo * light.diffuse * (1.0 - E) * (1.0 - pbr.metallic) * pbr.ao * light.attenuation; @@ -160,39 +160,6 @@ float4 YumBRDF(v2f i, const YumLighting light, YumPbr pbr) { indirect_standard = Fr + Fd; } - // Apply lightmap-derived directional light for metallic surfaces - float3 derivedLightContribution = 0; -#if defined(_LIGHTMAP_SPECULAR) && defined(LIGHTMAP_ON) && defined(DIRLIGHTMAP_COMBINED) - if (light.derivedLight.directionality > 0.001) { - // Calculate lighting vectors for derived light - const float3 h_derived = normalize(light.view_dir + light.derivedLight.direction); - const float LoH_derived = saturate(dot(light.derivedLight.direction, h_derived)); - const float NoH_derived = saturate(dot(pbr.normal, h_derived)); - const float NoL_derived = light.derivedLight.NoL; - - // Apply specular contribution from lightmap (similar to Filament's approach) - const float reflectance = computeDielectricF0(_reflectance); - const float3 f0 = lerp(reflectance, pbr.albedo, pbr.metallic); - - // Calculate specular lobe for the derived light - float3 Fr_derived = specularLobe(pbr, f0, h_derived, LoH_derived, NoH_derived, NoV, NoL_derived) * PI; - - // Apply AO and energy compensation - float specularAO = computeSpecularAO(NoV, pbr.ao, pbr.roughness); - const float3 dfg = PrefilteredDFG_LUT(pbr.roughness_perceptual, NoV); - const float3 energy_compensation = energyCompensation(dfg, f0); - - // The derived light contribution is weighted by metallic value - // This ensures metallic surfaces get shadowing from lightmaps via specular - derivedLightContribution = Fr_derived * light.derivedLight.color * - light.derivedLight.directionality * - specularAO * energy_compensation * NoL_derived; - - // For dielectrics, reduce the diffuse contribution to avoid double-counting - indirect_standard *= (1.0 - light.derivedLight.directionality * (1.0 - pbr.metallic)); - } -#endif - #if defined(_MATERIAL_TYPE_CLOTH) float cloth_mask = _Cloth_Mask.Sample(linear_repeat_s, i.uv01.xy); float3 direct = lerp(direct_standard, direct_cloth, cloth_mask); @@ -202,7 +169,7 @@ float4 YumBRDF(v2f i, const YumLighting light, YumPbr pbr) { float3 indirect = indirect_standard; #endif - return float4(direct + indirect + derivedLightContribution, pbr.albedo.a); + return float4(direct + indirect, pbr.albedo.a); } #endif // __YUM_BRDF_INC diff --git a/yum_lighting.cginc b/yum_lighting.cginc index d1cf779..a8e5d4b 100644 --- a/yum_lighting.cginc +++ b/yum_lighting.cginc @@ -253,9 +253,6 @@ YumLighting GetYumLighting(v2f i, YumPbr pbr) { light.attenuation = getShadowAttenuation(i); #endif - // Use filamented's comprehensive irradiance calculation - float occlusion; - Light derivedLight; float3 tangentNormal = mul(pbr.normal, transpose(float3x3(i.tangent, i.binormal, i.normal))); float3x3 tangentToWorld = float3x3(i.tangent, i.binormal, i.normal); @@ -274,8 +271,8 @@ YumLighting GetYumLighting(v2f i, YumPbr pbr) { // You'll need to add this to your v2f if using Bakery vertex directional i.bakeryVertexDir, #endif - occlusion, // out occlusion - derivedLight // out Light + light.occlusion, // out occlusion + light.derivedLight // out Light ); #if defined(_MIN_BRIGHTNESS) |
