I’m trying to write a shader on URP, usind the Forward+ rendering path. I’ve been following the manual page on adding additional lights for a custom node, but the lights only render either when the camera is inside their area, or when the light is near the bottom left of the screen. The scene only has three lights: a directional light, which seems to be functioning without issue, a a spotlight and a point light. Unity version is 6000.0.34f1, but I’ve tested and the issue still happens in both 6000.0.59f1 and 6000.2.8f1.

This is the custom node:
#ifndef MY_SHADER_INCLUDED
#define MY_SHADER_INCLUDED
#ifndef SHADERGRAPH_PREVIEW
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/CommonMaterial.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RealtimeLights.hlsl"
float3 MyLightingFunction(float3 normalWS, Light light)
{
float NdotL = dot(normalWS, normalize(light.direction));
NdotL = (NdotL + 1) * 0.5;
return saturate(NdotL) * light.color * light.distanceAttenuation * light.shadowAttenuation;
}
#endif // SHADERGRAPH_PREVIEW
void LightingCelShaded_float(
in float3 Position,
in float3 Normal,
out float3 Color)
{
#if defined(SHADERGRAPH_PREVIEW)
Color = float3(0, 0, 0); // Value for preview
#else
InputData inputData = (InputData)0;
inputData.positionWS = Position;
inputData.normalWS = Normal;
inputData.viewDirectionWS = GetWorldSpaceNormalizeViewDir(Position);
float4 clipPos = TransformWorldToHClip(Position);
inputData.positionCS = clipPos;
inputData.normalizedScreenSpaceUV = GetNormalizedScreenSpaceUV(clipPos.xy);
Light mainLight = GetMainLight();
// Main light
Color = MyLightingFunction(Normal, mainLight);
// Additional lights
#if defined(_ADDITIONAL_LIGHTS)
#if USE_FORWARD_PLUS
UNITY_LOOP for (uint lightIndex = 0; lightIndex < min(URP_FP_DIRECTIONAL_LIGHTS_COUNT, MAX_VISIBLE_LIGHTS); lightIndex++)
{
Light additionalLight = GetAdditionalLight(lightIndex, inputData.positionWS, half4(1,1,1,1));
Color += MyLightingFunction(Normal, additionalLight);
}
#endif
uint pixelLightCount = GetAdditionalLightsCount();
LIGHT_LOOP_BEGIN(pixelLightCount)
Light additionalLight = GetAdditionalLight(lightIndex, inputData.positionWS, half4(1,1,1,1));
Color += MyLightingFunction(Normal, additionalLight);
LIGHT_LOOP_END
#endif // _ADDITIONAL_LIGHTS
#endif // SHADERGRAPH_PREVIEW
}
#endif // MY_SHADER_INCLUDED
This is the complete shader:
And finally this is the rendering path settings asset, in case it helps:
The closes post I found to my issue was this one, but changing the clipping planes does nothing for me.
The farthest I got in troubleshooting was hardcoding the inputData.positionCS = clipPos; to a static value, which did change the angles at which the light renders. That said, I can’t see what’s wrong with the way I’m setting up that value.
Any help is appreciated!



