Lighting

Lighting refers to all systems in Source which light up a level to make it look realistic. There are many areas of knowledge about lighting that a source level designer should know, most of which are accessible through this page.
== Guides ==
* Adding Light - A beginners tutorial on how to set up a basic light entity.
* Intermediate Lighting - A tutorial dealing with all the light sources in more detail.
* Advanced Lighting - Additional information about lighting.
* Constant-Linear-Quadratic Falloff - An easy-to-read explanation of the old C-L-Q light attenuation system.
* HDR - High Dynamic Range Lighting.
== Types ==
=== Static Light Sources ===
;:A static, omni-directional point light source. (e.g. a naked light bulb or flame.)
;:A static, uni-directional point light source. (e.g. a torch or flashlight) The conical beam angle cannot exceed 90°.
;:Provides two linked light sources:
:*A diffuse 'ambient' light (representing reflected light from clouds and the atmosphere in general) that emits from all skybox surfaces
:*A directional 'brightness' light (representing sunlight or moonlight) that is only cast in a single direction.
:Both are emitted from the toolsskybox and toolsskybox2d materials wherever they are used in a map. See also Skybox.
;:Illuminates particles produced by . Particles are not affected by normal lighting. Use (no more than) two of these to make env_smokestack particles appear to reflect ambient lighting.
; :Essentially a second (or third, or…) one of the direct light from light_environment. Like light_environment's direct light, it is emitted only from brush faces textured with toolsskybox. Unlike light_environment, it can be toggled or use lightstyles without significant bugs.
;Glowing Textures: Any brush surfaces with a light-emitting material (as defined in a RAD file, either the one in your mod directory or the one in sourcesdk/bin/) applied will cast volumetric light in a 180° cone.
=== Static Light Receivers ===
;Brushes
:The "Lightmap Scale" tool in the Hammer Face Edit Dialog can be used to control how sharp or diffuse the lightmap of a brush surface will be—an effect most noticeable between areas of high contrast, e.g. shadows. Note that, while adding extra light sources will not significantly affect performance, decreasing lightmap scale (i.e., increasing resolution) will more directly increase map file size and memory usage.
;
:Unlike other model entities, prop_statics are lit statically: a lighting value is stored for every vertex, and the model's collision mesh (or, optionally, reference mesh) is used to calculate lightmap shadows.
:There are the following options:
:*disableshadows - Do not cast lightmap shadows
:*disablevertexlighting - Only store a single lighting value for the entire model
:*disableselfshadowing - Prevents the entity from casting shadows on itself
:*ignorenormals - Ignores normals of vertex data to calculate lighting. This is extremely useful for foliage and other thin types of vertex meshes.
:*generatelightmaps - Allows the props to use lightmaps (like world brushes) if VRAD is run with -StaticPropLighting and the prop is not bumpmapped. Lightmap resolution can be configured with lightmapresolutionx and lightmapresolutiony. Can also be manually defined with the shader parameter, including on non-static props.
:
; All non-internal brush entities 
:Use the vrad_brush_cast_shadows keyvalue to allow them to cast lightmap shadows. Might be in some games and/or on some entities.
=== Dynamic Light Sources ===
;:A simple, uni-directional dynamic light that can be moved, turned, and adjusted.
;:A dynamic spotlight beam effect, with an optional dynamic light source where it hits a surface.
;:A spotlight NPC, similar to point_spotlight, but with the capability of tracking targets.
;:A dynamic light that lights with a texture rather than a solid color and "subtracts" realistic dynamic shadows. Affects all surfaces that can accept lighting, and is used for the player's flashlight in .
:*In games since , most visible dynamic entities can have texture projection disabled with the disableflashlight keyvalue, and they can have it toggled at runtime with the EnableReceivingFlashlight and DisableReceivingFlashlight inputs. Their shadow-casting behavior, however, must be controlled separately (see under Dynamic Shadows). In earlier games, this behavior can still be controlled via the EF_NOFLASHLIGHT effect flag (see below).
;Effect flags :Most entities with a parent can have or applied to them to have them radiate dynamic light of the appropriate brightness.
=== Dynamic Shadows===
 
 
;:Point entity used to control Dynamic shadow projections for the entire map, including maximum distance cast, direction cast, and sharpness/diffuseness.
;:Point entity used to list brush surfaces that should not receive Dynamic shadows. 
;Most dynamic visible entities:Have a shadowcastdist keyvalue to override how far these objects cast Dynamic shadows, a disableshadows keyvalue to control whether they cast Dynamic shadows, and EnableShadow and DisableShadow inputs to control Dynamic shadows cast by them. In games since , they also have disableshadowdepth to prevent them casting shadows from env_projectedtexture.
;Effect flags :Most entities with a parent can have various effect flags applied to them to regulate many of the same effects as the aforementioned keyvalues, even if they don't have those keyvalues in your version of Source.
=== Tyndall Effects ===
Tyndall effects are caused by light scattering on suspended (colloid) particles in a transparent medium. E.g., car headlights in fog.
* Halo (Glow Sprite) effects : 
:* - entity used to create omni-directional glow or flare effects.
:* - an asymmetrical glow (for areas of contrasting light).
:* - adds a bright haloed spot to the Skybox to represent the position of the Sun or Moon.
* Lightbeam (Volumetric Light) effects : 
:*Brush texture : models/effects/vol_light001 
:*Brush texture : models/effects/vol_light002
:*Model : models/Effects/vol_light.mdl - use with .
* See also Render Modes for sprites, particularly World Space Glow.
== Common Values ==
 	Brightness
Car Headlights 	231 223 192
Combine lamp 	147 226 240
Tungsten bulb 	254 216 146
Fluorescent tube (cold)	159 237 215
Flourescent tube (warm)	255 245 145
 
For values to accompany the stock skybox materials, see Sky List.
== Notes ==
*Naming a static light makes it more expensive. Only name lights when you need to. Multiple lights sharing the same name are cheaper than lights with separate names.
* is especially expensive and will not even show up on some systems
*The basic light entities do not come with a visible representation (e.g. a lightbulb). For that, you need a prop. See HL2 Light Props for a list.
*The basic light entities do not come with a "glow" as you'd expect to see in a foggy or misty area. To provide this, either compile and run the map with HDR enabled, or add a (with dynamic lighting off unless needed), , or entity.
*Maps will not be lit unless you run VRAD (or equivalent). VRAD will not run properly and will not calculate realistic light bounces unless the level is free of leaks.
*Moving brushed-based objects will not change the way they are lit. Their lighting will be calculated only according to their positions in Hammer. (e.g. a brush in a dark room will not become bright if it is brought into a bright room.)
*Light can be reflected off surfaces during compile, indirectly illuminating the environment around them. See .
== Console Commands ==
;
:0 is normal lighting.
:1 is 'full bright' lighting, where everything is 100% lit. This will be enabled by default if there's no lighting data on the map (BSP), or the map was compiled for HDR lighting only and HDR is disabled.
:2 has been introduced with the Orange Box and is 'lighting only'. It replaces all textures' images with a colourless monotone, allowing you to see exactly what is lit, where, and probably how.
== See also ==
* HL2 Light Props
* Color theory (level design)
* Light entities - A list of light entities.
* Intermediate Lighting
* Advanced Lighting
* Window lighting - How to simulate refracted sunlight through openings.
* Light editor
== External links ==
* Understanding and Using Lightmaps 
* Volumetric Lighting 
* Lighting Tutorial - Covers entities & variables with examples 
* Quadratic/Linear/Constant in Lights 
*HDR/Shaped Light/Burning Light/Darkness/Sun/Volumetric 
Category:Level Design
Category:Hubs
*