VRAD
VRAD is the command-line tool for Source 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:
- Generate lightmaps
- Generate ambient samples
- Generate per-vertex prop_static lighting
- Generate per-object detail prop lighting
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.
Syntax
For example, a regular compile would look like thus:
This will generate and embed both Standard and High Dynamic Range lighting data, at per-vertex detail for prop_static entities. It also generates shadows based on transparency for prop_static entities that have been flagged as casting texture shadows.
Options
Use these in combination with expert compile mode, a batch file, or a frontend such as Compile Pal.
Effects
- -ldr
- -hdr
- -both
- Whether to compile Standard Dynamic Range lighting, High Dynamic Range lighting, or both respectively.
- -fast
- Compiles quick low quality lighting. Used for quick previewing.
- Note:-fast will cause random and discolored splotching to appear in darker areas, as well as shadowed edges around Displacements. It is advised to not ship your map using -fast.Tip:If you have a relatively modern CPU, you can try using other parameters to reduce the standard compile time instead. For example: -fastambient -bounce 1 -noextra -nodetaillight -noskyboxrecurse instead of -fast
- -final
- Increases the quality of light_environment and indirect lighting by spending more time firing rays.
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 RAD 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 automatic phong smoothing of lightmaps between edges, in degrees (default: 45). Use smoothing groups to explicitly define faces as phonged together.
- -luxeldensity <normal>
- Scale down all luxels. Default (and maximum) value is 1. Warning:Setting too low of a value will cause lighting errors.
- -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 )
- Generate per-vertex lighting on prop_statics; always enabled for light_spot entities. Disables info_lighting entities on props without $bumpmap or $phong, unless the
disablevertexlighting
KV is set for the prop. Does not work on props with bump maps, except in . - Note:(only in )(also in ) Also generates lightmaps for static props that have
generatelightmaps
enabled. - Warning:This can increase your map's compile times substantially. Disable vertex lighting for props that don't need it to keep compile times down.
- Bug:Not compatible with Cascade Shadow Mapping in Black Mesa, doesn't work properly with static prop if vertex lighting is enabled.Workaround:Use[todo tested in?]
-StaticPropLighting3
instead.
- -StaticPropLighting3 (only in )
- This is a more precise and less buggy version of
-StaticPropLighting
.
- -StaticPropPolys (in all games since )
- 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 )
- Generates lightmap shadows from
$alphatest
and$translucent
surfaces of prop_static models that are specified in a RAD file or were compiled with $casttextureshadows. Usually requires -StaticPropPolys to have any effect.
|
- Note:(only in ) Also generates lightmap shadows from brushes (but not displacements) using
$alphatest
. - Note:A surface will need a low lightmap scale for most texture shadows to be recognizable.
Nonetheless, textures such as grate fences, foliage, and barbed wire will still cast noticeably more accurate shadows with this command enabled compared to disabled. - Warning:This will not work if a translucent texture's $basetexture parameter in the VMT contains the .vtf file extension; file extensions should be omitted from texture paths in VMTs.
- Bug:Static props with multiple skins will always use the alpha channel(s) from the default skin's texture(s), even though the alternative skins' alpha textures are loaded by VRAD. (tested in: )
- -aoscale <float> (in all games since ) (also in ,)
- Scales the radius of VRAD's simulated ambient occlusion. 1.0 is default.
- Tip:Valve uses 1.5 for the new Dust 2.
- -aoradius <float> (only in )
- Set the radius of VRAD's simulated ambient occlusion. 36 is default.
- -aosamples <integer> (only in ) (also in )
- How many samples to use for VRAD's simulated ambient occlusion.
- -StaticPropBounce <integer> (only in ) (also in )
- Number of static prop light bounces to simulate. The default is 0.
- Tip:Valve uses 3 static prop bounces for the new Dust 2.
- Note:Any static props that you want light to bounce off of must also have their "Enable Bounced Lighting" keyvalue set.
- -StaticPropLightingOld (only in )
- Will use the old lighting algorithm on props, light affects them much more.
- -choptexlights (only in )
- 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.
- -transferscale <float> (only in )
- 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 )
- This is the threshold that checks how saturated a material color is. Used with -satthreshscale. Default 0.4.
- -satthreshscale <float> (only in )
- The amount to scale light transfers from surfaces that pass the saturation threshold. Default 3.0.
|
|
- -cascadeshadows (only in )
- Indicates that lightmap alpha data is interleved in the lighting lump, required for CSM.
-StaticPropLighting3
to have proper lighting of static props.
|
- -realskylight (only in )
- Enables VRAD to compute skylight ambient color by using actual values from skybox.
|
- -realskylightscale <float> (only in )
- Scale factor of -realskylight intensity. Default: 1.0
- -directsunlightisforadditivemode (only in )
- Toggles direct sunlight for additive mode.
- Bug:This option is not compatible with cascade shadows.
|
- -ambient <vector> (only in ) (also in )
- Sets the ambient term. Can be used to tweak lightmap color. Appears to just mix the color into all lightmaps.
- -PortalTraversalLighting (only in )
- Enables static lights to go through linked_portal_door, if
Static Portal
value isYes
.
|
- -PortalTraversalAO (only in )
- Enables static light Ambient Occlusion to go through linked_portal_door, if
Static Portal
value isYes
.
|
- -coring (only in )
- Scale the light threshold before a luxel is completely unlit, used to save lightmap data.
- -worldtextureshadows (only in )
- Allows world polys to cast texture shadows, much like models can.
- Bug:Doesn't work with displacements. [todo tested in?]
|
- -translucentshadows (only in )
- Enables -worldtextureshadows on
$translucent
surfaces. As by default only $alphatest surfaces cast baked shadows. - Bug:Doesn't work with displacements. [todo tested in?]
Performance
{{ColumnBox|count=1|
- -low
- Run as a low-priority process.
- -threads <integer>
- Override the number of CPU threads used. Maximum is 16 threads (32 in , unlimited in )
- Workaround:With a patched vrad_dll you can use 32 threads. fixtoolthreads is a patch for VRAD (and VVIS) that supports unlimited threads and fixes a thread scaling issue.
- Tip:If you know that the compile time will be very long and would rather do something else while waiting, it may be useful to specify a number of threads 1 or 2 lower than what your CPU has. This allows the computer to allocate some more power to other applications, making it less choppy while lighting is being compiled. Keep in mind that this may slightly extend your compile time.
- -mpi
- Use VMPI to distribute computations.
- -mpi_pw <string>
- Use a password to choose a specific set of VMPI workers.
- -noextra
- Disable supersampling. This will lead to blockier, less accurate lighting.
- -maxchop <integer>
- Coarsest allowed number of luxel widths for a patch, used in face interiors. (Default: 4)
- -LargeDispSampleRadius
- 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. Todo: Find out if this is branch specific, as it doesn't work with TF2.
- -fastambient
- Uses low quality per-leaf ambient sampling to save compute time.
- -LeafAmbientSampleReduction <float> (only in )
- Reduction factor for ambient samples. Defaults to 1.0.
- -StaticPropSampleScale <float> (only in ) (also in )
- Extra sampling factor for indirect lighting on prop_static.
- slow: 16 (high quality); default: 4 (normal); fast: 0.25 (low quality)
- Note:-final is the equivalent of having -StaticPropSampleScale 16.
- -disppatchradius <float>
- Sets the maximum radius allowed for displacement patches. If you get "Patch Sample Radius Clamped", you can try increasing this limit.
Debugging
- -rederrors
- 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.
- -v
- -verbose
- Turn on verbose output.
- -novconfig
- Don't bring up graphical UI on vproject errors.
- -dump
- Dump patches to debug files.
- -dumpnormals
- Write normals to debug .txt files.
- -debugextra
- Places debugging data in lightmaps to visualize supersampling.
- -dlightmap
- Force direct lighting into different lightmap than radiosity.
- -stoponexit
- Wait for a keypress on exit.
- -nodetaillight
- Don't light detail props.
- -centersamples
- Move sample centers.
- -loghash
- Log the sample hash table to samplehash.txt.
- -onlydetail
- Only light detail props and per-leaf lighting.
- -maxdispsamplesize <integer>
- Set max displacement sample size (default: 512).
- -FullMinidump
- Write large minidumps on crash.
- -OnlyStaticProps
- Only perform direct static prop lighting.
- -StaticPropNormals
- When lighting static props, just show their normal vector.
- -noskyboxrecurse
- Turn off recursion into 3d skybox (skybox shadows on world).
- -nossprops
- Globally disable self-shadowing on static props.
- -dumppropmaps (only in ) (also in )
- Dump computed static prop lightmaps as TGA files.Tip:This can be used to create lightmaps for dynamic props, using the $lightmap shader parameter.Tip:To pair static props in a map with their dumped lightmaps, use
r_staticpropinfo 2
to show static prop IDs on screen.Bug:The resulting TGAs are written with the wrong color space; convert the resulting PPL files instead. This command can be useful for indicating which model and at what location each prop is, which the PPL filenames lack. This issue is fixed in
- -reflectivityScale <float> (only in )
- Scale the $reflectivity of all textures. Default 1.0
Lights files
Console Output
Bugs and Caveats
raytrace.cpp
isn't present so check if these versions also have the bug or not.
- Tip:Source Engine BSP Lightmap Editor can be used to manually correct a .bsp lightmap data.[todo tested in?]
See also
- QRAD and HLRAD - GoldSrc counterparts.
- VRAD2 & VRAD3 - Source 2 counterparts.
- Map Compiling Theory
- HDR Lighting Basics
- VRAD HDR Crash Fix
- Static Props show up black
|