struct maskData {
    bool terrain;
    bool hand;
} mask;

struct materialData {
    float foliage;
    float emissive;
    bool beacon;
    bool unlit;
} mat;

struct pbrData {
    float roughness;
    float specular;
    float metallic;
    float sss;
} pbr;

void decodeData() {
    float maskData  = scene.sample3.r;
    float matData   = scene.sample3.g;

    vec2 pbrDecode1 = decodeV2(scene.sample2.b);
    vec2 pbrDecode2 = decodeV2(scene.sample3.b);

    mat.beacon      = unmap(matData, 0.92, 0.95)>0.5;
    mat.unlit       = unmap(matData, 0.96, 0.975)>0.5;
    
    mask.terrain    = ((maskData > 0.125) || mat.beacon);
    mask.hand       = (maskData > 0.375 && maskData < 0.75);

    mat.foliage     = unmap(matData, 0.1, 0.5);
    mat.emissive    = unmap(matData, 0.71, 0.90);

    pbr.specular    = pbrDecode1.x;
    pbr.roughness   = pow2(pbrDecode1.y);

    pbr.metallic    = pbrDecode2.x;
    pbr.sss         = pbrDecode2.y;
}