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

$blendtintbybasealpha: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
m (Conjugation)
 
(26 intermediate revisions by 12 users not shown)
Line 1: Line 1:
'''$blendtintbybasealpha''' is a [[VMT]] parameter that allows tinting of a mesh's material using the [[$basetexture]]'s [[Alpha_channel| Alpha Channel]] as a mask to determine tint '''intensity''' (but ''not'' the tint's [[$color| RGB color]]!) Applying an actual color RGB values is done elsewhere - either in-game or in Hammer with entities using the 'fxcolor' keyvalue. This technique is used in games like Left 4 Dead 2 to allow for recoloring of the vehicle props, and in Team Fortress 2 for painting hats.  
__FORCETOC__
{{stub}}
{{this is a|shader parameter|name=$blendtintbybasealpha|shader=VertexLitGeneric|since=Left 4 Dead}} It is also available in {{src13|4.1}}.


The tint mask simply controls the intensity of tint. Brighter pixels apply more tint while darker pixels apply no tinting whatsoever.  
It allows tinting of a model's material using the [[$basetexture]]'s [[alpha channel]] as a mask to determine tint '''intensity''' (but ''not'' the tint's [[$color| RGB color]]!) Applying an actual color RGB values is done elsewhere - either in-game, in Hammer with entities using the 'rendercolor' keyvalue, or using {{cmd|$color2}} in the VMT. This technique is used in games like '''Left 4 Dead''' to allow for recoloring of the vehicle props, and in {{tf2|1.bold}} for painting hats.


'''$blendtintcoloroverbase''', a related parameter, controls the amount of color ''replacement'' versus ''tinting''. (Confirm this!)
{{bug|Not compatible with a number of shader parameters:
*[[$alphatest]] or [[$translucent]] - overrides both, disabling translucency. Use the [[Modulate]] shader as a workaround.
*[[$basealphaenvmapmask]], in {{src13|4.1}} and in {{tf2|4.1}}, fails to load the shader combo. Use a separate [[$envmapmask]].
*[[$selfillum]], fails to load the shader combo. Using a separate selfillum mask has no effect. Use [[$detail]] with <code>$detailblendmode <b>5</b></code> as a workaround.
*[[$detail]], detail texture will render and disable the tint masking. Occurs in {{Left 4 Dead 2|5}}. {{todo|Test other games.}}}}
{{note|Only compatible with [[VertexLitGeneric]].}}


==Usage==
The tint mask simply controls the intensity of tinting. The more alpha, the more intense tinting is.


{{stub}}
In practice, it is a good idea to use the mask to avoid tinting parts of the model that aren't covered by paint: either elements like lights, license plates, wheels, warning stripes, or scratched off, rusted or dirty areas, where the paint lost its effect.
 
Alternatively, this method can be used to only paint selected elements, like labels, colored glass, parts of clothing, character hair, makeup and so on.
 
<gallery mode=nolines widths=300px heights=300px>
File:Blendtint-truck-regular.jpg|Using <code>rendercolor</code> on [[prop physics]] or [[prop dynamic]] entities without <code>$blendtintbybasealpha</code>. The tint is applied across the entire texture, which in this case is undesireable.
File:Blendtint-truck-enabled.jpg|Same but with <code>$blendtintbybasealpha</code> enabled and the texture edited. The alpha channel of the texture, plus painting the base white, allows the trucks to be tinted in a desireable manner.
</gallery>
 
<gallery mode=nolines widths=300px heights=300px>
File:Blendtint-truck-textures.jpg|The example texture for the truck. The white base (top) eliminates unwanted color influences, and the alpha channel (bottom) contains the tint mask.
</gallery>
 
==$blendtintcoloroverbase==
{{src13|only}} '''$blendtintcoloroverbase''', a related parameter, controls the amount of color ''replacement'' versus ''tinting''. (replacing the color per pixel entirely, versus adding more color to make the colors closer to the tint RGB color.) A value of '0' will be full tint while a value of '1.00' will replace the [[albedo]] in the mask area with the color defined with $color2.
[[Category:Shader parameters|b]]
 
<gallery mode=nolines widths=300px heights=300px>
File:Blendtint-truck-coloroverbase.jpg|Using <code>$blendtintbybasealpha</code> as above plus <code>$blendtintcoloroverbase</code> at 1.0. The color replacement (instead of tinting) removes texture detail from the masked areas.
File:Blendtint-truck-colorreplacement.jpg|Same but with <code>$color2</code> at <code>"{255 0 0}"</code>.
</gallery>
 
{{todo|Explain the practical effect of this in better detail. What's the reason for the black colours? Is this a result of opposite colours mixing?}}
{{todo|Also explain how this is useful for creating [[skin]]s by manipulating the $color2 in the vmt while reusing the same basetexture.}}
 
==See also==
*'''[[$color]]''' and '''[[$color2]]'''

Latest revision as of 04:07, 9 June 2025

Stub

This article or section is a stub. You can help by expanding it.

$blendtintbybasealpha is a material shader parameter for the VertexLitGeneric shader available in all Source Source games since Left 4 Dead Left 4 Dead. It is also available in Source 2013 Source 2013.

It allows tinting of a model's material using the $basetexture's alpha channel as a mask to determine tint intensity (but not the tint's RGB color!) Applying an actual color RGB values is done elsewhere - either in-game, in Hammer with entities using the 'rendercolor' keyvalue, or using $color2 in the VMT. This technique is used in games like Left 4 Dead to allow for recoloring of the vehicle props, and in Team Fortress 2 for painting hats.

Icon-Bug.pngBug:Not compatible with a number of shader parameters:
Note.pngNote:Only compatible with VertexLitGeneric.

Usage

The tint mask simply controls the intensity of tinting. The more alpha, the more intense tinting is.

In practice, it is a good idea to use the mask to avoid tinting parts of the model that aren't covered by paint: either elements like lights, license plates, wheels, warning stripes, or scratched off, rusted or dirty areas, where the paint lost its effect.

Alternatively, this method can be used to only paint selected elements, like labels, colored glass, parts of clothing, character hair, makeup and so on.

$blendtintcoloroverbase

(only in Source 2013) $blendtintcoloroverbase, a related parameter, controls the amount of color replacement versus tinting. (replacing the color per pixel entirely, versus adding more color to make the colors closer to the tint RGB color.) A value of '0' will be full tint while a value of '1.00' will replace the albedo in the mask area with the color defined with $color2.

Todo: Explain the practical effect of this in better detail. What's the reason for the black colours? Is this a result of opposite colours mixing?
Todo: Also explain how this is useful for creating skins by manipulating the $color2 in the vmt while reusing the same basetexture.

See also