-
Notifications
You must be signed in to change notification settings - Fork 145
Projected textures
Projected textures are basically dynamic lights which can cast dynamic shadows. Mappers can place their own projected textures via the env_projectedtexture
entity. Click here for more information on projected textures in Source.
Mapbase's projected textures are made from tons of custom code gathered from the Alien Swarm SDK and open-source projects all over the Source community.
They were first created using Insolence's implementation of Alien Swarm projected textures, which in turn has improvements from City 17: Episode One's projected textures, G-String's projected textures, and the VDC fixes. From this, Mapbase adds its own improvements, like texture clipping fixes or Constant/Linear/Quadratic attenuation control.
env_projectedtexture
in Mapbase uses a lot of new I/O/KV. Instead of automatically updating when parented, there is now an "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. This means Mapbase's projected textures are fully compatible with maps that preclude Mapbase.
Mapbase raises the number of shadow depth textures to 5
, meaning you could safely use up to 4
projected textures at any time. However, you could use the -numshadowtextures
launch parameter before starting the game to set the shadow map limit yourself. This is based on the Gmod launch parameter of the same name.
Mapbase uses shader code from the aforementioned projects, including Alien Swarm, G-String, City 17: Episode One, etc. 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.
Before:
After:
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.
The projected textures in the following pictures have had their brightness scaled by 5 to make them more visible.
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.
Even though the vast majority of these changes come from other projects, Mapbase still has its own changes that help with env_projectedtexture itself. Here's some new I/O/KV that were not ported from other projects and are not known to exist elsewhere:
KeyValues
-
Constant
<float>
- The light's constant attenuation, giving the light no falloff. (This value is internally corrected with x*0.5) -
Linear
<float>
- 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) -
Quadratic
<float>
- The light's quadratic attenuation, giving the light exponentially decreasing falloff. (This value is internally corrected with x*10000) -
Shadow Atten
<float>
- 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. -
Always Draw
<bool>
- Forces the projected texture to always draw, regardless of whether the player can see its frustum. This is for projected textures that can be seen on monitors or are in the skybox. -
Don't follow target
<bool>
- Prevents the projected texture from actually following its target, if it has one. Intended to be used with "Light Only Target" so it only lights the target without actually following it.
Inputs
-
AlwaysDrawOn/Off
<void>
- Toggles the "Always Draw" keyvalue. -
SetConstant
<float>
- Sets the constant attenuation. -
SetLinear
<float>
- Sets the linear attenuation. -
SetQuadratic
<float>
- Sets the quadratic attenuation. -
SetShadowAtten
<float>
- Sets the shadow attenuation.
TODO
-
Something Index
- Something special
- Something else