summaryrefslogtreecommitdiffstats
path: root/yum_lighting.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-04-08 17:52:52 -0700
committeryum <yum.food.vr@gmail.com>2025-04-08 17:52:52 -0700
commit40c33d438afa036acfcbc58ca4078f25db1624f2 (patch)
tree045d3d3b44e785ad7d8fbaaa2ec874585a5d9773 /yum_lighting.cginc
parent2dfd6322587eb095a5a4f7b22d70e1abcc14d5e3 (diff)
Add static flag to limit fallback cubemap to metallic
Diffstat (limited to 'yum_lighting.cginc')
-rw-r--r--yum_lighting.cginc13
1 files changed, 11 insertions, 2 deletions
diff --git a/yum_lighting.cginc b/yum_lighting.cginc
index 3af5654..b2a7952 100644
--- a/yum_lighting.cginc
+++ b/yum_lighting.cginc
@@ -124,8 +124,11 @@ float3 getIndirectSpecular(v2f i, YumPbr pbr, float3 view_dir, float diffuse_lum
data.probePosition[1] = unity_SpecCube1_ProbePosition;
#endif
+ const float3 env_refl = UnityGI_prefilteredRadiance(data, roughness, reflect_dir);
+
#if defined(_FALLBACK_CUBEMAP)
// Check if there's no valid scene cubemap
+ float3 canned_refl = env_refl;
if (!SceneHasReflections() || _Fallback_Cubemap_Force) {
// Set up data for fallback sampling similar to Unity's system
half3 reflectVector = reflect(-view_dir, pbr.normal);
@@ -136,11 +139,17 @@ float3 getIndirectSpecular(v2f i, YumPbr pbr, float3 view_dir, float diffuse_lum
half mip = roughness * UNITY_SPECCUBE_LOD_STEPS;
float4 envSample = UNITY_SAMPLE_TEXCUBE_LOD(_Fallback_Cubemap, reflectVector, mip);
- return DecodeHDR(envSample, _Fallback_Cubemap_HDR) * _Fallback_Cubemap_Brightness * diffuse_luminance;
+ canned_refl = DecodeHDR(envSample, _Fallback_Cubemap_HDR) * _Fallback_Cubemap_Brightness * diffuse_luminance;
}
#endif
- return UnityGI_prefilteredRadiance(data, roughness, reflect_dir);
+#if defined(_FALLBACK_CUBEMAP_LIMIT_METALLIC)
+ return lerp(env_refl, canned_refl, pbr.metallic);
+#elif defined(_FALLBACK_CUBEMAP)
+ return canned_refl;
+#else
+ return env_refl;
+#endif
}
float3 yumSH9(float4 n) {