Lightmapped 4WayBlend: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
Line 41: Line 41:
== Controlling Blending ==
== Controlling Blending ==


[[File:multiblend_box.jpg|thumb|250px|The blend tools inside the displacement sculpt window.]]
{|
 
| 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 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.
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.
| [[Image:SculptBlendDialog 4WayBlend.jpg|thumb|160px|The blend tools inside the displacement sculpt window.]]
|}


=== Luminance Adjust ===
== Luminance Adjust ==


The lumstart and lumend parameters adjust the luminance value into a usable range with a [http://en.wikipedia.org/wiki/Smoothstep smoothstep].
The lumstart and lumend parameters adjust the luminance value into a usable range with a [http://en.wikipedia.org/wiki/Smoothstep smoothstep].
Line 53: Line 54:
You can think of this as adjusting the contrast of the luminance. In general, you need more contrast to get a more interesting blend.
You can think of this as adjusting the contrast of the luminance. In general, you need more contrast to get a more interesting blend.


=== Vertex Blend Modulate ===
{|
| [[File:GrimeTextureLum.jpg|thumb|180px|Luminance without any adjusting]] ||[[File:GrimeTextureLumAdjust1.jpg|thumb|180px|lumstart = 0.0, lumend = 0.5]] ||[[File:GrimeTextureLumAdjust2.jpg|thumb|180px|lumstart = 0.0, lumend = 0.2]]
|}
 
== Vertex Blend Modulate ==


The resulting luminance is used to modulate the vertex blend value with this formula:
The resulting luminance is used to modulate the vertex blend value with this formula:
Line 59: Line 64:
The vertexblend is what you paint using the blend tool in hammer.
The vertexblend is what you paint using the blend tool in hammer.


=== Blend Adjust ===
== Blend Adjust ==


Finally, the result of that formula is adjusted by another [http://en.wikipedia.org/wiki/Smoothstep smoothstep] with the blendstart and blendend parameters.
Finally, the result of that formula is adjusted by another [http://en.wikipedia.org/wiki/Smoothstep smoothstep] with the blendstart and blendend parameters.

Revision as of 16:18, 21 January 2014

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.

Note.pngNote:This shader only works on displacements.
Note.pngNote:This shader is only available in Counter-Strike: Global Offensive Counter-Strike: Global Offensive as of January 2014.

Example

Lightmapped_4WayBlend
{
    "$basetexture"         "de_cbble/stone_alt/brick_a"
    "$bumpmap"             "de_cbble/stone_alt/brick_a_normal"
"$basetexture2" "de_cbble/stone_alt/brick_a_damaged" "$bumpmap2" "de_cbble/stone_alt/brick_a_damaged_normals" "$texture2_uvscale" "[1.0 1.0]" "$texture2_lumstart" "0.0" "$texture2_lumend" "0.8" "$texture2_blendstart" "0.8" "$texture2_blendend" "0.9"
"$basetexture3" "de_cbble/stone_alt/brick_a_bottom_grime" "$texture3_blendmode" "0" "$texture3_uvscale" "[2.0 2.0]" "$texture3_lumstart" "0.005" "$texture3_lumend" "0.05" "$texture3_blendstart" "0.8" "$texture3_blendend" "1.0"
"$basetexture4" "de_cbble/stone_alt/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"
"$detail" "detail\noise_detail_01" "$detailscale" "[ 20 20 ]" "$detailblendfactor" ".7" "$detailblendfactor2" ".4" "$detailblendfactor3" ".2" "$detailblendfactor4" ".2" }

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.

The blend tools inside the displacement sculpt window.

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 without any adjusting
lumstart = 0.0, lumend = 0.5
lumstart = 0.0, lumend = 0.2

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.

Supported effects

The effects supported by LightmappedGeneric plus:

See also