palette

  • Creates palette textures containing all unique values of scalar Material properties within the scene, then merges materials. For scenes with many solid-colored materials (often found in CAD, architectural, or low-poly styles), texture palettes can reduce the number of materials used, and significantly increase the number of Mesh objects eligible for join operations.

    Materials already containing texture coordinates (UVs) are not eligible for texture palette optimizations. Currently only a material's base color, alpha, emissive factor, metallic factor, and roughness factor are converted to palette textures.

    Example:

    import { palette, flatten, dequantize, join } from '@gltf-transform/functions';
    
    await document.transform(
        palette({ min: 5 }),
        flatten(),
        dequantize(),
        join()
    );
    

    The illustration below shows a typical base color palette texture:

    Row of colored blocks

Function symbol, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy. Documentation built with greendoc and published under Creative Commons Attribution 3.0.