Decals are materials projected onto existing surfaces. They can be placed by the level designer, and are also generated by the engine for bullet impacts, blood, and other effects.
Decals are "sprayed" from a location and mark every surface in their path. For instance, a decal applied downward onto a staircase would cascade down onto the top (but not front) of each step.
$modelmaterialwork everywhere (see below).
- Decal tool
- Creates infodecal entities, which decal brushes and displacements.
- An entity that decals models or displacements (but not brushes). The angle of projection can be set, allowing for distortion.
- Overlay tool
- Overlays are more expensive decals that offer level designers more control.
All three of these methods create entities, albeit ones that are removed shortly after the map spawns.
activateinput, instead of when the map starts. The entity then disappears.
scripts/decals_subrect.txtcan be used! The file isn't extracted from the GCFs by the mod wizard.
CBaseEntity::DecalTrace(trace_t* pTrace, const char* decalName)
- Shared code. The trace defines where the decal is projected from and its location. To do: How to avoid transmission being suppressed due to prediction?
C_BaseEntity::AddDecal( <lots of args> );
- Client function where the decal is actually created. In most cases you are better off just calling
Normally created by the level designer. These decals last forever and are always transmitted, including to players who connect later on. Any material can be used.
engine->StaticDecal( Vector localOrigin, int decalIndex, int entityIndex, int modelIndex, bool lowpriority )
- Server only. This system does not appear use entities.
- Where the decal will be created, relative to the target's origin.
- A value received from
UTIL_PrecacheDecal(). Don't use
- Information about the target entity.
- Low priority decals are not saved/restored, and can be "re-used on the client preferentially".
UTIL_PrecacheDecal(const char *filename, bool preload)
- Returns a decal index for use with
StaticDecal(). If this is in
precache(), remember that it may be called statically; store the result in a global var.
- This section assumes that you understand the basics of material creation.
- Prevents decal texture clipping.
- Same as a brush face's texture scale value: the number of units that each texel covers. Normally 0.25 or lower. Note:This defines the size of the decal's geometry, and cannot be changed after its creation. Use $basetexturetransform if you want motion.
- A separate
VertexLitGenericmaterial to that will replace this one if the decal hits a model.
- Amount of time to spend fading out. Requires
- Delay before fadeout begins.
- To do
- To do: found in L4D2 decals/checkpoint01_black.vmt using DecalModulate shader.
For decals intended to mimic the look of pock marks or dents in a surface, the
DecalModulate (a.k.a. mod2x) shader is especially suitable: it lightens destination pixels for every source pixel that is over mid-range gray (128) and darkens any destination pixels for every source pixel that is below mid-range gray. This effect can be used to give the impression of depth when applied to a surface.
To begin, create a source image whose color channel will be used for the modulation's source values. Again, light values will lighten pixels they're drawn over, while dark values will darken the destination pixels. Mid-gray values will be treated as translucent.
Next, create an alpha channel that defines a mask for the decal. Because modulation cannot have an exact middle value currently, the mask is necessary to prevent "bordering" from occurring around the decal.
To do: Try converting source images with background colors RGB 127 127 127 with vtex found in other games other than L4D2 and see if it results in a background with RGB 124 126 124. Also, does RGB 124 126 124 apply to other versions of the Source engine as alpha for DXT1 compression?
Finally, you must create a material that uses the
DecalModulate shader. Neither
$decal are needed this time.