You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
1.2 KiB

#ifndef TOON_MAINLIGHT_INCLUDED
#define TOON_MAINLIGHT_INCLUDED
void MainLight_float(float3 WorldPos, out float3 Direction, out float3 Color, out float ShadowAtten)
{
#ifdef SHADERGRAPH_PREVIEW
Direction = normalize(float3(0.5, 0.5, -0.5));
Color = 1;
ShadowAtten = 1;
#else
float4 shadowCoord = TransformWorldToShadowCoord(WorldPos);
Light mainLight = GetMainLight();
Direction = mainLight.direction;
Color = mainLight.color;
// Sample the main light shadowmap directly, bypassing the MAIN_LIGHT_CALCULATE_SHADOWS keyword.
ShadowSamplingData samplingData = GetMainLightShadowSamplingData();
half4 shadowParams = GetMainLightShadowParams();
real shadowStrength = shadowParams.x;
// 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
}
#endif