void readAlbedo(ivec2 coord, out vec3 albedo) {
    albedo = texelFetch(colortex0, coord, 0).rgb;
}

void readGbuffer1(ivec2 coord, out vec3 normal, out vec3 geoNormal, out float roughness) {
    vec3 ctex6 = texelFetch(colortex6, coord, 0).rgb;
    normal = decodeNormal3x16(ctex6.r);
    geoNormal = decodeNormal3x16(ctex6.g);
    roughness = ctex6.b;
}

void readGbuffer1Filter(ivec2 coord, out vec3 normal, out vec3 specNormal, out float roughness) {
    vec4 ctex6 = texelFetch(colortex6, coord, 0);
    normal = decodeNormal3x16(ctex6.r);
    specNormal = decodeNormal3x16(ctex6.a);
    roughness = ctex6.b;
}

void readGbuffer2(ivec2 coord, out vec2 lmcoord, out vec3 specularMap, out int id) {
    vec4 ctex7 = texelFetch(colortex7, coord, 0);
    lmcoord = ctex7.rg;
    vec3 specularRead = decode3x16(ctex7.b);
    specularMap.r = clamp(1 - specularRead.x, 0.089, 1.0);
        specularMap.r = specularMap.r * specularMap.r;
    specularMap.y = clamp(specularRead.y, 0.02, 0.9);
    specularMap.z = specularRead.b;
    id = int(ctex7.a*255.0);
}

void readTranslucentGBuffer(ivec2 coord, out vec3 transNorm, out vec3 transCol, out int transId) {
    vec4 ctex9 = texelFetch(colortex9, coord, 0);
    transNorm = reconstructNormal(ctex9.rg);
    transCol = decode3x16(ctex9.b);
    transId = ctex9.a*255.0 < 0.4 ? 0 : int(ctex9.a*255.0);
}