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

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
m (Pee moved page Archived Page History/VRAD/en to Template:Archived page history/VRAD/en without leaving a redirect)
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{langsp}}
{{APH|VRAD}}
{{toc-right}}
 
{{vrad|4}} 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:'''
 
* Generate [[lightmap]]s
* Generate [[Ambient light|ambient samples]]
* Generate per-object or per-vertex [[prop_static]] and [[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 [[leak]]s.
 
{{warning|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 {{sourceio|4.1}}, {{crafty|4.1}} or [[propper]] and put it into the [[RAD file]] or compile with {{ent|$casttextureshadows}}. Alternatively, use an existing fence prop or the "blocklight" [[tool texture]].
{{tip|{{slamminsrc|only}} You can use -worldtextureshadows to make vrad compile shadows based on Brush entities alpha channel.}}}}
 
{{warning|VRAD will use 100% of your CPU unless specified otherwise with the -threads # launch option.}}
 
{{bug|In {{ep1}} and {{l4d}}, users seeing crashes when VRAD compiles HDR lighting should read [[VRAD HDR Crash Fix]].}}
 
{{bug|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.}} }}
 
{{bug|{{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.}}
 
{{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 [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}}{{mapbase}}
{{todo|Is this fixed in {{slamminsrc}}? When was "5-10 years ago"?}}}}
 
{{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|[https://github.com/Enderlux/sourcelightmap Source Engine BSP Lightmap Editor] can be used to manually correct a {{mono|.bsp}} lightmap data.}}}}
 
{{note|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 calculation.{{clarify|1=This isn't due to bounce calculations.<sup>[https://developer.valvesoftware.com/w/index.php?title=VRAD/en&diff=389410&oldid=389397]</sup>}} }}
 
{{bug|VRAD is unable to calculate texture shadows for textures using DXT3 compression. Use DXT5 instead.}}
 
== Syntax ==
 
{{codeblock|vrad [options...] <bsp file>}}
 
For example, a regular compile would look like thus:
 
{{codeblock|"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 [[Texture Shadows|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 {{compilepal|2}}.
 
=== Effects ===
{{ColumnBox|count=1|1={{IO|-ldr}}
{{IO|-hdr}}
{{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|{{bms}}{{slamminsrc}} defaults to compiling only HDR automatically.}}}}
{{IO|-fast|Compiles quick low quality lighting.  Used for quick previewing.
: {{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|-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|-lights <filename>.rad|Load a custom [[RAD file]] in addition to {{mono|lights.rad}} and the map-specific lights file. Include the file extension in the parameter.}}
{{IO|-bounce|param=int|Set the ''maximum'' number of light ray bounces. (default: 100).}}
{{IO|-smooth|param=int|Set the threshold for automatic phong smoothing of lightmaps between edges, in degrees (default: 45). Use [[smoothing group]]s to explicitly define faces as phonged together.{{modernConfirm|Not in all branches; {{src13}}{{csgo}} have it, but {{src07}} does not.}} }}
{{IO|-luxeldensity|param=normal|Scale down all luxels. Default (and maximum) value is 1. {{warning|Setting too low of a value will cause lighting errors.}}}}
{{IO|-softsun|param=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 {{mono|light_environment}}, use that instead.}}
{{IO|-StaticPropLighting|Generate per-vertex lighting on {{Ent|prop_static}}s; always enabled for {{Ent|light_spot}} entities. Disables {{Ent|info_lighting}} entities on props without [[bump maps]]. Does not work on props with bump maps, except in {{csgo}}.
: {{note|{{src13mp|only}}{{gmod|also}} Also generates lightmaps for static props that have {{code|[[prop_static#Keyvalues|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.}}
: {{note|In {{csgo}}, in order to get proper lighting on your static props, you will need to run VRAD with this command.}}|since=EP2}}
{{IO|-StaticPropPolys|Use the actual meshes of static props to generate shadows instead of using their [[collision mesh]]es. This results in far more accurate shadowing.|since=EP2}}
: {{tip|{{expand|title=Examples|<gallery mode=nolines widths=320px heights=192px>
File:Polys1.jpg|Disabled.
File:Polys2.jpg|Enabled.
</gallery>
}}}}
}}
{{IO|-TextureShadows|Generates lightmap shadows from {{cmd|$alphatest}} and {{cmd|$translucent}} surfaces of {{ent|prop_static}} models that are specified in a [[RAD file]] or were compiled with {{ent|$casttextureshadows}}. Usually requires {{mono|-StaticPropPolys}} to have any effect.
{{expand|title=Examples|
<br>
<gallery mode=nolines widths=320px heights=192px>
File:Polys2.jpg|Disabled.
File:Polys3.jpg|Enabled.
</gallery>
}}
: {{note|{{bms|only}} Also generates lightmap shadows from brushes (but not displacements) using {{cmd|$alphatest}}.{{bug|Not compatible with {{cmd|$envmap|env_cubemap}}; manually define the {{cmd|$envmap}} path instead.}}}}
: {{note|A surface will need a low [[lightmap]] scale for most texture shadows to be recognizable.<br>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 [[skin]]s 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 {{dods}})}} |since=EP2}}
{{IO|-aoscale|param=float|Scales the intensity of VRAD's simulated ambient occlusion. 1.0 is default.
: {{Tip|Valve uses 1.5 for the new Dust 2.}}|since=CSGO|also={{slamminsrc}},{{gmod}}}}
{{IO|-aoradius|param=float|Set the radius of VRAD's simulated ambient occlusion. {{TODO|Figure out what exactly this does.}}|only={{Nwi_games}}}}
{{IO|-aosamples|param=int|How many samples to use for VRAD's simulated ambient occlusion.|only={{Nwi_games}}|also={{slamminsrc}}}}
{{IO|-StaticPropBounce|param=int|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.}}|only=CSGO}}
{{IO|-StaticPropLightingFinal|{{obs}} Merged with {{mono|-final}}.|only=CSGO}}
{{IO|-StaticPropLightingOld|Will use the old lighting algorithm on props, light affects them much more.|only=CSGO}}
{{IO|-choptexlights|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.|only=BMS}}
{{IO|-extratransfers|Enable overscaling of light transfers.|only=BMS}}
{{IO|-transferscale|param=float|This is the scale factor of light transfers. Increased values make surfaces transfer extra light (scale of 2-4 suggested). Default 1.0.|only=BMS}}
{{IO|-satthresh|param=float|This is the threshold that checks how saturated a material color is. Used with {{mono|-satthreshscale}}. Default 0.4.|only=BMS}}
{{IO|-satthreshscale|param=float|The amount to scale light transfers from surfaces that pass the saturation threshold. Default 3.0.|only=BMS}}
{{IO|-ambientocclusion|Enable lightmapped ambient occlusion.
{{tip|Use very low lightmap scale for small stairs or add additional light sources to light them, otherwise stairs will be completely black.}}
|only=BMS|also={{slamminsrc}},{{gmod}}}}
{{expand|title=Examples|
<br>
<gallery mode=nolines widths=320px heights=192px>
File:NOAO.jpg|Disabled.
File:AO.jpg|Enabled.
</gallery>
}}
{{IO|-experimentalambientocclusion|Use an improved algorithm for the ambient occlusion.
{{warning|Broken. Not being used.}}
|only=BMS}}
{{expand|title=Examples|
<br>
<gallery mode=nolines widths=320px heights=192px>
File:AO.jpg|Ambient occlusion.
File:EAO.jpg|Experimental ambient occlusion.
</gallery>
}}
{{IO|-cascadeshadows|Indicates that lightmap alpha data is interleved in the lighting lump, required for CSM.
{{important|Must be used with <code>-staticproplighting</code> to have proper lighting of static props.
{{expand|title=Examples|
<br>
<gallery mode=nolines widths=320px heights=192px>
File:CSMlSkyLight1.jpg|With <code>-cascadeshadows</code> only.
File:CSMlSkyLight2.jpg|With <code>-cascadeshadows</code> and <code>-staticproplighting</code>.
</gallery>
}}
}}
|only=BMS}}
{{IO|-realskylight|Enables VRAD to compute skylight ambient color by using actual values from skybox.
{{note|This option was originally designed only for levels in Xen, to make lighting for islands more natural. With earthbound outdoor levels this option makes level lighting weird, especially if level uses a skybox with an open, clear sky.}}
{{expand|title=Examples|
<br>
<gallery mode=nolines widths=320px heights=192px>
File:RealSkyLight1.jpg|Without <code>-realskylight</code>.
File:RealSkyLight2.jpg|With <code>-realskylight</code>.
</gallery>
}}
|only=BMS}}
{{IO|-realskylightscale|param=float|Scale factor of -realskylight intensity. Default: 1.0|only=BMS}}
{{IO|-directsunlightisforadditivemode|Toggles direct sunlight for additive mode.
:{{bug|This option is not compatible with cascade shadows.
:{{expand|title=An example.|
<br>
<gallery mode=nolines widths=320px heights=192px>
File:cascadeshadowsbug.jpg|Example with <code>dm_pro_crossfire__twilight_r2</code>.
</gallery>
}}
}}
|only=BMS}}
{{IO|-ambient|param=vector|Sets the ambient term. Can be used to tweak lightmap color. Appears to just mix the color into all lightmaps.|only=CSGO|also={{Dmmm}}{{slamminsrc}}}}
<div id="p2ceparms">{{IO|-PortalTraversalLighting|Enables static lights to go through static worldportals.|only={{P2CE}}}}</div>
{{IO|-PortalTraversalAO|Enables static light AO to go through static worldportals.|only={{P2CE}}}}
{{IO|-softencosine|Softens coloured lighting so it blends more accurately.|only={{slamminsrc}}}}
{{IO|-coring|Scale the light threshold before a luxel is completely unlit, used to save lightmap data.
:{{modernConfirm|Although this command exists in stock {{src13}} VRAD, it does not seem to do anything.}}|only={{slamminsrc}}}}
{{IO|-worldtextureshadows|Allows world polys to cast texture shadows, much like models can.
:{{bug|Doesn't work with displacements.}}
|only={{slamminsrc}}}}
:{{expand|title=Examples|
<gallery mode=nolines widths=320px heights=192px>
File:WorldTex1.jpg|Disabled.
File:WorldTex2.jpg|Enabled.
</gallery>
}}
{{IO|-translucentshadows|Enables -worldtextureshadows on {{Command|$translucent}} surfaces. As by default only {{ent|$alphatest}} surfaces cast baked shadows.
:{{bug|Doesn't work with displacements.}}
|only={{slamminsrc}}}}
:{{expand|title=Examples|<gallery mode=nolines widths=320px heights=192px>
File:Translu2.jpg|Disabled.
File:Translu1.jpg|Enabled.
</gallery>
}}
 
=== Performance ===
 
{{ColumnBox|count=1|{{IO|-low|Run as a low-priority process.}}
{{IO|-threads|param=int|Override the number of CPU threads used. Maximum is 16 threads (32 in {{csgo}} also in {{slamminsrc}}{{mapbase}}). With a [[Increased_Thread_Limit_for_Compile_Tools|patched vrad_dll]] you can use 32 threads.}}
:{{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.}}
{{IO|-mpi|Use [[Vmpi|VMPI]] to distribute computations.}}
{{IO|-mpi_pw|param=string|Use a password to choose a specific set of VMPI workers.}}
{{IO|-noextra|Disable supersampling. This will lead to blockier, less accurate lighting.}}
{{IO|-chop|param=int|Smallest number of [[luxel]] widths for a bounce patch, used on edges. (Default: 4)}}
{{IO|-maxchop|param=int|Coarsest allowed number of luxel widths for a patch, used in face interiors. (Default: 4)}}
{{IO|-dispchop|param=int|Smallest acceptable [[luxel]] width of displacement patch face. (Default: 8)}}
{{IO|-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.}}
{{IO|-compressconstant|param=int|Compress [[lightmap]]s whose color variation is less than this many units.}} {{todo|Find out if this is branch specific, as it doesn't work with TF2.}}
{{IO|-fastambient|Uses low quality per-leaf ambient sampling to save compute time.}}
{{IO|-LeafAmbientSampleReduction|param=float|Reduction factor for ambient samples. Defaults to 1.0.|only=CSGO}}
{{IO|-noao|Disables compiling simulated ambient occlusion for lightmaps.|only={{Nwi_games}}}}
{{IO|-StaticPropSampleScale|param=float|Regulates the generated per-vertex prop_static lighting.
: slow: 16 (high quality); default: 4 (normal); fast: 0.25 (low quality)
: {{note|-final is the equivalent of having -StaticPropSampleScale 16.}}|only=CSGO}}
{{IO|-disppatchradius|param=float|Sets the maximum radius allowed for displacement patches.}}
{{IO|-ambientfromleafcenters|Samples ambient lighting from the center of the leaf.|only=CSGO}}
}}
 
=== Debugging ===
 
{{ColumnBox|count=1|{{IO|-rederrors|Emit red light when "a luxel has no samples".}}
{{IO|-vproject <directory>}}
{{IO|-game <directory>|Override the VPROJECT environment variable.}}
{{IO|-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.}}
{{IO|-v}}
{{IO|-verbose|Turn on verbose output.}}
{{IO|-novconfig|Don't bring up graphical UI on vproject errors.}}
{{IO|-dump|Dump patches to debug files.}}
{{IO|-dumpnormals|Write normals to debug .txt files.}}
{{IO|-debugextra|Places debugging data in lightmaps to visualize supersampling.}}
{{IO|-dlightmap|Force direct lighting into different lightmap than radiosity.}}
{{IO|-stoponexit|Wait for a keypress on exit.}}
{{IO|-nodetaillight|Don't light detail props.}}
{{IO|-centersamples|Move sample centers.}}
{{IO|-loghash|Log the sample hash table to samplehash.txt.}}
{{IO|-onlydetail|Only light detail props and per-leaf lighting.}}
{{IO|-maxdispsamplesize|param=int|Set max displacement sample size (default: 512).}}
{{IO|-FullMinidump|Write large minidumps on crash.}}
{{IO|-OnlyStaticProps|Only perform direct static prop lighting.}}
{{IO|-StaticPropNormals|When lighting static props, just show their normal vector.}}
{{IO|-noskyboxrecurse|Turn off recursion into 3d skybox (skybox shadows on world).}}
{{IO|-nossprops|Globally disable self-shadowing on static props.}}
{{IO|-dumppropmaps|Dump computed static prop lightmaps as [[TGA]] files.{{tip|This can be used to create lightmaps for dynamic props, using the {{ent|$lightmap}} shader parameter.}}|only=2013MP}}
{{IO|-unlitdetail|Disables lighting for detail props.|only=CSGO}}
{{IO|-reflectivityScale|param=float|Scale the [[$reflectivity]] of all textures. Default 1.0|only={{slamminsrc}}}}
}}
 
==Lights files==
{{main|RAD file#Source 1}}
<!-- This section is kept here due to having a lot of links to it, including from external sites -->
 
==Console Output ==
{{todo|Add description about missing outputs output (BuildVisLeafs, other)}}
 
==See also ==
 
* [[QRAD]] and [[HLRAD]] - {{gldsrc|4}} counterparts.
* [[VRAD_(Source 2)|VRAD2 & VRAD3]] - {{source2|4}} counterparts.
* [[Map Compiling Theory]]
* [[HDR Lighting Basics]]
* [[VRAD HDR Crash Fix]]
* [[Static Props show up black]]

Latest revision as of 18:09, 15 July 2024

Note.pngNote:Archived rest of page history of page VRAD
Icon-Important.pngImportant:These pages are linked often from page history logs so Special:WhatLinksHere will not show anything.