declare const _default: "\n#ifndef ENV_ATLAS\n#define ENV_ATLAS\nuniform sampler2D texture_envAtlas;\n#endif\nuniform float material_reflectivity;\n\n// calculate mip level for shiny reflection given equirect coords uv.\nfloat shinyMipLevel(vec2 uv) {\n vec2 dx = dFdx(uv);\n vec2 dy = dFdy(uv);\n\n // calculate second dF at 180 degrees\n vec2 uv2 = vec2(fract(uv.x + 0.5), uv.y);\n vec2 dx2 = dFdx(uv2);\n vec2 dy2 = dFdy(uv2);\n\n // calculate min of both sets of dF to handle discontinuity at the azim edge\n float maxd = min(max(dot(dx, dx), dot(dy, dy)), max(dot(dx2, dx2), dot(dy2, dy2)));\n\n return clamp(0.5 * log2(maxd) - 1.0 + textureBias, 0.0, 5.0);\n}\n\nvec3 calcReflection(vec3 reflDir, float gloss) {\n vec3 dir = cubeMapProject(reflDir) * vec3(-1.0, 1.0, 1.0);\n vec2 uv = toSphericalUv(dir);\n\n // calculate roughness level\n float level = saturate(1.0 - gloss) * 5.0;\n float ilevel = floor(level);\n\n // accessing the shiny (top level) reflection - perform manual mipmap lookup\n float level2 = shinyMipLevel(uv * atlasSize);\n float ilevel2 = floor(level2);\n\n vec2 uv0, uv1;\n float weight;\n if (ilevel == 0.0) {\n uv0 = mapShinyUv(uv, ilevel2);\n uv1 = mapShinyUv(uv, ilevel2 + 1.0);\n weight = level2 - ilevel2;\n } else {\n // accessing rough reflection - just sample the same part twice\n uv0 = uv1 = mapRoughnessUv(uv, ilevel);\n weight = 0.0;\n }\n\n vec3 linearA = $DECODE(texture2D(texture_envAtlas, uv0));\n vec3 linearB = $DECODE(texture2D(texture_envAtlas, uv1));\n vec3 linear0 = mix(linearA, linearB, weight);\n vec3 linear1 = $DECODE(texture2D(texture_envAtlas, mapRoughnessUv(uv, ilevel + 1.0)));\n\n return processEnvironment(mix(linear0, linear1, level - ilevel));\n}\n\nvoid addReflection(vec3 reflDir, float gloss) { \n dReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);\n}\n"; export default _default;