declare const _default: "\n uniform vec4 dynSkyCloudParams; // x: coverage, y: softness, z: pattern repeats per km, w: height in km\n uniform vec4 dynSkyCloudOffset; // xy: drift of the shapes, in their repeats, zw: drift of the detail\n uniform vec4 dynSkyCloudShading; // x: opacity, z: fine step per coarse step, w: offset of the jitter\n uniform vec3 dynSkyCloudLight; // the light above the clouds - color times intensity\n uniform vec3 dynSkyCloudLightDir; // direction toward the light\n\n const float DYNSKY_PLANET_RADIUS = 6371.0; // km\n\n // distance along a view ray of the given elevation to a layer at the given height, in km\n float dynSkyLayerDistance(float y, float h) {\n float b = DYNSKY_PLANET_RADIUS * y;\n return -b + sqrt(b * b + 2.0 * DYNSKY_PLANET_RADIUS * h + h * h);\n }\n\n // how visible the clouds in a direction are, 0..1 - they fade into the haze with the distance,\n // and out toward the horizon\n float dynamicSkyCloudFade(vec3 dir) {\n float t = dynSkyLayerDistance(max(dir.y, 0.0), dynSkyCloudParams.w);\n return dynSkyCloudShading.x * smoothstep(0.0, 0.08, dir.y) * exp(-t / 120.0);\n }\n\n // composites the clouds over the sky behind them, and over the lights of the sky - the sun, the\n // moon and the stars. The faded clouds let the sky behind them through. The lights are far\n // brighter than the clouds, so the little of them a faded cloud would let through would still\n // shine through it - the lights pass the clouds by their transmittance alone, and the dense\n // clouds the march stopped in block them fully\n vec3 dynamicSkyCompositeClouds(vec3 sky, vec3 lights, vec4 clouds, vec3 dir) {\n float lightsTransmit = mix(1.0, clamp((clouds.a - 0.01) / 0.99, 0.0, 1.0), dynSkyCloudShading.x);\n return sky * mix(1.0, clouds.a, dynamicSkyCloudFade(dir)) + lights * lightsTransmit + clouds.rgb;\n }\n\n #if defined(DYNSKY_CLOUDS_FLAT) || (defined(DYNSKY_CLOUDS_VOLUMETRIC) && !defined(DYNSKY_CLOUDS_BUFFER))\n uniform sampler2D dynSkyCloudMap;\n #endif\n\n #ifdef DYNSKY_CLOUDS_FLAT\n\n // the density of the clouds, 0..1\n float dynSkyFlatDensity(vec2 uv) {\n vec4 shape = texture2D(dynSkyCloudMap, uv + dynSkyCloudOffset.xy);\n float n = shape.r * 0.62 + shape.g * 0.38;\n return clamp((n - (1.0 - dynSkyCloudParams.x)) / dynSkyCloudParams.y, 0.0, 1.0);\n }\n\n // the flat clouds in a direction, lit by the light above them and the sky around them. The\n // dense cores block the light behind them fully\n vec4 dynamicSkyCloudsFlat(vec3 dir, vec3 ambient) {\n float y = max(dir.y, 0.0);\n vec3 L = normalize(dynSkyCloudLightDir);\n float mu = dot(dir, L);\n\n float t = dynSkyLayerDistance(y, dynSkyCloudParams.w);\n float density = dynSkyFlatDensity(dir.xz * (t * dynSkyCloudParams.z));\n float rim = pow(max(mu, 0.0), 8.0) * (1.0 - density) * 1.5;\n vec3 color = ambient * mix(1.0, 0.55, density) + dynSkyCloudLight * (exp(-density * 1.2) * 0.75 + rim);\n color = mix(color, ambient, 1.0 - exp(-t / 45.0));\n\n float cover = 1.0 - exp(-density * 5.0);\n float transmit = (1.0 - cover) * (1.0 - density * density * density);\n return vec4(color * (cover * dynamicSkyCloudFade(dir)), transmit);\n }\n\n #endif\n\n #if defined(DYNSKY_CLOUDS_VOLUMETRIC) && !defined(DYNSKY_CLOUDS_BUFFER)\n\n // Volumetric technique - the clouds ray marched through a layer of 3D noise.\n //\n // Adapted from the sky shaders demo of the Godot Engine demo projects,\n // https://github.com/godotengine/godot-demo-projects/tree/master/3d/sky_shaders - MIT License,\n // Copyright (c) 2014-present Godot Engine contributors, Copyright (c) 2007-2014 Juan Linietsky,\n // Ariel Manzur. Based on A. Schneider, \"The Real-Time Volumetric Cloudscapes of Horizon: Zero\n // Dawn\", SIGGRAPH 2015.\n\n uniform highp sampler2DArray dynSkyCloudShapeMap;\n uniform highp sampler2DArray dynSkyCloudDetailMap;\n uniform sampler2D dynSkyBlueNoise; // 32x32 texels\n uniform vec4 dynSkyCloudVolume; // xy: bottom and top of the layer in km, z: steps, w: steps toward the light\n\n const float DYNSKY_SHAPE_LAYERS = 64.0;\n const float DYNSKY_DETAIL_LAYERS = 32.0;\n const float DYNSKY_DETAIL_SCALE = 10.0; // repeats of the detail per repeat of the shapes\n const float DYNSKY_WEATHER_SCALE = 0.25; // repeats of the weather per repeat of the shapes\n const float DYNSKY_EXTINCTION = 50.0; // per km, at the full density\n const float DYNSKY_MAX_PATH = 20.0; // km - the longest march through the layer\n const int DYNSKY_MAX_STEPS = 128;\n\n // directions spreading the samples toward the light into a cone\n const vec3 DYNSKY_CONE[6] = vec3[6](\n vec3(0.38051305, 0.92453449, -0.02111345),\n vec3(-0.50625799, -0.03590792, -0.86163418),\n vec3(-0.32509218, -0.94557439, 0.01428793),\n vec3(0.09026238, -0.27376545, 0.95755165),\n vec3(0.28128598, 0.42443639, -0.86065785),\n vec3(-0.16852403, 0.14748697, 0.97460106)\n );\n\n // Henyey-Greenstein phase function, relative to the isotropic one\n float dynSkyCloudHg(float mu, float g) {\n float g2 = g * g;\n return (1.0 - g2) / pow(max(1.0 + g2 - 2.0 * g * mu, 1e-4), 1.5);\n }\n\n // 3D noise, stored in the layers of texture arrays and interpolated between the layers. The\n // shapes - Perlin-Worley noise, and the detail - fractal cellular noise, both 0..1\n float dynSkyShapeNoise(vec3 p) {\n float z = p.y * DYNSKY_SHAPE_LAYERS - 0.5;\n float z0 = floor(z);\n float l0 = z0 - DYNSKY_SHAPE_LAYERS * floor(z0 / DYNSKY_SHAPE_LAYERS);\n float l1 = l0 + 1.0 < DYNSKY_SHAPE_LAYERS ? l0 + 1.0 : 0.0;\n float a = textureLod(dynSkyCloudShapeMap, vec3(p.xz, l0), 0.0).r;\n float b = textureLod(dynSkyCloudShapeMap, vec3(p.xz, l1), 0.0).r;\n return mix(a, b, z - z0);\n }\n\n float dynSkyDetailNoise(vec3 p) {\n float z = p.y * DYNSKY_DETAIL_LAYERS - 0.5;\n float z0 = floor(z);\n float l0 = z0 - DYNSKY_DETAIL_LAYERS * floor(z0 / DYNSKY_DETAIL_LAYERS);\n float l1 = l0 + 1.0 < DYNSKY_DETAIL_LAYERS ? l0 + 1.0 : 0.0;\n float a = textureLod(dynSkyCloudDetailMap, vec3(p.xz, l0), 0.0).r;\n float b = textureLod(dynSkyCloudDetailMap, vec3(p.xz, l1), 0.0).r;\n return mix(a, b, z - z0);\n }\n\n // the fraction of the height through the cloud layer of a point relative to the viewer, in km\n float dynSkyHeightFraction(vec3 pos) {\n float altitude = pos.y + dot(pos.xz, pos.xz) / (2.0 * DYNSKY_PLANET_RADIUS);\n return clamp((altitude - dynSkyCloudVolume.x) / (dynSkyCloudVolume.y - dynSkyCloudVolume.x), 0.0, 1.0);\n }\n\n // the profile of the clouds over the height of the layer, by the kind of the clouds - from\n // stratus (0) over stratocumulus (0.5) to cumulus (1)\n float dynSkyHeightGradient(float h, float kind) {\n vec4 g = vec4(0.02, 0.05, 0.09, 0.11) * clamp(1.0 - kind * 2.0, 0.0, 1.0) +\n vec4(0.02, 0.2, 0.48, 0.625) * (1.0 - abs(kind - 0.5) * 2.0) +\n vec4(0.01, 0.0625, 0.78, 1.0) * clamp(kind - 0.5, 0.0, 1.0) * 2.0;\n return smoothstep(g.x, g.y, h) - smoothstep(g.z, g.w, h);\n }\n\n // the coverage of the clouds at a point of the weather pattern, 0..1. The weather gathers the\n // clouds into fields, covering a fraction of the sky growing with the coverage - the clouds of\n // a low coverage are few, rather than small - and varies the coverage within the fields\n float dynSkyFieldCoverage(float weather) {\n float coverage = dynSkyCloudParams.x;\n float spread = min(coverage * 2.5, 1.0);\n float field = smoothstep(1.0 - spread, 1.0 - spread * 0.6, weather);\n return field * max(coverage, 0.3) * mix(0.6, 1.0, weather);\n }\n\n // the density of the clouds at a point in repeats of the shapes, at the height fraction h. The\n // detail erodes the edges of the shapes. The softness thins the clouds into translucent,\n // wispy ones, or thickens them into dense clouds with crisp edges\n float dynSkyVolumeDensity(vec3 p, float h, float coverage, float kind, bool detail) {\n float shape = dynSkyShapeNoise(p + vec3(dynSkyCloudOffset.x, 0.0, dynSkyCloudOffset.y));\n float cloud = shape * dynSkyHeightGradient(h, kind) + coverage - 1.0;\n if (detail && cloud > 0.0) {\n float hfbm = dynSkyDetailNoise(p * DYNSKY_DETAIL_SCALE + vec3(dynSkyCloudOffset.z, 0.0, dynSkyCloudOffset.w));\n hfbm = mix(hfbm, 1.0 - hfbm, clamp(h * 4.0, 0.0, 1.0));\n float erosion = hfbm * mix(0.1, 0.3, h);\n cloud = (cloud - erosion) / (1.0 - erosion);\n }\n return pow(clamp(cloud, 0.0, 1.0), (1.0 - h) * 0.8 + 0.5) * (0.3 / dynSkyCloudParams.y);\n }\n\n // blue noise tiled over the pixels, offset every frame when the frames are accumulated -\n // offsets the steps of neighboring pixels, trading the banding of the few steps for a fine\n // grain. Unlike white noise, it has no clumps the 3x3 blur of the clouds when they are\n // composited would leave, and unlike a regular pattern, such as interleaved gradient noise,\n // it leaves no moire with the steps, which would crawl over the clouds as the camera turns\n float dynSkyJitter() {\n float noise = texelFetch(dynSkyBlueNoise, ivec2(gl_FragCoord.xy) & 31, 0).r;\n return fract(noise + dynSkyCloudShading.w);\n }\n\n // the volumetric clouds in a direction - the light they scatter toward the viewer, and the\n // light behind them they let through. The empty sky is crossed in coarse steps of the cheap\n // density without the detail - when they find a cloud, the march steps back and continues in\n // fine steps, until it leaves the cloud\n vec4 dynamicSkyCloudsVolumetric(vec3 dir, vec3 ambient) {\n\n // below the horizon the clouds are faded out, so the march is skipped\n float fadeIn = dynSkyCloudShading.x * smoothstep(0.0, 0.08, dir.y);\n if (fadeIn <= 0.0 || dynSkyCloudParams.x <= 0.0) {\n return vec4(0.0, 0.0, 0.0, 1.0);\n }\n\n float y = max(dir.y, 0.0);\n vec3 L = normalize(dynSkyCloudLightDir);\n float mu = dot(dir, L);\n float steps = dynSkyCloudVolume.z;\n float lightSteps = dynSkyCloudVolume.w;\n float scale = dynSkyCloudParams.z;\n\n float tStart = dynSkyLayerDistance(y, dynSkyCloudVolume.x);\n float tEnd = min(dynSkyLayerDistance(y, dynSkyCloudVolume.y), tStart + DYNSKY_MAX_PATH);\n float coarse = (tEnd - tStart) / (steps * 0.5);\n float ds = coarse * dynSkyCloudShading.z;\n\n // the samples toward the light reach about a sixth of the layer, whatever their count\n float lightStep = (dynSkyCloudVolume.y - dynSkyCloudVolume.x) / (6.0 * lightSteps);\n vec3 cloudAmbient = mix(ambient, vec3(dot(ambient, vec3(0.2126, 0.7152, 0.0722))), 0.5);\n\n // stacked phase lobes - the forward lobe gives the silver lining toward the light, the\n // others some back scattering\n float phase = max(max(dynSkyCloudHg(mu, 0.6), dynSkyCloudHg(mu, 0.4 - 1.4 * L.y)), dynSkyCloudHg(mu, -0.2));\n\n float transmittance = 1.0;\n vec3 scattered = vec3(0.0);\n float t = tStart + coarse * dynSkyJitter();\n bool inCloud = false;\n float empty = 0.0;\n float coverage = 0.0;\n float kind = 0.0;\n for (int i = 0; i < DYNSKY_MAX_STEPS; i++) {\n if (float(i) >= steps || t > tEnd || transmittance < 0.01) {\n break;\n }\n vec3 pos = dir * t;\n float h = dynSkyHeightFraction(pos);\n\n if (!inCloud) {\n // the weather gathers the clouds into fields, and sets their kind. It barely\n // changes over the fine steps through a cloud, which reuse it\n vec4 weather = textureLod(dynSkyCloudMap, (pos.xz * scale + dynSkyCloudOffset.xy) * DYNSKY_WEATHER_SCALE, 0.0);\n coverage = dynSkyFieldCoverage(weather.a);\n kind = mix(0.5, 1.0, weather.r);\n\n if (dynSkyVolumeDensity(pos * scale, h, coverage, kind, false) > 0.0) {\n inCloud = true;\n empty = 0.0;\n t -= coarse - ds;\n } else {\n t += coarse;\n }\n continue;\n }\n t += ds;\n\n // the detail is lost in the distance\n float density = dynSkyVolumeDensity(pos * scale, h, coverage, kind, t < 25.0);\n if (density <= 0.0) {\n empty += 1.0;\n inCloud = empty < 6.0;\n } else {\n empty = 0.0;\n\n // the cloud toward the light - samples spreading in a cone, and a distant one\n float lightDensity = 0.0;\n vec3 lp = pos;\n for (int j = 0; j < 6; j++) {\n if (float(j) >= lightSteps) {\n break;\n }\n lp += (L + DYNSKY_CONE[j] * float(j)) * lightStep;\n lightDensity += dynSkyVolumeDensity(lp * scale, dynSkyHeightFraction(lp), coverage, kind, false);\n }\n vec3 fp = pos + L * (3.0 * lightSteps * lightStep);\n lightDensity += dynSkyVolumeDensity(fp * scale, dynSkyHeightFraction(fp), coverage, kind, false);\n\n // the light passing through the cloud. The weaker second absorption keeps the\n // insides of the clouds bright, as the light scatters through them many times\n float depth = DYNSKY_EXTINCTION * lightDensity * lightStep;\n float beers = max(exp(-depth), exp(-depth * 0.25) * 0.4);\n\n // the sky lights the tops of the clouds more than their bases\n vec3 inScatter = dynSkyCloudLight * (beers * phase) + cloudAmbient * mix(0.3, 1.0, h);\n\n float stepTransmittance = exp(-DYNSKY_EXTINCTION * density * ds);\n scattered += inScatter * (transmittance * (1.0 - stepTransmittance));\n transmittance *= stepTransmittance;\n }\n }\n\n // the haze between the viewer and the distant clouds\n scattered = mix(scattered, ambient * (1.0 - transmittance), 1.0 - exp(-tStart / 45.0));\n return vec4(scattered * (fadeIn * exp(-tStart / 120.0)), transmittance);\n }\n\n #endif\n"; export default _default;