mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-07-08 05:04:06 -05:00
AdditionalLightに対応
This commit is contained in:
parent
1e01559220
commit
f970da6f3a
|
|
@ -55,6 +55,15 @@ half4 MToonFragment(const FragmentInput fragmentInput) : SV_Target
|
|||
mtoonInput.alpha = alpha;
|
||||
half4 col = GetMToonLighting(unityLighting, mtoonInput);
|
||||
|
||||
#ifdef _ADDITIONAL_LIGHTS
|
||||
uint pixelLightCount = GetAdditionalLightsCount();
|
||||
for (uint lightIndex = 0u; lightIndex < pixelLightCount; ++lightIndex)
|
||||
{
|
||||
UnityLighting additionalUnityLighting = GetAdditionalUnityLighting(input, normalWS, lightIndex);
|
||||
col.rgb += GetMToonLighting(additionalUnityLighting, mtoonInput).rgb;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Apply Fog
|
||||
#ifdef MTOON_URP
|
||||
float fogCoord = input.fogFactorAndVertexLight.x;
|
||||
|
|
|
|||
|
|
@ -77,4 +77,29 @@ UnityLighting GetUnityLighting(const Varyings input, const half3 normalWS)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef MTOON_URP
|
||||
UnityLighting GetAdditionalUnityLighting(const Varyings input, const half3 normalWS, int lightIndex)
|
||||
{
|
||||
// TODO: Duplicate in GetUnityLighting
|
||||
#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 light = GetAdditionalLight(lightIndex, input.positionWS, shadowMask);
|
||||
|
||||
UnityLighting output;
|
||||
output.indirectLight = 0;
|
||||
output.indirectLightEqualized = 0;
|
||||
output.directLightColor = light.color;
|
||||
output.directLightDirection = light.direction;
|
||||
output.directLightAttenuation = light.shadowAttenuation * light.distanceAttenuation;
|
||||
return output;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user