Difference between revisions of "Light dynamic"

From Valve Developer Community
Jump to: navigation, search
m
(Changed internal keyvalue names to use KV intn parameter, revamped flags with Fl templates, changed Targetname templates into BaseEntity templates, added outputs)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{base point|light_dynamic|sprite=light}} It is an invisible light source that changes over time. Can be turned on and off through inputs, and can aim at any object, including moving ones. Dynamic lights are calculated on the fly in the game, which means they have a higher processing cost but are much more flexible than static lighting. It is also the only entity except [[env_projectedtexture]] that can light up brushes at real-time (But it doesn't replace their original lighting).
+
{{base point|light_dynamic|sprite=light}} It is an invisible light source that changes over time. Can be turned on and off through inputs, and can aim at any object, including moving ones. Dynamic lights are calculated on the fly in the game, which means they have a higher processing cost but are much more flexible than static lighting. It is also the only entity except {{ent|env_projectedtexture}} that can light up brushes in real-time (but it doesn't replace their original lighting).
  
 
{{clr}}
 
{{clr}}
Line 5: Line 5:
 
{{note|This entity actually consists of two lights, a cone model light and a spot world light.  Some values may affect one and not the other.}}
 
{{note|This entity actually consists of two lights, a cone model light and a spot world light.  Some values may affect one and not the other.}}
  
{{note|For the light to work properly the "distance" keyvalue must be greater than the distance from the entity to the surface it is supposed to light, otherwise it will not show. Also, it is recommended to set the "brightness" keyvalue to either 6 or 8 as it typically looks best. Normal brightness values do not apply. Finally, adjusting the angle using the circle tool in the top-right or by using the "point at" tool will only adjust the cone model, the angle keyvalue must be set manually to adjust the spot world light.}}
+
{{note|For the light to work properly, the "'''Maximum distance'''" keyvalue must be greater than the distance from the entity to the surface it is supposed to light, otherwise it will not show. Also, it is recommended to set the "'''Light brightness'''" keyvalue to either 6 or 8 as it typically looks best. Normal brightness values do not apply. Finally, adjusting the angle using the circle tool in the top-right or by using the "point at" tool will only adjust the cone model, the angle keyvalue must be set manually to adjust the spot world light.}}
  
 
{{note|For the 2013 SDK this is limited to 17 lights on at any one time so use wisely. }}
 
{{note|For the 2013 SDK this is limited to 17 lights on at any one time so use wisely. }}
Line 11: Line 11:
 
[[Image:lightdynamic.jpg|thumb|right|300px|A example Light_dynamic with different colors]]
 
[[Image:lightdynamic.jpg|thumb|right|300px|A example Light_dynamic with different colors]]
 
== Keyvalues ==
 
== Keyvalues ==
{{KV|Entity to point at (target)|target_destination|The name of an entity in the map that the dynamic light will point at.}}
+
{{KV|Entity to point at|intn=target|target_destination|The name of an entity in the map that the dynamic light will point at.}}
{{KV|Light color (_light)|color255|The RGB render color of the spotlight. Colors must be between 0 and 255.}}
+
{{KV|Light color|intn=_light|color255|The RGB render color of the spotlight. Colors must be between 0 and 255.}}
{{KV|Light brightness (brightness)|integer|The intensity of the spotlight.}}
+
{{KV|Light brightness|intn=brightness|integer|The intensity of the spotlight.}}
{{KV|Inner (bright) angle (_inner_cone)|integer|The angles of the inner spotlight beam. 0 makes it omnidirectional.}}
+
{{KV|Inner (bright) angle|intn=_inner_cone|integer|The angles of the inner spotlight beam. 0 makes it omnidirectional.}}
{{KV|Outer (fading) angle (_cone)|integer|The angles of the outer spotlight beam. 0 makes it omnidirectional.}}
+
{{KV|Outer (fading) angle|intn=_cone|integer|The angles of the outer spotlight beam. 0 makes it omnidirectional.}}
{{KV|Pitch (pitch)|integer|Used instead of Pitch Yaw Roll's value for reasons unknown. }}
+
{{KV|Pitch|intn=pitch|integer|Used instead of Pitch Yaw Roll's value for reasons unknown. }}
{{KV|Maximum distance (distance)|float|This is the distance that light is allowed to cast, in inches.}}
+
{{KV|Maximum distance|intn=distance|float|This is the distance that light is allowed to cast, in inches.}}
{{KV|Spotlight end radius (spotlight_radius)|float|This is the radius of the light, in inches, at the object that it is hitting.}}
+
{{KV|Spotlight end radius|intn=spotlight_radius|float|This is the radius of the light, in inches, at the object that it is hitting.}}
{{KV|Appearance (style)|choices|Various Custom Appearance ([[#Appearances|see below]]) presets.}}
+
{{KV|Appearance|intn=style|choices|Various Custom Appearance ([[#Appearances|see below]]) presets.}}
{{KV Targetname}}
 
{{KV Parentname}}
 
{{KV Angles}}
 
 
 
=== Appearances ===
 
 
{{light appearances}}
 
{{light appearances}}
 +
{{KV BaseEntity}}
  
 
== Flags ==
 
== Flags ==
* 1 : Do not light [[worldspawn|world]] (better perf)
+
{{Fl|1|Do not light [[worldspawn|world]] (better perf)}}
* 2 : Do not light models
+
{{Fl|2|Do not light models}}
* 4 : Add [[Displacement#Blended_displacement_materials_.28alpha_channel_painting.29|Displacement Alpha]]
+
{{Fl|4|Add [[Displacement#Blended_displacement_materials_.28alpha_channel_painting.29|Displacement Alpha]]}}
* 8 : Subtract Displacement Alpha
+
{{Fl|8|Subtract Displacement Alpha}}
  
 
==Inputs==
 
==Inputs==
Line 44: Line 40:
 
{{IO|TurnOff|Turn the light on.}}
 
{{IO|TurnOff|Turn the light on.}}
 
{{IO|Toggle|Toggle the light on/off.}}
 
{{IO|Toggle|Toggle the light on/off.}}
{{I Targetname}}
+
{{I BaseEntity}}
{{I Parentname}}
+
 
 +
==Outputs==
 +
{{O BaseEntity|l4d=1}}
 +
 
 +
== Console commands ==
 +
{{IO|r_dynamic|param=bool|Enables dynamic lights.}}
 +
{{IO|r_dynamiclighting|param=bool|Enables [[Naming Lights|toggled lights]].}}
 +
{{IO|r_maxdlights|param=int|Sets the maximum amount of dynamic lights.}}
  
 
== See also ==
 
== See also ==

Latest revision as of 07:47, 28 January 2021

light_dynamic is a point entity available in all Source games. It is an invisible light source that changes over time. Can be turned on and off through inputs, and can aim at any object, including moving ones. Dynamic lights are calculated on the fly in the game, which means they have a higher processing cost but are much more flexible than static lighting. It is also the only entity except env_projectedtexture that can light up brushes in real-time (but it doesn't replace their original lighting).

Note.png Note: This entity actually consists of two lights, a cone model light and a spot world light. Some values may affect one and not the other.
Note.png Note: For the light to work properly, the "Maximum distance" keyvalue must be greater than the distance from the entity to the surface it is supposed to light, otherwise it will not show. Also, it is recommended to set the "Light brightness" keyvalue to either 6 or 8 as it typically looks best. Normal brightness values do not apply. Finally, adjusting the angle using the circle tool in the top-right or by using the "point at" tool will only adjust the cone model, the angle keyvalue must be set manually to adjust the spot world light.
Note.png Note: For the 2013 SDK this is limited to 17 lights on at any one time so use wisely.
A example Light_dynamic with different colors

Keyvalues

Entity to point at (target) <targetname>
The name of an entity in the map that the dynamic light will point at.
Light color (_light) <color255>
The RGB render color of the spotlight. Colors must be between 0 and 255.
Light brightness (brightness) <integer>
The intensity of the spotlight.
Inner (bright) angle (_inner_cone) <integer>
The angles of the inner spotlight beam. 0 makes it omnidirectional.
Outer (fading) angle (_cone) <integer>
The angles of the outer spotlight beam. 0 makes it omnidirectional.
Pitch (pitch) <integer>
Used instead of Pitch Yaw Roll's value for reasons unknown.
Maximum distance (distance) <float>
This is the distance that light is allowed to cast, in inches.
Spotlight end radius (spotlight_radius) <float>
This is the radius of the light, in inches, at the object that it is hitting.
Appearance (style) <choices>
Various Custom Appearance (see below) presets.
Light Appearances
Literal Value Description Sequence Preview
0 Normal m Sequence 0.gif
10 Fluorescent flicker mmamammmmammamamaaamammma Sequence 10.gif
2 Slow, strong pulse abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba Sequence 2.gif
11 Slow pulse, noblack abcdefghijklmnopqrrqponmlkjihgfedcba Sequence 11.gif
5 Gentle pulse jklmnopqrstuvwxyzyxwvutsrqponmlkj Sequence 5.gif
1 Flicker A mmnmmommommnonmmonqnmmo Sequence 1.gif
6 Flicker B nmonqnmomnmomomno Sequence 6.gif
3 Candle A mmmmmaaaaammmmmaaaaaabcdefgabcdefg Sequence 3.gif
7 Candle B mmmaaaabcdefgmmmmaaaammmaamm Sequence 7.gif
8 Candle C mmmaaammmaaammmabcdefaaaammmmabcdefmmmaaaa Sequence 8.gif
4 Fast strobe mamamamamama Sequence 4.gif
9 Slow strobe aaaaaaaazzzzzzzz Sequence 9.gif
12 !FGD Underwater light mutation mmnnmmnnnmmnn Sequence 12.gif


Base:

Name (targetname) <string>
The name that other entities use to refer to this entity.
Parent (parentname) <targetname>
Maintain the same initial offset to this entity. An attachment point can also be used if separated by a comma at the end. (parentname [targetname],[attachment])
Tip.png Tip: Entities transition to the next map with their parents
Tip.png Tip: phys_constraintcan be used as a workaround if parenting fails.
Global Entity Name (globalname) <string>
When the player transitions to a new map, entities in the new map with matching globalnames will have their previous map's states copied over to it.
Origin (X Y Z) (origin) <coordinates>
The position of this entity's center in the world. Rotating entities typically rotate around their origin.
Note.png Note: Hammer does not move the entities accordingly only in the editor.
Pitch Yaw Roll (X Y Z) (angles) <angle>
This entity's orientation in the world. Pitch is rotation around the Y axis, yaw is the rotation around the Z axis, roll is the rotation around the X axis.
Note.png Note: This works on brush entities, although Hammer doesn't show the new angles.
Response Contexts (ResponseContext) <string>
Pre-defined response system contexts; Format is [key]:[value],[key]:[value],...and so on.
Tip.png Tip: Can also be filtered for or against!
Classname (classname) <string> !FGD
Determines the characteristics of the entity before it spawns.
Tip.png Tip: Changing classnames using theAddOutputinput can still influence the game's code, like making the classname match one element in the S_PreserveEnts list will make the entity persists on new rounds!
Flags (spawnflags) <integer> !FGD
Toggles exclusive features of an entity, its specific number is determined by the combination of flags added.
Effects (effects) <integer> !FGD
Combination of effect flags to use.
Hammer ID (hammerid) <integer> !FGD
The entity's unique Hammer ID that's auto-generated on map compiles. Mainly used by plugins or debugging commands (like theent_keyvaluecommand). Run-time spawned entities don't have a Hammer ID.
Entity Scripts (vscripts) <scriptlist> (in all games since Left 4 Dead 2)
Space delimited list of VScript files (without file extension) that are executed after all entities have spawned. The scripts are all executed in the same script scope, later ones overwriting any identical variables and functions.
Script think function (thinkfunction) <string> (in all games since Left 4 Dead 2)
Name of a function in this entity's script which will be called automatically every 100 milliseconds (ten times a second) for the duration of the script. It can be used to create timers or to simulate autonomous behavior. The return value (if present) will set the time until the next call. Try to avoid expensive operations in this function, as it may cause performance problems.
Lag Compensation (LagCompensate) <boolean> (in all games since Left 4 Dead 2) !FGD
Set to Yes to lag compensate this entity. Should be used very sparingly!
Disable for Xbox 360 (disableX360) <boolean> (in all games since Left 4 Dead 2) !FGD
If this entity should automatically be given the 'Disable' input on the Xbox 360 version of Source.
Is Automatic-Aim Target (is_autoaim_target) <boolean> (in all games since Counter-Strike: Global Offensive) !FGD
If set to 1, this entity will slow down aiming movement for consoles and joystick controllers when the entity is under the crosshairs.


Flags

  •  [1] : Do not light world (better perf)
  •  [2] : Do not light models
  •  [8] : Subtract Displacement Alpha

Inputs

Color <color255>
Set the light's render color (R G B).
brightness <integer>
Set the light brightness.
distance <float>
Set the maximum light distance.
_inner_cone <integer>
Set the inner (bright) angle.
_cone <integer>
Set the outer (fading) angle.
spotlight_radius <float>
Set the radius of the spotlight at the end point.
style <integer>
Change the lightstyle (see Appearance field for possible values).
TurnOn
Turn the light off.
TurnOff
Turn the light on.
Toggle
Toggle the light on/off.


Base:

AddContext <string>
Adds to the entity's list of response contexts. Format is <key>:<value>.
AddOutput <string>
Assigns a new keyvalue/output on this entity. For keyvalues, some rely on extra necessary code to be ran and won't work if its simply just changed through this input. There is a strict format that must be followed:
Syntax: 


ClearContext
Removes all contexts from this entity's list.
ClearParent
Removes this entity from the the movement hierarchy, leaving it free to move independently.
FireUser1 to FireUser4
Fires the respectiveOnUseroutputs; see User Inputs and Outputs.
Kill
Removes this entity and any entities parented to it from the world.
KillHierarchy
Functions the same as Kill, although this entity and any entities parented to it are killed on the same frame, being marginally faster thanKillinput.
RemoveContext <string>
Remove a context from this entity's list. The name should match the key of an existing context.
SetParent <string>
Move with this entity. See Entity Hierarchy (parenting).
SetParentAttachment <string>
Change this entity to attach to a specific attachment point on its parent. The entity will teleport so that the position of its root bone matches that of the attachment. Entities must be parented before being sent this input.
SetParentAttachmentMaintainOffset <string>
As above, but without teleporting. The entity retains its position relative to the attachment at the time of the input being received.
Use  !FGD
Same as a player invoking +use; no effect in most cases.
DispatchResponse <string> !FGD
Dispatches a response to the entity. See Response and Concept.
DispatchEffect <string> (removed since Left 4 Dead) !FGD
Dispatches a special effect from the entity's origin; see also List of Client Effects. Replaced by the particle system since Left 4 Dead.
RunScriptFile <script> (in all games since Left 4 Dead 2)
Execute a VScript file from disk, without file extension. The script contents are merged with the script scope of the receiving entity.
RunScriptCode <string> (in all games since Left 4 Dead 2)
Execute a string of VScript source code in the scope of the entity receiving the input. String quotation may be needed when fired via console.
Bug.png Bug: In Hammer, using string arguments will corrupt the VMF file's structure, making the file unviewable for the next Hammer session.
Fix: Remove the string argument manually with a text editor.
CallScriptFunction <string> (in all games since Left 4 Dead 2) !FGD
Execute a VScript function in the scope of the receiving entity.
SetLocalOrigin <coordinates> (in all games since Alien Swarm) !FGD
Send this entity to a spot in the map. If the entity is parented to something, it will be offset from the parent by this amount.
SetLocalAngles <angles> (in all games since Alien Swarm) !FGD
Set this entity's angles.


Outputs

Base:

OnUser1 to OnUser4
These outputs each fire in response to the firing of the like-numbered FireUser1 to FireUser4 Input; see User Inputs and Outputs.
OnKilled  (only in Left 4 Dead Left 4 Dead 2)
This output fires when the entity is killed and removed from the game.

Console commands

r_dynamic <boolean>
Enables dynamic lights.
r_dynamiclighting <boolean>
Enables toggled lights.
r_maxdlights <integer>
Sets the maximum amount of dynamic lights.

See also