Template:Archived page history/VRAD/en: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(added slammin' to aoscale)
m (page reorganization)
Line 2: Line 2:
{{toc-right}}
{{toc-right}}


'''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 [[Wikipedia:Radiosity (3D computer graphics)|radiosity]] algorithm.
'''VRAD''' is the [[command-line]] tool for {{source|4|}} 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 [[Wikipedia:Radiosity (3D computer graphics)|radiosity]] algorithm.
VRAD will:
 
'''VRAD will:'''


* Generate [[lightmap]]s
* Generate [[lightmap]]s
Line 11: Line 12:
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 [[leak]]s.
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 [[leak]]s.


{{ModernWarning|Vrad does not compile shadows based on Brush entities alpha channel. If you must have shadows made by a brush entities fence texture , turn the brush entity into a prop via [[SourceIO]], [[crafty]] or [[propper]] and put it into your lights.rad. Alternatively, use an existing fence prop or the "blocklight" [[tool texture]].}}
{{ModernWarning|VRAD does not compile shadows based on Brush entities alpha channel. If you must have shadows made by a brush entity (such as a fence texture), you can turn the brush entity into a prop via {{blender}}[[SourceIO]], [[crafty]] or [[propper]] and put it into your lights.rad. Alternatively, use an existing fence prop or the "blocklight" [[tool texture]].}}


{{ModernTip|If you are watching the compile dialog and it looks like it has hung at ''{{mono|9...}}'' this is usually because VRAD takes longer with each light bounce calculation.  You can use {{mono|-bounce}} to limit the amount of bounces for faster compilation.}}
{{ModernWarning|VRAD will use 100% of your CPU unless specified otherwise with the -threads # launch option.}}


{{ModernBug|In {{ep1}}{{l4d}}, users seeing crashes when VRAD compiles HDR lighting should read [[VRAD HDR Crash Fix]].}}
{{ModernBug|In {{ep1}} and {{l4d}}, users seeing crashes when VRAD compiles HDR lighting should read [[VRAD HDR Crash Fix]].}}


{{ModernBug|In games before {{l4d}}, {{mono|.mdl}} files that don't have {{mono|.dx80.vtx}} files with them will lead to VRAD skipping lighting for that prop. Copying the {{mono|.dx90.vtx}} file and renaming it to a {{mono|.dx80.vtx}} will fix the issue.{{Tip|A windows batch file to do this automatically has been created [https://drive.google.com/file/d/1OlQcFDlJPbK5vp6PTv7CZGXBjF9Z1UU0 here], place above model folder and run .bat.}}{{Note|{{Dmmm}} is exempt from this issue.}} }}
{{ModernBug|In games before {{l4d}}, {{mono|.mdl}} files that don't have {{mono|.dx80.vtx}} files with them will lead to VRAD skipping lighting for that prop. Copying the {{mono|.dx90.vtx}} file and renaming it to a {{mono|.dx80.vtx}} will fix the issue.{{Tip|A windows batch file to do this automatically has been created [https://drive.google.com/file/d/1OlQcFDlJPbK5vp6PTv7CZGXBjF9Z1UU0 here], place above model folder and run .bat.}}{{Note|{{Dmmm}} is exempt from this issue.}} }}


{{ModernBug|{{mono|.mdl}} files that have the {{mono|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 {{mono|IDST0}} in a Hex Editor, or by recompiling the prop in a non-L4D branch [[Studiomdl]] application such as Source 2013.}}
{{ModernBug|{{mono|.mdl}} files that have the {{mono|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 {{mono|IDST0}} in a Hex Editor, or by recompiling the prop in a non-L4D branch [[Studiomdl]] application such as Source 2013.}}
{{ModernWarning|VRAD will use 100% of your CPU unless specified otherwise with the -threads # launch option.}}


{{ModernBug|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 [https://github.com/ValveSoftware/source-sdk-2013/pull/436 here] and edited DLLs are available [http://www.content.tophattwaffle.com/Content/modded_vrad_dll.zip here].  This issue is fixed in {{csgo}} and {{tf2}}}}
{{ModernBug|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 [https://github.com/ValveSoftware/source-sdk-2013/pull/436 here] and edited DLLs are available [http://www.content.tophattwaffle.com/Content/modded_vrad_dll.zip here].  This issue is fixed in {{csgo}} and {{tf2}}}}
Line 27: Line 26:
{{ModernBug|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.
{{ModernBug|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|[https://github.com/Enderlux/sourcelightmap Source Engine BSP Lightmap Editor] can be used to manually correct a {{mono|.bsp}} lightmap data.}}}}
: {{tip|[https://github.com/Enderlux/sourcelightmap Source Engine BSP Lightmap Editor] can be used to manually correct a {{mono|.bsp}} lightmap data.}}}}
{{ModernTip|If you are watching the compile dialog and it looks like it has hung at ''{{mono|9...}}'' this is usually because VRAD takes longer with each light bounce calculation. You can use {{mono|-bounce}} to limit the amount of bounces for faster compilation.}}
== Syntax ==
== Syntax ==


Line 46: Line 47:
{{IO|-both|Whether to compile Standard Dynamic Range lighting, [[HDR|High Dynamic Range]] lighting, or both respectively.
{{IO|-both|Whether to compile Standard Dynamic Range lighting, [[HDR|High Dynamic Range]] lighting, or both respectively.
: {{note|Since {{l4d2}}, SDR support was dropped.  Thus making {{mono|-ldr}} and {{mono|-both}} obsolete in engine branches made on or after {{l4d2}}.  Instead, {{mono|-hdr}} is required in order to produce proper lighting for your map.}}
: {{note|Since {{l4d2}}, SDR support was dropped.  Thus making {{mono|-ldr}} and {{mono|-both}} obsolete in engine branches made on or after {{l4d2}}.  Instead, {{mono|-hdr}} is required in order to produce proper lighting for your map.}}
: {{note|For {{l4d2}}, there is no need to use {{mono|-both}} or {{mono|-ldr}} because they could slow down the progress of baking lighting and increase the size of bsp file!}}
: {{note|{{bms}} defaults to compiling only HDR automatically.}}}}
: {{note|{{bms}} defaults to compiling only HDR automatically.}}}}
{{IO|-fast|Compiles quick low quality lighting.  Used for quick previewing.
{{IO|-fast|Compiles quick low quality lighting.  Used for quick previewing.
: {{Note|{{mono|-fast}} will cause random and miscolored splotching to appear in darker areas.  As well as shadowed edges around Displacements.  It is advised to not ship your map using {{mono|-fast}}.}}}}
: {{Note|{{mono|-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 {{mono|-fast}}.}}}}
{{IO|-final|Increases the quality of {{Ent|light_environment}} and indirect lighting by spending more time firing rays.<br>{{csgo}} Sets{{mono|-StaticPropSampleScale}} to 16.}}
{{IO|-final|Increases the quality of {{Ent|light_environment}} and indirect lighting by spending more time firing rays.<br>{{csgo}} Sets{{mono|-StaticPropSampleScale}} to 16.}}
{{IO|-extrasky|param=int|Trace N times as many rays for indirect light and sky ambient. {{clr}}({{mono|-final}} is equivalent to {{mono|-extrasky 16}}; normal is equivalent to {{mono|-extrasky 1}})}}
{{IO|-extrasky|param=int|Trace N times as many rays for indirect light and sky ambient. {{clr}}({{mono|-final}} is equivalent to {{mono|-extrasky 16}}; normal is equivalent to {{mono|-extrasky 1}})}}

Revision as of 11:24, 1 November 2023

Flag-white.pngEnglish (en)

VRAD is the command-line tool for Source 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:

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.

Template:ModernWarning

Template:ModernWarning

Template:ModernBug

Template:ModernBug

Template:ModernBug

Template:ModernBug

Template:ModernBug

Template:ModernTip

Syntax

vrad [options...] <bsp file>

For example:

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

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 or a batch file.

Effects

-ldr
-hdr
-both
Whether to compile Standard Dynamic Range lighting, High Dynamic Range lighting, or both respectively.
Note.pngNote:Since Left 4 Dead 2, SDR support was dropped. Thus making -ldr and -both obsolete in engine branches made on or after Left 4 Dead 2. Instead, -hdr is required in order to produce proper lighting for your map.
Note.pngNote:Black Mesa defaults to compiling only HDR automatically.
-fast
Compiles quick low quality lighting. Used for quick previewing.
Note.pngNote:-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.
-final
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 (Does not work in Counter-Strike: Source)
-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 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.
Note.pngNote:(only in Source 2013 Multiplayer)(also in Garry's Mod) Also generates lightmaps for static props that have generatelightmaps enabled.
Warning.pngWarning:This can increase your map's filesize substantially. Disable vertex lighting for props that don't need it to keep filesize low.
Note.pngNote: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 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 Two)
Generates lightmap shadows from $alphatest and $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.pngNote:A surface will need a low lightmap scale for most texture shadows to be recognisable.
Warning.pngWarning: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.
-aoscale <float> (in all games since Counter-Strike: Global Offensive) (also in Slammin' Source Map Tools)
Scales the intensity of VRAD's simulated ambient occlusion. 1.0 is default.
Tip.pngTip: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.
Todo: Figure out what exactly this does.
-aosamples <integer> (only in Insurgency Day of Infamy) (also in Slammin' Source Map Tools)
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.pngTip:Valve uses 3 static prop bounces for the new Dust 2.
Note.pngNote: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)
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)
Enable overscaling of light transfers.
-transferscale <float> (only in Black Mesa)
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)
This is the threshold that checks how saturated a material color is. Used with -satthreshscale. Default 0.4.
-satthreshscale <float> (only in Black Mesa)
The amount to scale light transfers from surfaces that pass the saturation threshold. Default 3.0.
-ambientocclusion  (only in Black Mesa) (also in Slammin' Source Map Tools)
Enable lightmapped ambient occlusion
-experimentalambientocclusion  (only in Black Mesa)
Use an improved algorithm for the ambient occlusion
-cascadeshadows  (only in Black Mesa)
indicates that lightmap alpha data is interleved in the lighting lump, required for CSM.
-realskylight  (only in Black Mesa)
Enables VRAD to compute skylight ambient color by using actual values from skybox.
-realskylightscale <float> (only in Black Mesa)
Scale factor of -realskylight intensity. Default: 1.0
-directsunlightisforadditivemode  (only in Black Mesa)
Toggles direct sunlight for additive mode.
-ambient <vector> (only in Counter-Strike: Global Offensive) (also in Dark Messiah of Might and MagicSlammin' Source Map Tools)
Sets the ambient term. Can be used to tweak lightmap color. Appears to just mix the color into all lightmaps.
-PortalTraversalLighting  (only in Portal 2: Community Edition)
Enables static lights to go through static worldportals.
-PortalTraversalAO  (only in Portal 2: Community Edition)
Enables static light AO to go through static worldportals.
-softencosine  (only in Slammin' Source Map Tools)
Softens coloured lighting so it blends more accurately.
-coring  (only in Slammin' Source Map Tools)
Scale the light threshold before a luxel is completely unlit, used to save lightmap data.
-worldtextureshadows  (only in Slammin' Source Map Tools)
Allows world polys to cast texture shadows, much like models can.

Performance

-low
Run as a low-priority process.
-threads <integer>
Override the number of CPU threads used. Maximum is 16 threads (32 in Counter-Strike: Global Offensive also in Slammin' Source Map Tools). With a patched vrad_dll you can use 32 threads.
Tip.pngTip: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, 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)
-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 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.pngNote:-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.

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 Source 2013 Multiplayer)
Dump computed static prop lightmaps as TGA files.
Tip.pngTip:This can be used to create lightmaps for dynamic props, using the $lightmap shader parameter.
-unlitdetail  (only in Counter-Strike: Global Offensive)
Disables lighting for detail props.

Lights files

Main article:  RAD file#Source 1

Console Output

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

See Also