Where to begin. I guess I’m just not sure exactly how the additional lights function and I know there have been a lot of posts on this, but my head hurts having tried to troubleshoot this for the past week. I’m not that well versed in shading programming so bear with me. Note, I am only trying to retrieve light color information.
The issue: Using additional lights with Unity 6 URP shadergraph in Forward+ throws an undeclared identifier ‘AdditionalLights_float’ if not using the LIGHT_LOOP_BEGIN/END functions. Otherwise, I get an ‘_AdditionalLightsPosition’: implicity array missing initial value at line 169 if I do use the loop.
My search took me all over the place, but still haven’t found a solution yet so this is where I’m at:
#pragma multi_compile _ _FORWARD_PLUS
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RealtimeLights.hlsl"
void AdditionalLights_float(float3 worldPosition, float3 worldNormal, out float3 color)
{
color = float3(1, 0, 0); // Default to red if lights don't work
#if _FORWARD_PLUS
uint lightCount = GetAdditionalLightsCount();
InputData inputData = (InputData)0;
inputData.positionWS = input.PositionWS;
if (lightCount > 0)
{
color = float3(0, 1, 0); // Turn green if lights exist
LIGHT_LOOP_BEGIN(lightCount)
uint perObjectLightIndex = GetPerObjectLightIndex(lightIndex);
Light light = GetAdditionalLight(perObjectLightIndex, worldPosition);
color += light.color;
LIGHT_LOOP_END
}
#endif
}
The function custom function I’ve isolated into its own graph.







