Lighting
From Valve Developer Community
| [edit (http://developer.valvesoftware.com/w/index.php?title=Template:Abstract_Mapping_Ideas&action=edit)]Abstract Mapping series Discuss your thoughts—Help us develop the articles or ideas you want
Animals | Animated Clouds | Animated Sky | Antlions | Beams | Bushes | Cables | Color | Combat | Creatures | Doors | Dust | Elevators | Environmental Lighting | Explosions | Fire | Fog | Foliage | Glass | Grass | Ladders | Lasers | Lighting | Moving Clouds | Music | Optimization | Outdoors | Physics | Retinal scanners | Ropes | Smoke | Sound | Special effects | Sun | Terrain | Trains | Trees | Turrets | Water | Weather | Windows |
[edit]
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
- Constant-Linear-Quadratic Falloff - An easy-to-read explanation of the old C-L-Q light attenuation system.
- HDR - High Dynamic Range Lighting.
[edit]
Entities
[edit]
Static light sources
Tip: Static lighting is compiled into Lightmaps (which illuminate world brushes) and Cubemaps (which illuminate models).- 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) The conical beam angle cannot exceed 90°.
- light_environment
- Provides two linked light sources; a "Diffuse light" reflected from overhead clouds/sky and a "Parallel light" which represents sun- or moon- light. Both are emitted from the toolsskybox material wherever it is used on 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.
- luminous materials
- Brush surfaces with a light-emitting material (as defined in
game_dir/lights.rad) applied will cast volumetric light in a 180° cone.
[edit]
Dynamic light sources
Tip: Dynamic lighting is calculated at runtime, which makes it expensive to render.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 using a texture rather than a solid colour, and which also casts realistic dynamic shadows. Affects all surfaces that can accept lighting, and is used for the player flashlight in Episode Two.
[edit]
Shadows
- Static Shadows are cast only by the combination of static light sources and static geometry (Brushes and Models); they are calculated and baked into the Lightmaps by VRAD, so they look much better and are relatively cheap to render.
- 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.
- Sometimes (?) Dynamic Shadows are projected through walls and floors, giving away the location of enemies. Use info_no_dynamic_shadow to workaround this problem.
- Dynamic Shadows do not coagulate with each other or with Lightmapped shadows when they overlap. For example, light_environment casts both Static and Dynamic Shadows, so use info_no_dynamic_shadow to prevent 'shadows within shadows' from a single light source.
- shadow_control
- Point entity used to control Dynamic Shadow projections for the entire map.
- info_no_dynamic_shadow
- Point entity used to list Brush surfaces that should not receive Dynamic Shadows.
- Lightmap Scale
- Hammer Face Edit Dialog tool used to define how sharp/diffuse the Static Shadows will be on individual Brush surfaces. See also the shadow_control Entity's "distance" parameter for diffusion of 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"
To do: to prevent...?
- prop_static entities
- have "disableshadows" as well as "disablevertexlighting", "disableselfshadowing" and "ignorenormals" vertex lighting controls.
[edit]
Tyndall effects
Tyndall effects (http://en.wikipedia.org/wiki/Tyndall_effect) are caused by light scattering on suspended (colloid) particles in a transparent medium. Eg car headlights in fog.
- Halo (http://en.wikipedia.org/wiki/Halo_%28optical_phenomenon%29) (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.
- Lightbeam (http://en.wikipedia.org/wiki/Light_beam) (Volumetric Light) effects :
- Brush texture :
models/effects/vol_light001 - Brush texture :
models/effects/vol_light002 - Model :
models/Effects/vol_light.mdl- use with prop_static.
- Brush texture :
- See also Render Modes for sprites, particularly World Space Glow.
[edit]
Common values
- City 17 day
- Brightness
237 218 143 800 - Ambience
190 201 220 100 - Ravenholm night
- Brightness
175 230 239 50 - Ambience
43 45 57 5 - Combine lamp
- Brightness
147 226 240 3000 - Ambience N/A
- Tungsten bulb
- Brightness
254 216 146 - Ambience N/A
- Fluorescent bulb
- Brightness
159 237 215 - Ambience N/A
For values to accompany the stock skybox materials, see Sky List.
[edit]
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.
- 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) or env_lightglow 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.
- Several textures provide their own light & can do so using
lights.radin a mod's directory or the one insourcesdk/bin. - 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.)
[edit]
Console commands
mat_fullbright boolean— Toggles map lighting
[edit]
See also
- HL2 light props
- Color theory (level design)
- Light entities - A list of light entities.
[edit]
External links
- Lighting Tutorial (http://www.freewebs.com/flashsjunk/lightingtutorial.htm) - Covers entities & variables with examples
- Quadratic/Linear/Constant in Lights (http://www.editlife.net/tutorials.php?id=15)
