$blendmodulatetexture: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
($blendmodulatetextures do display in L4D2's version of Hammer.)
m (added language bar.)
Line 1: Line 1:
[[File:Blendmodulate.jpg|thumb|250px|Without vs With. The technique was first used in Day of Defeat's snow maps, such as Kalt.]]
{{lang|$blendmodulatetexture}}
[[File:Blendmodulate.jpg|thumb|250px|Without vs With. The technique was first used in {{dod|2}}'s snow maps, such as Kalt.]]
[[File:Blendmoc.jpg|thumb|250px|The green channel of DOD's <code>ground\snowblendtexture</code>.]]
[[File:Blendmoc.jpg|thumb|250px|The green channel of DOD's <code>ground\snowblendtexture</code>.]]
[[File:Blendmod_mockup.jpg|thumb|250px|A custom blend modulation mask (all channels) side-by-side its affected texture rendered in-game.]]
[[File:Blendmod_mockup.jpg|thumb|250px|A custom blend modulation mask (all channels) side-by-side its affected texture rendered in-game.]]
Line 8: Line 9:


== Caveats ==
== Caveats ==
 
* Incompatible with {{ent|$normalmapalphaenvmapmask}} (use {{ent|$envmapmask}} instead). {{todo|Only in later games?}}
* Incompatible with <code>[[$normalmapalphaenvmapmask]]</code> (use <code>[[$envmapmask]]</code> instead). {{todo|Only in later games?}}
* In {{src06|4}}, {{src07|4}}, and {{tf2|4}}, incompatible with {{ent|$basetexturetransform}} and {{ent|$detail}}.
* In {{Game name|src06|name=Source 2006}}, {{Game name|src07|name=Source 2007}}, and {{Game name|tf2|name=Team Fortress 2}}, incompatible with <code>[[$basetexturetransform]]</code> and <code>[[$detail]]</code>.
* In {{src06|4}}, also incompatible with {{ent|$envmaptint}} and {{ent|$envmapmask}}.
* In {{Game name|src06|name=Source 2006}}, additionally incompatible with <code>[[$envmaptint]]</code> and <code>[[$envmapmask]]</code>.
* In {{as|4}}, modulation textures are not aligned correctly. Use <code>$blendmasktransform "center .5 .5 scale 1 -1 rotate 90 translate 0 0"</code> to fix them up.
* In {{Game name|as|name=Alien Swarm}}, modulation textures are not aligned correctly. Use <code>$blendmasktransform "center .5 .5 scale 1 -1 rotate 90 translate 0 0"</code> to fix them up.


In some additional cases, textures will blend as if <code>$blendmodulatetexture</code> were not used:
In some additional cases, textures will blend as if <code>$blendmodulatetexture</code> were not used:
* Does not display when viewed through water. {{todo|Only in earlier games?}}
* Does not display when viewed through water. {{todo|Only in earlier games?}}
* Does not display when illuminated with player's flashlight in {{Game name|hl2|name=Half-Life 2}}. This is fixed in {{Game name|mapbase|name=Mapbase}}.
* Does not display when illuminated with player's flashlight in {{hl2|4}}. This is fixed in {{mapbase|4}}.
* Does not display in the Hammer Editor in most games. Known exceptions include {{Game name|csgo|name=Counter-Strike: Global Offensive}}, {{Game name|portal2|name=Portal 2}}, {{Game name|gmod|name=Garry's Mod}}, {{game name|l4d2|name=Left 4 Dead 2}}, and {{Game name|mapbase|name=Mapbase}}.
* Does not display in the Hammer Editor in most games. Known exceptions include {{csgo|4}}, {{portal2|4}}, {{gmod|4}}, {{l4d2|4}}, and {{mapbase|4}}.


== Parameters ==
== Parameters ==
{{MatParam|$blendmodulatetexture|texture|The modulation texture for the blending. See below for more details.}}
{{MatParam|$blendmodulatetexture|texture|The modulation texture for the blending. See below for more details.}}
{{MatParam|$blendmasktransform|matrix|Transforms the modulation texture before use in the material.
{{MatParam|$blendmasktransform|matrix|Transforms the modulation texture before use in the material.
Line 29: Line 27:


== Blend Modulation Textures ==
== Blend Modulation Textures ==
{{tip|The best way to create a modulation texture is to import the two [[albedo]]s to an image editor as layers and create an alpha channel there by hand.}}


{{tip|The best way to create a modulation texture is to import the two [[albedo]]s to an image editor as layers, and create an alpha channel there by hand.}}
Only two color channels are read from the texture:
 
Only two colour channels are read from the texture:


; Green
; Green
Line 41: Line 38:
: 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.
: 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.


There is not always a need for the texture to be high resolution - high frequency blends can be produced from low-res textures.  
There is not always a need for the texture to be high resolution—high-frequency blends can be produced from low-res textures.
 
[[Category:List of Shader Parameters|B]]
[[Category:List of Shader Parameters|B]]

Revision as of 15:08, 9 May 2022

English (en)Translate (Translate)
Without vs With. The technique was first used in Day of Defeat Day of Defeat's snow maps, such as Kalt.
The green channel of DOD's ground\snowblendtexture.
A custom blend modulation mask (all channels) side-by-side its affected texture rendered in-game.

Template:Shaderparam 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

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

Parameters

$blendmodulatetexture $blendmasktransform

$maskedblending

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:

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.
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.

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