Lightmap: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(redone)
Line 1: Line 1:
A lightmap is the static lighting data for each [[Brush]] face. This light data is applied additively to each surface texture to produce the final lit effect. Especially common in [[BSP]] based engines, it's the method used for most lighting effects within the source engine.
{{toc-right}}


Determined during the [[vrad]] compile process lightmaps are only applied to brush faces as models are lit differently.  
A '''lightmap''' is a generated [[texture]] applied [[Wikipedia:Additive color|additively]] to [[LightmappedGeneric]] [[brush]] faces to simulate lighting. The color values in the surface's [[albedo]] are multiplied by the color values in its lightmap.


== Lightmap Scale ==
Lightmaps are created by [[VRAD]] each time a map is compiled. They are static and cannot change, though it is possible to switch lightmap 'pages' on and off.
The '''lightmap scale''' determines how sharp or diffuse the static shadows will be on a particular facet. It is defined by the number of [[dimensions|game units]] per lightmap pixel (luxel). The default value in Hammer is 16 units/luxel. Smaller values increase the sharpness of shadows, but mean more luxels,  larger lightmap file size and slower compile times.
* In Hammer, the "lightmap" viewmode shows the lightmap scale on all surfaces in the camera view. For individual surfaces, view and edit lightmap scale in the [[Hammer_Face_Edit_Dialog|Face Edit Dialog]].
* Faces such as [[displacement]] maps calculate and use their own lightmap scale; different values will often get reset by Hammer to match the displacements' lightmap size.


[[image:intlight_lmap4.jpg|thumb|left|A lightmap scale of 4]]
== Scale ==
[[image:intlight_lmap16.jpg|thumb|left|A lightmap scale of 16]]
[[image:intlight_lmap64.jpg|thumb|left|A lightmap scale of 64]]
{{clr}}


{{tip|A couple of things to bear in mind when configuring static shadow diffusion:}}
The '''lightmap scale''' of a face defines the resolution of its lightmap. The default scale of 16 makes each lightmap pixel ("luxel") 16 [[unit]]s across, while a lightmap scale of 1 makes one luxel equal one unit. The [[Hammer Face Edit Dialog]] is used to change the value per-face.
:* Generally, shadows will become more diffuse as they get further away from your average light bulb or flame. As these light sources are radial, the illuminated surface area is much smaller closer to the light. Thus increasing the lightmap density for these small, close areas is relatively [[cheap]].
:* However, Direct light from the Sun or Moon (see [[light_environment]]) has negligible falloff and spread (ie parallel rather than radial rays) because these strong light sources are so far away. Direct parallel light will tend to cast equally sharp/diffuse shadows at any distance within a map.
:* Thicker Fog (see [[env_fog_controller]]) increases atmospheric scattering, which means all shadows will be be (a lot) more diffuse.


