env_projectedtexture
env_projectedtexture is an existing point entity available
with all versions of Mapbase.Projected textures are basically dynamic lights which can cast dynamic shadows. Mapbase’s projected textures are in large part based on code originating from the Alien Swarm SDK, snippets from the Valve Developer Community, and the original G-String code release. From this, Mapbase adds its own improvements, like texture clipping fixes or Constant/Linear/Quadratic attenuation control.
While the traditional VDC fix automatically updates the projected texture when parented, Mapbase uses Alien Swarm’s “Always Update” spawnflag for control over whether the projected texture updates. However, projected textures made before Mapbase (detected by checking a static keyvalue) will still use the VDC fix for automatically updating when there’s a parent.
Mapbase raises the number of shadow depth textures to 5. Since the player’s flashlight occupies one of those textures, you could safely use up to 4 projected textures at any time. However, you could also use the -numshadowtextures launch parameter (based on the Gmod parameter of the same name) before starting the game to set the shadow map limit yourself. This parameter could be set through gameinfo.txt’s newly supported CommandLine keyvalue.
Shader changes for projected textures
See also: Other Shader Changes
The shader changes alone fix most of the bugs the VDC fixes couldn’t fix, including the “reverse projection” bug and the bug with decals not receiving casted shadows. These shader changes also use a new shadow calculation method which makes shadows appear much sharper.
The changes also fix a long-standing bug with Source 2013 projected textures that calculates the attenuation with the player’s view, rather than the light’s origin. This is very noticeable in the comparison pictures below. (Click on an image to expand it)
By default, Mapbase uses a shadow map resolution of 2048 with a filter size of 0.5. This can be changed in imaterialsystem.h. See this section on the Valve Developer Community for more information.
KeyValues
Prevents this entity from trying to point at its target, if it has one. Intended for when you want to use 'Light Only Target' without the entity trying to point to it.
The horizontal FOV value. This allows the projected texture to use rectangular dimensions. Leave this at 0 if you want to keep this the same as the regular FOV value.
The attenuation of the shadows, or how much the shadows should fade into the light of the projected texture, if at all. The player's flashlight uses 0.35 by default, although higher values may be needed for a visible effect.
The amount to filter the shadows. This blurs shadows to make them appear less pixelated, but higher values may have more visible noise.
The light color's brightness scale.
Amount of time it takes for a color or brightness change to occur. 0 = instant
The light's constant attenuation, giving the light no falloff. (This value is internally corrected with x*0.5)
The light's linear attenuation, giving the light linear decline. This is the most common attenuation for projected textures. (This value is internally corrected with x*100)
The light's quadratic attenuation, giving the light exponentially decreasing falloff. (This value is internally corrected with x*10000)
The texture which should be used. Please note that env_projectedtexture uses .vtf files directly and does not use .vmt files. The material browser is only available here to assist with finding textures since materials typically have the same name as their textures.
Sets the frame of the projected texture. Only relevant if the texture is animated/has multiple frames.
Always draws the projected texture, regardless of whether the player can see its frustum. Use this for projected textures that can be seen on monitors or in the skybox.
(Don't change). Differentiates between projected textures built before/outside of Mapbase and projected textures using new features.
Flags
Inputs
Turns on per frame updating (for moving lights)
Turns off per frame updating (for moving lights)
Sets the FOV.
Sets the vertical FOV.
Sets the horizontal FOV.
Sets the spotlight texture
Sets the spotlight texture frame
Set the if shadows are enabled
Change the light color
Sets brightness.
Sets the color transition time.
Sets the constant attenuation.
Sets the linear attenuation.
Sets the quadratic attenuation.
Sets the shadow attenuation.
Sets the shadow filter.
Sets NearZ.
Sets FarZ.
Turns off BBox culling (for skybox or monitor lights)
Turns on BBox culling if it was off before
Causes this entity to stop following the target, if it has one
Causes this entity to start following the target if it was set to not follow it before
