Lightmapped 4WayBlend
Lightmapped_4WayBlend
is the shader used to blend the vertices of a displacement surface between four different materials. It handles four at once by using mirrored sets of parameters with "2", "3", or "4" in their name.
The first 2 textures can have bumpmaps like WorldVertexTransition. If you want to use an envmap and have masking then you should use the alpha channels of the base textures and $basealphaenvmapmask. This shader does not support $normalmapalphaenvmapmask. You can use an $envmapmask texture, but you'll have to hand paint it to match what you want on the blended result.
Being a replacement of the older Multiblend shader, it was introduced to Counter-Strike: Global Offensive for the map cs_insertion.




Example
Lightmapped_4WayBlend { "$basetexture" "brick_a" "$bumpmap" "brick_a_normal" "$texture1_lumstart" "0.0" "$texture1_lumend" "0.5"
"$basetexture2" "brick_a" "$ssbump" "1" "$bumpmap2" "brick_a_normal" "$surfaceprop" "concrete" "$texture2_lumstart" "0.0" "$texture2_lumend" "0.5" "$texture2_blendmode" "0" "$texture2_blendstart" "0.8" "$texture2_blendend" "0.9" "$texture2_uvscale" "[1.0 1.0]" "$texture2_bumpblendfactor" "0.7"
"$basetexture3" "brick_a_bottom_grime" "$texture3_blendmode" "0" "$texture3_uvscale" "[2.0 2.0]" "$texture3_lumstart" "0.0" "$texture3_lumend" "0.05" "$texture3_blendstart" "0.8" "$texture3_blendend" "1.0" "$texture3_bumpblendfactor" "0.7"
"$basetexture4" "brick_a_top_grime" "$texture4_blendmode" "0" "$texture4_uvscale" "[2.0 2.0]" "$texture4_lumstart" "0.0" "$texture4_lumend" "0.2" "$texture4_blendstart" "0.90" "$texture4_blendend" "0.99" "$texture4_bumpblendfactor" "0.3"
"$detail" "detail\noise_detail_01" "$detailscale" "[ 32 32 ]" "$detailblendfactor" "0.7" "$detailblendfactor2" "0.4" "$detailblendfactor3" "0.2" "$detailblendfactor4" "0.2"
"$lumblendfactor2" "0.5" "$lumblendfactor3" "0.7" "$lumblendfactor4" "0.4" }
Controlling Blending
The pattern of the blend is defined by Hammer's sculpt window blend tool (shown in the picture on the right). The texture preview in Hammer requires you to set up additional VMT files for each texture to show up in the dialog. Those are not used by the shader itself. The Alpha Blend and Color Blend features of this dialog are disabled when using 4WayBlend, they are only used by the Multiblend material.
The blend can be tuned between being a linear gradient and a more realistic look using the luminance of each basetexture adjusted by parameters. This is done using some simple math in the shader, and avoids requiring extra textures.
Luminance Adjust
The lumstart and lumend parameters adjust the luminance value into a usable range with a smoothstep.
luminance = smoothstep( lumstart, lumend, luminanceof(basetexture) )
You can think of this as adjusting the contrast of the luminance. In general, you need more contrast to get a more interesting blend.

Luminance Blending
When blending a given layer, you can choose between using the luminance of that layer or the inverse of blended luminance of the layers below it. This is done with the lumblendfactor parameters.
Vertex Blend Modulate
The resulting luminance is used to modulate the vertex blend value with this formula:
blend = vertexblend * luminance + vertexblend
.
The vertexblend is what you paint using the blend tool in hammer.
Blend Adjust
Finally, the result of that formula is adjusted by another smoothstep with the blendstart and blendend parameters.
blend = smoothstep( blendstart, blendend, blend )
You can think of this as adjusting the sharpness of the blend.
Parameters and Effects
Most of these parameters have counterparts that can be applied to the first, second, third or fourth layers of a material. For brevity's sake, this will be indicated by [null/1/2/3/4]
where applicable, where they may be interchanged. Note that "null
" means that, if intended for use with the first layer, there should simply be no number in that place (only EITHER null or 1 will be applicable in these cases). Only one of the options in [null/1/2/3/4]
should be used; do not actually write "null/1/2/3/4" as such.
$basetexture[null/2/3/4] <texture>
- See
$basetexture
. Defines the albedo texture for a given layer. $surfaceprop[null/2/3/4] <texture>
- See
$surfaceprop
. Defines the type of surface and its properties for a given layer. $bumpmap[null/2/3/4] <texture>
- See
$bumpmap
. Defines the bumpmap for a given layer. $ssbump <bool>
- See
$ssbump
. Defines whether or not the bumpmap is self-shadowing.
$texture[1/2/3/4]_lumstart <normal>
- Used with
$texture[1/2/3/4]_lumend
to adjust the luminance range used to modulate blending. $texture[1/2/3/4]_lumend <normal>
Note:A smoothstep operation is performed on the luminance of the texture, like so:
smoothstep(lumstart, lumend, luminanceof(texture))
.$texture[1/2/3/4]_uvscale "[<float X> <float Y>]"
- Sets the scale of the UV.
Note:Base texture is assumed to be 512x512px, larger textures will be scaled to fit 512x512.
Note:Changing UV scale of the base texture will scale all other textures as well, and can be compensated for by scaling other textures in the opposite direction.
$texture[2/3/4]_blendstart <normal>
- Used with
$texture[2/3/4]_blendend
to define the blend range in a given layer. $texture[2/3/4]_blendend <normal>
Note:A smoothstep operation is performed on the blend, like so:
smoothstep(blendstart, blendend, blend)
.$texture[2/3/4]_blendmode <int>
- Defines the blend mode for a given layer. You can choose between normal blending by setting it to 0, the default, or modulate 2x blending by setting it to 1.
$texture[2/3/4]_bumpblendfactor <normal>
- Defines how much the $bumpmap is shown for a given layer.
Note:If the material has a
$bumpmap[null/2/3/4]
defined, then this parameter is ignored. Instead the bumpmaps blend the same as they would in WorldVertexTransition.
$detail <texture>
- See
$detail
. Defines a detail texture for the whole material. Confirm:Does
$detail[2/3/4]
exist/can it be used?$detailblendfactor[null/2/3/4] <normal>
- See
$detailblendfactor
. Acts as a sort of opacity for the$detail
texture specified.
$lumblendfactor[2/3/4] <normal>
- Defines luminance value to use for blending for a given layer.
Confirm:Does
$lumblendfactor1
exist?Note:This is choosing between the luminance of the given layer and the inverse of the blended luminance of the layers below it using a lerp:
lerp( 1 - blended_lum_of_layers_below, lum_of_current_layer, lumblendfactor )