Naming Lights: Difference between revisions
(added screenshot.) |
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified) |
||
(30 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
{{LanguageBar}} | |||
Giving a light entity a [[targetname]] makes [[VRAD]] compile a second [[lightmap]] "page" for the surfaces that its emitted light touches. This won't harm in-game performance, but it will increase compile time and BSP filesize, regardless of whether the light ever receives [[input]] to change its state. | Giving a light entity a [[targetname]] makes [[VRAD]] compile a second [[lightmap]] "page" for the surfaces that its emitted light touches. This won't harm in-game performance, but it will increase compile time and BSP filesize, regardless of whether the light ever receives [[input]] to change its state. | ||
However, the system can be overloaded if you try to make it handle a large number of overlapping | However, the system can be overloaded if you try to make it handle a large number of overlapping lights with different names (since the number of pages needed increases exponentially). When this happens performance ''can'' be harmed and you may well see lighting anomalies. | ||
VRAD attempts to avoid this with its '''hard-coded limits''' of two switchable lights affecting a brush face and 32 pages | VRAD attempts to avoid this with its '''hard-coded limits''' of two switchable lights affecting a brush face and 32 total pages per lightmap (a page exists for each possibility of combined states). More than this causes VRAD to throw a warning such as ''"Too many light styles on a face"'' and refuse to compute the lightmaps for those lights; this will make those areas appear as if they are not lit. You can help too by giving lights that will always change state at the same time a '''shared targetname''', which makes VRAD merge their pages together. | ||
{{note|To reduce the number of pages created, light from named light entities is direct and won't bounce between surfaces. This can look very crude!}} | {{tip|If your game supports dynamic lighting system ({{bms|4}} or {{p2d|4}} for example) - use dynamic light sources instead of {{ent|light}} and {{ent|light_spot}}. This will reduce map size and make load times better. Don't do so in cases when dynamic light looks much worse then baked light, or when dynamic light causes big problems with performance.}} | ||
{{note| | |||
* Light styles will affect page growth exponentially. To calculate the number of pages a brush face will have, take 2<sup>n</sup> where n is the number of different names used for lights affecting the brush face. | |||
* To reduce the number of pages created, light from named light entities is direct and won't bounce between surfaces. This can look very crude! | |||
:{{fix|{{gmod}} [[VRAD]] has a {{code|-bounceFromNamed}} parameter that can force named and styled lights to cast bounced lighting. Note that this ''will'' increase lightmap usage!}} | |||
* Setting an [[lightstyle|animated appearance]] for the light counts as "naming it", even though the {{mono|style}} key is incompatible with {{mono|[[targetname]]}}. | |||
* Pre-baked [[static prop]] lighting is always generated in with named and styled lights in their "off" position. If this is an issue, disable per-vertex lighting for the given prop. | |||
* Cubemaps defined using {{ent|env_cubemap}} will only store lighting for one state of the toggled light. If this is an issue, and the surface is not part of a static prop or displacement, manually define an {{cmd|$envmap}} and use a material proxy to toggle the {{cmd|$envmapframe}}.<!-- is there a better place to say this? --> | |||
}} | |||
{{ | {{bug|hidetested=1|There is a bug in the {{l4d|4}} engine that affect the use of named lights. A named light, even if totally still will be considered fully dynamic by the engine and pump up a large chunk of frames per second until it is turned off and on for the first time. The workaround is to set the light to start turned off and to turn it on on map spawn using a {{ent|logic_auto}} entity for instance. This could also affect {{l4d2|4}}, but this has not been proven.|since=l4d}} | ||
{{Warning|Although lights with the same targetname share lightmap pages, each light will still count as a separate [[edict]]! If using a bunch of lights with a shared name, consider removing the targetname from all but one of the light entities of a given name after compiling lighting, using a tool such as {{entspy|2}}. | |||
{{code fix|Modify [[VRAD]] to add a {{mono|_targetname}} KV to lights that acts the same as {{mono|targetname}}. This way, only one light will need a {{mono|targetname}}, and the rest will have a {{mono|_targetname}} that is ignored by the game instead.}} | |||
}} | |||
== See also == | == See also == | ||
* {{ent|light}} | |||
* | * {{ent|light_spot}} | ||
* | * {{ent|light_directional}} | ||
[[Category:Level Design]] | [[Category:Level Design]] | ||
[[Category:Lighting]] |
Latest revision as of 07:14, 20 May 2025


Giving a light entity a targetname makes VRAD compile a second lightmap "page" for the surfaces that its emitted light touches. This won't harm in-game performance, but it will increase compile time and BSP filesize, regardless of whether the light ever receives input to change its state.
However, the system can be overloaded if you try to make it handle a large number of overlapping lights with different names (since the number of pages needed increases exponentially). When this happens performance can be harmed and you may well see lighting anomalies.
VRAD attempts to avoid this with its hard-coded limits of two switchable lights affecting a brush face and 32 total pages per lightmap (a page exists for each possibility of combined states). More than this causes VRAD to throw a warning such as "Too many light styles on a face" and refuse to compute the lightmaps for those lights; this will make those areas appear as if they are not lit. You can help too by giving lights that will always change state at the same time a shared targetname, which makes VRAD merge their pages together.




- Light styles will affect page growth exponentially. To calculate the number of pages a brush face will have, take 2n where n is the number of different names used for lights affecting the brush face.
- To reduce the number of pages created, light from named light entities is direct and won't bounce between surfaces. This can look very crude!
Fix:
VRAD has a -bounceFromNamed parameter that can force named and styled lights to cast bounced lighting. Note that this will increase lightmap usage!
- Setting an animated appearance for the light counts as "naming it", even though the style key is incompatible with targetname.
- Pre-baked static prop lighting is always generated in with named and styled lights in their "off" position. If this is an issue, disable per-vertex lighting for the given prop.
- Cubemaps defined using env_cubemap will only store lighting for one state of the toggled light. If this is an issue, and the surface is not part of a static prop or displacement, manually define an $envmap and use a material proxy to toggle the $envmapframe.





