|
|
|
|
@ -13,18 +13,18 @@ void MainLight_float(float3 WorldPos, out float3 Direction, out float3 Color, ou |
|
|
|
|
Direction = mainLight.direction; |
|
|
|
|
Color = mainLight.color; |
|
|
|
|
|
|
|
|
|
// 直接採樣主光陰影貼圖,繞過 MAIN_LIGHT_CALCULATE_SHADOWS keyword 條件。 |
|
|
|
|
// Sample the main light shadowmap directly, bypassing the MAIN_LIGHT_CALCULATE_SHADOWS keyword. |
|
|
|
|
ShadowSamplingData samplingData = GetMainLightShadowSamplingData(); |
|
|
|
|
half4 shadowParams = GetMainLightShadowParams(); |
|
|
|
|
real shadowStrength = shadowParams.x; |
|
|
|
|
|
|
|
|
|
// PCF 過濾採樣 → 柔邊、消鋸齒(不依賴 _SHADOWS_SOFT keyword) |
|
|
|
|
// PCF-filtered sampling -> soft, anti-aliased edges (independent of the _SHADOWS_SOFT keyword) |
|
|
|
|
real atten = SampleShadowmapFiltered( |
|
|
|
|
TEXTURE2D_ARGS(_MainLightShadowmapTexture, sampler_LinearClampCompare), |
|
|
|
|
shadowCoord, samplingData); |
|
|
|
|
atten = LerpWhiteTo(atten, shadowStrength); |
|
|
|
|
|
|
|
|
|
// 超出陰影最遠距離 = 不打陰影 |
|
|
|
|
// Beyond the max shadow distance -> no shadow |
|
|
|
|
ShadowAtten = BEYOND_SHADOW_FAR(shadowCoord) ? 1.0 : atten; |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|