So lately i've been working on a more efficient lighting model. And already got all the diffuse and etc. calculations need. But when I try to add shadows for additional lights. The pass won't work and i can't find any good references online. So i figured to ask for help here.
AdditionalLights Code:
{
void AdditionalLightsDiffuse(Varyings IN, out half3 finalColor)
{
uint pixelLightCount = GetAdditionalLightsCount();
half3 accumulatedColor = IN.mainLightColor;
// For LIGHT_LOOP_BEGIN macro
#if USE_CLUSTER_LIGHT_LOOP
InputData inputData = (InputData)0;
inputData.normalizedScreenSpaceUV = IN.screenPosition.xy / IN.screenPosition.w;
inputData.positionWS = IN.positionWS;
#endif
LIGHT_LOOP_BEGIN(pixelLightCount)
#if !USE_CLUSTER_LIGHT_LOOP
lightIndex = GetPerObjectLightIndex(lightIndex);
#endif
Light currentLight;
#if _RECEIVE_SHADOWS
half4 shadowMask = CalculateShadowMask(inputData);
currentLight = GetAdditionalLight(lightIndex, IN.positionWS, shadowMask);
#else
currentLight = GetAdditionalLight(lightIndex, IN.positionWS);
#endif
if (currentLight.distanceAttenuation <= 0.0)
continue;
// Diffuse calculation
half NdotL = saturate(dot(IN.normalWS, currentLight.direction));
half thisDiffuse = NdotL * (currentLight.distanceAttenuation * currentLight.shadowAttenuation);
accumulatedColor += currentLight.color.rgb * thisDiffuse;
LIGHT_LOOP_END
finalColor = accumulatedColor;
}
}