Fast Custom Lighting - Custom Lighting Models - Episode 14 @BenCloward
Fast Custom Lighting - Custom Lighting Models - Episode 14  @BenCloward
Uploaded April 2025 | Updated September 2026, 2 weeks ago
In this video, I show how to create a custom lighting model that renders as fast as possible. This might work well for low power mobile phones or XR headsets that have weak GPUs or require high frame rates.

In order to render faster, this model does not support specular, reflections, metallic, screen space ambient occlusion, light cookies, etc. It leaves out features in favor of faster rendering.

Here's the code for the additional lights subgraph:

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

Diffuse = MainDiffuse;
Color = MainColor * MainDiffuse;

#ifndef SHADERGRAPH_PREVIEW

uint pixelLightCount = GetAdditionalLightsCount();

#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
Light light = GetAdditionalPerObjectLight(lightIndex, WorldPosition);
float NdotL = saturate(dot(WorldNormal, light.direction));
float thisDiffuse = light.distanceAttenuation * NdotL;
Diffuse += thisDiffuse;
Color += light.color * thisDiffuse;
LIGHT_LOOP_END
float total = Diffuse;
Color = total !!!!= 0 ? MainColor : Color / total;
#endif

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

In the code above, please replace the !!!! with the less than sign on the second to last line. YouTube doesn't allow that symbol in video descriptions.

Here's last week's video on converting a scene to use custom lighting:
youtu.be/oXo7pN8YnAw

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
Fast Custom Lighting - Custom Lighting Models - Episode 14Convert a Scene to Use Custom Lighting - Custom Lighting Models - Episode 13Water Decals - Building Worlds In Unreal - Episode 10Underwater Caustics Part 2 - Advanced Materials - Episode 42MatCap Materials - Shader Graph Basics - Episode 31Water Depth Shader - Advanced Materials - Episode 39Ice Shader Part 1 - Advanced Materials - Episode 5Simple Lighting Model - Custom Lighting Models - Episode 4UV Rotation - Shader Graph Basics - Episode 42Particle System Wind and Gravity - Advanced Materials - Episode 49Animated Cloud Pattern - Procedural Shapes and Patterns - Episode 16Terrain Tiling Break-Up - Terrain Shaders - Episode 4
Ben Cloward |

Fast Custom Lighting - Custom Lighting Models - Episode 14

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER