$color: Difference between revisions
Deprecated (talk | contribs) (Made additional parameters a subheader of models because they only work on models, added engine branch information for $blendtintbybasealpha and $blendtintcoloroverbase) |
Deprecated (talk | contribs) (Changed to use Shaderparam and MatParam templates, added quotemarks note) |
||
Line 1: | Line 1: | ||
{{Shaderparam|$color}} It independently scales the [[RGB|red, green and blue]] channels of an [[albedo]]. There are two ways of expressing a value: | |||
$color "[ <[[float]]> <float> <float> ]" | $color "[ <[[float]]> <float> <float> ]" | ||
$color "{ <[[int]]> <int> <int> }" | $color "{ <[[int]]> <int> <int> }" | ||
The default is <code>[1 1 1]</code> or <code>{255 255 255}</code>. | The default is <code>"[1 1 1]"</code> or <code>"{255 255 255}"</code>. | ||
{{Note|You ''must'' use quotemarks, as there are space characters within the value.}} | |||
== Gamma == | == Gamma == | ||
Line 14: | Line 15: | ||
This parameter can be used ''without'' an albedo to display a solid color without the need of a texture (except a <code>[[%tooltexture]]</code>). As well as a small saving in performance and memory footprint, [[material_modify_control]] can be used to completely change the material's color at run-time if desired. | This parameter can be used ''without'' an albedo to display a solid color without the need of a texture (except a <code>[[%tooltexture]]</code>). As well as a small saving in performance and memory footprint, [[material_modify_control]] can be used to completely change the material's color at run-time if desired. | ||
In this scenario, <code>[1 1 1]</code> is pure white. | In this scenario, <code>"[1 1 1]"</code> is pure white. | ||
{{tip|If the material is representing empty blackness, you will probably want to use the <code>[[UnlitGeneric]]</code> shader to prevent it from ever becoming grey.}} | {{tip|If the material is representing empty blackness, you will probably want to use the <code>[[UnlitGeneric]]</code> shader to prevent it from ever becoming grey.}} | ||
Line 26: | Line 27: | ||
=== Additional Model Parameters === | === Additional Model Parameters === | ||
{{MatParam|$blendtintbybasealpha|bool|Enables the use of an alpha mask to define areas on the model to tint. Uses the alpha channel of the <code>$basetexture.</code> | |||
: {{Note|This parameter is also available in [[Source 2013]].}}|since=L4D}} | |||
: {{Note|This parameter is also available in [[Source 2013]].}} | {{MatParam|$blendtintcoloroverbase|float|Sets the amount to replace with solid 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 <code>$color2.</code> Default value is '0'. | ||
: {{Note|This parameter is not available in {{l4ds}} and {{As}}.}}|since=TF2}} | |||
{{MatParam|[[$allowdiffusemodulation]]|bool|Prevents the model's material from being tinted by <code>$color2</code> or <code>rendercolor.</code>|since=L4D}} | |||
: {{Note|This parameter is not available in {{l4ds}} and {{As}}.}} | {{MatParam|[[$notint]]|bool|Prevents the model's material from being tinted by <code>$color2</code> or <code>rendercolor.</code> Replaces <code>$allowdiffusemodulation</code> in {{csgo}}.|since=CSGO}} | ||
== External Links == | == External Links == |
Revision as of 11:41, 8 June 2019
Template:Shaderparam It independently scales the red, green and blue channels of an albedo. There are two ways of expressing a value:
$color "[ <float> <float> <float> ]" $color "{ <int> <int> <int> }"
The default is "[1 1 1]"
or "{255 255 255}"
.

Gamma
Source uses a gamma correction of 2.2 by default. This must be taken into account when attempting to adjust the color of a texture to match some other color in a screenshot (for example, when trying to match the color of the bottom of a skybox material to the color of fog in the map). This is done by raising the initially calculated scale to the power of 2.2 before setting the $color
value for your material. For example, if the sample (target) color in a screenshot is 120, the color of your texture at the point of interest is 240, and you want the two colors to match, you need to compute the albedo scale for your material as (120 / 240) ^ 2.2 = 0.218
(not 0.5, as one might expect).

Solid color
This parameter can be used without an albedo to display a solid color without the need of a texture (except a %tooltexture
). As well as a small saving in performance and memory footprint, material_modify_control can be used to completely change the material's color at run-time if desired.
In this scenario, "[1 1 1]"
is pure white.

UnlitGeneric
shader to prevent it from ever becoming grey.Models
A variant of $color
named $color2
is specific for use with VertexLitGeneric. It works the same way as $color
but for use on models.
$color2 "[ <float> <float> <float> ]" $color2 "{ <int> <int> <int> }"
Additional Model Parameters
$blendtintbybasealpha
$blendtintcoloroverbase
[[$allowdiffusemodulation|$allowdiffusemodulation]]
[[$notint|$notint]]