Lighting: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (→‎See also: Fixed link)
 
(78 intermediate revisions by 28 users not shown)
Line 1: Line 1:
{{lang|Lighting}}
{{Abstract Mapping}}
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 ==
== Guides ==
[[File:Proper lighting example.png|right|thumb|An example of a well-lit room.]]
* [[Adding Light]] - A beginners tutorial on how to set up a basic [[light]] entity.
* [[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.
* [[Intermediate Lighting]] - A tutorial dealing with all the light sources in more detail.
* [[Advanced Lighting]]
* [[Advanced Lighting]] - Additional information about lighting.
* [[Constant-Linear-Quadratic Falloff]] - An easy-to-read explanation of the old C-L-Q light attenuation system.
* [[Constant-Linear-Quadratic Falloff]] - An easy-to-read explanation of the old C-L-Q light attenuation system.
* [[HDR]] - High Dynamic Range Lighting.
* [[HDR]] - High Dynamic Range Lighting.


== Types ==
== Types ==
=== Static light sources ===
=== Static Light Sources ===


{{tip|Static lighting is compiled into [[Lightmap]]s, which illuminate [[brush]]es and [[model]]s, and [[Cubemaps]], which provide static [[reflection]]s.
{{tip|Static lighting is compiled into [[lightmap]]s, which illuminate [[brush]]es and [[model]]s, and [[cubemaps]], which provide static [[reflection]]s.


It is [[free]] to render, as additional static lights only ''alter'' that which is already being processed.}}
It is [[free]] to render, as additional static lights only ''alter'' that which is already being processed.}}


;[[light]]:A static, omni-directional point light source. (e.g. a naked light bulb or flame.)
;{{ent|light}}:A static, omni-directional point light source. (e.g. a naked light bulb or flame.)
;[[light_spot]]:A static, uni-directional point light source. (e.g. a torch or flashlight) The conical beam angle cannot exceed 90°.
;{{ent|light_spot}}:A static, uni-directional point light source. (e.g. a torch or flashlight) The conical beam angle cannot exceed 90°.
;[[light_environment]]: Provides two linked light sources:
;{{ent|light_environment}}: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 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.
:*A directional 'brightness' light (representing sunlight or moonlight) that is only cast in a single direction.
:Both are emitted from the [[Tool textures#skybox|toolsskybox]] material wherever it is used on a map. See also [[Skybox]].
:Both are emitted from the <code>[[Tool textures#skybox|toolsskybox]]</code> and <code>[[Tool textures#skybox|toolsskybox2d]]</code> materials wherever they are used in a map. See also [[Skybox]].
;[[env_particlelight]]: Illuminates particles produced by [[env_smokestack]]. Particles are not affected by normal lighting. Use (no more than) two of these to make (only) [[env_smokestack]] particles appear to reflect ambient lighting.
;{{ent|env_particlelight}}:Illuminates particles produced by {{ent|env_smokestack}}. Particles are not affected by normal lighting. Use (no more than) two of these to make <code>env_smokestack</code> particles appear to reflect ambient lighting.
;[[Glowing Textures]]
;{{ent|light_directional}} {{since|{{l4d}}}}{{slammin|also}}:Essentially a second (or third, or…) one of the direct light from <code>light_environment</code>. Like <code>light_environment</code>'s direct light, it is emitted only from brush faces textured with <code>toolsskybox</code>. Unlike <code>light_environment</code>, it can be toggled or use lightstyles without significant bugs.
:[[Brush]] surfaces with a light-emitting material (as defined in <code>game_dir/lights.rad</code>) applied will cast volumetric light in a 180&deg; cone.
;[[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 <code>sourcesdk/bin/</code>) applied will cast volumetric light in a 180° cone.
 
=== Static light receivers ===


=== Static Light Receivers ===
;[[Brush]]es
;[[Brush]]es
:This [[Hammer Face Edit Dialog]] tool '[[Lightmap Scale]]' 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 affect performance, decreasing lightmap scale (i.e. increasing resolution) will.
: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.
;[[prop_static]]
;{{ent|prop_static}}
:Unlike other model entities, prop_static 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.
:Unlike other model entities, <code>prop_static</code>s 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:
:There are the following options:
:*<code>disableshadows</code> - Do not cast lightmap shadows
:*<code>disableshadows</code> - Do not cast lightmap shadows
:*<code>disablevertexlighting</code> - Only store a single lighting value for the entire model
:*<code>disablevertexlighting</code> - Only store a single lighting value for the entire model
:*<code>disableselfshadowing</code> - Prevents the entity from casting shadows on itself
:*<code>disableselfshadowing</code> - Prevents the entity from casting shadows on itself
:*<code>ignorenormals</code> - Unknown
:*<code>ignorenormals</code> - Ignores normals of vertex data to calculate lighting. This is extremely useful for foliage and other thin types of vertex meshes.
:*<code>generatelightmaps</code> {{only|{{src13mp}} {{tf2branch}} {{gmod}} }} - Allows the props to use lightmaps (like world brushes) if VRAD is run with <code>-StaticPropLighting</code> and the prop is not [[Bump Map|bumpmapped]]. Lightmap resolution can be configured with <code>lightmapresolutionx</code> and <code>lightmapresolutiony</code>. Can also be manually defined with the {{ent|$lightmap}} [[shader parameter]], including on non-static props.
:{{warning|There are a number of caveats related to lighting on '''prop_static'''. [[Prop_static#Known_limitations|See its page]] for detailed info.}}
; All [[internal entity|non-internal]] brush entities {{src07|since}}
:Use the <code>vrad_brush_cast_shadows</code> keyvalue to allow them to cast lightmap shadows. Might be {{not in FGD}} in some games and/or on some entities.


=== Dynamic light sources ===
=== Dynamic Light Sources ===
{{tip|Dynamic lighting is calculated at runtime, which makes it [[expensive]] to render.}}
{{tip|Dynamic lighting is calculated at runtime, which makes it [[expensive]] to render. However, if your game/mod uses [[deferred shading]] or [[clustered_rendering|clustered forward/deferred]], dynamic lighting are [[cheap]] to render, and not restricted to certain number of lights.}}


[[Image:Shadowmap.jpg|thumb|[[env_projectedtexture]] shines from a doorway.]]
[[File:Shadowmap.jpg|thumb|180px|<code>env_projectedtexture</code> shines from a doorway.]]


;[[light_dynamic]]:A simple, uni-directional dynamic light that can be moved, turned, and adjusted.
;{{ent|light_dynamic}}:A simple, uni-directional dynamic light that can be moved, turned, and adjusted.
;[[point_spotlight]]:A dynamic spotlight beam effect, with an optional dynamic light source where it hits a surface.
;{{ent|point_spotlight}}:A dynamic spotlight beam effect, with an optional dynamic light source where it hits a surface.
;[[npc_spotlight]]:A spotlight [[NPC]], similar to point_spotlight but with the capability of tracking targets.
;{{ent|npc_spotlight}}:A spotlight [[NPC]], similar to <code>point_spotlight</code>, but with the capability of tracking targets.
;[[env_projectedtexture]]:A dynamic light that lights with a texture rather than a solid colour, and which also 'subtracts' realistic dynamic shadows. Affects all surfaces that can accept lighting, and is used for the player [[flashlight]] in [[Episode Two]].
;{{ent|env_projectedtexture}}: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 {{game link|Half-Life 2: Episode Two}}.
:*In games since {{Portal 2|4}}, most visible dynamic entities can have texture projection disabled with the <code>disableflashlight</code> 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 <code>EF_NOFLASHLIGHT</code> effect flag (see below).
;[[Effect flags]] {{not in FGD}}:Most entities with an [[origin]] KV can have {{ent|EF_BRIGHTLIGHT}} or {{ent|EF_DIMLIGHT}} applied to them to have them radiate dynamic light of the appropriate brightness.


=== Dynamic shadows ===
=== Dynamic Shadows<span id="Dynamic shadows"></span>===


{{tip|Dynamic Shadows are cast only by world [[model]]s (NPCs, phys-props, etc), and only onto [[brush]] surfaces (from both Static and Dynamic light sources). They are calculated at runtime, so they are quite crude and relatively [[showbudget|expensive]] to render.}}
{{tip|Dynamic shadows are cast only by world [[model]]s (NPCs, phys-props, etc), and only onto [[brush]] surfaces (from both Static and Dynamic light sources). They are calculated at runtime, so they are quite crude and relatively [[showbudget|expensive]] to render. However, dynamic shadows in certain mods or games using [[deferred rendering]] or [[clustered rendering]], are significantly [[Cheap|cheaper]].}}  


{{warning|Dynamic Shadows can sometimes project through walls and floors, giving away the location of players or objects. Use [[info_no_dynamic_shadow]] to workaround this problem if you encounter it.}}
{{warning| In games since {{Left 4 Dead|4}}, the direction of a shadow is calculated on a per-entity basis, and dictated by the closest light to the entity. This is not the case in games up to (and including) {{Src13|4}}, unless you apply [[Dynamic RTT shadow angles in Source 2007]] to your mod.}}


{{note|Dynamic Shadows do not merge with each other or with Lightmaps when they overlap. This can produce undesirable 'doubling up' effects when, for instance, phys props are placed on a phys prop table. You can enable and disable shadows on dynamic entities to work around this.}}
{{warning|Dynamic shadows can sometimes project through walls and floors, giving away the location of players or objects. Use <code>info_no_dynamic_shadow</code> to get around this problem if you encounter it. [[CSM]] does not have this issue.}}


;[[shadow_control]]:Point entity used to control Dynamic Shadow projections for the entire map, including maximum distance cast, direction cast, and sharpness/diffuseness.
{{note|Shadows are "cast" by the visual mesh only if there is no shadowlod defined in the [[QC]]. Shadow LODs are just low detail meshes used to generate the shadow. These don't apply to shadowmapping (flashlights and other <code>env_projectedtexture</code>-based effects).}}
;[[info_no_dynamic_shadow]]:Point entity used to list [[Brush]] surfaces that should ''not'' receive Dynamic Shadows.
;[[prop_physics]] entities : have a "shadowcastdist" keyvalue to override how far this object casts Dynamic Shadows.
;[[prop_dynamic]] entities : have a "disableshadows" keyvalue, and "enableshadows" and "disableshadows" inputs to control Dynamic Shadows cast by them.
;NPC entities : have the prop_dynamic shadow controls, plus a "disablereceiveshadows" {{TODO|to prevent...?}}


=== Tyndall effects ===
{{note|Dynamic shadows do not merge with each other or with lightmaps when they overlap. This can produce undesirable "doubling-up" effects when, for instance, physics props are placed on a phys prop table. You can enable and disable shadows on dynamic entities to work around this. [[CSM]] does not have this issue.}}
[[Wikipedia:Tyndall effect|Tyndall effects]] are caused by light scattering on suspended (colloid) particles in a transparent medium. Eg car headlights in fog.
 
{{note|Dynamic shadows support translucency. If your model has varying levels of opacity, it can show up in the shadow [http://img4.imageshack.us/img4/3627/parttrans.png as seen here]. {{todo|link broken, find another example}} }}
 
;{{ent|shadow_control}}:Point entity used to control Dynamic shadow projections for the entire map, including maximum distance cast, direction cast, and sharpness/diffuseness.
;{{ent|env_cascade_light}}:Point entity used to control Dynamic shadow projections casted via the {{code|[[Tool textures (Source)#fog|tools/toolsskybox]]}} texture. Uses [https://learn.microsoft.com/en-us/windows/win32/dxtecharts/cascaded-shadow-maps Cascade Shadow Map] technique. {{Only|{{csgo}} {{xengine}}}}
;{{ent|info_no_dynamic_shadow}}:Point entity used to list [[brush]] surfaces that should ''not'' receive Dynamic shadows.
;Most dynamic visible entities:Have a <code>shadowcastdist</code> keyvalue to override how far these objects cast Dynamic shadows, a <code>disableshadows</code> keyvalue to control whether they cast Dynamic shadows, and EnableShadow and DisableShadow inputs to control Dynamic shadows cast by them. In games since {{Portal 2|4}}, they also have <code>disableshadowdepth</code> to prevent them casting shadows from <code>env_projectedtexture</code>.
;[[Effect flags]] {{not in FGD}}:Most entities 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 ===
[[Wikipedia:Tyndall effect|Tyndall effects]] are caused by light scattering on suspended (colloid) particles in a transparent medium. E.g., car headlights in fog.
* [[Wikipedia:Halo_(optical_phenomenon)|Halo]] (Glow Sprite) effects :  
* [[Wikipedia:Halo_(optical_phenomenon)|Halo]] (Glow Sprite) effects :  
:*[[env_sprite]] - entity used to create omni-directional glow or flare effects.
:*{{ent|env_sprite}} - entity used to create omni-directional glow or flare effects.
:*[[env_lightglow]] - an asymmetrical glow (for areas of contrasting light).
:*{{ent|env_lightglow}} - an asymmetrical glow (for areas of contrasting light).
:*[[env_sun]] - adds a bright haloed spot to the [[Skybox]] to represent the position of the Sun or Moon.
:*{{ent|env_sun}} - adds a bright haloed spot to the [[Skybox]] to represent the position of the Sun or Moon.
* [[Wikipedia:Light beam|Lightbeam]] (Volumetric Light) effects :  
* [[Wikipedia:Light beam|Lightbeam]] (Volumetric Light) effects :  
:*Brush texture : <code>models/effects/vol_light001</code>  
:*Brush texture : <code>models/effects/vol_light001</code>  
:*Brush texture : <code>models/effects/vol_light002</code>
:*Brush texture : <code>models/effects/vol_light002</code>
:*Model : <code>models/Effects/vol_light.mdl</code> - use with [[prop_static]].
:*Model : <code>models/Effects/vol_light.mdl</code> - use with {{ent|prop_static}}.
* See also [[Render Modes]] for sprites, particularly ''World Space Glow''.
* See also [[Render Modes]] for sprites, particularly [[Render Modes#World Space Glow (9)|World Space Glow]]''.
 
== Common Values ==
{| class="wikitable"
|-
! !! Brightness
|-
| Car Headlights
| style="background: #e7dfc0;color: #000;" class="table-yes"|231 223 192
|-
| Combine lamp
| style="background: #93e2f0;color: #000;" class="table-yes"|147 226 240
|-
| Tungsten bulb
| style="background: #fed892;color: #000;" class="table-yes"|254 216 146
|-
| Fire
| style="background: #FEAE0A;color: #000;" class="table-yes"|254 174 10
|-
| Fluorescent tube (cold)
| style="background: #9fedd7;color: #000;" class="table-yes"|159 237 215
|-
| Flourescent tube (warm)
| style="background: #fff591;color: #000;" class="table-yes"|255 245 145
|}


== Common values ==
;City 17 day
:Brightness <code>237 218 143 800</code>
:Ambience <code>190 201 220 100</code>
;Ravenholm night
:Brightness <code>175 230 239 50</code>
:Ambience <code>43 45 57 5</code>
;Combine lamp
:Brightness <code>147 226 240 3000</code>
:Ambience N/A
;Tungsten bulb
:Brightness <code>254 216 146</code>
:Ambience N/A
;Fluorescent bulb
:Brightness <code>159 237 215</code>
:Ambience N/A
For values to accompany the stock [[skybox]] materials, see [[Sky List]].
For values to accompany the stock [[skybox]] materials, see [[Sky List]].


== Notes ==
== Notes ==
*Naming a 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.
*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.
*[[light_dynamic]] is especially expensive, and will not even show up on some systems
*{{ent|light_dynamic}} 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 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 [[point_spotlight]] (with dynamic lighting ''off'' unless needed) or [[env_lightglow]] entity.
*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 {{ent|point_spotlight}} (with dynamic lighting ''off'' unless needed), {{ent|env_lightglow}}, or {{ent|env_sprite}} 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 [[leak]]s.
*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 [[leak]]s.
*Several textures provide their own light & can do so using <code>[[lights.rad]]</code> in a mod's directory or the one in <code>sourcesdk/bin</code>.
*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.)
*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 {{ent|$reflectivity}}.


== [[Console command]]s ==
== Console Commands ==


[[Image:Mat fullbright 2.jpg|thumb|<code>mat_fullbright 2</code>. The bright white physics props seem to be a bug; they are lit correctly when in motion. ]]
[[File:Mat fullbright 2.jpg|thumb|<code>mat_fullbright 2</code>. The bright white physics props seem to be a bug; they are lit correctly when in motion. ]]


;<code>mat_fullbright <0-2></code>
;{{Command|mat_fullbright|<0-2>}}
:<code>0</code> is normal lighting.
:<code>0</code> is normal lighting.
:<code>1</code> is 'full bright' lighting, where everything is 100% lit.
:<code>1</code> 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.
:<code>2</code> 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.
:<code>2</code> has been introduced with the Orange Box and is 'lighting only'. It replaces all {{cmd|$basetexture}}s with a colorless monotone, allowing you to see exactly what is lit, where, and probably how. Ignored for materials with {{cmd|$no_fullbright}}.
{{bug|tested={{dods}}|Lightmapped props are unaffected by mat_fullbright 1.}}


== See also ==
== See also ==
* [[HL2 light props]]
* [[HL2 Light Props]]
* [[Color theory (level design)]]
* [[Color theory (level design)]]
* [[List_of_entities#Light_entities|Light entities]] - A list of light entities.
* [[List_of_entities#Light_entities|Light entities]] - A list of light entities.
* [[Intermediate Lighting]]
* [[Advanced Lighting]]
* [[Window lighting]] - How to simulate refracted sunlight through openings.
* [[Light editor]]


== External links ==
== External links ==
<!--
* [http://web.archive.org/web/20070826121450/http://www.halflifestorm.com:80/?page=tutorials&tutorial=18 Understanding and Using Lightmaps] {{Archived|date=26 August, 2007}}
* [http://www.halflifestorm.com/?page=tutorials&tutorial=18 Understanding and Using Lightmaps] - Tutorial
* [http://web.archive.org/web/20070824050403/http://www.halflifestorm.com:80/?page=tutorials&tutorial=44 Volumetric Lighting] {{Archived|date=24 August, 2007}}
* [http://www.halflifestorm.com/?page=tutorials&tutorial=44 Volumetric Lighting] - Tutorial
* [http://web.archive.org/web/20160906193301/http://source-tutorials.yolasite.com:80/lighting-tutorial.php Lighting Tutorial] - Covers entities & variables with examples {{Archived|date=6 September, 2016}}
the Half-Life Storm website seems to have gone AWOL -->
* [http://web.archive.org/web/20101124123030/http://www.editlife.net/tutorial.php?tutid=15 Quadratic/Linear/Constant in Lights] {{Archived|date=24 November, 2010}}
* [http://source-tutorials.synthasite.com/lighting-tutorial.php Lighting Tutorial] - Covers entities & variables with examples
*[http://web.archive.org/web/20080120193849/http://www.sdknuts.net:80/akg/?sdk=tutlights HDR/Shaped Light/Burning Light/Darkness/Sun/Volumetric] {{Archived|date=20 January, 2008}}
* [http://www.editlife.net/tutorials.php?id=15 Quadratic/Linear/Constant in Lights]
 
<!-- SDK nuts has closed. When (and if) this tutorial is ported onto the VDC, please link to it instead!
*[http://www.sdknuts.net/akg/?sdk=tutlights HDR/Shaped Light/Burning Light/Darkness/Sun/Volumetric]
-->


[[Category:Level Design]]
[[Category:Level Design]]
[[Category:Hubs]]
[[Category:Lighting|*]]

Latest revision as of 04:15, 30 May 2025

English (en)Español (es)Русский (ru)中文 (zh)Translate (Translate)
Abstract Mapping series Discuss your thoughts - Help us develop the articles or ideas you want

Ammunition | List of HL2 Animals and Creatures | Mapping with Antlions | Beams and Lasers | Cables and Ropes | Moving Clouds | Color Theory in Level Design | Combat | Combine | Compression (Source 1) | Doors | Dust, Fog, & Smoke | Elevators | Level Transitions | Environmental Lighting, Sun, Weather, & Outdoors | Explosions | Fire | Half-Life 2 Foliage | Glass & Windows | Headcrab | Health | Ladders | Lighting | Optimization (level design) | Physics | Retinal scanners | Sound and Music | Special effects | Terrain | Trains | Turrets | Water | Weapons | Zombie

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

An example of a well-lit room.

Types

Static Light Sources

Tip.pngTip:Static lighting is compiled into lightmaps, which illuminate brushes and models, and cubemaps, which provide static reflections. It is free to render, as additional static lights only alter that which is already being processed.
light
A static, omni-directional point light source. (e.g. a naked light bulb or flame.)
light_spot
A static, uni-directional point light source. (e.g. a torch or flashlight) The conical beam angle cannot exceed 90°.
light_environment
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.
env_particlelight
Illuminates particles produced by env_smokestack. Particles are not affected by normal lighting. Use (no more than) two of these to make env_smokestack particles appear to reflect ambient lighting.
light_directional (in all games since Left 4 Dead)(also in Slammin' Source Map Tools)
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.
prop_static
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 (only in Source 2013 Multiplayer Team Fortress 2 branch Garry's Mod) - 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 $lightmap shader parameter, including on non-static props.
Warning.pngWarning:There are a number of caveats related to lighting on prop_static. See its page for detailed info.
All non-internal brush entities (in all games since Source 2007)
Use the vrad_brush_cast_shadows keyvalue to allow them to cast lightmap shadows. Might be !FGD in some games and/or on some entities.

Dynamic Light Sources

Tip.pngTip:Dynamic lighting is calculated at runtime, which makes it expensive to render. However, if your game/mod uses deferred shading or clustered forward/deferred, dynamic lighting are cheap to render, and not restricted to certain number of lights.
env_projectedtexture shines from a doorway.
light_dynamic
A simple, uni-directional dynamic light that can be moved, turned, and adjusted.
point_spotlight
A dynamic spotlight beam effect, with an optional dynamic light source where it hits a surface.
npc_spotlight
A spotlight NPC, similar to point_spotlight, but with the capability of tracking targets.
env_projectedtexture
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 Half-Life 2: Episode Two Half-Life 2: Episode Two .
  • In games since Portal 2 Portal 2, 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 !FGD
Most entities with an origin KV can have EF_BRIGHTLIGHT or EF_DIMLIGHT applied to them to have them radiate dynamic light of the appropriate brightness.

Dynamic Shadows

Tip.pngTip:Dynamic shadows are cast only by world models (NPCs, phys-props, etc), and only onto brush surfaces (from both Static and Dynamic light sources). They are calculated at runtime, so they are quite crude and relatively expensive to render. However, dynamic shadows in certain mods or games using deferred rendering or clustered rendering, are significantly cheaper.
Warning.pngWarning: In games since Left 4 Dead Left 4 Dead, the direction of a shadow is calculated on a per-entity basis, and dictated by the closest light to the entity. This is not the case in games up to (and including) Source 2013 Source 2013, unless you apply Dynamic RTT shadow angles in Source 2007 to your mod.
Warning.pngWarning:Dynamic shadows can sometimes project through walls and floors, giving away the location of players or objects. Use info_no_dynamic_shadow to get around this problem if you encounter it. CSM does not have this issue.
Note.pngNote:Shadows are "cast" by the visual mesh only if there is no shadowlod defined in the QC. Shadow LODs are just low detail meshes used to generate the shadow. These don't apply to shadowmapping (flashlights and other env_projectedtexture-based effects).
Note.pngNote:Dynamic shadows do not merge with each other or with lightmaps when they overlap. This can produce undesirable "doubling-up" effects when, for instance, physics props are placed on a phys prop table. You can enable and disable shadows on dynamic entities to work around this. CSM does not have this issue.
Note.pngNote:Dynamic shadows support translucency. If your model has varying levels of opacity, it can show up in the shadow as seen here.
Todo: link broken, find another example
shadow_control
Point entity used to control Dynamic shadow projections for the entire map, including maximum distance cast, direction cast, and sharpness/diffuseness.
env_cascade_light
Point entity used to control Dynamic shadow projections casted via the tools/toolsskybox texture. Uses Cascade Shadow Map technique. (only in Counter-Strike: Global Offensive Xengine)
info_no_dynamic_shadow
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 Portal 2 Portal 2, they also have disableshadowdepth to prevent them casting shadows from env_projectedtexture.
Effect flags !FGD
Most entities 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 :
  • env_sprite - entity used to create omni-directional glow or flare effects.
  • env_lightglow - an asymmetrical glow (for areas of contrasting light).
  • env_sun - adds a bright haloed spot to the Skybox to represent the position of the Sun or Moon.
  • Brush texture : models/effects/vol_light001
  • Brush texture : models/effects/vol_light002
  • Model : models/Effects/vol_light.mdl - use with prop_static.

Common Values

Brightness
Car Headlights 231 223 192
Combine lamp 147 226 240
Tungsten bulb 254 216 146
Fire 254 174 10
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.
  • light_dynamic 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 point_spotlight (with dynamic lighting off unless needed), env_lightglow, or env_sprite 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 $reflectivity.

Console Commands

mat_fullbright 2. The bright white physics props seem to be a bug; they are lit correctly when in motion.
mat_fullbright <0-2>
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 $basetextures with a colorless monotone, allowing you to see exactly what is lit, where, and probably how. Ignored for materials with $no_fullbright.
Icon-Bug.pngBug:Lightmapped props are unaffected by mat_fullbright 1.  (tested in: Day of Defeat: Source)

See also

External links