precision highp float;    
precision highp int;

in vec3 vPositionW;
in float vColorPixelIndex;
uniform vec3 size;
#if defined(readAlphaPropertyByte) || defined(outlinedProperty)
    uniform sampler2D propertiesSampler;
    // #typescript options?.clipPlaneUniforms()
#endif
uniform sampler2D diffuseSampler;


vec3 unpackRGBColor(float f)
{
    uint bits = uint(f);
    return vec3(
        float(bits & 0xFFu),
        float((bits >> 8u) & 0xFFu),
        float((bits >> 16u) & 0xFFu)
    ) / 255.0;
}

void main(void) {
    ivec2 textureSize = textureSize(diffuseSampler, 0);
    
    // #include ColorPickingIndex.glsl
    
    // colorPixelIndex holds the gpu picking color 
    vec3 gpuPickingColorAndAlpha = unpackRGBColor(colorPixelIndex);  
    
    #if defined(readAlphaPropertyByte) || defined(outlinedProperty)
        // #include PropertiesPixel.glsl
    #endif
    #ifdef isIFcPickingMaterial
        #ifdef requiresWorldFragment
            vec3 worldSpaceVertex = vPositionW;

            // #typescript options?.clipPlaneDiscarding()
        #endif
        
        
        if (!visible) {
            discard;
        }

        float alpha = texelFetch(diffuseSampler, ivec2(pixelIndex), 0).a;
        if (sign(alpha) < 1.0) {
            discard;
        }
    #endif
    #ifdef outlinedProperty
        
        if (!outlined) {
            discard;
        }
    #endif
    
    
    gl_FragColor = vec4(gpuPickingColorAndAlpha, 1.0);
}