From Valve Developer Community
Revision as of 07:30, 1 September 2021 by Amicdict (talk | contribs) (Converted {{otherlang2}} to {{lang}}.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
English Русский

VRAD is the command-line tool that takes a compiled BSP map and embeds lighting data into it. VRAD's static and pre-compiled light is bounced around the world with a radiosity algorithm.

VRAD will:

VRAD is generally the slowest of the three compilers due to the many, many calculations it must perform. Lighting optimization can help, as can ensuring your map is free of leaks.

Tip.png Tip: If you are watching the compile dialog and it looks like it has hung at 9... this is usually because VRAD takes longer with each light bounce calculation.
Warning.png Warning: VRAD will take up a lot of CPU during conversion of trying to make light.
Bug.png Bug: Ep1 and L4D users seeing crashes when VRAD compiles HDR lighting should read VRAD HDR Crash Fix.
Bug.png Bug: In pre-L4D branch games, .mdl files that don't have .dx80.vtx files with them will lead to VRAD skipping lighting for that prop. Copying the .dx90.vtx file and renaming it to a .dx80.vtx will fix the issue.

A windows batch file to do this automatically has been created here: [1] (place above model folder and run .bat)

Bug.png Bug: .mdl files that have the IDST1 header will fail to load for VBSP, and will give a error message stating the prop failed to load; this can be fixed by changing the header to IDST0 in a Hex Editor, or by recompiling the prop in a non-L4D branch Studiomdl application such as Source 2013.
Bug.png Bug: As of around 5-10 years ago up until at least October 2017, all known copies of VRAD have a thread sharing bug which causes performance to scale poorly to multiple threads, particularly on outdoor scenes with -final set (despite showing 100% CPU usage). The fix to this bug for Source 2013 is available here and edited DLLs are available here. Valve also released a patch for CSGO's VRAD that fixes this issue.
Bug.png Bug: Randomly causes corrupt lightmaps that look like "ink spills". These can be mostly avoided by not using very long or diagonal brushes, as well as not having too low of a light level in your indoor areas.
Tip.png Tip: Source Engine BSP Lightmap Editor can be used to manually correct a .bsp lightmap data.


vrad [options...] <bsp file>

For example:

"Half-Life 2\bin\vrad.exe" -both -StaticPropLighting sdk_trainstation_01

This will generate and embed both standard and High Dynamic Range lighting data, at per-vertex detail for prop_static entities.


Use these in combination with expert compile mode or a batch file.


Whether to compile standard lighting, High Dynamic Range lighting, or both.
Note.png Note: In InsurgencyDay of InfamyCounter-Strike: Global Offensive, you MUST compile with -hdr in order have proper lighting, as LDR isn't supported.
In Black Mesa (Source), HDR compiles automatically regardless of -hdr's presence.
Left 4 Dead 2 does not use -ldr, therefore making -both also obsolete. All maps can be compiled using only -hdr.
Quick and dirty lighting. Don't ship with this.
Note.png Note: -fast will cause random and miscolored splotching to appear in darker areas.
Increases the quality of light_environment and indirect lighting by spending more time firing rays.
Counter-Strike: Global Offensive Sets-StaticPropSampleScale to 16.
-extrasky <integer>
Trace N times as many rays for indirect light and sky ambient.
(-final is equivalent to -extrasky 16; normal is equivalent to -extrasky 1)
-lights <filename>.rad
Load a custom lights file in addition to lights.rad and the map-specific lights file. Include the file extension in the parameter.
-bounce <integer>
Set the maximum number of light ray bounces. (default: 100).
-smooth <integer>
Set the threshold for smoothing groups, in degrees (default: 45).
-luxeldensity <normal>
Scale down all luxels. Default (and maximum) value is 1.
-reflectivityScale <float>
Scale the $reflectivity of all textures. Default 1.0
-softsun <float>
Treat the sun as an area light source of this many degrees. Produces soft shadows. Recommended values are 0-5, default is 0. Identical to the SunSpreadAngle parameter for light_environment, use that instead.
-StaticPropLighting  (in all games since Half-Life 2: Episode TwoHalf-Life 2: Episode Two)
Generate per-vertex lighting on prop_statics; always enabled for light_spot entities. Disables info_lighting entities on props without bump maps. Does not work on props with bump maps, except in Counter-Strike: Global Offensive.
Warning.png Warning: This can increase your map's filesize substantially. Disable vertex lighting for props that don't need it to keep filesize low.
Note.png Note: In Counter-Strike: Global Offensive, in order to get proper lighting on your static props, you will need to run VRAD with this command.
-StaticPropPolys  (in all games since Half-Life 2: Episode TwoHalf-Life 2: Episode Two)
Use the actual meshes of static props to generate shadows instead of using their collision meshes. This results in far more accurate shadowing.
-TextureShadows  (in all games since Half-Life 2: Episode TwoHalf-Life 2: Episode Two)
Generates lightmap shadows from $translucent surfaces of models (NOT brushes) that are specified in a lights file and being used with prop_static. Usually requires -StaticPropPolys to have any effect.
Note.png Note: A surface will need a low lightmap scale for most texture shadows to be recognisable.
Note.png Note: For some strange reason this will not work if a translucent texture's VMT file contains the .vtf file ending in the basetexture lines.
-aoscale <float> (in all games since Counter-Strike: Global Offensive)
Scales the intensity of VRAD's simulated ambient occlusion. 1.0 is default.
Tip.png Tip: Valve uses 1.5 for the new Dust 2.
-aoradius <float> (only in Insurgency Day of Infamy)
Set the radius of VRAD's simulated ambient occlusion. To do: Figure out what exactly this does.
-aosamples <integer> (only in Insurgency Day of Infamy)
How many samples to use for VRAD's simulated ambient occlusion.
-StaticPropBounce <integer> (only in Counter-Strike: Global Offensive)
Number of static prop light bounces to simulate. The default is 0.
Tip.png Tip: Valve uses 3 static prop bounces for the new Dust 2.
Note.png Note: Any static props that you want light to bounce off of must also have their "Enable Bounced Lighting" keyvalue set.
-StaticPropLightingFinal  (only in Counter-Strike: Global Offensive)
<Obsolete> Replaced by -final.
-StaticPropLightingOld  (only in Counter-Strike: Global Offensive)
Will use the old lighting algorithm on props, light affects them much more.
-choptexlights  (only in Black Mesa (Source))
Enables chopping of texture lights generated from a lights file. Control texture light quality with lightmap density in Hammer. Dramatically increases both texture light quality and compile time.
-extratransfers  (only in Black Mesa (Source))
Enable overscaling of light transfers.
-transferscale <float> (only in Black Mesa (Source))
This is the scale factor of light transfers. Increased values make surfaces transfer extra light (scale of 2-4 suggested). Default 1.0.
-satthresh <float> (only in Black Mesa (Source))
This is the threshold that checks how saturated a material color is. Used with -satthreshscale. Default 0.4.
-satthreshscale <float> (only in Black Mesa (Source))
The amount to scale light transfers from surfaces that pass the saturation threshold. Default 3.0.
-ambientocclusion  (only in Black Mesa (Source))
Enable lightmapped ambient occlusion
-experimentalambientocclusion  (only in Black Mesa (Source))
Use an improved algorithm for the ambient occlusion
-cascadeshadows  (only in Black Mesa (Source))
indicates that lightmap alpha data is interleved in the lighting lump, required for CSM.
-realskylight  (only in Black Mesa (Source))
Enables VRAD to compute skylight ambient color by using actual values from skybox.
-realskylightscale <float> (only in Black Mesa (Source))
Scale factor of -realskylight intensity. Default: 1.0
-directsunlightisforadditivemode  (only in Black Mesa (Source))
Toggles direct sunlight for additive mode.
-ambient <vector> (only in Counter-Strike: Global Offensive)
Sets the ambient term. Can be used to tweak lightmap color.


Run as a low-priority process.
-threads <integer>
Override the number of CPU threads used. Maximum is 16 threads. With a patched vrad_dll you can use 32 threads.
Use VMPI to distribute computations.
-mpi_pw <string>
Use a password to choose a specific set of VMPI workers.
Disable supersampling. This will lead to blockier, more inaccurate lighting.
-chop <integer>
Smallest number of luxel widths for a bounce patch, used on edges. (Default: 4)
-maxchop <integer>
Coarsest allowed number of luxel widths for a patch, used in face interiors. (Default: 4)
-dispchop <integer>
Smallest acceptable luxel width of displacement patch face. (Default: 8)
This can be used if there are splotches of bounced light on terrain. The compile will take longer, but it will gather light across a wider area.
-compressconstant <integer>
Compress lightmaps whose color variation is less than this many units. To do: Find out if this is branch specific, as it doesn't work with TF2.
Uses low quality per-leaf ambient sampling to save compute time.
-LeafAmbientSampleReduction <float> (only in Counter-Strike: Global Offensive)
Reduction factor for ambient samples. Defaults to 1.0.
-noao  (only in Insurgency Day of Infamy)
Disables compiling simulated ambient occlusion for lightmaps.
-StaticPropSampleScale <float> (only in Counter-Strike: Global Offensive)
Regulates the generated per-vertex prop_static lighting.
slow: 16 (high quality); default: 4 (normal); fast: 0.25 (low quality)
Note.png Note: -final is the equivalent of having -StaticPropSampleScale 16.
-disppatchradius <float>
Sets the maximum radius allowed for displacement patches.
-ambientfromleafcenters  (only in Counter-Strike: Global Offensive)
Samples ambient lighting from the center of the leaf.


Emit red light when "a luxel has no samples".
-vproject <directory>
-game <directory>
Override the VPROJECT environment variable.
-insert_search_path <directory>
Includes an extra base directory for mounting additional content (like Gameinfo.txt entries). Useful if you want to separate some assets from the mod for whatever reason.
Turn on verbose output.
Don't bring up graphical UI on vproject errors.
Dump patches to debug files.
Write normals to debug .txt files.
Places debugging data in lightmaps to visualize supersampling.
Force direct lighting into different lightmap than radiosity.
Wait for a keypress on exit.
Don't light detail props.
Move sample centers.
Log the sample hash table to samplehash.txt.
Only light detail props and per-leaf lighting.
-maxdispsamplesize <integer>
Set max displacement sample size (default: 512).
Write large minidumps on crash.
Only perform direct static prop lighting.
When lighting static props, just show their normal vector.
Turn off recursion into 3d skybox (skybox shadows on world).
Globally disable self-shadowing on static props.
-dumppropmaps  (only in <Source><Source><Source>)
Dump computed prop lightmaps.
-unlitdetail  (only in Counter-Strike: Global Offensive)
Disables lighting for detail props.

Lights files

A light file is a plain text file that can be used to manipulate the way VRAD handles given materials when compiling static lighting. All lights files must have the .rad file extension and must be in the same folder as your gameinfo.txt.

There are:

  1. lights.rad, the global file.
  2. An auto-loaded map light file, using the format <map name>.rad. The file must be placed in the same folder as <map name>.vmf.
  3. Any number of additional lights files that can be added with the -lights parameter.


Lights files perform these functions, one rule per line:

<material> <red> <green> <blue> <intensity> <hdr_red> <hdr_green> <hdr_blue> <hdr_intensity>
Makes the material emit the given light value when applied to a brush face (hdr_ values are optional). Texture scale has an effect on final intensity.
Note.png Note: The material does not truly emit light, but instead, a light entity is generated across the surface. More technically, lights are placed at the center of every subdivision on the surface. The brightness of each light is distributed uniformly, by taking the area of each subdivision. Lower lightmap scales will increase subdivision and therefore more lights will be created. This will not occur on textures that are unlit, as no subdivision occurs on these textures. Leaf splits will still incur subdivision however, which might make the light creation unpredictable (using a func_detail will avoid this). It may be smarter and cheaper to instead manually place light entities near the material.
Note.png Note: Materials that aren't in a folder must have a slash before their name.
Warning.png Warning: A func_detail with an emissive material applied on a face may randomly cause VRAD to fail computing lighting for the face.
noshadow <material name>
Prevents the named material from casting shadows.
forcetextureshadow <model path>.mdl
Enables translucency shadow testing for a model when VRAD is run with -TextureShadows. Path is relative to the models folder.
Prefixes to make any rule only apply to LDR or HDR lighting.
Lines beginning with both tags (in that order) will always be ignored by VRAD. Can be used to add comments or quickly disable some entries.

Console Output

To do: Add description about missing outputs output (BuildVisLeafs, other)

See also