== Related [[ConCommand]]s ==
Lowering scale will make lightmap shadows sharper, but leads to larger map filesize, slightly slower rendering and exponentially slower compiles (that at ''very'' low scales start to eat up shocking amounts of system memory).
*[[Lightmap Commands#mat_filterlightmaps|mat_filterlightmaps]]
 
*[[Lightmap Commands#mat_showlightmapcomponent|mat_showlightmapcomponent]]
<div style="text-align:center;margin:auto;width:608px;background:F9F9F9;border:1px solid #CCCCCC;padding:.3em;">
*[[Lightmap Commands#mat_showlightmappage|mat_showlightmappage]]
<div>[[File:intlight_lmap4.jpg|200px|Lightmap scale 4]] [[File:intlight_lmap16.jpg|200px|Lightmap scale 16]] [[File:intlight_lmap64.jpg|200px|Lightmap scale 64]]</div>
*[[Lightmap Commands#r_avglightmap|r_avglightmap]]
<div style="font-size:.75em;">Lightmap scales of 4, 16, and 64.</div>
*[[Lightmap Commands#r_lightmap|r_lightmap]]
</div>
 
When generating lightmaps, VRAD does not create [[Wikipedia:Umbra|penumbras]]. The effect can be simulated by increasing lightmap scale, however (which is why the relatively large value of 16 is the default).
 
{{note|Each compiled [[brush]] polygon can host a maximum of 31x31 luxels. [[VBSP]] will chop faces to get extra luxels on if it needs to.}}
 
{{tip|[[Fog]] will increase atmospheric scattering, making all shadows a lot more diffuse.}}
 
== Hammer view ==
 
Clicking the ''camera'' control in the top-left of a 3D view in Hammer provides the option of "3D Lightmap Grid". This view textures each brush surface with a grid that represents its lightmap scale.
 
Tool brushes are textured like any other in this mode, despite being invisible in-game, so switch them all off from their auto-[[visgroup]].
 
== Console commands ==
 
The following are all [[sv_cheats|cheats]]:
 
; <code>mat_luxels <[[bool]]></code>
: Display luxels on all brush surfaces. {{bug|Breaks on displacements}}
; <code>mat_filterlightmaps <bool></code>
: Control whether luxels are smoothed together in the same way as [[texel]]s.
; <code>r_avglightmap <bool></code>
: Doom mode! Averages lightmap values across each polygon.
; <code>mat_showlightmappage <[[int]]></code>
: Unwraps each lightmap into a small, tessellating display in the top left of the screen. Not terribly useful to modders.
; <code>r_lightmap <?></code>
: {{todo|No apparent effect.}}
; <code>r_unloadlightmaps <bool></code>
: {{todo|Unknown. Possibly a way of flushing lightmap data between map loads?}}


== See Also ==
== See Also ==
*[http://www.vadear.com/koko/?p=194 Basic Lightmaps on Vadear.com]


* [[LightmappedGeneric]]
* [http://www.vadear.com/koko/?p=194 Basic Lightmaps on Vadear.com]


[[Category:Level Design]]
[[Category:Level Design]]
[[Category:Glossary]]
[[Category:Glossary]]

Revision as of 08:10, 21 June 2009

A lightmap is a generated texture applied additively to LightmappedGeneric brush faces to simulate lighting. The color values in the surface's albedo are multiplied by the color values in its lightmap.

Lightmaps are created by VRAD each time a map is compiled. They are static and cannot change, though it is possible to switch lightmap 'pages' on and off.

Scale

The lightmap scale of a face defines the resolution of its lightmap. The default scale of 16 makes each lightmap pixel ("luxel") 16 units across, while a lightmap scale of 1 makes one luxel equal one unit. The Hammer Face Edit Dialog is used to change the value per-face.

Lowering scale will make lightmap shadows sharper, but leads to larger map filesize, slightly slower rendering and exponentially slower compiles (that at very low scales start to eat up shocking amounts of system memory).

Lightmap scale 4 Lightmap scale 16 Lightmap scale 64
Lightmap scales of 4, 16, and 64.

When generating lightmaps, VRAD does not create penumbras. The effect can be simulated by increasing lightmap scale, however (which is why the relatively large value of 16 is the default).

Note.pngNote:Each compiled brush polygon can host a maximum of 31x31 luxels. VBSP will chop faces to get extra luxels on if it needs to.
Tip.pngTip:Fog will increase atmospheric scattering, making all shadows a lot more diffuse.

Hammer view

Clicking the camera control in the top-left of a 3D view in Hammer provides the option of "3D Lightmap Grid". This view textures each brush surface with a grid that represents its lightmap scale.

Tool brushes are textured like any other in this mode, despite being invisible in-game, so switch them all off from their auto-visgroup.

Console commands

The following are all cheats:

mat_luxels <bool>
Display luxels on all brush surfaces.
Icon-Bug.pngBug:Breaks on displacements  [todo tested in ?]
mat_filterlightmaps <bool>
Control whether luxels are smoothed together in the same way as texels.
r_avglightmap <bool>
Doom mode! Averages lightmap values across each polygon.
mat_showlightmappage <int>
Unwraps each lightmap into a small, tessellating display in the top left of the screen. Not terribly useful to modders.
r_lightmap <?>
Todo: No apparent effect.
r_unloadlightmaps <bool>
Todo: Unknown. Possibly a way of flushing lightmap data between map loads?

See Also