declare const _default: "\nuniform sampler2D texture_planarReflectionMap;\nuniform mat4 planarReflectionMatrix;\nuniform float planarReflectionMipmaps;\nuniform float material_reflectivity;\n\n// The weights of the cubic B-spline of the four texels around a sample position.\nvec4 planarCubicWeights(float v) {\n vec4 n = vec4(1.0, 2.0, 3.0, 4.0) - v;\n vec4 s = n * n * n;\n float x = s.x;\n float y = s.y - 4.0 * s.x;\n float z = s.z - 4.0 * s.y + 6.0 * s.x;\n return vec4(x, y, z, 6.0 - x - y - z) * (1.0 / 6.0);\n}\n\n// A mip level of the reflection, filtered by a bicubic B-spline from four bilinear taps. Where a\n// small mip level covers many pixels, this is smooth, while the bilinear filtering shows its texels.\nvec3 samplePlanarBicubic(vec2 uv, float level) {\n vec2 size = vec2(textureSize(texture_planarReflectionMap, int(level)));\n vec2 texel = uv * size - 0.5;\n vec2 f = fract(texel);\n texel -= f;\n\n vec4 wx = planarCubicWeights(f.x);\n vec4 wy = planarCubicWeights(f.y);\n vec4 c = texel.xxyy + vec2(-0.5, 1.5).xyxy;\n vec4 s = vec4(wx.xz + wx.yw, wy.xz + wy.yw);\n vec4 offset = (c + vec4(wx.yw, wy.yw) / s) / size.xxyy;\n\n vec3 s0 = {reflectionDecode}(texture2DLod(texture_planarReflectionMap, offset.xz, level));\n vec3 s1 = {reflectionDecode}(texture2DLod(texture_planarReflectionMap, offset.yz, level));\n vec3 s2 = {reflectionDecode}(texture2DLod(texture_planarReflectionMap, offset.xw, level));\n vec3 s3 = {reflectionDecode}(texture2DLod(texture_planarReflectionMap, offset.yw, level));\n\n float sx = s.x / (s.x + s.y);\n float sy = s.z / (s.z + s.w);\n return mix(mix(s3, s2, sx), mix(s1, s0, sx), sy);\n}\n\nvec3 calcReflection(vec3 reflDir, float gloss) {\n\n // Project a point a short distance along the reflected ray into the texture. For a surface\n // lying on the plane, this is the pixel the surface itself projects to. A normal tilted away\n // from the plane, by a normal map or a bevel, moves the point, distorting the reflection.\n vec4 clipPos = planarReflectionMatrix * vec4(vPositionW + reflDir * 0.2, 1.0);\n vec2 uv = getGrabScreenPos(clipPos);\n\n // rougher surfaces sample the smaller mipmaps of the texture, blurring the reflection, up to\n // its last mip level, when it has mipmaps\n vec2 size = vec2(textureSize(texture_planarReflectionMap, 0));\n float maxLevel = floor(log2(max(size.x, size.y))) * planarReflectionMipmaps;\n float lod = min((1.0 - gloss) * log2(size.x), maxLevel);\n float level = floor(lod);\n\n // the top level is sampled bilinearly, which keeps a mirror sharp, and the blurred levels by\n // the bicubic B-spline, blending the two levels around the level of detail\n vec3 reflection;\n if (level < 1.0) {\n reflection = {reflectionDecode}(texture2DLod(texture_planarReflectionMap, uv, 0.0));\n } else {\n reflection = samplePlanarBicubic(uv, level);\n }\n if (lod > level) {\n reflection = mix(reflection, samplePlanarBicubic(uv, level + 1.0), lod - level);\n }\n return reflection;\n}\n\nvoid addReflection(vec3 reflDir, float gloss) {\n dReflection += vec4(calcReflection(reflDir, gloss), material_reflectivity);\n}\n"; export default _default;