mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-25 12:05:08 -05:00
MTOON_LIGHT_DESCRIPTIONを定義
This commit is contained in:
@@ -17,30 +17,7 @@ struct UnityLighting
|
||||
|
||||
UnityLighting GetUnityLighting(const Varyings input, const half3 normalWS)
|
||||
{
|
||||
#ifdef MTOON_URP
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
float4 shadowCoord = input.shadowCoord;
|
||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
float4 shadowCoord = TransformWorldToShadowCoord(input.positionWS);
|
||||
#else
|
||||
float4 shadowCoord = float4(0, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
half4 shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV);
|
||||
Light mainLight = GetMainLight(shadowCoord, input.positionWS, shadowMask);
|
||||
|
||||
const half3 lightDir = mainLight.direction;
|
||||
const half3 lightColor = mainLight.color.rgb;
|
||||
|
||||
float atten = mainLight.shadowAttenuation;
|
||||
|
||||
#else
|
||||
UNITY_LIGHT_ATTENUATION(atten, input, input.positionWS);
|
||||
|
||||
const half3 lightDir = normalize(UnityWorldSpaceLightDir(input.positionWS));
|
||||
const half3 lightColor = _LightColor0.rgb;
|
||||
|
||||
#endif
|
||||
MTOON_LIGHT_DESCRIPTION(input, atten, lightDir, lightColor);
|
||||
|
||||
if (MToon_IsForwardBasePass())
|
||||
{
|
||||
@@ -57,16 +34,13 @@ UnityLighting GetUnityLighting(const Varyings input, const half3 normalWS)
|
||||
output.directLightAttenuation = atten;
|
||||
return output;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnityLighting output;
|
||||
output.indirectLight = 0;
|
||||
output.indirectLightEqualized = 0;
|
||||
output.directLightColor = lightColor;
|
||||
output.directLightDirection = lightDir;
|
||||
output.directLightAttenuation = atten;
|
||||
return output;
|
||||
}
|
||||
UnityLighting output;
|
||||
output.indirectLight = 0;
|
||||
output.indirectLightEqualized = 0;
|
||||
output.directLightColor = lightColor;
|
||||
output.directLightDirection = lightDir;
|
||||
output.directLightAttenuation = atten;
|
||||
return output;
|
||||
}
|
||||
|
||||
#ifdef MTOON_URP
|
||||
|
||||
@@ -48,6 +48,33 @@
|
||||
UNITY_LIGHTING_COORDS(6,7)
|
||||
#endif
|
||||
|
||||
// Light
|
||||
#ifdef MTOON_URP
|
||||
|
||||
#if defined(REQUIRES_VERTEX_SHADOW_COORD_INTERPOLATOR)
|
||||
#define MTOON_SHADOW_COORD input.shadowCoord
|
||||
#elif defined(MAIN_LIGHT_CALCULATE_SHADOWS)
|
||||
#define MTOON_SHADOW_COORD TransformWorldToShadowCoord(input.positionWS)
|
||||
#else
|
||||
#define MTOON_SHADOW_COORD float4(0, 0, 0, 0)
|
||||
#endif
|
||||
|
||||
#define MTOON_LIGHT_DESCRIPTION(input, atten, lightDir, lightColor) \
|
||||
half4 shadowMask = SAMPLE_SHADOWMASK(input.lightmapUV); \
|
||||
Light mainLight = GetMainLight(MTOON_SHADOW_COORD, input.positionWS, shadowMask); \
|
||||
const half3 lightDir = mainLight.direction; \
|
||||
const half3 lightColor = mainLight.color.rgb; \
|
||||
const float atten = mainLight.shadowAttenuation;
|
||||
|
||||
#else
|
||||
|
||||
#define MTOON_LIGHT_DESCRIPTION(input, atten, lightDir, lightColor) \
|
||||
UNITY_LIGHT_ATTENUATION(atten, input, input.positionWS); \
|
||||
const half3 lightDir = normalize(UnityWorldSpaceLightDir(input.positionWS)); \
|
||||
const half3 lightColor = _LightColor0.rgb;
|
||||
|
||||
#endif
|
||||
|
||||
// Transform
|
||||
inline float3 MToon_TransformObjectToWorldNormal(float3 normalOS)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user