Difference between revisions of "Point spotlight"

From Valve Developer Community
Jump to: navigation, search
m
(Improved formatting and added a note about point_spotlight representing multiple entities)
 
(8 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{screenshot}}
+
[[Image:PointSpotlight.jpg|thumb|right|300px|A point_spotlight.]]
+
{{base point|point_spotlight}} It is a {{ent|light_dynamic}} with two glow sprite effects: a ''beam'' effect for viewers outside the light cone and a ''halo'' effect for viewers inside the cone.
{{base point|point_spotlight}} It is a [[light_dynamic]] with two glow sprite effects: a ''beam'' effect for viewers outside the light cone and a ''halo'' effect for viewers inside the cone.  
+
 
*If the 'No Dynamic Light' spawn flag is checked this entity will just provide a sprite effects, and will not illuminate other objects.
+
The <code>light_dynamic</code> functionality can be disabled with the 'No Dynamic Light' spawnflag. In that state, the spotlight will not actually illuminate other objects on its own and can be used with an accompanying {{ent|light_spot}} or {{ent|env_projectedtexture}} instead.
 +
 
 +
{{codenote|By default, point_spotlight uses the material ''sprites/glow_test02.vmt''. You can change this if you are shipping your own binaries by going into ''point_spotlight.cpp'' in the server project, navigating to line 351 and replacing the file path with your own material.}}
 +
{{note|This entity creates an {{ent|env_beam}} and a <code>spotlight_end</code> to accomplish its sprite effects. This means a single <code>point_spotlight</code> actually represents three different entities, including the <code>point_spotlight</code> itself. All of these contribute to the [[entity limit]].}}
 +
 
 +
{{TODO|Define a way to set a custom materials through this ents keyvalues}}
  
 
== Keyvalues ==
 
== Keyvalues ==
{{KV|Spotlight Length|integer|Length of the spotlight beam.}}
+
{{KV|Spotlight Length (spotlight_length)|integer|Length of the spotlight beam.}}
{{KV|Spotlight Width|integer|Width of the spotlight beam.}}
+
{{KV|Spotlight Width (spotlight_width)|integer|Width of the spotlight beam.}}
{{KV|Color (R G B)|color255|Spotlight color.}}
+
{{KV|Color (R G B) (rendercolor)|color255|Spotlight color.}}
{{KV|HDR color scale.|float|float value to multiply sprite color by when running in HDR mode.}}
+
{{KV|HDR color scale. (HDRColorScale)|float|Float value to multiply sprite color by when running in HDR mode.}}
{{KV|Halo size scale.|float|float value to determine the size of the halo.|since=L4D2}}
+
{{KV|Halo size scale. (HaloScale)|float|Float value to determine the size of the halo.|since=L4D2}}
 
{{KV Targetname}}
 
{{KV Targetname}}
 
{{KV Parentname}}
 
{{KV Parentname}}
Line 18: Line 23:
  
 
== Flags ==
 
== Flags ==
* 1 : Start On
+
{{Fl|1|Start On}}
* 2 : No Dynamic Light
+
{{Fl|2|No Dynamic Light}}
  
 
== Inputs ==
 
== Inputs ==
 
{{IO|LightOn|Turn the spotlight on.}}
 
{{IO|LightOn|Turn the spotlight on.}}
{{IO|LightOff|Turn the spotlight off}}
+
{{IO|LightOff|Turn the spotlight off.}}
{{IO|SetColor|Change the color of the spotlight|param=color255|since=AS}}
+
{{IO|SetColor|Change the color of the spotlight. Light must be turned off then back on for dynamic light to update.|param=color255|since=AS|also=GMOD}}
{{IO|ForceUpdate|Force an update of the spotlight position and orientation|since=AS}}
+
{{IO|ForceUpdate|Force an update of the spotlight position and orientation.|since=AS|also=GMOD}}
 
{{I Targetname}}
 
{{I Targetname}}
 
{{I Parentname}}
 
{{I Parentname}}

Latest revision as of 17:12, 11 February 2021

A point_spotlight.

point_spotlight is a point entity available in all Source games. It is a light_dynamic with two glow sprite effects: a beam effect for viewers outside the light cone and a halo effect for viewers inside the cone.

The light_dynamic functionality can be disabled with the 'No Dynamic Light' spawnflag. In that state, the spotlight will not actually illuminate other objects on its own and can be used with an accompanying light_spot or env_projectedtexture instead.

Code:By default, point_spotlight uses the material sprites/glow_test02.vmt. You can change this if you are shipping your own binaries by going into point_spotlight.cpp in the server project, navigating to line 351 and replacing the file path with your own material.
Note.png Note: This entity creates an env_beam and a spotlight_end to accomplish its sprite effects. This means a single point_spotlight actually represents three different entities, including the point_spotlight itself. All of these contribute to the entity limit.

To do: Define a way to set a custom materials through this ents keyvalues

Keyvalues

