Env projectedtexture: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(Major cleanup and added new keyvalues and inputs.)
Line 1: Line 1:
[[File:Projected texture.jpg|thumb|Projecting a colourful [[texture]].]]
[[File:Projected texture.jpg|thumb|Projecting a colourful [[texture]].]]
[[File:trainstationdlight_0.jpg|thumb|[[Env_projectedtexture]]s allow for self-shadows, shadow-receivers, and properly oriented and proportioned shadows. Two of these entities are currently being used in this scene. After "grain" fix]]
[[File:trainstationdlight_0.jpg|thumb|[[Env_projectedtexture]]s allow for self-shadows, shadow-receivers, and properly oriented and proportioned shadows. Two of these entities are currently being used in this scene. After "grain" fix]]
[[File:Global_shadow_mapping.jpg|thumb|Example of the improved texture projection in [[Portal 2]].]]


{{base point ep2|env_projectedtexture}} It creates a dynamic [[Wikipedia:Shadow mapping|shadow-mapping]] light that affects all objects in the world. It is used to create the flashlights in [[Source 2007]], [[Source 2009]] and [[Left 4 Dead (engine branch)|Left 4 Dead]] engine games.
{{base point ep2|env_projectedtexture}} It creates a dynamic [[Wikipedia:Shadow mapping|shadow-mapping]] light that affects all objects in the world. It is used to create the flashlights in [[Source 2007]], [[Source 2009]] and [[Left 4 Dead (engine branch)|Left 4 Dead]] engine games. In [[Alien Swarm]] and [[Portal 2]], it is also used for world lighting in combination with static lights.


As expected, projected textures have been improved in ''[[Portal 2]]''. Light no longer bleeds around objects and shadows appear to be more accurate and precise. In addition, more flashlight [[ConVar]]s are available (try ''find r_flashlight'' in the console). However, ''[[Portal 2]]'' never has (nor can have) more than one active at any given time.
{{note|Shadows are only rendered when the user is running with "High" shadow detail.}}


