From c218e2a1957520fe6e6a200e51d44aeaec93a3d3 Mon Sep 17 00:00:00 2001 From: yum Date: Mon, 6 Feb 2023 16:01:11 -0800 Subject: Shader now supports custom cubemap Applied to both PBS and TaSTT shaders. --- Shaders/TaSTT_lighting_template.cginc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'Shaders/TaSTT_lighting_template.cginc') diff --git a/Shaders/TaSTT_lighting_template.cginc b/Shaders/TaSTT_lighting_template.cginc index d2d4005..386a509 100644 --- a/Shaders/TaSTT_lighting_template.cginc +++ b/Shaders/TaSTT_lighting_template.cginc @@ -72,6 +72,9 @@ float Margin_Scale; float Margin_Rounding_Scale; float Enable_Margin_Effect_Squares; +float Enable_Custom_Cubemap; +UNITY_DECLARE_TEXCUBE(Custom_Cubemap); + // %TEMPLATE__CG_ROW_COL_CONSTANTS% float3 HUEtoRGB(in float H) @@ -398,10 +401,18 @@ UnityIndirect GetIndirect(v2f i, float3 view_dir, float smoothness) { // There's a nonlinear relationship between mipmap level and roughness. float roughness = 1 - smoothness; roughness *= 1.7 - .7 * roughness; - float3 env_sample = UNITY_SAMPLE_TEXCUBE_LOD( - unity_SpecCube0, - reflect_dir, - roughness * UNITY_SPECCUBE_LOD_STEPS); + float3 env_sample; + if (Enable_Custom_Cubemap) { + env_sample = UNITY_SAMPLE_TEXCUBE_LOD( + Custom_Cubemap, + reflect_dir, + roughness * UNITY_SPECCUBE_LOD_STEPS); + } else { + env_sample = UNITY_SAMPLE_TEXCUBE_LOD( + unity_SpecCube0, + reflect_dir, + roughness * UNITY_SPECCUBE_LOD_STEPS); + } indirect.specular = env_sample; #endif -- cgit v1.2.3