diff options
| author | yum <yum.food.vr@gmail.com> | 2023-02-06 16:01:11 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2023-02-06 16:01:11 -0800 |
| commit | c218e2a1957520fe6e6a200e51d44aeaec93a3d3 (patch) | |
| tree | fa28f903f859602fb90a580c117c2c67f953c585 /Shaders/PBS_lighting.cginc | |
| parent | 64239b6949ad185c62f4a86acaced9f811d54e9e (diff) | |
Shader now supports custom cubemap
Applied to both PBS and TaSTT shaders.
Diffstat (limited to 'Shaders/PBS_lighting.cginc')
| -rw-r--r-- | Shaders/PBS_lighting.cginc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Shaders/PBS_lighting.cginc b/Shaders/PBS_lighting.cginc index d41d44b..13bde82 100644 --- a/Shaders/PBS_lighting.cginc +++ b/Shaders/PBS_lighting.cginc @@ -38,6 +38,9 @@ float4 BG_Metallic_ST; float4 BG_Smoothness_ST; float4 BG_Emission_Mask_ST; +float Enable_Custom_Cubemap; +UNITY_DECLARE_TEXCUBE(Custom_Cubemap); + void getVertexLightColor(inout v2f i) { #if defined(VERTEXLIGHT_ON) @@ -206,10 +209,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 |
