summaryrefslogtreecommitdiffstats
path: root/Shaders/TaSTT_lighting_template.cginc
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-02-06 16:01:11 -0800
committeryum <yum.food.vr@gmail.com>2023-02-06 16:01:11 -0800
commitc218e2a1957520fe6e6a200e51d44aeaec93a3d3 (patch)
treefa28f903f859602fb90a580c117c2c67f953c585 /Shaders/TaSTT_lighting_template.cginc
parent64239b6949ad185c62f4a86acaced9f811d54e9e (diff)
Shader now supports custom cubemap
Applied to both PBS and TaSTT shaders.
Diffstat (limited to 'Shaders/TaSTT_lighting_template.cginc')
-rw-r--r--Shaders/TaSTT_lighting_template.cginc19
1 files changed, 15 insertions, 4 deletions
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