{{note|Shadows are only rendered when the user is running with "High" shadow detail.}}
{{note|In multiplayer, ''mp_flashlight'' and ''mat_flashlight'' must be set to 1 for flashlights to work; by default, these ConVars are disabled in ''[[Team Fortress 2]]'', so this entity won't work there without special configuration.}}


{{note|Portal 2 does not allow more than one env_projectedtexture, if one is activated while another is already on, it will disable the previous one.}}
{{bug|In Source 2007/2009, a configurable texture value from Hammer is not accepted - will always default to the flashlight. You must use the <code>SpotlightTexture</code> [[input]] or [[env_projectedtexture/fixes#Fix_configurable_texture_value_in_Hammer|use the code fix available on the Bug Fixes page]].}}


{{note|In multiplayer, ''mp_flashlight'' and ''mat_flashlight'' must be set to 1 for flashlights to work; by default, these ConVars are disabled in ''[[Team Fortress 2]]''.}}
{{bug|[[Model]]s will not receive their own shadows correctly unless using [[$bumpmap]]; even a flat bump map is suffice.}}


{{bug|Does not accept a configurable texture value from Hammer - will always default to the flashlight. You must use the <code>SpotlightTexture</code> [[input]] or  [[env_projectedtexture/fixes#Fix_configurable_texture_value_in_Hammer|use the code fix available on the Bug Fixes page]].}}
{{bug|[[Viewmodel]]s won't receive light or shadows from projected textures, not even in [[Portal 2]]. See [[Env_projectedtexture/fixes#Enabling shadow receiving on the view model|the code fix available on the Bug Fixes page]].}}


{{bug|[[Model]]s will not receive their own shadows correctly unless using [[$bumpmap]]; even a flat bump map is suffice.}}
{{bug|Causes issues if it overlaps a prop_portal from [[Portal]] 1. However, this has been fixed in [[Portal 2]].}}


{{bug|[[Viewmodel]]s won't receive light or shadows from projected textures(Not even in Portal 2). See [[Env_projectedtexture/fixes#Enabling shadow receiving on the view model|the code fix available on the Bug Fixes page]].}}
== Portal 2 improvements ==
[[File:Global_shadow_mapping.jpg|thumb|Example of the improved texture projection in [[Portal 2]].]]


{{bug|Causes issues if it overlaps a prop_portal from [[Portal]] 1, however this is fixed in [[Portal 2]]}}
As expected, projected textures have been improved in ''[[Portal 2]]''. Light no longer bleeds around objects and shadows appear to be more accurate and precise. In addition, more flashlight [[ConVar]]s are available (try ''find r_flashlight'' in the console).


{{bug|Does not work in [[Team Fortress 2]]}}
{{note|Portal 2 does not allow more than one active env_projectedtexture at any given time. If one is activated while another is already on, it will disable the previous one and a warning message is displayed in the console.}}
{{clr}}


==Bug fixes==
==Bug fixes==
See [[env_projectedtexture/fixes]].
See [[env_projectedtexture/fixes]].


==Keyvalues==
==Keyvalues==
 
{{KV|target|target_destination|The entity will rotate to point at its target, no matter where it is in the world. See also <code>lightonlytarget</code>. {{bug|Does not work with stock SDK code. See [[Env_projectedtexture/fixes#Fixing targeting]].}}}}
; target <code><[[string]]> </code>
{{KV|FOV|float|The field of view angle at which the texture is projected. The projection is square, but the texture can make it appear of any shape. <br/> Remember the default Player FOV is 75&deg;.}}
: The entity will rotate to point at its target, no matter where it is in the world. See also <code>lightonlytarget</code>. {{bug|Does not work with stock SDK code. See [[Env_projectedtexture/fixes#Fixing targeting]].}}
{{KV|NearZ|float|Near Z for projected texture. Default value is 4.0.<br/> Objects closer than this will not receive the projection.}}
; FOV <code><[[float]]></code>
{{KV|FarZ|float|Far Z for projected texture. Default value is 750.0.<br/> Objects beyond this distance will not receive the projection. Think of it as the range limit.}}
: The angle at which the texture is projected. The projection is square, but the texture can make it appear of any shape.
{{KV|Enable Shadows|boolean|Enables/disables shadows from this projected texture.}}
: Remember the default Player FOV is 75&deg;.
{{KV|Shadow Quality|Choices|Quality of shadows. ({{todo|what's the difference?}})}}
; NearZ <code><float></code>
:* 0 : Low
: Near Z for projected texture. Default value is 4.0.
:* 1 : High
: Objects closer than this will not receive the projection.
{{KV|Light Only Target|boolean|Limit flashlight effect to only effect target entity? {{note|The world will still be lit.}}}}
; FarZ <code><float></code>
{{KV|Light World|boolean|Control whether flashlight effects static world geometry.}}
: Far Z for projected texture. Default value is 750.0.
{{KV|Light Color|color255|Light Color RGB-Intensity}}
: Objects beyond this distance will not receive the projection. Think of it as the range limit.
{{KV|Camera Space|integer|Display relative to player's view. Breaks things horribly unless the entity moves with the player.}}
; Enable Shadows <code><[[bool]]></code>
{{KV|Brightness Scale|float|Scale the light color by this brightness.|since=AS}}
: Should I cast shadows?
{{KV|Color Transition Time|float|Amount of time it takes for a color change to occur.|since=AS}}
; Shadow Quality <code><bool></code>
{{KV|Texture Name|material|Sets the current projected texture associated with this entity. {{bug|Does not work with stock SDK code. See [[Env_projectedtexture/fixes#Fix configurable texture value in Hammer]].}}|since=AS}}
: Quality of shadows ({{todo|what's the difference?}})
{{KV|Appearance|Choices|Various Custom Appearance (see below) presets.|since=P2}}
; Light Only Target <code><bool></code>
:* 0 : Normal
: Should I light only the entity that is my <code>target</code>? The world will still be lit.
:* 10 : Fluorescent flicker
; Light World <code><bool></code>
:* 2 : Slow, strong pulse
: Should I light the [[world]]?
:* 11 : Slow pulse, noblack
; Camera Space <code><bool></code>
:* 5 : Gentle pulse
: Display relative to player's view. Breaks things horribly unless the entity moves with the player.
:* 1 : Flicker A
; Light Color <code>{{color}}</code>
:* 6 : Flicker B
: Tint of projected texture.
:* 3 : Candle A
; texturename <code><VTF/string></code>
:* 7 : Candle B
: Sets the current projected texture associated with this entity.
:* 8 : Candle C
: {{bug|Does not work with stock SDK code. See [[Env_projectedtexture/fixes#Fix configurable texture value in Hammer]].}}
:* 4 : Fast strobe
: {{bug|KeyValue not recognised by [[Hammer]] as it is not in the base FGD. Value must be set manually.}}
:* 9 : Slow strobe
{{KV|Custom Appearance|string|Set a custom pattern of light brightness for this light. Pattern format is a string of characters, where '''a''' is total darkness, '''z''' fully bright. i.e. <code>aaggnnttzz</code> would be a steppy fade in from dark to light.|since=P2}}
{{KV Targetname}}
{{KV Parentname}}
{{KV Parentname}}
: {{bug|Does not work with stock SDK code. See [[Env_projectedtexture/fixes#Fixing Parenting]].}}
: {{bug|Does not work with stock SDK code. See [[Env_projectedtexture/fixes#Fixing Parenting]].}}
: {{note|Does work in Portal 2}}
{{KV Angles}}
{{KV Angles}}
{{KV Targetname}}


==Flags==
==Flags==
* Enabled
* 1 : Enabled
* 2 : Always Update (moving light) {{AS add}}


==Inputs==
==Inputs==
{{note|In Source 2007/2009, only <code>TurnOn</code>, <code>TurnOff</code> and <code>SetFOV</code> are known to Hammer.}}


''These inputs are accepted by the entity but not known to Hammer:''
{{IO|TurnOn|Turn on the texture.}}
 
{{IO|TurnOff|Turn off the texture.}}
; <code>target <[[string]]></code>
{{IO|SetFOV|Set FOV. See lightfov keyvalue above.|param=float}}
: Specify a new target entity to point at.
{{IO|SpotlightTexture|Set the spotlight texture. Must be a [[Valve Texture Format|VTF]] file (not VMT), relative to <code>/materials</code>.|param=string}}
; <code>cameraspace <[[bool]]></code>
{{IO|Target|Specify a new target entity to point at.|param=string}}
: See above keyvalues.
{{IO|CameraSpace|See above keyvalues.|param=boolean}}
; <code>LightOnlyTarget <bool></code>
{{IO|LightOnlyTarget|See above keyvalues. {{bug|Non-functional.}}|param=boolean}}
: See above keyvalues. {{bug|Non-functional.}}
{{IO|LightWorld|See above keyvalues. {{bug|Cannot be re-enabled.}}|param=boolean}}
; <code>LightWorld <bool></code>
{{IO|Ambient|Allows for an ambiance light, much like the shadow color for it.|param=boolean}}
: See above keyvalues. {{bug|Cannot be re-enabled.}}
{{IO|AlwaysUpdateOn|Turn on per frame updating (for moving lights)|since=AS}}
; <code>EnableShadows <bool></code>
{{IO|AlwaysUpdateOff|Turn off per frame updating (for moving lights)|since=AS}}
: See above keyvalues.
{{IO|EnableShadows|Set the if shadows are enabled|param=bool|since=AS}}
; <code>Ambient <[[float]]></code>
{{IO|LightColor|Change the light color/brightness|param=color255|since=AS}}
: Allows for an ambiance light, much like the shadow color for it.
{{IO|SetLightStyle|Change the lightstyle. (see Appearance keyvalue above for possible values)|param=integer|since=P2}}
; <code>SpotlightTexture <VTF/string></code>
{{IO|SetPattern|Set a custom pattern of light brightness for this light. (see Custom Appearance keyvalue above)|param=string|since=P2}}
: A [[Valve Texture Format|VTF]] file (not VMT), relative to <code>/materials</code>.
{{IO|SetNearZ|Sets the near Z distance.|param=float|since=P2}}
; {{P2-add|<code>SetPattern <[[string]]></code>}}
{{IO|SetFarZ|Sets the far Z distance.|param=float|since=P2}}
: Much like the [[light]]'s custom appearance keyvalue. A string of characters, like a sequence of piano keys, that define a pattern of brightness. a is dark and z is full intensity.
{{I Targetname}}
 
''These inputs are known to Hammer:''
 
; <code>TurnOn</code>
; <code>TurnOff</code>
: Enable or disable the light.
; <code>FOV <[[float]]></code>
: See lightfov keyvalue above.
{{I Parentname}}
{{I Parentname}}
{{I Targetname}}


==Outputs==
==Outputs==
{{O Targetname}}
{{O Targetname}}


[[Category:Lighting]]
[[Category:Lighting]]

Revision as of 20:33, 7 June 2011

Projecting a colourful texture.
Env_projectedtextures allow for self-shadows, shadow-receivers, and properly oriented and proportioned shadows. Two of these entities are currently being used in this scene. After "grain" fix

Template:Base point ep2 It creates a dynamic shadow-mapping light that affects all objects in the world. It is used to create the flashlights in Source 2007, Source 2009 and Left 4 Dead engine games. In Alien Swarm and Portal 2, it is also used for world lighting in combination with static lights.

Note.pngNote:Shadows are only rendered when the user is running with "High" shadow detail.
Note.pngNote:In multiplayer, mp_flashlight and mat_flashlight must be set to 1 for flashlights to work; by default, these ConVars are disabled in Team Fortress 2, so this entity won't work there without special configuration.
Icon-Bug.pngBug:In Source 2007/2009, a configurable texture value from Hammer is not accepted - will always default to the flashlight. You must use the SpotlightTexture input or use the code fix available on the Bug Fixes page.  [todo tested in ?]
Icon-Bug.pngBug:Models will not receive their own shadows correctly unless using $bumpmap; even a flat bump map is suffice.  [todo tested in ?]
Icon-Bug.pngBug:Viewmodels won't receive light or shadows from projected textures, not even in Portal 2. See the code fix available on the Bug Fixes page.  [todo tested in ?]
Icon-Bug.pngBug:Causes issues if it overlaps a prop_portal from Portal 1. However, this has been fixed in Portal 2.  [todo tested in ?]

Portal 2 improvements

Example of the improved texture projection in Portal 2.

As expected, projected textures have been improved in Portal 2. Light no longer bleeds around objects and shadows appear to be more accurate and precise. In addition, more flashlight ConVars are available (try find r_flashlight in the console).

Note.pngNote:Portal 2 does not allow more than one active env_projectedtexture at any given time. If one is activated while another is already on, it will disable the previous one and a warning message is displayed in the console.

Bug fixes

See env_projectedtexture/fixes.

Keyvalues

target ([todo internal name (i)]) <targetname>
The entity will rotate to point at its target, no matter where it is in the world. See also lightonlytarget.
Icon-Bug.pngBug:Does not work with stock SDK code. See Env_projectedtexture/fixes#Fixing targeting.  [todo tested in ?]
FOV ([todo internal name (i)]) <float>
The field of view angle at which the texture is projected. The projection is square, but the texture can make it appear of any shape.
Remember the default Player FOV is 75°.
NearZ ([todo internal name (i)]) <float>
Near Z for projected texture. Default value is 4.0.
Objects closer than this will not receive the projection.
FarZ ([todo internal name (i)]) <float>
Far Z for projected texture. Default value is 750.0.
Objects beyond this distance will not receive the projection. Think of it as the range limit.
Enable Shadows ([todo internal name (i)]) <boolean>
Enables/disables shadows from this projected texture.
Shadow Quality ([todo internal name (i)]) <choices>
Quality of shadows. (
Todo: what's the difference?
)
  • 0 : Low
  • 1 : High
Light Only Target ([todo internal name (i)]) <boolean>
Limit flashlight effect to only effect target entity?
Note.pngNote:The world will still be lit.
Light World ([todo internal name (i)]) <boolean>
Control whether flashlight effects static world geometry.
Light Color ([todo internal name (i)]) <color255>
Light Color RGB-Intensity
Camera Space ([todo internal name (i)]) <integer>
Display relative to player's view. Breaks things horribly unless the entity moves with the player.
Brightness Scale ([todo internal name (i)]) <float> (in all games since Alien Swarm)
Scale the light color by this brightness.
Color Transition Time ([todo internal name (i)]) <float> (in all games since Alien Swarm)
Amount of time it takes for a color change to occur.
Texture Name ([todo internal name (i)]) <material> (in all games since Alien Swarm)
Sets the current projected texture associated with this entity.
Icon-Bug.pngBug:Does not work with stock SDK code. See Env_projectedtexture/fixes#Fix configurable texture value in Hammer.  [todo tested in ?]
Appearance ([todo internal name (i)]) <choices> (in all games since Portal 2)
Various Custom Appearance (see below) presets.
  • 0 : Normal
  • 10 : Fluorescent flicker
  • 2 : Slow, strong pulse
  • 11 : Slow pulse, noblack
  • 5 : Gentle pulse
  • 1 : Flicker A
  • 6 : Flicker B
  • 3 : Candle A
  • 7 : Candle B
  • 8 : Candle C
  • 4 : Fast strobe
  • 9 : Slow strobe
Custom Appearance ([todo internal name (i)]) <string> (in all games since Portal 2)
Set a custom pattern of light brightness for this light. Pattern format is a string of characters, where a is total darkness, z fully bright. i.e. aaggnnttzz would be a steppy fade in from dark to light.
Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

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.
Icon-Bug.pngBug:Does not work with stock SDK code. See Env_projectedtexture/fixes#Fixing Parenting.  [todo tested in ?]
Pitch Yaw Roll (Y Z X) (angles) <QAngle>
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.

Flags

Inputs

Note.pngNote:In Source 2007/2009, only TurnOn, TurnOff and SetFOV are known to Hammer.


TurnOn
Turn on the texture.
TurnOff
Turn off the texture.
SetFOV <floatRedirectInput/float>
Set FOV. See lightfov keyvalue above.
SpotlightTexture <stringRedirectInput/string>
Set the spotlight texture. Must be a VTF file (not VMT), relative to /materials.
Target <stringRedirectInput/string>
Specify a new target entity to point at.
CameraSpace <booleanRedirectInput/boolean>
See above keyvalues.
LightOnlyTarget <booleanRedirectInput/boolean>
See above keyvalues.
Icon-Bug.pngBug:Non-functional.  [todo tested in ?]
LightWorld <booleanRedirectInput/boolean>
See above keyvalues.
Icon-Bug.pngBug:Cannot be re-enabled.  [todo tested in ?]
Ambient <booleanRedirectInput/boolean>
Allows for an ambiance light, much like the shadow color for it.
AlwaysUpdateOn  (in all games since Alien Swarm)
Turn on per frame updating (for moving lights)
AlwaysUpdateOff  (in all games since Alien Swarm)
Turn off per frame updating (for moving lights)
EnableShadows <booleanRedirectInput/boolean> (in all games since Alien Swarm)
Set the if shadows are enabled
LightColor <color255RedirectInput/color32> (in all games since Alien Swarm)
Change the light color/brightness
SetLightStyle <integerRedirectInput/integer> (in all games since Portal 2)
Change the lightstyle. (see Appearance keyvalue above for possible values)
SetPattern <stringRedirectInput/string> (in all games since Portal 2)
Set a custom pattern of light brightness for this light. (see Custom Appearance keyvalue above)
SetNearZ <floatRedirectInput/float> (in all games since Portal 2)
Sets the near Z distance.
SetFarZ <floatRedirectInput/float> (in all games since Portal 2)
Sets the far Z distance.


Parentname:
SetParent <stringRedirectInput/string>
Move with this entity. See Entity Hierarchy (parenting).
SetParentAttachment <stringRedirectInput/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 <stringRedirectInput/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.

Outputs