UnlitTwoTexture: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(clarified purpose)
No edit summary
 
(7 intermediate revisions by 6 users not shown)
Line 1: Line 1:
* Two base textures are multiplied together. (Just like the [http://en.wikipedia.org/wiki/Blend_modes#Multiply Multiply] blending mode in typical image editors.)
* Two base textures are multiplied together and can be [[Material proxies|transformed]] independently. (Just like the [http://en.wikipedia.org/wiki/Blend_modes#Multiply Multiply] blending mode in typical image editors.)
* Unrelated to [[WorldVertexTransition]], which is used for making alpha fading transitions between two base textures on displacements.
* Unrelated to [[WorldVertexTransition]], which is used for making alpha fading transitions between two base textures on displacements.<br>
<br>
{{note|This Shader works on both Brushes and Models}}
{{confirm| Do models require {{ent|$model}} in branches before {{csgo}}?}}
{{tip|The same effect can be created using {{cmd|$detailblendmode|8}} on '''[[UnlitGeneric]]'''.}}


[[Category:Shaders]]
[[Category:Shaders]]


===E.G.===
== Parameters ==
{{MatParamDef|$basetexture|texture|}}
The first Texture that is used, how it is used depends on the effects which are enabled.
By default <code>$basetexture</code> will be multiplied with <code>$texture2</code>.<br>
{{MatParamDef|$frame|int|The frame to start an animated <code>$texture2</code> on.}}
{{MatParamDef|$basetexturetransform|matrix|Transforms the texture before use in the material. {{VMT UVtransform}} }}
<br>
{{MatParamDef|$texture2|texture|}}
Second Texture that is used in different ways depending on which effects are used.<br>
By default <code>$basetexture</code> will be multiplied with <code>$texture2</code>.<br>
{{note|First texture is applied via {{ent|$basetexture}}.}}
{{MatParamDef|$frame2|int|The frame to start an animated <code>$texture2</code> on.}}
{{MatParamDef|$texture2transform|matrix|Transforms the texture before use in the material. {{VMT UVtransform}} }}
<br>
{{MatParamDef|$color|RGB matrix|tints the result, on brushes.}}
{{MatParamDef|$color2|RGB matrix|tints the result, on models.}}
<br>
{{MatParamDef|$beachfoam|bool|Introduced with Dangerzone, adds animated wave-like effects using a special texture|only={{csgo}}}}
{{important|This parameter is intended to be used with {{ent|$additive}}.}}
On the Dangerzone Wave Model, both <code>$texture2</code> and <code>$basetexture</code> use the 'Beachwaves' Texture.
{{todo|Do both Parameters need to use the same Texture?}}
The 'Beachwaves' Texture uses the RGB channels for different purposes.
<small>{{todo|Find a better Name for the Texture...}}</small>
* Red Channel : Waves Albedo Texture
{{todo|Can this be tinted using $color/$color2?}}
* Green Channel : Distortion/Noise for the Red Channel
* Blue Channel : Distortion/Noise for the Red Channel
{{todo|Further documentation required.}}
<br>
<br>
{{MatParamDef|$CrosshairMode|bool| Enables "Crosshair mode" using <code>$basetexture</code> for the Crosshair|only={{csgo}}}}
<code>$texture2</code> is used for a framebuffer texture.<br>
The result will be blended between <code>Crosshair Texture + CrosshairTint</code> and <code>Crosshair Texture * CrosshairTint</code> using <code>Average Luminance of $texture2 * $CrosshairColorAdapt</code>
{{MatParamDef|$CrosshairTint|RGB matrix| Tints the <code>$basetexture</code> when using <code>$CrosshairMode</code>|only={{csgo}}}}
{{MatParamDef|$CrosshairColorAdapt|float|Used for multiplying the average Luminance of <code>$texture2</code> <br>{{note|Default Value <code>"0.4"</code>}}|only={{csgo}}}}
{{MatParamDef|$translucent|bool|[[$translucent]] is a [[Expensive|expensive]] translucency using a full [[Alpha]] mask, for very fine gradients. Uses [[$basetexture]] as the source alpha, and blends [[$texture2]]'s alpha over whatever is opaque.</code>|since={{l4d}}}}
<br>
<br>
===Example===
Stock .vmt
Stock .vmt
hl2/materials/models/props_combine/portalball001_sheet.vmt
{{path|hl2/materials/models/props_combine/portalball001_sheet|vmt}}


<syntaxhighlight>
<syntaxhighlight>
Line 29: Line 71:
}
}
</syntaxhighlight>
</syntaxhighlight>
{{csgo}} {{path|models/props/hr_massive/beachwaves/beachwaves|vmt}}
<syntaxhighlight>
UnlitTwoTexture
{
    "$beachfoam"  "1"
    "$basetexture" "models/props/hr_massive/beachwaves/beachwaves"
    "$texture2"    "models/props/hr_massive/beachwaves/beachwaves"
    "$additive"    "1"
}
</syntaxhighlight>
{{l4d}} {{path|effects/smoke_plumes_anim|vmt}}
<syntaxhighlight>
UnLitTwoTexture
{
"%tooltexture" "effects/smoke_plumes_00"
$basetexture "effects/smoke_plumes_scroll"
$texture2 "effects/smoke_plumes_00"
$translucent 1
$nocull 1
$no_fullbright 1
$nofog 1
$scale "[1 1]"
$scroll "[2 2]"
Proxies
{
LinearRamp
{
resultVar "$scroll[0]"
rate -.01
}
LinearRamp
{
resultVar "$scroll[1]"
rate .035
}
TextureTransform
{
scaleVar $scale
translateVar $scroll
resultVar $basetexturetransform
}
}
}
</syntaxhighlight>
== See also ==
*<code>[[LightmappedTwoTexture]]</code>

Latest revision as of 11:40, 23 August 2025

  • Two base textures are multiplied together and can be transformed independently. (Just like the Multiply blending mode in typical image editors.)
  • Unrelated to WorldVertexTransition, which is used for making alpha fading transitions between two base textures on displacements.


Note.pngNote:This Shader works on both Brushes and Models
Confirm: Do models require $model in branches before Counter-Strike: Global Offensive?
Tip.pngTip:The same effect can be created using $detailblendmode 8 on UnlitGeneric.

Parameters

Todo: This material shader parameter has not been described.

The first Texture that is used, how it is used depends on the effects which are enabled. By default $basetexture will be multiplied with $texture2.

The frame to start an animated $texture2 on.
Transforms the texture before use in the material.
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 ?]


Todo: This material shader parameter has not been described.

Second Texture that is used in different ways depending on which effects are used.
By default $basetexture will be multiplied with $texture2.

Note.pngNote:First texture is applied via $basetexture.
The frame to start an animated $texture2 on.
Transforms the texture before use in the material.
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 ?]


tints the result, on brushes.
tints the result, on models.


$beachfoam <boolean> (only in Counter-Strike: Global Offensive)
Introduced with Dangerzone, adds animated wave-like effects using a special texture
Icon-Important.pngImportant:This parameter is intended to be used with $additive.

On the Dangerzone Wave Model, both $texture2 and $basetexture use the 'Beachwaves' Texture.

Todo: Do both Parameters need to use the same Texture?

The 'Beachwaves' Texture uses the RGB channels for different purposes.

Todo: Find a better Name for the Texture...
  • Red Channel : Waves Albedo Texture
Todo: Can this be tinted using $color/$color2?
  • Green Channel : Distortion/Noise for the Red Channel
  • Blue Channel : Distortion/Noise for the Red Channel
Todo: Further documentation required.



$CrosshairMode <boolean> (only in Counter-Strike: Global Offensive)
Enables "Crosshair mode" using $basetexture for the Crosshair

$texture2 is used for a framebuffer texture.
The result will be blended between Crosshair Texture + CrosshairTint and Crosshair Texture * CrosshairTint using Average Luminance of $texture2 * $CrosshairColorAdapt

$CrosshairTint <RGB matrix> (only in Counter-Strike: Global Offensive)
Tints the $basetexture when using $CrosshairMode
$CrosshairColorAdapt <float> (only in Counter-Strike: Global Offensive)
Used for multiplying the average Luminance of $texture2
Note.pngNote:Default Value "0.4"
$translucent <boolean> (in all games since Left 4 Dead)
$translucent is a expensive translucency using a full Alpha mask, for very fine gradients. Uses $basetexture as the source alpha, and blends $texture2's alpha over whatever is opaque.



Example

Stock .vmt 🖿hl2/materials/models/props_combine/portalball001_sheet.vmt

"UnlitTwoTexture"
{
	"$basetexture" "models/props_combine/portalball001_sheet"
	"$texture2" "models/props_combine/portalball001b_sheet"
 	"$model" 1
	"$nocull" "1"
	"$additive" "1"
	"Proxies"
	{

		"TextureScroll"
		{
			"texturescrollvar" "$texture2transform"
			"texturescrollrate" -.2
			"texturescrollangle" 60
		}
	}

}

Counter-Strike: Global Offensive 🖿models/props/hr_massive/beachwaves/beachwaves.vmt

UnlitTwoTexture
{
    "$beachfoam"   "1"
    "$basetexture" "models/props/hr_massive/beachwaves/beachwaves"
    "$texture2"    "models/props/hr_massive/beachwaves/beachwaves"
    "$additive"    "1"
}

Left 4 Dead 🖿effects/smoke_plumes_anim.vmt

UnLitTwoTexture
{
"%tooltexture" "effects/smoke_plumes_00"
$basetexture "effects/smoke_plumes_scroll"
$texture2 "effects/smoke_plumes_00"

$translucent 1

$nocull 1
$no_fullbright 1
$nofog 1
$scale "[1 1]"
$scroll "[2 2]"
Proxies
{
LinearRamp
{
resultVar "$scroll[0]"
rate -.01
}
LinearRamp
{
resultVar "$scroll[1]"
rate .035
}
TextureTransform
{
scaleVar $scale
translateVar $scroll
resultVar $basetexturetransform
}
}
}

See also