Combining Base Color Factor and Texture in glTF
In the glTF 2.0 physically based rendering (PBR) specification, the
final surface color is determined by blending the material's
baseColorFactor and the baseColorTexture. This
article explains the mathematical formula used to combine these two
inputs, how color space conversions apply, and how renderers handle
default values when one of the elements is omitted.
The Combination Formula
The baseColorFactor and baseColorTexture
are combined using component-wise multiplication, also known as
modulation or tinting.
Both the RGB color components and the alpha transparency channel are multiplied directly:
- Red: \(Color_{final}.r = Texture.r \times Factor.r\)
- Green: \(Color_{final}.g = Texture.g \times Factor.g\)
- Blue: \(Color_{final}.b = Texture.b \times Factor.b\)
- Alpha: \(Color_{final}.a = Texture.a \times Factor.a\)
In vector notation within a shader, this is expressed simply as:
vec4 finalBaseColor = textureColor * baseColorFactor;
Because the operation is multiplicative, multiplying by a factor of
1.0 preserves the original texture value, while values
below 1.0 darken or tint the texture.
Color Space Considerations
Proper color space conversion is required before this multiplication takes place:
baseColorTexture: Image files (such as PNG or JPEG) assigned tobaseColorTextureare encoded in the sRGB color space. The rendering engine must decode the sRGB color channels (RGB) into linear space before multiplying. The alpha channel (A) is already linear and does not require sRGB-to-linear decoding.baseColorFactor: The values defined in the glTF JSON array[R, G, B, A]are already defined in linear space. No decoding is necessary.
The multiplication must strictly occur in linear space to maintain physically accurate rendering.
Defaults and Edge Cases
The glTF specification defines fallback behaviors depending on which properties are defined in the material:
- Both Texture and Factor Present: The linear texture sample is multiplied by the factor as described above.
- Texture Present, Factor Omitted: The
baseColorFactordefaults to[1.0, 1.0, 1.0, 1.0]. The texture colors remain unchanged. - Factor Present, Texture Omitted: The material
displays a solid linear color determined solely by
baseColorFactor. - Both Omitted: The base color defaults entirely to
solid white (
[1.0, 1.0, 1.0, 1.0]) at full opacity.