/**
 * NOTE: This file is autogenerated. Do not edit.
 */
export const transparentIfcShader = {
    vertex: (options) => /* glsl */ `
        attribute vec3 position;
        attribute vec2 uv;
        
        uniform mat4 worldViewProjection;
        #ifdef requiresWorldFragment
            uniform mat4 worldMatrix;
        #endif
        
        out float vColorPixelIndex;
        #ifdef requiresWorldFragment
            out vec3 vPositionW;
        #endif
        
        void main(void) {
            #ifdef requiresWorldFragment
                vPositionW = (worldMatrix * vec4(position, 1.0)).xyz;
            #endif
            vColorPixelIndex = uv.x;
            gl_Position = worldViewProjection * vec4(position, 1.0);
        }`,
    fragment: (options) => /* glsl */ `
        precision highp float;
        
        // #typescript options?.clipPlaneUniforms()
        ${options?.clipPlaneUniforms()}
        
        uniform sampler2D diffuseSampler;
        uniform sampler2D propertiesSampler;
        uniform vec3 size;
        uniform float packSize;
        uniform vec3 highlightColors[3];
        
        // #include DitherUniforms.glsl
        #ifdef dithering
            uniform sampler2D ditherSampler;
            uniform vec2 ditherSize;
            uniform vec2 resolution;
        #endif
        
        // #include HSVMapping.glsl
        #ifdef useHSVMapping
            // Official HSV to RGB conversion 
            vec3 hsv2rgb( in vec3 c )
            {
                vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
        
                return c.z * mix( vec3(1.0), rgb, c.y);
            }
        
            // Smooth HSV to RGB conversion 
            vec3 hsv2rgb_smooth( in vec3 c )
            {
                vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 );
        
                rgb = rgb*rgb*(3.0-2.0*rgb); // cubic smoothing	
        
                return c.z * mix( vec3(1.0), rgb, c.y);
            }
        
            vec3 rgb2hsv_2(vec3 c){
                vec4 K=vec4(0.,-1./3.,2./3.,-1.),
                    p=mix(vec4(c.bg ,K.wz),vec4(c.gb,K.xy ),step(c.b,c.g)),
                    q=mix(vec4(p.xyw,c.r ),vec4(c.r ,p.yzx),step(p.x,c.r));
                float d=q.x-min(q.w,q.y),
                    e=1e-10;
                return vec3(abs(q.z+(q.w-q.y)/(6.*d+e)),d/(q.x+e),q.x);
            }
            
            uniform vec3 hsvValues;
        #endif
        
        in float vColorPixelIndex;
        #ifdef requiresWorldFragment
            in vec3 vPositionW;
        #endif
        
        void main(void) {
        
            ivec2 textureSize = textureSize(diffuseSampler, 0);
            // #include ColorPickingIndex.glsl
        float colorPixelIndex = vColorPixelIndex + 0.5;
        float uvY = floor(colorPixelIndex / float(textureSize.x)); 
        float uvX = floor(floor(colorPixelIndex) - uvY * float(textureSize.x));    
        vec2 pixelIndex = vec2(uvX, uvY);
            // #include PropertiesPixel.glsl
        vec4 properties = texelFetch(propertiesSampler, ivec2(floor(pixelIndex)), 0);
        
        int castedA = int(ceil(clamp(properties.a, 0., 1.) * 255.0));
        #ifdef depthWriteIgnoresVisibilityProperty
            int lastBitMask = 1; // Depth write bit
            int depthWriteIgnoresVisibilityValue = castedA & lastBitMask;
            bool depthWriteIgnoresVisibility = depthWriteIgnoresVisibilityValue == lastBitMask;
        #endif
        
        #ifdef visibilityProperty
            int secondLastBitMask = 2; // Visibility bit
            int visibilityValue = castedA & secondLastBitMask;
            bool visible = visibilityValue == secondLastBitMask;
        #endif
        
        #ifdef highlightProperty
            int fourthAndThirdLastBitsMask = 12; // Highlight bits
            int highlightIndex = (castedA & fourthAndThirdLastBitsMask) >> 2; // Move 2 bits right to get 0-3 range
            bool highlighted = highlightIndex != 0;
        #endif
        
        #ifdef outlinedProperty
            int fifthBitMask = 16; // Outline bit
            int outlinedValue = castedA & fifthBitMask;
            bool outlined = outlinedValue == fifthBitMask;
        #endif
        
        #ifdef ignoreClipPlanesProperty
            int sixthBitMask = 32; // Clip plane ignore bit
            int clipPlaneIgnoreValue = castedA & sixthBitMask;
            bool clipPlaneIgnore = clipPlaneIgnoreValue == sixthBitMask;
        #endif
        
        
            vec4 diffuseColor = texelFetch(diffuseSampler, ivec2(pixelIndex), 0);
        
            if (diffuseColor.a == 0.0) {
                discard;
            }
        
            #ifdef requiresWorldFragment
                vec3 worldSpaceVertex = vPositionW;
                // #typescript options?.clipPlaneDiscarding()
        ${options?.clipPlaneDiscarding()}
            #endif
        
            float opaqueness = diffuseColor.a;
        
            vec3 finalDiffuse = diffuseColor.rgb;
            
            #ifdef requiresWorldFragment
                // #typescript options?.clipPlaneColorBlending()
        ${options?.clipPlaneColorBlending()}
            #endif
        
            // #include HSVColorChanger.glsl
        #ifdef useHSVMapping
            finalDiffuse = rgb2hsv_2(finalDiffuse);
        
            finalDiffuse.x *= hsvValues.x;
            finalDiffuse.y *= hsvValues.y;
            finalDiffuse.z *= hsvValues.z;
        
            finalDiffuse = hsv2rgb_smooth(finalDiffuse);
        #endif
            
            if (!visible) {
                discard;
            }
        
            if (highlighted) {
                finalDiffuse = highlightColors[highlightIndex - 1];
            }
        
            
            #ifdef dithering
                float distanceImpact = 0.0;
                // #include DitherDiscard.glsl
        // Cranked up a bit since the new blending mode has a less noticeable impact
        float perspectiveDitherCutoffDistance = 500.0;
        float orthoDitherCutoffDistance = 1000.0;
        
        float transparency = (1.0 - step(0.99, opaqueness)) * max(1.0 - opaqueness * DITHERING_OPACITY_COEFFICIENT, 0.0);
        
        float fakeDistance = pow(min((gl_FragCoord.z / gl_FragCoord.w) / 7.5, 1.0), 1.15);
        
        vec2 samplePosition = (gl_FragCoord.xy / resolution) * ditherSize;
        vec3 dither = texture2D(ditherSampler, samplePosition).xyz;
        
        float exponent = dither.r;
        float mantissa = dither.g;
        float unpackedValue = mantissa * exp2(exponent);
        
        float transparencyWithDistanceImpact = transparency - (fakeDistance * distanceImpact * transparency);
        float depth = 0.0;
        
        if(isPerspective) {
            depth = linearizeDepth(gl_FragCoord.z, nearPlane, farPlane);
            depth = smoothstep(0.0, perspectiveDitherCutoffDistance, depth);
        } else {
            depth = smoothstep(0.0, orthoDitherCutoffDistance, orthoSize);
        }
        transparencyWithDistanceImpact = mix(transparencyWithDistanceImpact, 0.0, depth * ditherDistanceFade);
        if (unpackedValue < transparencyWithDistanceImpact) {
            discard;
        }
                const float DITHERING_COLOR_COEFFICIENT = 2.0;
                // Also make the color a bit brigther since there are fewer lit fragments
                gl_FragColor = vec4(finalDiffuse * DITHERING_COLOR_COEFFICIENT, 1.0); // Alpha does not matter here as blending is disabled when dithering is enabled
            #else
                gl_FragColor = vec4(finalDiffuse, opaqueness);
            #endif
        }`
};
//# sourceMappingURL=TransparentIfcShader.js.map