Spotlight Length (spotlight_length) <integer>
Length of the spotlight beam.
Spotlight Width (spotlight_width) <integer>
Width of the spotlight beam.
Color (R G B) (rendercolor) <color255>
Spotlight color.
HDR color scale. (HDRColorScale) <float>
Float value to multiply sprite color by when running in HDR mode.
Halo size scale. (HaloScale) <float> (in all games since <Left 4 Dead 2>)
Float value to determine the size of the halo.

Targetname:

Name (targetname) <string>
The targetname that other entities refer to this entity by.
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.
Note.png Note: Try to avoid expensive operations in this function, as it may cause performance problems.

Parentname:

Parent (parentname) <targetname>
Specifies a movement parent. An entity will maintain its initial offset from its parent. An attachment point can be added to the end of the name, separated by a comma.

RenderFields:

Render Mode (rendermode) <choices>
Set a non-standard rendering mode on this entity.



Render FX / Transparency (0 - 255) (renderamt) <integer>
Transparency amount, requires a Render Mode other than Normal. 0 is invisible, 255 is fully visible.
Render Color (R G B) (rendercolor) <color255>
Color tint.
Disable Receiving Shadows (disablereceiveshadows) <boolean>
Prevent the entity from receiving shadows on itself.

RenderFXChoices:

Render FX (renderfx) <choices>
Preset pattern of appearance effects.



Angles:

Pitch Yaw Roll (Y Z X) (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.

DXLevelChoice:

Minimum DX Level (mindxlevel) <choices>
The entity will not exist if the engine is running outside the given range of DirectX Versions. Replaced by SystemLevelChoice from <Left 4 Dead> Left 4 Dead onwards.
Warning.png Warning: If these are used, the object may break when the user switches their DirectX settings.
Maximum DX Level (maxdxlevel) <choices>

SystemLevelChoice (in all games since <Left 4 Dead>) :

Minimum Effect Details Level (mincpulevel) <choices> (in all games since <Left 4 Dead>)
Effect Details level of a user's lower than this will not render this entity.
Maximum Effect Details Level (maxcpulevel) <choices> (in all games since <Left 4 Dead>)
Effect Details level of a user's higher than this will not render this entity.
  • 0: Default ("Low" formincpulevel, "High" formaxcpulevel)
  • 1: Low
  • 2: Medium
  • 3: High
Note.png Note: The commandcpu_levelrelates to Effect Details, thus the keys's names.
Minimum Shader Details Level (mingpulevel) <choices> (in all games since <Left 4 Dead>)
Shader Details levels (orgpu_levelcommand) lower than this will not render this object.
Maximum Shader Details Level (maxgpulevel) <choices> (in all games since <Left 4 Dead>)
Shader Details levels (orgpu_levelcommand) higher than this will not render this object.
  • 0: Default ("Low" formingpulevel, "Very High" formaxgpulevel)
  • 1: Low
  • 2: Medium
  • 3: High
  • 4: Very High
Note.png Note: The commandgpu_levelrelates to Shader Details, thus the keys's names.

Flags

  •  [1] : Start On
  •  [2] : No Dynamic Light

Inputs

LightOn
Turn the spotlight on.
LightOff
Turn the spotlight off.
SetColor <color255> (in all games since <Alien Swarm>) (also in <Garry's Mod>)
Change the color of the spotlight. Light must be turned off then back on for dynamic light to update.
ForceUpdate  (in all games since <Alien Swarm>) (also in <Garry's Mod>)
Force an update of the spotlight position and orientation.

Targetname:

Kill
Removes this entity from the world.
KillHierarchy
Removes this entity and its children from the world.
Note.png Note: Entities already remove orphaned children upon being removed, but this input removes all children on the same frame, being marginally faster than Kill.
AddOutput <string>
Adds a keyvalue/output to this entity. It can be potentially very dangerous, use with care.
KV Format: <key> <value>
I/O Format: <output name> <targetname>:<inputname>:<parameter>:<delay>:<max times to fire, -1 means infinite>
FireUser1 to FireUser4
Fire the OnUser outputs; see User Inputs and Outputs.
Use  !FGD
Same as a player invoking +use; may not do anything depending on the entity. Can also be invoked by firing an output that does not specify an input.
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 <Left 4 Dead 2>, the code is executed in the script scope of the entity that fires the output, not the one receiving the input.
Warning.png Warning: Never try to pass string parameters to a script function with this input. It will corrupt the VMF structure because of the nested quotation marks, which then must be removed 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.

Parentname:

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.
ClearParent
Removes this entity from the the movement hierarchy, leaving it free to move independently.


RenderFields:

Alpha <integer>
Sets the entity's transparency to a number from 0 (invisible) to 255 (fully visible). Requires the entity to have its Render Mode (rendermode) set to a number other than 0.
Color <color255>
Sets an RGB color for the entity.

Outputs

OnLightOn
Fires when light turns on.
OnLightOff
Fires when light turns off.

Targetname:

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.

See also