Difference between revisions of "$color"

From Valve Developer Community
Jump to: navigation, search
(hit save by mistake!)
Line 17: Line 17:
  
 
{{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.}}
 +
 +
== Models ==
 +
 +
A variant of '''<code>$color</code>''' named '''<code>$color2</code>''' is specific for use with '''<code>VertexLitGeneric</code>'''. It works the same way as '''<code>$color</code>''' but for use on models.
 +
 +
$color2 "[ <[[normal]]> <normal> <normal> ]"
 +
$color2 "{ <[[int]]> <int> <int> }"
 +
 +
== Additional parameters ==
 +
 +
; <code>$blendTintByBaseAlpha <[[boolean]]></code>
 +
: Enables the use of a mask to define areas to color. Uses the mask of the Base Texture.
 +
; <code>$blendTintColorOverBase <[[float]]></code>
 +
: Positive values begin to replace dark areas on the [[albedo]] with solid color (to white) while negative values begin to remove color (to black).
  
 
[[Category:List of Shader Parameters|C]]
 
[[Category:List of Shader Parameters|C]]

Revision as of 19:09, 23 December 2011

$color independently scales the red, green and blue channels of an albedo. There are two ways of expressing a value:

$color "[ <normal> <normal> <normal> ]"
$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.

Tip.png Tip: If the material is representing empty blackness, you will probably want to use the 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 "[ <normal> <normal> <normal> ]"
$color2 "{ <int> <int> <int> }"

Additional parameters

$blendTintByBaseAlpha <boolean>
Enables the use of a mask to define areas to color. Uses the mask of the Base Texture.
$blendTintColorOverBase <float>
Positive values begin to replace dark areas on the albedo with solid color (to white) while negative values begin to remove color (to black).