This article's documentation is for anything that uses the Source engine. Click here for more information.

$blendmodulatetexture

From Valve Developer Community
Jump to: navigation, search
English (en)Translate (Translate)
Without vs With. The technique was first used in Day of Defeat: Source Day of Defeat: Source's snow maps, such as Kalt.
The green channel of Day of Defeat: Source Day of Defeat: Source's 🖿ground/snowblendtexture.vtf.
Several (non-snowy) Left 4 Dead series Left 4 Dead series materials also use this texture, under a different name.
A custom blend modulation mask (all channels) side-by-side its affected texture rendered in-game.

$blendmodulatetexture is a material shader parameter for the LightmappedGeneric and WorldVertexTransition shader available in all Source Source games since Source 2006 Source 2006. It changes the transition between the textures from a smooth, linear gradient to one "stamped" with a pattern.

Tip.pngTip:You should use $blendmodulatetexture wherever possible, as the improvement in visual quality is immense!

Caveats

Todo: Only in later games? If so, which?

In some additional cases, textures will blend as if $blendmodulatetexture were not used:

Parameters

The modulation texture for the blending. See below for more details.
Transforms the modulation texture before use in the material.
Note.pngNote:Requires $MaskedBlending and a $BumpTransform that is not an identity matrix (It needs to have Non-Default Values).
The default position is center .5 .5 scale 1 1 rotate 0 translate 0 0.
  1. center defines the point of rotation. Only useful if rotate is being used.
  2. scale fits the texture into the material the given number of times. 2 1 is a 50% scale in the horizontal X axis while the vertical Y axis is still at original scale.
  3. rotate rotates the texture counter-clockwise in degrees. Accepts any number, including negatives.
  4. translate shifts the texture by the given numbers. .5 will shift it half-way. 1 will shift it once completely over, which is the same as not moving it at all.
Note.pngNote:All values must be included!
Icon-Bug.pngBug:Scaling the texture may cause odd issues where the Texture Lock tool in Hammer will not actually lock the texture in place.  [todo tested in?]
Icon-Bug.pngBug:Rotating textures applied on brushes will rotate around the map origin (confirm: Orangebox engine only?). A fix for this is to change the center position in the VMT to the brush's origin.  [todo tested in?]
Makes the shader use the modulation texture for the blend factor instead of using the vertex alpha from the displacement.
Icon-Bug.pngBug:The surface must still be a displacement in order to blend properly.  [todo tested in?]

Blend Modulation Textures

Tip.pngTip:The best way to create a modulation texture is to import the two albedos to an image editor as layers and create an alpha channel there by hand.

Only two color channels are read from the texture:

Red
Sharpens. 0 makes the transition binary, 255 effectively disables modulation.
The red channel of Valve's snow modulation texture is a constant 99, which produces a fairly sharp falloff. Using different values in different places has the potential to produce a more complex effect.
Green
Biases in favor of $basetexture; high-value areas will be the most resistant to modulation. 128 is normal.
The idea is to paint noise and patterns into this channel, so that the edge between the two textures becomes irregular. Valve's snow texture (see right) has lots of ragged edges in the green channel, and even some bootprints. There are also lines painted along the edges of the albedo's bricks that give them a tendency to have snow along their edges.

There is not always a need for the texture to be high resolution—high-frequency blends can be produced from low-res textures.