GridVids
Sign in with YouTube

Fast Custom Lighting - Custom Lighting Models - Episode 14

Ben Cloward Apr 24, 2025 15:01
Create an account to hide videos, mark them watched, or save them to Don't Miss.
Don't Miss
Create an account to hide videos, mark them watched, or save them to Don't Miss.
Mark watched
Create an account to hide videos, mark them watched, or save them to Don't Miss.
Hide
Open in popup Open on YouTube
Share video

Share video

Copy the GridVids link or iframe code.

Video link
Iframe code
Iframe content

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: https://youtu.be/oXo7pN8YnAw Here's the playlist for the whole series: https://www.youtube.com/playlist?list=PL78XDi0TS4lGnGa7L2X4o3UV-XYZEKNwj Shader Book Recommendations https://www.bencloward.com/resources_books.shtml ------------------------------ Theme Music Peace in the Circuitry - Glitch Hop http://teknoaxe.com/Link_Code_3.php?q=1526 Background Music Speo - The Little Things https://www.youtube.com/watch?v=kvCYuyyLgC0 #UnrealEngine #shadergraph #Unity
Education
#UE4 #UE5 #Unreal #Unreal Engine #Unity #shader #material #material editor #game development #real-time #tutorial #training #graphics #3d #GPU #tech art #computer graphics #fundamentals #shader graph #fast rendering #simple custom lighting #basic #diffuse-only