Skip to content

Projected textures

Blixibon edited this page Aug 26, 2019 · 11 revisions

A projected texture projects a texture onto the surfaces of brushes/models and (optionally) casts dynamic shadows. It's normally used to create dynamic light, like the player's flashlight. Mappers can place their own projected textures via the "env_projectedtexture" entity. Click here for more information on projected textures in Source.


In most Source games, only one shadow-casting projected texture could be active at the time, including the player's flashlight. It also suffered from several noticeable bugs in earlier branches of the engine, including Source 2013.

Mapbase's projected textures are a mix of Insolence's implementation of Alien Swarm projected textures, City 17: Episode One's projected textures, G-String's projected textures, the VDC fixes, and Mapbase's own adjustments. It sounds like a nightmarish projected Frankenstein, but overall, they've become more stable, more flexible, and much more usable. Most of the bugs they suffered from in Source 2013 have been fixed and up to 5 shadow-casting projected textures can be active at a time, including the player's flashlight. 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.

Most of the work involved is based off of the Alien Swarm SDK, meaning env_projectedtextures use a lot of Alien Swarm I/O/KV and features, like the "Always Update" spawnflag. There's some other new features as well, like the ability to set the FOV's width and height separately, a feature from City 17: Episode One.


Shader changes

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. It also adds a "reflection" on brush surfaces and changes the way projected textures fade out, among other things.

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.

Other new options

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

  • Always Draw <boolean> - 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 <boolean> - 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.

Clone this wiki locally