|
|
|
|
|
|
#pragma prefer_hlslcc gles |
|
|
|
#pragma target 3.0 |
|
|
|
|
|
|
|
// ------------------------------------- |
|
|
|
// Lightweight Pipeline keywords |
|
|
|
// We have no good approach exposed to skip shader variants, e.g, ideally we would like to skip _CASCADE for all puctual lights |
|
|
|
// Lightweight combines light classification and shadows keywords to reduce shader variants. |
|
|
|
// Lightweight shader library declares defines based on these keywords to avoid having to check them in the shaders |
|
|
|
// Core.hlsl defines _MAIN_LIGHT_DIRECTIONAL and _MAIN_LIGHT_SPOT (point lights can't be main light) |
|
|
|
// Shadow.hlsl defines _SHADOWS_ENABLED, _SHADOWS_SOFT, _SHADOWS_CASCADE, _SHADOWS_PERSPECTIVE |
|
|
|
#pragma multi_compile _ _MAIN_LIGHT_DIRECTIONAL_SHADOW _MAIN_LIGHT_DIRECTIONAL_SHADOW_CASCADE _MAIN_LIGHT_DIRECTIONAL_SHADOW_SOFT _MAIN_LIGHT_DIRECTIONAL_SHADOW_CASCADE_SOFT _MAIN_LIGHT_SPOT_SHADOW _MAIN_LIGHT_SPOT_SHADOW_SOFT |
|
|
|
#pragma multi_compile _ _MAIN_LIGHT_COOKIE |
|
|
|
#pragma multi_compile _ _ADDITIONAL_LIGHTS |
|
|
|
#pragma multi_compile _ _VERTEX_LIGHTS |
|
|
|
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE |
|
|
|
#pragma multi_compile _ FOG_LINEAR FOG_EXP2 |
|
|
|
// ------------------------------------- |
|
|
|
// Lightweight Pipeline keywords |
|
|
|
#pragma multi_compile _ _ADDITIONAL_LIGHTS |
|
|
|
#pragma multi_compile _ _VERTEX_LIGHTS |
|
|
|
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE |
|
|
|
#pragma multi_compile _ FOG_LINEAR FOG_EXP2 |
|
|
|
// ------------------------------------- |
|
|
|
// Unity defined keywords |
|
|
|
#pragma multi_compile _ UNITY_SINGLE_PASS_STEREO STEREO_INSTANCING_ON STEREO_MULTIVIEW_ON |
|
|
|
#pragma multi_compile _ DIRLIGHTMAP_COMBINED LIGHTMAP_ON |
|
|
|
|
|
|
|
//-------------------------------------- |
|
|
|
// GPU Instancing |
|
|
|
#pragma multi_compile_instancing |
|
|
|
// ------------------------------------- |
|
|
|
// Unity defined keywords |
|
|
|
#pragma multi_compile _ DIRLIGHTMAP_COMBINED |
|
|
|
#pragma multi_compile _ LIGHTMAP_ON |
|
|
|
// LW doesn't support dynamic GI. So we save 30% shader variants if we assume |
|
|
|
// LIGHTMAP_ON when DIRLIGHTMAP_COMBINED is set |
|
|
|
#ifdef DIRLIGHTMAP_COMBINED |
|
|
|
#define LIGHTMAP_ON |
|
|
|
#endif |
|
|
|
//-------------------------------------- |
|
|
|
// GPU Instancing |
|
|
|
#pragma multi_compile_instancing |
|
|
|
|
|
|
|
#pragma vertex vert |
|
|
|
#pragma fragment frag |
|
|
|
|
|
|
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight); |
|
|
|
o.clipPos = clipPos; |
|
|
|
|
|
|
|
#if defined(_SHADOWS_ENABLED) && !defined(_SHADOWS_CASCADE) |
|
|
|
o.shadowCoord = ComputeShadowCoord(lwWorldPos); |
|
|
|
#else |
|
|
|
o.shadowCoord = float4(0, 0, 0, 0); |
|
|
|
#endif |
|
|
|
|
|
|
|
o.shadowCoord = ComputeShadowCoord(o.clipPos); |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
inputData.viewDirectionWS = normalize(WorldSpaceViewDirection); |
|
|
|
#endif |
|
|
|
|
|
|
|
#ifdef _SHADOWS_ENABLED |
|
|
|
#else |
|
|
|
inputData.shadowCoord = float4(0, 0, 0, 0); |
|
|
|
#endif |
|
|
|
|
|
|
|
inputData.fogCoord = IN.fogFactorAndVertexLight.x; |
|
|
|
inputData.vertexLighting = IN.fogFactorAndVertexLight.yzw; |
|
|
|