Version: Unity 6.5 (6000.5)
Language : English
Use built-in HLSL structures in the Built-In Render Pipeline
ShaderLab pass tags in the Built-In Render Pipeline reference

Lighting variables in the Built-In Render Pipeline reference

Important: The Built-In Render Pipeline is deprecated and will be made obsolete in a future release.
It remains supported, including bug fixes and maintenance, through the full Unity 6.7 LTS lifecycle.
For more information on migration, refer to Migrating from the Built-In Render Pipeline to the Universal Render Pipeline and Render pipeline feature comparison.

Find the built-in shaderA program that runs on the GPU. More info
See in Glossary
variables that control lighting in the Built-In Render PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info
See in Glossary
.

Light parameters are passed to shaders in different ways depending on which Rendering PathThe technique that a render pipeline uses to render graphics. Choosing a different rendering path affects how lighting and shading are calculated. Some rendering paths are more suited to different platforms and hardware than others. More info
See in Glossary
is used, and which LightMode Pass Tag is used in the shader.

Forward renderingA rendering path that renders each object in one or more passes, depending on lights that affect the object. Lights themselves are also treated differently by Forward Rendering, depending on their settings and intensity. More info
See in Glossary
(ForwardBase and ForwardAdd pass types):

Name Type Value
_LightColor0 (declared in UnityLightingCommon.cginc) fixed4 Light color.
_WorldSpaceLightPos0 float4 Directional lights: (world space direction, 0). Other lights: (world space position, 1).
unity_WorldToLight (declared in AutoLight.cginc) float4x4 World-to-light matrix. Used to sample cookie & attenuation textures.
unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0 float4 (ForwardBase pass only) world space positions of first four non-important point lights.
unity_4LightAtten0 float4 (ForwardBase pass only) attenuation factors of first four non-important point lights.
unity_LightColor half4[4] (ForwardBase pass only) colors of the first four non-important point lights.
unity_WorldToShadow float4x4[4] World-to-shadow matrices. One matrix for Spot Lights, up to four for directional light cascades.

Deferred shading, used in the lighting pass shader (all declared in UnityDeferredLibrary.cginc):

Name Type Value
_LightColor float4 Light color.
unity_WorldToLight float4x4 World-to-light matrix. Used to sample cookie & attenuation textures.
unity_WorldToShadow float4x4[4] World-to-shadow matrices. One matrix for Spot Lights, up to four for directional light cascades.

Spherical harmonics coefficients (used by ambient and light probes) are set up for ForwardBase and Deferred pass types. They contain 3rd order SH to be evaluated by world space normal (see ShadeSH9 from UnityCG.cginc). The variables are all half4 type, unity_SHAr and similar names.

Vertex-lit rendering (Vertex pass type):

Up to 8 lights are set up for a Vertex pass type; always sorted starting from the brightest one. So if you want to render objects affected by two lights at once, you can just take first two entries in the arrays. If there are fewer than eight lights affecting the object, the rest will have their color set to black.

Name Type Value
unity_LightColor half4[8] Light colors.
unity_LightPosition float4[8] View-space light positions. (-direction,0) for directional lights; (position,1) for Point or Spot Lights.
unity_LightAtten half4[8] Light attenuation factors. x is cos(spotAngle/2) or –1 for non-Spot Lights; y is 1/cos(spotAngle/4) or 1 for non-Spot Lights; z is quadratic attenuation; w is squared light range.
unity_SpotDirection float4[8] View-space Spot Lights positions; (0,0,1,0) for non-Spot Lights.

Additional resources

Use built-in HLSL structures in the Built-In Render Pipeline
ShaderLab pass tags in the Built-In Render Pipeline reference