Some custom lighting functions/sub-graphs for Shader Graph, Universal Render Pipeline. If anything breaks, let me know by opening an issue!
+ This version is for URP v12+ (Unity 2021.2+) For use with older versions use the v8 branch!
https://github.com/Cyanilux/URP_ShaderGraphCustomLighting.git
Main Light
Main Light Shadows
Main Light Cookie
- For supporting cookies. Will also enable cookies for additional lights (as they use the same keyword)
Main Light Layer Test
- For supporting Light Layers. Pass your shading calculation from main light through here.
Main Light Diffuse
(handles Lambert / NdotL calculation)
Main Light Specular Highlights
- handles specular highlights based on Phong or BlinnPhong models
Additional Lights
- Loops through each additional light, point, spotlights, etc. Handles diffuse, specular and shadows. Supports Forward+ path (in 2022.2+)
Main Light Cookie
node is used (or _LIGHT_COOKIES
Boolean Keyword is defined in Blackboard)Main Light Layer Test
node is used (or _LIGHT_LAYERS
Boolean Keyword is defined in Blackboard)Sample Shadowmask
- attach this to the Shadowmask port on the Main Light Shadows and Additional Lights sub graphs, in order to support Shadowmask baked lighting mode
Ambient SampleSH
- uses per-pixel SampleSH, use add node to apply this. Can alternatively use the built-in Baked GI node)
Subtractive GI
- for supporting Subtractive baked lighting mode. Should connect Main Light Shadows node to first port. Uses MixRealtimeAndBakedGI function from URP ShaderLibrary
Mix Fog
- applies fog to the colour, should be used just before outputting to BaseColor on Master Stack
Phong Specular
and Blinn-Phong Specular
subgraphs are now considered deprecated - use Main Light Specular Highlights
instead.