URP Lighting Model - Custom Lighting Models - Episode 20 @BenCloward
URP Lighting Model - Custom Lighting Models - Episode 20  @BenCloward
Uploaded June 2025 | Updated November 2026, 1 day ago
In this video, I show how to re-create the URP lighting model using Shader Graph. Last week we created just the specular component of the lighting, and this week we fill in the rest so you have the complete URP lighting model.

Here's the code for the Additional Lights custom function node:
---------------------------------------

Diffuse = MainDiffuse;
Specular = MainSpecular;
Color = MainColor * (MainDiffuse + MainSpecular);

#ifndef SHADERGRAPH_PREVIEW

uint pixelLightCount = GetAdditionalLightsCount();
half Roughness = pow(1 - Smoothness, 2);
half Roughness2 = Roughness * Roughness;
half Roughness2Minus1 = Roughness2 - 1;
half normalizationTerm = (Roughness * half(4.0) + half(2.0));

#if USE_CLUSTER_LIGHT_LOOP
// for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS
InputData inputData = (InputData)0;

inputData.normalizedScreenSpaceUV = ScreenPosition;
inputData.positionWS = WorldPosition;
#endif

LIGHT_LOOP_BEGIN(pixelLightCount)
// Convert the pixel light index to the light data index
#if !USE_CLUSTER_LIGHT_LOOP
lightIndex = GetPerObjectLightIndex(lightIndex);
#endif
// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value
Light light = GetAdditionalPerObjectLight(lightIndex, WorldPosition);
// Manually set the shadow attenuation by calculating realtime shadows
light.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);
#if defined(_LIGHT_COOKIES)
float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);
light.color *= cookieColor;
#endif
float NdotL = saturate(dot(WorldNormal, light.direction));
float atten = light.distanceAttenuation * light.shadowAttenuation;
float thisDiffuse = NdotL * atten;
//DirectBRDFSpecular

float3 lightDirectionWSFloat3 = float3(light.direction);
float3 halfDir = SafeNormalize(lightDirectionWSFloat3 + float3(WorldView));
float NoH = saturate(dot(float3(WorldNormal), halfDir));
half LoH = half(saturate(dot(lightDirectionWSFloat3, halfDir)));
float d = NoH * NoH * Roughness2Minus1 + 1.00001f;
half LoH2 = LoH * LoH;
half spec = Roughness2 / ((d * d) * max(0.1h, LoH2) * normalizationTerm);
#if REAL_IS_HALF
spec = spec - HALF_MIN;
spec = clamp(spec, 0.0, 1000.0);
#endif
float3 thisSpecular = spec * Reflectance * NdotL * atten;

Diffuse += thisDiffuse;
Specular += thisSpecular;

Color += light.color * (thisDiffuse + thisSpecular);
LIGHT_LOOP_END
float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));
Color = total &&&&= 0 ? MainColor : Color / total;
#endif

----------------------------------------------------
Be sure to replace the &&&& with a less than symbol. YouTube doesn't allow that symbol in descriptions.

Here's the set of Keywords that need to go into the Lit subgraph:

_CLUSTER_LIGHT_LOOP
_LIGHT_COOKIES
_REFLECTION_PROBE_BLENDING
_REFLECTION_PROBE_BOX_PROJECTION
_REFLECTION_PROBE_ATLAS
_SHADOWS_SOFT
_ADDITIONAL_LIGHT_SHADOWS
_MAIN_LIGHT_SHADOWS_CASCADE

Here's last week's video on URP Specular:
youtube.com/watch?v=2ABQj7qDT4E

Here's the playlist for the whole series:
youtube.com/playlist?list=PL78XDi0TS4lGnGa7L2X4o3UV-XYZEKNwj

Shader Book Recommendations
bencloward.com/resources_books.shtml

------------------------------

Theme Music
Peace in the Circuitry - Glitch Hop
teknoaxe.com/Link_Code_3.php?q=1526

Background Music
Speo - The Little Things
youtube.com/watch?v=kvCYuyyLgC0

#UnrealEngine #shadergraph #Unity
URP Lighting Model - Custom Lighting Models - Episode 20Metallic Lighting Model - Custom Lighting Models - Episode 5Optimizing Individual Draw Calls - Game Optimization - Episode 9Eliminate Slope Stretching - Terrain Shaders - Episode 8The Graphics Pipeline and Rendering Types - Game Optimization - Episode 2Screen Space Ambient Occlusion - Custom Lighting Models - Episode 9URP Specular - Custom Lighting Models - Episode 19Interior Mapping - Shader Graph Basics - Episode 34Substrate Car Paint - Unreal Substrate - Episode 9Particle System Soft Edges - Advanced Materials - Episode 54Vertex Lighting - Custom Lighting Models - Episode 2Terrain Advanced Auto Material - Terrain Shaders - Episode 16
Ben Cloward |

URP Lighting Model - Custom Lighting Models - Episode 20

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER