/** * @zendir/ui - ZenSpace3D Shaders * * Advanced GLSL shaders for atmosphere, glow effects, coverage visualization, * and other space rendering effects. */ export declare const atmosphereVertexShader = "\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nvoid main() {\n vNormal = normalize(normalMatrix * normal);\n vPosition = position;\n \n // Calculate intensity based on view angle\n vec4 worldPosition = modelMatrix * vec4(position, 1.0);\n vec3 viewDirection = normalize(cameraPosition - worldPosition.xyz);\n vIntensity = pow(0.65 - dot(vNormal, viewDirection), 2.0);\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"; export declare const atmosphereFragmentShader = "\nvarying vec3 vNormal;\nvarying vec3 vPosition;\nvarying float vIntensity;\n\nuniform vec3 glowColor;\nuniform float glowIntensity;\n\nvoid main() {\n // Fresnel-based glow\n float intensity = vIntensity * glowIntensity;\n \n // Add subtle color variation\n vec3 color = glowColor * intensity;\n \n // Fade at edges for smoother blending\n float alpha = intensity * 0.8;\n \n gl_FragColor = vec4(color, alpha);\n}\n"; export declare const starsVertexShader = "\nattribute float opacity;\nattribute float size;\nattribute vec3 customColor;\n\nvarying float vOpacity;\nvarying vec3 vColor;\n\nuniform float time;\nuniform float pointSize;\n\nvoid main() {\n vOpacity = opacity;\n vColor = customColor;\n \n // Twinkle effect\n float twinkle = sin(time * (0.5 + opacity * 2.0) + opacity * 100.0) * 0.5 + 0.5;\n vOpacity = opacity * (0.6 + twinkle * 0.4);\n \n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n \n // Size attenuation\n float sizeMultiplier = size > 0.0 ? size : 1.0;\n gl_PointSize = pointSize * sizeMultiplier * (300.0 / -mvPosition.z);\n gl_PointSize = clamp(gl_PointSize, 0.5, 8.0);\n \n gl_Position = projectionMatrix * mvPosition;\n}\n"; export declare const starsFragmentShader = "\nvarying float vOpacity;\nvarying vec3 vColor;\n\nvoid main() {\n // Circular point with soft edge\n vec2 center = gl_PointCoord - vec2(0.5);\n float dist = length(center);\n \n if (dist > 0.5) discard;\n \n // Soft glow falloff\n float alpha = smoothstep(0.5, 0.0, dist) * vOpacity;\n \n // Apply color\n vec3 color = vColor.r > 0.0 ? vColor : vec3(1.0, 1.0, 1.0);\n \n gl_FragColor = vec4(color, alpha);\n}\n"; export declare const coverageVertexShader = "\nvarying vec2 vUv;\nvarying vec3 vNormal;\nvarying vec3 vPosition;\n\nvoid main() {\n vUv = uv;\n vNormal = normalize(normalMatrix * normal);\n vPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"; export declare const coverageFragmentShader = "\nuniform sampler2D coverageMap;\nuniform vec3 lowColor;\nuniform vec3 highColor;\nuniform float opacity;\nuniform float time;\n\nvarying vec2 vUv;\nvarying vec3 vNormal;\nvarying vec3 vPosition;\n\nvoid main() {\n // Sample coverage value\n float coverage = texture2D(coverageMap, vUv).r;\n \n // Animated pulse for active areas\n float pulse = sin(time * 2.0) * 0.1 + 0.9;\n coverage *= coverage > 0.5 ? pulse : 1.0;\n \n // Color gradient\n vec3 color = mix(lowColor, highColor, coverage);\n \n // Fresnel edge highlight\n vec3 viewDir = normalize(cameraPosition - vPosition);\n float fresnel = pow(1.0 - dot(vNormal, viewDir), 2.0);\n color += vec3(0.1, 0.3, 0.5) * fresnel * coverage;\n \n // Hexagon pattern overlay (subtle)\n float hexPattern = fract(vUv.x * 20.0 + vUv.y * 10.0);\n color *= 0.95 + hexPattern * 0.05;\n \n gl_FragColor = vec4(color, coverage * opacity);\n}\n"; export declare const visibilityConeVertexShader = "\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying float vDistFromApex;\n\nuniform vec3 apexPosition;\n\nvoid main() {\n vPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n vNormal = normalize(normalMatrix * normal);\n vDistFromApex = distance(position, apexPosition);\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"; export declare const visibilityConeFragmentShader = "\nuniform vec3 coneColor;\nuniform float coneOpacity;\nuniform float time;\n\nvarying vec3 vPosition;\nvarying vec3 vNormal;\nvarying float vDistFromApex;\n\nvoid main() {\n // Fresnel effect for edge visibility\n vec3 viewDir = normalize(cameraPosition - vPosition);\n float fresnel = pow(1.0 - abs(dot(vNormal, viewDir)), 2.0);\n \n // Animated scan line effect\n float scan = fract(vDistFromApex * 0.001 - time * 0.5);\n scan = smoothstep(0.0, 0.1, scan) * smoothstep(0.2, 0.1, scan);\n \n // Distance-based opacity (fade towards apex)\n float distFade = smoothstep(0.0, 500.0, vDistFromApex);\n \n // Combine effects\n float alpha = (fresnel * 0.3 + 0.1 + scan * 0.2) * coneOpacity * distFade;\n \n gl_FragColor = vec4(coneColor, alpha);\n}\n"; export declare const orbitLineVertexShader = "\nattribute float lineDistance;\nvarying float vLineDistance;\nvarying float vOpacity;\n\nuniform float totalLength;\nuniform float time;\nuniform float dashScale;\n\nvoid main() {\n vLineDistance = lineDistance;\n \n // Animated dash effect\n float animOffset = mod(time * 0.5, 1.0) * totalLength;\n float dashPos = mod(lineDistance + animOffset, dashScale);\n vOpacity = smoothstep(0.0, dashScale * 0.3, dashPos) * \n smoothstep(dashScale, dashScale * 0.7, dashPos);\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"; export declare const orbitLineFragmentShader = "\nuniform vec3 lineColor;\nuniform float lineOpacity;\n\nvarying float vLineDistance;\nvarying float vOpacity;\n\nvoid main() {\n gl_FragColor = vec4(lineColor, lineOpacity * vOpacity);\n}\n"; export declare const objectGlowVertexShader = "\nvarying vec3 vNormal;\nvarying vec3 vViewPosition;\n\nvoid main() {\n vNormal = normalize(normalMatrix * normal);\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n vViewPosition = -mvPosition.xyz;\n \n gl_Position = projectionMatrix * mvPosition;\n}\n"; export declare const objectGlowFragmentShader = "\nuniform vec3 glowColor;\nuniform float glowIntensity;\nuniform float glowPower;\n\nvarying vec3 vNormal;\nvarying vec3 vViewPosition;\n\nvoid main() {\n vec3 viewDir = normalize(vViewPosition);\n float fresnel = pow(1.0 - abs(dot(vNormal, viewDir)), glowPower);\n \n vec3 color = glowColor * glowIntensity * fresnel;\n float alpha = fresnel * glowIntensity;\n \n gl_FragColor = vec4(color, alpha);\n}\n"; export declare const selectionRingVertexShader = "\nvarying vec2 vUv;\n\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"; export declare const selectionRingFragmentShader = "\nuniform vec3 ringColor;\nuniform float time;\nuniform float ringWidth;\nuniform float ringRadius;\n\nvarying vec2 vUv;\n\nvoid main() {\n vec2 center = vUv - vec2(0.5);\n float dist = length(center);\n \n // Ring shape\n float ring = smoothstep(ringRadius - ringWidth, ringRadius, dist) *\n smoothstep(ringRadius + ringWidth, ringRadius, dist);\n \n // Animated rotation\n float angle = atan(center.y, center.x);\n float rotatingDash = sin(angle * 8.0 - time * 3.0) * 0.5 + 0.5;\n \n // Pulse effect\n float pulse = sin(time * 2.0) * 0.2 + 0.8;\n \n float alpha = ring * rotatingDash * pulse;\n \n gl_FragColor = vec4(ringColor, alpha);\n}\n"; export declare const terminatorVertexShader = "\nvarying vec3 vWorldPosition;\nvarying vec3 vNormal;\n\nvoid main() {\n vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n vNormal = normalize(normalMatrix * normal);\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"; export declare const terminatorFragmentShader = "\nuniform vec3 sunDirection;\nuniform sampler2D dayTexture;\nuniform sampler2D nightTexture;\n\nvarying vec3 vWorldPosition;\nvarying vec3 vNormal;\n\nvoid main() {\n // Calculate sun illumination\n float sunDot = dot(vNormal, sunDirection);\n \n // Smooth transition at terminator\n float dayFactor = smoothstep(-0.1, 0.2, sunDot);\n \n // Sample textures (simplified - using world position for UV)\n vec2 uv = vec2(\n atan(vWorldPosition.z, vWorldPosition.x) / (2.0 * 3.14159) + 0.5,\n asin(vWorldPosition.y / length(vWorldPosition)) / 3.14159 + 0.5\n );\n \n vec4 dayColor = texture2D(dayTexture, uv);\n vec4 nightColor = texture2D(nightTexture, uv);\n \n // Blend day and night\n vec4 color = mix(nightColor, dayColor, dayFactor);\n \n // Add city lights glow on night side\n float nightGlow = (1.0 - dayFactor) * nightColor.r * 0.5;\n color.rgb += vec3(1.0, 0.9, 0.7) * nightGlow;\n \n gl_FragColor = color;\n}\n"; export declare const gridVertexShader = "\nvarying vec3 vPosition;\n\nvoid main() {\n vPosition = position;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"; export declare const gridFragmentShader = "\nuniform vec3 gridColor;\nuniform float gridOpacity;\nuniform float gridSpacing;\nuniform float lineWidth;\n\nvarying vec3 vPosition;\n\nvoid main() {\n // Convert position to lat/lon\n float lat = asin(vPosition.y / length(vPosition)) * 57.2958; // rad to deg\n float lon = atan(vPosition.z, vPosition.x) * 57.2958;\n \n // Create grid lines\n float latLine = abs(mod(lat + 90.0, gridSpacing) - gridSpacing * 0.5);\n float lonLine = abs(mod(lon + 180.0, gridSpacing) - gridSpacing * 0.5);\n \n float line = min(latLine, lonLine);\n float alpha = smoothstep(lineWidth, 0.0, line) * gridOpacity;\n \n // Highlight equator and prime meridian\n float equator = smoothstep(1.0, 0.0, abs(lat));\n float primeMeridian = smoothstep(1.0, 0.0, abs(lon));\n alpha += (equator + primeMeridian) * 0.3;\n \n gl_FragColor = vec4(gridColor, alpha);\n}\n"; export declare const planetRingVertexShader = "\nvarying vec2 vUv;\nvarying vec3 vWorldPosition;\n\nvoid main() {\n vUv = uv;\n vWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n"; export declare const planetRingFragmentShader = "\nuniform vec3 ringColor;\nuniform float innerRadius;\nuniform float outerRadius;\nuniform float ringOpacity;\nuniform vec3 sunDirection;\n\nvarying vec2 vUv;\nvarying vec3 vWorldPosition;\n\nvoid main() {\n vec2 center = vUv - vec2(0.5);\n float dist = length(center) * 2.0;\n \n // Ring bands\n float normalizedDist = (dist - innerRadius) / (outerRadius - innerRadius);\n \n if (normalizedDist < 0.0 || normalizedDist > 1.0) discard;\n \n // Create ring bands pattern\n float bands = sin(normalizedDist * 50.0) * 0.3 + 0.7;\n float gaps = step(0.3, fract(normalizedDist * 5.0));\n \n // Simple shadow from planet\n float shadow = smoothstep(0.3, 0.5, dist);\n \n float alpha = bands * gaps * ringOpacity * shadow;\n \n gl_FragColor = vec4(ringColor, alpha);\n}\n"; export declare const debrisVertexShader = "\nattribute vec3 instancePosition;\nattribute float instanceSize;\nattribute vec3 instanceColor;\n\nvarying vec3 vColor;\nvarying float vSize;\n\nuniform float time;\n\nvoid main() {\n vColor = instanceColor;\n vSize = instanceSize;\n \n // Apply instance transform\n vec3 transformed = position * instanceSize + instancePosition;\n \n // Slight rotation animation\n float angle = time * 0.5 + instancePosition.x * 0.01;\n mat2 rot = mat2(cos(angle), -sin(angle), sin(angle), cos(angle));\n transformed.xz = rot * transformed.xz;\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(transformed, 1.0);\n}\n"; export declare const debrisFragmentShader = "\nvarying vec3 vColor;\nvarying float vSize;\n\nvoid main() {\n gl_FragColor = vec4(vColor, 1.0);\n}\n"; export interface AtmosphereUniforms { glowColor: { value: [number, number, number]; }; glowIntensity: { value: number; }; } export interface StarsUniforms { time: { value: number; }; pointSize: { value: number; }; } export interface CoverageUniforms { coverageMap: { value: unknown; }; lowColor: { value: [number, number, number]; }; highColor: { value: [number, number, number]; }; opacity: { value: number; }; time: { value: number; }; } export interface VisibilityConeUniforms { coneColor: { value: [number, number, number]; }; coneOpacity: { value: number; }; time: { value: number; }; apexPosition: { value: [number, number, number]; }; } export declare function createAtmosphereUniforms(color?: [number, number, number], intensity?: number): AtmosphereUniforms; export declare function createStarsUniforms(pointSize?: number): StarsUniforms; export declare function createVisibilityConeUniforms(color?: [number, number, number], opacity?: number): VisibilityConeUniforms;