/** * Inline GLSL snippets shared by the hex-mode rendering paths. * * Co-located here so the same gradient-noise + bump primitives are reused * by `applyHexShader` (terrain bump + edge blend on the interactive hex * mesh) without re-declaring them per call site. * * These snippets are appended *raw* into Three.js' generated shaders via * `onBeforeCompile`; they are not standalone files and rely on uniforms / * varyings that the host material declares around them. */ /** * Sin-free hash + tri-linear gradient noise. Self-contained: provides * `_wHash3(p) → vec3` and `_wNoise(p) → float` (in `[0, 1]`) that the * other snippets in this file consume. */ export declare const GRADIENT_NOISE_GLSL = "\n// Sin-free polynomial hash \u2014 faster and avoids precision issues on mobile GPUs\nvec3 _wHash3(vec3 p) {\n p = fract(p * vec3(0.1031, 0.1030, 0.0973));\n p += dot(p, p.yxz + 33.33);\n return fract((p.xxy + p.yxx) * p.zyx);\n}\nfloat _wNoise(vec3 p) {\n vec3 i = floor(p);\n vec3 f = fract(p);\n vec3 u = f * f * (3.0 - 2.0 * f);\n float a = dot(_wHash3(i + vec3(0,0,0)) * 2.0 - 1.0, f - vec3(0,0,0));\n float b = dot(_wHash3(i + vec3(1,0,0)) * 2.0 - 1.0, f - vec3(1,0,0));\n float c = dot(_wHash3(i + vec3(0,1,0)) * 2.0 - 1.0, f - vec3(0,1,0));\n float d = dot(_wHash3(i + vec3(1,1,0)) * 2.0 - 1.0, f - vec3(1,1,0));\n float e = dot(_wHash3(i + vec3(0,0,1)) * 2.0 - 1.0, f - vec3(0,0,1));\n float f2= dot(_wHash3(i + vec3(1,0,1)) * 2.0 - 1.0, f - vec3(1,0,1));\n float g = dot(_wHash3(i + vec3(0,1,1)) * 2.0 - 1.0, f - vec3(0,1,1));\n float h = dot(_wHash3(i + vec3(1,1,1)) * 2.0 - 1.0, f - vec3(1,1,1));\n return mix(mix(mix(a,b,u.x), mix(c,d,u.x), u.y),\n mix(mix(e,f2,u.x),mix(g,h,u.x), u.y), u.z) * 0.5 + 0.5;\n}\n"; /** * Terrain bump-mapping — dual-octave normal perturbation for land tiles. * Submerged tiles (below the waterline on liquid worlds) are gated out via * `aLand`. Frozen / dry worlds flag every tile as land so the bump applies * uniformly across the surface. * * Injected after `normal_fragment_maps`. */ export declare const TERRAIN_NORMAL_GLSL = "\nif (vLand > 0.5 && uTerrainBumpEnabled > 0.5) {\n float _tEps = 0.025;\n\n float _tFreq = 8.0;\n float _tStrength = 0.22 * uBumpStrength;\n float _tFreq2 = 20.0;\n float _tStrength2 = 0.08 * uBumpStrength;\n\n // Primary octave bump \u2014 object-space so pattern follows rotation\n vec3 _tp1 = vObjectPos * _tFreq;\n float _th0 = _wNoise(_tp1);\n float _thx = _wNoise(_tp1 + vec3(_tEps, 0.0, 0.0));\n float _thy = _wNoise(_tp1 + vec3(0.0, _tEps, 0.0));\n float _thz = _wNoise(_tp1 + vec3(0.0, 0.0, _tEps));\n vec3 _tGrad = (vec3(_thx, _thy, _thz) - _th0) / _tEps;\n _tGrad -= normal * dot(_tGrad, normal);\n vec3 _tN = normalize(normal - _tGrad * _tStrength);\n\n // Secondary octave (sharper detail)\n vec3 _tp2 = vObjectPos * _tFreq2;\n float _th0b = _wNoise(_tp2);\n float _thxb = _wNoise(_tp2 + vec3(_tEps, 0.0, 0.0));\n float _thyb = _wNoise(_tp2 + vec3(0.0, _tEps, 0.0));\n float _thzb = _wNoise(_tp2 + vec3(0.0, 0.0, _tEps));\n vec3 _tGrad2 = (vec3(_thxb, _thyb, _thzb) - _th0b) / _tEps;\n _tGrad2 -= _tN * dot(_tGrad2, _tN);\n _tN = normalize(_tN - _tGrad2 * _tStrength2);\n\n normal = _tN;\n}\n"; /** * Edge blending — softens the hard color boundary between adjacent hex tiles. * * Near the tile edge (distance to tile center > 55% of tile radius), the * per-vertex color is progressively blended toward a world-space procedural * noise color. Because the noise field is continuous and identical on both * sides of a shared edge, the two adjacent tiles converge to the same color * at the boundary, creating a smooth gradient. * * The blend uses the vertex color's own luminance as the noise seed color, * shifted by a low-frequency noise pattern. This keeps the overall palette * intact while dissolving the sharp edges. * * Injected after `#include ` (alongside the terrain color block). */ export declare const EDGE_BLEND_GLSL = "\nif (uEdgeBlendEnabled > 0.5 && vTileRadius > 0.0) {\n float _edgeDist = length(vWorldPos - vTileCenter);\n float _edgeT = clamp(_edgeDist / vTileRadius, 0.0, 1.0);\n // Blend starts at 30% of the radius so the effect covers most of the tile\n float _edgeMix = smoothstep(0.30, 1.0, _edgeT);\n\n if (_edgeMix > 0.001) {\n // Object-space noise continuous across tile boundaries \u2014 follows rotation.\n // Single noise sample + sin-derived channels (saves 2 \u00D7 8 hash evals).\n float _en1 = _wNoise(vObjectPos * 8.0);\n float _en2 = sin(_en1 * 6.2831 + 1.85) * 0.5 + 0.5;\n float _en3 = sin(_en1 * 6.2831 + 3.71) * 0.5 + 0.5;\n\n // Noise color: wide modulation range so the blend is clearly visible\n vec3 _noiseColor = diffuseColor.rgb * (0.65 + 0.70 * vec3(_en1, _en2, _en3));\n\n diffuseColor.rgb = mix(diffuseColor.rgb, _noiseColor, _edgeMix * uEdgeBlendStrength);\n }\n}\n"; //# sourceMappingURL=hexShaderSnippets.d.ts.map