您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
57 行
2.5 KiB
57 行
2.5 KiB
#if USE_NORMAL_MAP
|
|
#if LIGHT_QUALITY_FAST
|
|
#define NORMALS_LIGHTING_COORDS(TEXCOORDA, TEXCOORDB) \
|
|
float4 lightDirection : TEXCOORDA;\
|
|
float2 screenUV : TEXCOORDB;
|
|
|
|
#define TRANSFER_NORMALS_LIGHTING(output, worldSpacePos)\
|
|
float4 clipVertex = output.positionCS / output.positionCS.w;\
|
|
output.screenUV = ComputeScreenPos(clipVertex).xy;\
|
|
output.lightDirection.xy = _LightPosition.xy - worldSpacePos.xy;\
|
|
output.lightDirection.z = _LightZDistance;\
|
|
output.lightDirection.w = 0;\
|
|
output.lightDirection.xyz = normalize(output.lightDirection.xyz);
|
|
|
|
#define APPLY_NORMALS_LIGHTING(input, lightColor)\
|
|
half4 normal = SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, input.screenUV);\
|
|
float3 normalUnpacked = UnpackNormal(normal);\
|
|
lightColor = lightColor * saturate(dot(input.lightDirection.xyz, normalUnpacked));
|
|
#else
|
|
#define NORMALS_LIGHTING_COORDS(TEXCOORDA, TEXCOORDB) \
|
|
float4 positionWS : TEXCOORDA;\
|
|
float2 screenUV : TEXCOORDB;
|
|
|
|
#define TRANSFER_NORMALS_LIGHTING(output, worldSpacePos) \
|
|
float4 clipVertex = output.positionCS / output.positionCS.w;\
|
|
output.screenUV = ComputeScreenPos(clipVertex).xy; \
|
|
output.positionWS = worldSpacePos;
|
|
|
|
#define APPLY_NORMALS_LIGHTING(input, lightColor)\
|
|
half4 normal = SAMPLE_TEXTURE2D(_NormalMap, sampler_NormalMap, input.screenUV);\
|
|
float3 normalUnpacked = UnpackNormal(normal);\
|
|
float3 dirToLight;\
|
|
dirToLight.xy = _LightPosition.xy - input.positionWS.xy;\
|
|
dirToLight.z = _LightZDistance;\
|
|
dirToLight = normalize(dirToLight);\
|
|
lightColor = lightColor * saturate(dot(dirToLight, normalUnpacked));
|
|
#endif
|
|
|
|
#define NORMALS_LIGHTING_VARIABLES \
|
|
TEXTURE2D(_NormalMap); \
|
|
SAMPLER(sampler_NormalMap); \
|
|
float4 _LightPosition;\
|
|
half _LightZDistance;
|
|
#else
|
|
#define NORMALS_LIGHTING_COORDS(TEXCOORDA, TEXCOORDB)
|
|
#define NORMALS_LIGHTING_VARIABLES
|
|
#define TRANSFER_NORMALS_LIGHTING(output, worldSpacePos)
|
|
#define APPLY_NORMALS_LIGHTING(input, lightColor)
|
|
#endif
|
|
|
|
|
|
#define SHAPE_LIGHT(index)\
|
|
TEXTURE2D(_ShapeLightTexture##index);\
|
|
SAMPLER(sampler_ShapeLightTexture##index);\
|
|
float2 _ShapeLightBlendFactors##index;\
|
|
float4 _ShapeLightMaskFilter##index;\
|
|
float4 _ShapeLightInvertedFilter##index;
|