PulseCanvas / app · pulsecanvas.ai / commits / 32796b3b
App source: current code (part 2 of 4) new
written by Branchwell · 32796b3b2cff314d20e7c78bdc17d74e2eace8c1 · parent 0c0f13ae
1647 files changed
Localization/Localizable.xcstrings added
| 1 | + { | |
| 2 | + "sourceLanguage": "en", | |
| 3 | + "strings": { | |
| 4 | + " · %lld unsupported files skipped": {}, | |
| 5 | + "%@ / %@": { | |
| 6 | + "shouldTranslate": false | |
| 7 | + }, | |
| 8 | + "%@ / %@ frames": {}, | |
| 9 | + "%@ assigned to section %lld · %@": {}, | |
| 10 | + "%@ for all visualizers": {}, | |
| 11 | + "%@ hi-hat strobe": {}, | |
| 12 | + "%@ is not a native Metal design": {}, | |
| 13 | + "%@ matching visualizers": {}, | |
| 14 | + "%@ presets are available from the curated library. Bundled originals retain their pinned Cream of the Crop provenance; user imports, if present, have separate origins. Display labels are separate from original filenames and creator metadata. Upstream assumes public domain where author licenses are missing; individual permissions remain unresolved. Attribution does not establish licensing clearance.": {}, | |
| 15 | + "%@ section %lld": {}, | |
| 16 | + "%@ song %@": {}, | |
| 17 | + "%@ soundtrack": {}, | |
| 18 | + "%@ · %@": { | |
| 19 | + "shouldTranslate": false | |
| 20 | + }, | |
| 21 | + "%@ – %@": { | |
| 22 | + "shouldTranslate": false | |
| 23 | + }, | |
| 24 | + "%lld": { | |
| 25 | + "shouldTranslate": false | |
| 26 | + }, | |
| 27 | + "%lld BPM": {}, | |
| 28 | + "%lld additional projects selected": {}, | |
| 29 | + "%lld bars": { | |
| 30 | + "localizations": { | |
| 31 | + "en": { | |
| 32 | + "variations": { | |
| 33 | + "plural": { | |
| 34 | + "one": { | |
| 35 | + "stringUnit": { | |
| 36 | + "state": "translated", | |
| 37 | + "value": "%lld bar" | |
| 38 | + } | |
| 39 | + }, | |
| 40 | + "other": { | |
| 41 | + "stringUnit": { | |
| 42 | + "state": "translated", | |
| 43 | + "value": "%lld bars" | |
| 44 | + } | |
| 45 | + } | |
| 46 | + } | |
| 47 | + } | |
| 48 | + } | |
| 49 | + } | |
| 50 | + }, | |
| 51 | + "%lld effects": { | |
| 52 | + "localizations": { | |
| 53 | + "en": { | |
| 54 | + "variations": { | |
| 55 | + "plural": { | |
| 56 | + "one": { | |
| 57 | + "stringUnit": { | |
| 58 | + "state": "translated", | |
| 59 | + "value": "%lld effect" | |
| 60 | + } | |
| 61 | + }, | |
| 62 | + "other": { | |
| 63 | + "stringUnit": { | |
| 64 | + "state": "translated", | |
| 65 | + "value": "%lld effects" | |
| 66 | + } | |
| 67 | + } | |
| 68 | + } | |
| 69 | + } | |
| 70 | + } | |
| 71 | + } | |
| 72 | + }, | |
| 73 | + "%lld fps": {}, | |
| 74 | + "%lld of %lld effects": {}, | |
| 75 | + "%lld of %lld visualizers": {}, | |
| 76 | + "%lld sections": { | |
| 77 | + "localizations": { | |
| 78 | + "en": { | |
| 79 | + "variations": { | |
| 80 | + "plural": { | |
| 81 | + "one": { | |
| 82 | + "stringUnit": { | |
| 83 | + "state": "translated", | |
| 84 | + "value": "%lld section" | |
| 85 | + } | |
| 86 | + }, | |
| 87 | + "other": { | |
| 88 | + "stringUnit": { | |
| 89 | + "state": "translated", | |
| 90 | + "value": "%lld sections" | |
| 91 | + } | |
| 92 | + } | |
| 93 | + } | |
| 94 | + } | |
| 95 | + } | |
| 96 | + } | |
| 97 | + }, | |
| 98 | + "%lld sections · %lld BPM": {}, | |
| 99 | + "%lld songs": { | |
| 100 | + "localizations": { | |
| 101 | + "en": { | |
| 102 | + "variations": { | |
| 103 | + "plural": { | |
| 104 | + "one": { | |
| 105 | + "stringUnit": { | |
| 106 | + "state": "translated", | |
| 107 | + "value": "%lld song" | |
| 108 | + } | |
| 109 | + }, | |
| 110 | + "other": { | |
| 111 | + "stringUnit": { | |
| 112 | + "state": "translated", | |
| 113 | + "value": "%lld songs" | |
| 114 | + } | |
| 115 | + } | |
| 116 | + } | |
| 117 | + } | |
| 118 | + } | |
| 119 | + } | |
| 120 | + }, | |
| 121 | + "%lld songs · Ready to play": { | |
| 122 | + "localizations": { | |
| 123 | + "en": { | |
| 124 | + "variations": { | |
| 125 | + "plural": { | |
| 126 | + "one": { | |
| 127 | + "stringUnit": { | |
| 128 | + "state": "translated", | |
| 129 | + "value": "%lld song · Ready to play" | |
| 130 | + } | |
| 131 | + }, | |
| 132 | + "other": { | |
| 133 | + "stringUnit": { | |
| 134 | + "state": "translated", | |
| 135 | + "value": "%lld songs · Ready to play" | |
| 136 | + } | |
| 137 | + } | |
| 138 | + } | |
| 139 | + } | |
| 140 | + } | |
| 141 | + } | |
| 142 | + }, | |
| 143 | + "%lld unsupported files skipped.": {}, | |
| 144 | + "%lld unsupported files were skipped.": {}, | |
| 145 | + "%lld visualizers": { | |
| 146 | + "localizations": { | |
| 147 | + "en": { | |
| 148 | + "variations": { | |
| 149 | + "plural": { | |
| 150 | + "one": { | |
| 151 | + "stringUnit": { | |
| 152 | + "state": "translated", | |
| 153 | + "value": "%lld visualizer" | |
| 154 | + } | |
| 155 | + }, | |
| 156 | + "other": { | |
| 157 | + "stringUnit": { | |
| 158 | + "state": "translated", | |
| 159 | + "value": "%lld visualizers" | |
| 160 | + } | |
| 161 | + } | |
| 162 | + } | |
| 163 | + } | |
| 164 | + } | |
| 165 | + } | |
| 166 | + }, | |
| 167 | + "%lld × %lld / %lld fps": {}, | |
| 168 | + "%lld × %lld · Full soundtrack included": {}, | |
| 169 | + "%lld%%": { | |
| 170 | + "shouldTranslate": false | |
| 171 | + }, | |
| 172 | + "1. Choose a visualizer from the top row. Adjust its colors, motion, and camera on the right.": {}, | |
| 173 | + "1080p": { | |
| 174 | + "shouldTranslate": false | |
| 175 | + }, | |
| 176 | + "120 fps (Experimental)": {}, | |
| 177 | + "120 fps renders twice as many frames as 60 fps. Export times and playback support vary.": {}, | |
| 178 | + "16:9 · Wide": {}, | |
| 179 | + "1:1 · Square": {}, | |
| 180 | + "2. Add a soundtrack. Play or scrub it to preview how the visuals react to the music.": {}, | |
| 181 | + "3. Open Project settings to choose your canvas shape and video quality. Save video lets you choose a folder and saves an MP4 with your full soundtrack and visuals.": {}, | |
| 182 | + "3:4 · Portrait": {}, | |
| 183 | + "4:3 · Landscape": {}, | |
| 184 | + "4K": { | |
| 185 | + "shouldTranslate": false | |
| 186 | + }, | |
| 187 | + "67 images come from the Milkdrop texture pack. Its inclusion guidance does not document individual asset grants; those permissions remain unresolved separately from the presets.": {}, | |
| 188 | + "720p": { | |
| 189 | + "shouldTranslate": false | |
| 190 | + }, | |
| 191 | + "9:16 · Phone": {}, | |
| 192 | + "A backup file is damaged.": {}, | |
| 193 | + "A backup file is missing or has an invalid size.": {}, | |
| 194 | + "A different backup uses this identity. Nothing restored.": {}, | |
| 195 | + "A fresh take on your Studio": {}, | |
| 196 | + "A local music catalog refers outside its folder.": {}, | |
| 197 | + "A project in the backup is invalid.": {}, | |
| 198 | + "A project’s soundtrack is missing from this backup.": {}, | |
| 199 | + "A radio track did not match the catalog. Refresh the library and try again.": {}, | |
| 200 | + "A saved data folder contains a symbolic link: %@": {}, | |
| 201 | + "About %@ remaining": {}, | |
| 202 | + "About %@ remaining · %@ frames/s": {}, | |
| 203 | + "Add %@ to Favorites": {}, | |
| 204 | + "Add a song as your Studio soundtrack, then create and export your video.": {}, | |
| 205 | + "Add a soundtrack": {}, | |
| 206 | + "Add a soundtrack to create Studio sections": {}, | |
| 207 | + "Add a soundtrack to create a sequence of visualizers.": {}, | |
| 208 | + "Add continuous forward zoom. Zero keeps the framing flat while the visualization continues animating.": {}, | |
| 209 | + "Add finer structure and surface detail.": {}, | |
| 210 | + "Add flowing ripples, finer folds, and sharper liquid reflections.": {}, | |
| 211 | + "Add music to sync your visuals.": {}, | |
| 212 | + "Add project files…": {}, | |
| 213 | + "Add soundtrack": {}, | |
| 214 | + "Add this visualizer to Favorites": {}, | |
| 215 | + "Add to all": {}, | |
| 216 | + "Added %lld favorites.": {}, | |
| 217 | + "Adding soundtrack…": {}, | |
| 218 | + "Adds rapid flashes in time with high-frequency percussion.": {}, | |
| 219 | + "Adjust palettes, motion, and Chaos for a different feel.": {}, | |
| 220 | + "Adjust to move between onboarding pages": {}, | |
| 221 | + "All Music": {}, | |
| 222 | + "All categories": {}, | |
| 223 | + "All collections": {}, | |
| 224 | + "All folders": {}, | |
| 225 | + "All music": {}, | |
| 226 | + "All songs": {}, | |
| 227 | + "All visualizers": {}, | |
| 228 | + "Analyzing music…": {}, | |
| 229 | + "Application": {}, | |
| 230 | + "Application license": {}, | |
| 231 | + "Applies to the visualizer strip, Library, Studio pickers and randomizers. Saved scenes keep their assignments until you replace or randomize them. Small pools repeat to fill a timeline.": {}, | |
| 232 | + "Apply %@ to all visualizers": {}, | |
| 233 | + "Apply all enables strobe everywhere with the settings below.": {}, | |
| 234 | + "Apply bars to all Studio sections": {}, | |
| 235 | + "Apply selected settings": {}, | |
| 236 | + "Apply selected settings to every visualizer and Studio section. Other settings stay unchanged.": {}, | |
| 237 | + "Apply settings to all": {}, | |
| 238 | + "Apply to all": {}, | |
| 239 | + "Apply to all scenes": {}, | |
| 240 | + "Arc width": {}, | |
| 241 | + "Assign this visualizer to the Studio section at the current song position": {}, | |
| 242 | + "Atom size": {}, | |
| 243 | + "Audio analysis failed: %@": {}, | |
| 244 | + "Audio could not start: %@": {}, | |
| 245 | + "Audio playback couldn't start: %@": {}, | |
| 246 | + "Automatic updates": {}, | |
| 247 | + "Automatically check for updates": {}, | |
| 248 | + "Back": {}, | |
| 249 | + "Back to Studio": {}, | |
| 250 | + "Back to editor": {}, | |
| 251 | + "Back up favorites": {}, | |
| 252 | + "Backup & Restore": {}, | |
| 253 | + "Backup & Restore…": {}, | |
| 254 | + "Backup library license": {}, | |
| 255 | + "Backup saved.": {}, | |
| 256 | + "Backup wasn't saved: %@": {}, | |
| 257 | + "Backups include personal music files. Store them somewhere private.": {}, | |
| 258 | + "Ball size": {}, | |
| 259 | + "Bar lengths": {}, | |
| 260 | + "Bar width": {}, | |
| 261 | + "Bars": {}, | |
| 262 | + "Bars for %@": {}, | |
| 263 | + "Bars for all Studio sections": {}, | |
| 264 | + "Bars for section %lld": {}, | |
| 265 | + "Bars per scene": {}, | |
| 266 | + "Bars per section": {}, | |
| 267 | + "Bars per visualizer": {}, | |
| 268 | + "Base animation speed before the music response.": {}, | |
| 269 | + "Beam width": {}, | |
| 270 | + "Blob size": {}, | |
| 271 | + "Bloom scale": {}, | |
| 272 | + "Blur": {}, | |
| 273 | + "Brightness": {}, | |
| 274 | + "Browse categories and heart the looks you love.": {}, | |
| 275 | + "Browse categories and save favorites": {}, | |
| 276 | + "Bubble size": {}, | |
| 277 | + "Build scenes in Studio": {}, | |
| 278 | + "Bulge size": {}, | |
| 279 | + "Call prepareOffscreen(width:height:) before rendering": {}, | |
| 280 | + "Camera rotation": {}, | |
| 281 | + "Camera zoom": {}, | |
| 282 | + "Cancel": {}, | |
| 283 | + "Cancel export": {}, | |
| 284 | + "Cancelling…": {}, | |
| 285 | + "Cannot allocate an export frame": {}, | |
| 286 | + "Cannot allocate blur texture": {}, | |
| 287 | + "Cannot allocate rhythm analysis buffer": {}, | |
| 288 | + "Cannot allocate surface depth buffer": {}, | |
| 289 | + "Cannot append export frame %lld": {}, | |
| 290 | + "Cannot append soundtrack sample": {}, | |
| 291 | + "Cannot back up %@. It is missing, too large, or a symbolic link.": {}, | |
| 292 | + "Cannot create H.264 encoder": {}, | |
| 293 | + "Cannot create MP4 soundtrack writer": {}, | |
| 294 | + "Cannot decode soundtrack composition": {}, | |
| 295 | + "Cannot map an encoder frame to the GPU": {}, | |
| 296 | + "Cannot open project: %@": {}, | |
| 297 | + "Cannot open soundtrack: %@": {}, | |
| 298 | + "Cannot prepare soundtrack composition": {}, | |
| 299 | + "Cannot read soundtrack PCM": {}, | |
| 300 | + "Cannot save project: %@": {}, | |
| 301 | + "Cannot share GPU frames with the video encoder": {}, | |
| 302 | + "Cannot start H.264 encoder": {}, | |
| 303 | + "Cannot start soundtrack writer": {}, | |
| 304 | + "Canvas": {}, | |
| 305 | + "Canvas shaders are unavailable": {}, | |
| 306 | + "Canvas shape and export quality for this project.": {}, | |
| 307 | + "Category": {}, | |
| 308 | + "Cavern scale": {}, | |
| 309 | + "Change selected settings across the timeline": {}, | |
| 310 | + "Change this section’s visualizer": {}, | |
| 311 | + "Change visualizer": {}, | |
| 312 | + "Chaos": {}, | |
| 313 | + "Check for Updates…": {}, | |
| 314 | + "Choose 1–8 bars per section on the song’s beat grid. Tail sections may be trimmed or repeated to fit the song.": {}, | |
| 315 | + "Choose 720p, 1080p, or 4K and 24, 30, 60, or 120 fps (Experimental)": {}, | |
| 316 | + "Choose 720p, 1080p, or 4K and 24, 30, or 60 fps": {}, | |
| 317 | + "Choose Hide room for full immersion before entering.": {}, | |
| 318 | + "Choose a PulseCanvas project": {}, | |
| 319 | + "Choose a destination and save your video as an MP4": {}, | |
| 320 | + "Choose a different visualizer and replay this section": {}, | |
| 321 | + "Choose a folder containing catalog.json and its audio files.": {}, | |
| 322 | + "Choose a folder with up to 500 songs, including its subfolders.": {}, | |
| 323 | + "Choose a radio library": {}, | |
| 324 | + "Choose a radio library to begin": {}, | |
| 325 | + "Choose a song to open Radio and start listening.": {}, | |
| 326 | + "Choose a supported PulseCanvas backup ZIP.": {}, | |
| 327 | + "Choose a supported PulseCanvas favorites backup.": {}, | |
| 328 | + "Choose a supported PulseCanvas user backup.": {}, | |
| 329 | + "Choose a visualizer and a bar length for each scene.": {}, | |
| 330 | + "Choose all visualizers, favorites, or a category for browsing, Studio and Radio. New choices get fresh looks; favorites restore their saved settings.": {}, | |
| 331 | + "Choose another category, add favorites, or turn the limit off. Randomizers stay idle when the pool is empty.": {}, | |
| 332 | + "Choose another visualizer from the selected group without restarting the song": {}, | |
| 333 | + "Choose audio file…": {}, | |
| 334 | + "Choose categories or favorites for browsing, Studio and randomizers": {}, | |
| 335 | + "Choose common settings for every visualizer and Studio section": {}, | |
| 336 | + "Choose favorite visualizer for section %lld": {}, | |
| 337 | + "Choose lengths from 1–8 bars on the song’s beat grid.": {}, | |
| 338 | + "Choose music": {}, | |
| 339 | + "Choose music folder…": {}, | |
| 340 | + "Choose music or import a soundtrack. Studio finds the beat so your scenes can change with the song.": {}, | |
| 341 | + "Choose music to sync your visuals": {}, | |
| 342 | + "Choose one of your favorites for this section": {}, | |
| 343 | + "Choose randomly from the current search, category, or favorites": {}, | |
| 344 | + "Choose the soundtrack for this video": {}, | |
| 345 | + "Choose the visualizers available throughout the app.": {}, | |
| 346 | + "Choose visualizer": {}, | |
| 347 | + "Choose visualizer for %@ section": {}, | |
| 348 | + "Choose visualizer for scene %lld": {}, | |
| 349 | + "Choose visualizer for section %lld": {}, | |
| 350 | + "Choose what to randomize across your Studio.": {}, | |
| 351 | + "Choose what to replace across all %lld Studio sections.": {}, | |
| 352 | + "Choose what to share across all %lld visualizers and every Studio section. Unselected settings keep their individual values.": {}, | |
| 353 | + "Choose where to save your finished video": {}, | |
| 354 | + "Choose whether to randomize visualizers, bar lengths, or both": {}, | |
| 355 | + "Clear local action checkmarks. Your music, projects and favorites stay intact. Apple's review limits are unchanged.": {}, | |
| 356 | + "Clear song search": {}, | |
| 357 | + "Close": {}, | |
| 358 | + "Cloud scale": {}, | |
| 359 | + "Collection": {}, | |
| 360 | + "Color palette": {}, | |
| 361 | + "Common chaos": {}, | |
| 362 | + "Common motion speed": {}, | |
| 363 | + "Common zoom speed": {}, | |
| 364 | + "Conflict copy — both edits were kept": {}, | |
| 365 | + "Conflicting backup paths.": {}, | |
| 366 | + "Connecting to iCloud Drive…": {}, | |
| 367 | + "Content blur": {}, | |
| 368 | + "Content blur is unavailable": {}, | |
| 369 | + "Copying music folder…": {}, | |
| 370 | + "Coral scale": {}, | |
| 371 | + "Could not allocate offline render target": {}, | |
| 372 | + "Could not create Metal render encoder": {}, | |
| 373 | + "Could not create the Metal command queue": {}, | |
| 374 | + "Could not encode %@": {}, | |
| 375 | + "Could not encode content blur": {}, | |
| 376 | + "Could not encode forward zoom": {}, | |
| 377 | + "Could not encode spatial visual": {}, | |
| 378 | + "Could not encode white flash": {}, | |
| 379 | + "Could not prepare forward zoom": {}, | |
| 380 | + "Could not read saved app data.": {}, | |
| 381 | + "Couldn't import favorites: %@": {}, | |
| 382 | + "Couldn't open the project yet. %@": {}, | |
| 383 | + "Couldn't open this project: %@": {}, | |
| 384 | + "Couldn't prepare iCloud sync: %@": {}, | |
| 385 | + "Couldn't preserve the previous account's sync history. Local data was kept.": {}, | |
| 386 | + "Couldn't remove the cloud project: %@": {}, | |
| 387 | + "Couldn't save favorites: %@": {}, | |
| 388 | + "Couldn't save project: %@": {}, | |
| 389 | + "Couldn't save this Studio session: %@": {}, | |
| 390 | + "Couldn't save this session: %@": {}, | |
| 391 | + "Cream of the Crop pack curated by ISOSCELES": {}, | |
| 392 | + "Create a music visual": {}, | |
| 393 | + "Creating your video": {}, | |
| 394 | + "Crust scale": {}, | |
| 395 | + "Crystal size": {}, | |
| 396 | + "Cube size": {}, | |
| 397 | + "Curl scale": {}, | |
| 398 | + "Current group: %@": {}, | |
| 399 | + "Current rendered frame": {}, | |
| 400 | + "Customize visualizer pool…": {}, | |
| 401 | + "Damaged backup manifest.": {}, | |
| 402 | + "Dancer": {}, | |
| 403 | + "Depth": {}, | |
| 404 | + "Depth / fog": {}, | |
| 405 | + "Disk width": {}, | |
| 406 | + "Dismiss export success": {}, | |
| 407 | + "Domino size": {}, | |
| 408 | + "Done": {}, | |
| 409 | + "Dot size": {}, | |
| 410 | + "Downloading and preparing your soundtrack…": {}, | |
| 411 | + "Downloading this project from iCloud. Try Open again when the download finishes.": {}, | |
| 412 | + "Drive & flight": {}, | |
| 413 | + "Drop size": {}, | |
| 414 | + "Dune scale": {}, | |
| 415 | + "Duplicate or invalid backup path.": {}, | |
| 416 | + "Edge smoothing": {}, | |
| 417 | + "Edge width": {}, | |
| 418 | + "Element size": {}, | |
| 419 | + "Enable iCloud": {}, | |
| 420 | + "Enable iCloud sync?": {}, | |
| 421 | + "Encoder pixel buffer pool is unavailable": {}, | |
| 422 | + "End of soundtrack": {}, | |
| 423 | + "Enjoy your visuals full screen, or export an MP4 with your soundtrack, ready to save and share.": {}, | |
| 424 | + "Enter full screen": {}, | |
| 425 | + "Entire timeline": {}, | |
| 426 | + "Estimating time remaining…": {}, | |
| 427 | + "Every genre, one station": {}, | |
| 428 | + "Exit full screen": {}, | |
| 429 | + "Exit presentation": {}, | |
| 430 | + "Experimental frame rate": {}, | |
| 431 | + "Explore the library": {}, | |
| 432 | + "Explore the visualizer library, save your favorites, and shape the colors and motion to suit your music.": {}, | |
| 433 | + "Export Backup": {}, | |
| 434 | + "Export MP4": {}, | |
| 435 | + "Export MP4 renders the Studio timeline with your soundtrack.": {}, | |
| 436 | + "Export cancelled": {}, | |
| 437 | + "Export dimensions must be between 1 and 8192 pixels": {}, | |
| 438 | + "Export failed: %@": {}, | |
| 439 | + "Export favorites…": {}, | |
| 440 | + "Export or restore favorites across builds and Macs. Imports keep your existing favorites.": {}, | |
| 441 | + "Export the current Radio song with the visualizer you’re watching.": {}, | |
| 442 | + "Export video": {}, | |
| 443 | + "Export your video": {}, | |
| 444 | + "Facet scale": {}, | |
| 445 | + "Favorite %@": {}, | |
| 446 | + "Favorite radio visualizer": {}, | |
| 447 | + "Favorite song": {}, | |
| 448 | + "Favorite songs": {}, | |
| 449 | + "Favorite visualizer": {}, | |
| 450 | + "Favorited": {}, | |
| 451 | + "Favorites": {}, | |
| 452 | + "Favorites backup saved.": {}, | |
| 453 | + "Favorites only": {}, | |
| 454 | + "Fewer %@": {}, | |
| 455 | + "Field density": {}, | |
| 456 | + "Find a look.\nMake it yours.": {}, | |
| 457 | + "Finishing video…": {}, | |
| 458 | + "First-party source is open source under the MIT license. Third-party assets keep their separate terms. Native Metal effects only; no projectM engine or external preset pack is included.": {}, | |
| 459 | + "Fit the visualization to the project’s %@ aspect ratio, with black bars where needed.": {}, | |
| 460 | + "Flame size": {}, | |
| 461 | + "Flash strength": {}, | |
| 462 | + "Flash strength for all visualizers": {}, | |
| 463 | + "Flashes follow hi-hat attacks. Zero Chaos keeps flashes off.": {}, | |
| 464 | + "Fold scale": {}, | |
| 465 | + "Folder": {}, | |
| 466 | + "Folder songs are copied to this Mac and loop continuously in Radio. They stay out of Studio.": {}, | |
| 467 | + "Form scale": {}, | |
| 468 | + "Forward travel speed. Zero keeps the framing flat.": {}, | |
| 469 | + "Fractal": {}, | |
| 470 | + "Fractal detail": {}, | |
| 471 | + "Frame rate": {}, | |
| 472 | + "Fresh looks replace visual settings. Timing and soundtrack stay.": {}, | |
| 473 | + "Fresh looks replace visual settings. Your soundtrack stays.": {}, | |
| 474 | + "Fresh looks replace visual settings; saved favorites keep their look. Your soundtrack stays.": {}, | |
| 475 | + "From your canvas\nto any screen.": {}, | |
| 476 | + "Full soundtrack included. Higher resolutions take longer to render.": {}, | |
| 477 | + "Full-screen visualization": {}, | |
| 478 | + "Geometric": {}, | |
| 479 | + "Getting stations and songs ready.": {}, | |
| 480 | + "Give your song\na visual story.": {}, | |
| 481 | + "Grid scale": {}, | |
| 482 | + "HTTPS catalog URL": {}, | |
| 483 | + "Halo count": {}, | |
| 484 | + "Help": {}, | |
| 485 | + "Help someone discover their next visual": {}, | |
| 486 | + "Hi-hat strobe": {}, | |
| 487 | + "Hide controls": {}, | |
| 488 | + "Hide room": {}, | |
| 489 | + "Higher sensitivity includes softer hi-hat hits.": {}, | |
| 490 | + "How many bars each Radio visualizer plays": {}, | |
| 491 | + "How strongly shapes react to music. Zero keeps procedural motion.": {}, | |
| 492 | + "How to create a video": {}, | |
| 493 | + "Immersive rendering failed: %@": {}, | |
| 494 | + "Immersive viewing couldn't open. Your Studio remains available.": {}, | |
| 495 | + "Immersive viewing is active": {}, | |
| 496 | + "Import / Restore": {}, | |
| 497 | + "Import a PulseCanvas favorites backup. Your current favorites will be kept.": {}, | |
| 498 | + "Import audio": {}, | |
| 499 | + "Import favorites…": {}, | |
| 500 | + "Imported": {}, | |
| 501 | + "In Project settings, choose a canvas and quality. Then choose Save video.": {}, | |
| 502 | + "Information": {}, | |
| 503 | + "Install update %@": {}, | |
| 504 | + "Invalid backup ZIP contents.": {}, | |
| 505 | + "Invalid export timestamp": {}, | |
| 506 | + "Invalid favorite appearance settings.": {}, | |
| 507 | + "Invalid immersive timestamp": {}, | |
| 508 | + "Invalid local music catalog.": {}, | |
| 509 | + "Invalid local music file reference.": {}, | |
| 510 | + "Invalid original file location.": {}, | |
| 511 | + "Invalid saved export format.": {}, | |
| 512 | + "Invalid saved favorites or actions.": {}, | |
| 513 | + "Invalid saved music location.": {}, | |
| 514 | + "Invalid saved preference.": {}, | |
| 515 | + "Invalid saved selection.": {}, | |
| 516 | + "Invalid saved settings data.": {}, | |
| 517 | + "Invalid saved settings.": {}, | |
| 518 | + "Invalid saved song favorites.": {}, | |
| 519 | + "Invalid saved visualizer filter.": {}, | |
| 520 | + "Invalid saved visualizer settings.": {}, | |
| 521 | + "Jet width": {}, | |
| 522 | + "Keep %@ growing.": {}, | |
| 523 | + "Keep unchanged": {}, | |
| 524 | + "Keep visualizer favorites, song favorites, saved looks and saved projects available on your Mac, iPhone, iPad and Apple Vision Pro using the same Apple Account.": {}, | |
| 525 | + "Last checked %@": {}, | |
| 526 | + "Leave full screen": {}, | |
| 527 | + "Leave radio": {}, | |
| 528 | + "Legal & Credits": {}, | |
| 529 | + "Library": {}, | |
| 530 | + "Library source": {}, | |
| 531 | + "Limit visualizers": {}, | |
| 532 | + "Line width": {}, | |
| 533 | + "Liquid & flow": {}, | |
| 534 | + "Liquid detail": {}, | |
| 535 | + "Listen with beat-aligned visuals from all, favorites, or a category": {}, | |
| 536 | + "Load library": {}, | |
| 537 | + "Loading %@…": {}, | |
| 538 | + "Loading Radio…": {}, | |
| 539 | + "Loading music…": {}, | |
| 540 | + "Loading radio library…": {}, | |
| 541 | + "Loading stations…": {}, | |
| 542 | + "Locate soundtrack": {}, | |
| 543 | + "Locate this project’s soundtrack: %@. Saved projects reference audio files; they do not include the audio.": {}, | |
| 544 | + "Loop": {}, | |
| 545 | + "Loop soundtrack": {}, | |
| 546 | + "Loop this section of the soundtrack and visualizer; click again to pause": {}, | |
| 547 | + "Make room\nfor your music.": {}, | |
| 548 | + "Match aspect ratio": {}, | |
| 549 | + "Merge this device’s favorites and saved looks with your Apple Account, and upload saved projects with their music. Changes sync to your other PulseCanvas devices. Turning sync off keeps local data and existing iCloud copies.": {}, | |
| 550 | + "Metal device is unavailable": {}, | |
| 551 | + "Metal edition": {}, | |
| 552 | + "Metal is unavailable": {}, | |
| 553 | + "More %@": {}, | |
| 554 | + "Motion & depth": {}, | |
| 555 | + "Motion speed": {}, | |
| 556 | + "Music and visuals on shuffle. Choose all, favorites, or a station.": {}, | |
| 557 | + "Music couldn’t load": {}, | |
| 558 | + "Music folder": {}, | |
| 559 | + "Music into moving visuals. Free to use, with no account or subscription.": {}, | |
| 560 | + "My music folder": {}, | |
| 561 | + "Native Metal": {}, | |
| 562 | + "Native shader %@ is missing": {}, | |
| 563 | + "Nature & space": {}, | |
| 564 | + "Next": {}, | |
| 565 | + "Next radio song": {}, | |
| 566 | + "Next song": {}, | |
| 567 | + "Next song will start paused": {}, | |
| 568 | + "Next station": {}, | |
| 569 | + "Next visualizer": {}, | |
| 570 | + "No changes were made. Choose a larger visualizer group or fewer sections, then try again.": {}, | |
| 571 | + "No favorite songs yet": {}, | |
| 572 | + "No favorite songs yet. Choose All music, then save songs with the heart.": {}, | |
| 573 | + "No favorite songs yet. Tap a song's heart in Radio to save it.": {}, | |
| 574 | + "No favorite visualizers in this group. Playing random visualizers from the group.": {}, | |
| 575 | + "No matches in your visualizer pool. Change the pool or turn its limit off.": {}, | |
| 576 | + "No matching favorite songs": {}, | |
| 577 | + "No matching songs": {}, | |
| 578 | + "No matching visualizers": {}, | |
| 579 | + "No playable songs found. Use MP3, M4A, WAV, AIFF, AAC, CAF or FLAC files up to 100 MB and two hours each.": {}, | |
| 580 | + "None of the radio tracks could be played. Check the library and try again.": {}, | |
| 581 | + "Not enough unique visualizers": {}, | |
| 582 | + "Not favorited": {}, | |
| 583 | + "Nothing exported: %@": {}, | |
| 584 | + "Nothing restored: %@": {}, | |
| 585 | + "Number of rings in each travelling group. Add more for a denser field of halos.": {}, | |
| 586 | + "OK": { | |
| 587 | + "shouldTranslate": false | |
| 588 | + }, | |
| 589 | + "Offline GPU render failed: %@": {}, | |
| 590 | + "Offline renderer is unavailable or the frame format is invalid": {}, | |
| 591 | + "Onboarding": {}, | |
| 592 | + "Open": {}, | |
| 593 | + "Open Project actions → Export MP4. Render, then Save video to Files.": {}, | |
| 594 | + "Open full-screen viewing": {}, | |
| 595 | + "Open licenses, notices & provenance": {}, | |
| 596 | + "Open local library…": {}, | |
| 597 | + "Open project": {}, | |
| 598 | + "Open the immersive screen": {}, | |
| 599 | + "Open the immersive screen to surround yourself with the visuals, or export your Studio project as an MP4.": {}, | |
| 600 | + "Open visualizer library": {}, | |
| 601 | + "Orb size": {}, | |
| 602 | + "Other native": {}, | |
| 603 | + "Palette": {}, | |
| 604 | + "Panel scale": {}, | |
| 605 | + "Particle size": {}, | |
| 606 | + "Particles": {}, | |
| 607 | + "Pause": {}, | |
| 608 | + "Pause Radio": {}, | |
| 609 | + "Pause presentation": {}, | |
| 610 | + "Pause soundtrack": {}, | |
| 611 | + "Paused": {}, | |
| 612 | + "Phone uses 9:16. Portrait uses 3:4.": {}, | |
| 613 | + "Pick a fresh visualizer look, or restore a saved favorite": {}, | |
| 614 | + "Pillar scale": {}, | |
| 615 | + "Piston scale": {}, | |
| 616 | + "Pixel size": {}, | |
| 617 | + "Plasma scale": {}, | |
| 618 | + "Play": {}, | |
| 619 | + "Play %@": {}, | |
| 620 | + "Play %@ in Radio": {}, | |
| 621 | + "Play & share": {}, | |
| 622 | + "Play Radio": {}, | |
| 623 | + "Play favorite songs": {}, | |
| 624 | + "Play or pause soundtrack (Space)": {}, | |
| 625 | + "Play presentation": {}, | |
| 626 | + "Play radio": {}, | |
| 627 | + "Play scene %lld": {}, | |
| 628 | + "Play soundtrack": {}, | |
| 629 | + "Play the Studio timeline full screen from the current position. Escape returns to the editor.": {}, | |
| 630 | + "Playing Studio section · Looping": {}, | |
| 631 | + "Playing soundtrack": {}, | |
| 632 | + "Playing soundtrack · Looping": {}, | |
| 633 | + "Plume scale": {}, | |
| 634 | + "Pool · %lld": {}, | |
| 635 | + "Preparing %@…": {}, | |
| 636 | + "Preparing Radio": {}, | |
| 637 | + "Preparing backup…": {}, | |
| 638 | + "Preparing export…": {}, | |
| 639 | + "Preparing music…": {}, | |
| 640 | + "Preparing next song…": {}, | |
| 641 | + "Preparing your soundtrack…": {}, | |
| 642 | + "Present": {}, | |
| 643 | + "Present Studio full screen": {}, | |
| 644 | + "Present radio": {}, | |
| 645 | + "Present visualizer": {}, | |
| 646 | + "Present visualizer full screen": {}, | |
| 647 | + "Preset provenance": {}, | |
| 648 | + "Press Present": {}, | |
| 649 | + "Preview": {}, | |
| 650 | + "Preview volume": {}, | |
| 651 | + "Previous visualizer": {}, | |
| 652 | + "Privacy": {}, | |
| 653 | + "Privacy policy": {}, | |
| 654 | + "Project actions": {}, | |
| 655 | + "Project opened": {}, | |
| 656 | + "Project opened, but its backup copy wasn't updated: %@": {}, | |
| 657 | + "Project opened. Close Settings to continue.": {}, | |
| 658 | + "Project saved": {}, | |
| 659 | + "Project saved, but its backup copy wasn't updated: %@": {}, | |
| 660 | + "Project settings": {}, | |
| 661 | + "Project was not opened. Its soundtrack is unavailable.": {}, | |
| 662 | + "ProjectM compositor is unavailable": {}, | |
| 663 | + "PulseCanvas": { | |
| 664 | + "shouldTranslate": false | |
| 665 | + }, | |
| 666 | + "PulseCanvas Radio": {}, | |
| 667 | + "PulseCanvas Studio": { | |
| 668 | + "shouldTranslate": false | |
| 669 | + }, | |
| 670 | + "PulseCanvas first-party code is open source under the MIT license. Third-party components and assets have separate terms.": {}, | |
| 671 | + "PulseCanvas processes music and videos locally on your Mac. Radio downloads its catalog and music from the library you choose; the hosting service receives ordinary network requests. Optional iCloud sync uploads your saved projects with their soundtracks, favorites and saved looks to your Apple Account. It is off until you enable it in Settings. Playback, volume, personal Radio albums and access bookmarks stay on this device. The app has no PulseCanvas account, usage analytics or advertising tracking and does not record your microphone. Ordinary project files reference audio; iCloud projects include a separate soundtrack copy.": {}, | |
| 672 | + "RATINGS & SUPPORT": {}, | |
| 673 | + "Radio": {}, | |
| 674 | + "Radio catalog URL": {}, | |
| 675 | + "Radio couldn't play this track. %@": {}, | |
| 676 | + "Radio downloads music to this Mac for playback and analysis. Your own soundtracks stay on your Mac.": {}, | |
| 677 | + "Radio music source": {}, | |
| 678 | + "Radio paused": {}, | |
| 679 | + "Radio song position": {}, | |
| 680 | + "Radio station": {}, | |
| 681 | + "Radio stopped · Your soundtrack restored": {}, | |
| 682 | + "Radio visualization": {}, | |
| 683 | + "Radio volume": {}, | |
| 684 | + "Random radio visualizer": {}, | |
| 685 | + "Random visualizer": {}, | |
| 686 | + "Random visualizer for section %lld": {}, | |
| 687 | + "Randomize": {}, | |
| 688 | + "Randomize %@": {}, | |
| 689 | + "Randomize all": {}, | |
| 690 | + "Randomize bar lengths": {}, | |
| 691 | + "Randomize current visual style": {}, | |
| 692 | + "Randomize favorites": {}, | |
| 693 | + "Randomize pool": {}, | |
| 694 | + "Randomize radio visualizer": {}, | |
| 695 | + "Randomize the timeline, then fine-tune your favorite moments.": {}, | |
| 696 | + "Randomize this timeline?": {}, | |
| 697 | + "Randomize timeline": {}, | |
| 698 | + "Randomize timeline bars": {}, | |
| 699 | + "Randomize timeline visualizers": {}, | |
| 700 | + "Randomize visual style": {}, | |
| 701 | + "Randomize visual style for section %lld": {}, | |
| 702 | + "Randomize visualizer group": {}, | |
| 703 | + "Randomize visualizers": {}, | |
| 704 | + "Randomize visuals": {}, | |
| 705 | + "Ready to export": {}, | |
| 706 | + "Remove %@ from Favorites": {}, | |
| 707 | + "Remove %@ from iCloud": {}, | |
| 708 | + "Remove from all": {}, | |
| 709 | + "Remove from iCloud": {}, | |
| 710 | + "Remove soundtrack": {}, | |
| 711 | + "Remove this project from iCloud?": {}, | |
| 712 | + "Remove this visualizer from Favorites": {}, | |
| 713 | + "Render another video": {}, | |
| 714 | + "Render video": {}, | |
| 715 | + "Rendering frame %lld of %lld": {}, | |
| 716 | + "Repeat the soundtrack and Studio timeline from the beginning": {}, | |
| 717 | + "Repeat the soundtrack when it ends": {}, | |
| 718 | + "Replace audio": {}, | |
| 719 | + "Replay all five onboarding screens from the beginning": {}, | |
| 720 | + "Requires the Creators edition": {}, | |
| 721 | + "Reset": {}, | |
| 722 | + "Reset this visualizer to its default visual settings; all sections using it update": {}, | |
| 723 | + "Reset visualizer to defaults": {}, | |
| 724 | + "Resolution": {}, | |
| 725 | + "Resolution uses the shorter canvas edge. Export saves an MP4 with the soundtrack included.": {}, | |
| 726 | + "Restart": {}, | |
| 727 | + "Restart presentation": {}, | |
| 728 | + "Restore": {}, | |
| 729 | + "Restore this backup?": {}, | |
| 730 | + "Restore this full backup on %@. Individual PulseCanvas projects can be opened on other platforms.": {}, | |
| 731 | + "Retry radio": {}, | |
| 732 | + "Retry stations": {}, | |
| 733 | + "Ribbon width": {}, | |
| 734 | + "Ring size": {}, | |
| 735 | + "Ring spacing": {}, | |
| 736 | + "Ring thickness": {}, | |
| 737 | + "Ring width": {}, | |
| 738 | + "Ringlet width": {}, | |
| 739 | + "Ripple scale": {}, | |
| 740 | + "Roll shared style settings and replay this section; all sections using this visualizer update": {}, | |
| 741 | + "Save a portable backup to restore in another build or on another Mac.": {}, | |
| 742 | + "Save a project to add it to iCloud. Projects download when you open them.": {}, | |
| 743 | + "Save a video": {}, | |
| 744 | + "Save another copy": {}, | |
| 745 | + "Save or remove this song in Library → Favorite songs": {}, | |
| 746 | + "Save project": {}, | |
| 747 | + "Save song": {}, | |
| 748 | + "Save songs with the heart in Radio, or choose All songs.": {}, | |
| 749 | + "Save songs with the heart while listening to Radio.": {}, | |
| 750 | + "Save video": {}, | |
| 751 | + "Save visualizer": {}, | |
| 752 | + "Save your creation": {}, | |
| 753 | + "Save your favorites, saved looks, projects, imported music and preferences in one ZIP file. Keep a copy outside this device.": {}, | |
| 754 | + "Saved %@": {}, | |
| 755 | + "Saved & restored projects": {}, | |
| 756 | + "Saved projects include their soundtracks and use your iCloud storage. Personal Radio albums, playback and volume stay on each device. Creators-only effects stay unavailable in Metal editions.": {}, | |
| 757 | + "Scene geometry is empty": {}, | |
| 758 | + "Screen distance": {}, | |
| 759 | + "Screen height": {}, | |
| 760 | + "Search songs or genres": {}, | |
| 761 | + "Search visualizers": {}, | |
| 762 | + "Section %lld visualizer, %@, %@ to %@": {}, | |
| 763 | + "Section unavailable": {}, | |
| 764 | + "See the onboarding again, from the beginning.": {}, | |
| 765 | + "Select at least one option to continue.": {}, | |
| 766 | + "Select scene %lld": {}, | |
| 767 | + "Select this section; keep playing if playback is running, or preview while paused": {}, | |
| 768 | + "Select visualizer": {}, | |
| 769 | + "Sensitivity": {}, | |
| 770 | + "Sensitivity · %.2f": {}, | |
| 771 | + "Sequin size": {}, | |
| 772 | + "Set every card to this length. Later cards shift to the beat grid; the last ends with the soundtrack.": {}, | |
| 773 | + "Set this card’s length in bars. Later cards shift; the last ends with the soundtrack.": {}, | |
| 774 | + "Settings": {}, | |
| 775 | + "Shape your style": {}, | |
| 776 | + "Sheen": {}, | |
| 777 | + "Show all effects": {}, | |
| 778 | + "Show all visualizers": {}, | |
| 779 | + "Show automatic backups": {}, | |
| 780 | + "Show favorite effects": {}, | |
| 781 | + "Show in Finder": {}, | |
| 782 | + "Show saved projects in Finder": {}, | |
| 783 | + "Shuffle scenes": {}, | |
| 784 | + "Shuffle songs": {}, | |
| 785 | + "Skip": {}, | |
| 786 | + "Skip onboarding": {}, | |
| 787 | + "Skipping %@: %@": {}, | |
| 788 | + "Slide width": {}, | |
| 789 | + "Some OpenGL presets may become darker or look different. Choose 60 fps if this happens.": {}, | |
| 790 | + "Song saved": {}, | |
| 791 | + "Songs": {}, | |
| 792 | + "Soundtrack contains no readable PCM samples": {}, | |
| 793 | + "Soundtrack duration is unavailable": {}, | |
| 794 | + "Soundtrack encoding failed": {}, | |
| 795 | + "Soundtrack encoding timed out": {}, | |
| 796 | + "Soundtrack must be shorter than 24 hours": {}, | |
| 797 | + "Soundtrack position": {}, | |
| 798 | + "Soundtrack ready": {}, | |
| 799 | + "Soundtrack writer stopped": {}, | |
| 800 | + "Source code on GitHub": {}, | |
| 801 | + "Space pauses playback. Escape returns to the editor.": {}, | |
| 802 | + "Sparkle provides signed updates for the direct-download edition. Update checks send only the information needed to deliver the app; system profiling is disabled.": {}, | |
| 803 | + "Spatial visual shader is unavailable": {}, | |
| 804 | + "Star size": {}, | |
| 805 | + "Start creating": {}, | |
| 806 | + "Start with a song": {}, | |
| 807 | + "Stations couldn't load. Check your connection and try again.": {}, | |
| 808 | + "Stations couldn't load. Your local music remains available.": {}, | |
| 809 | + "Step size": {}, | |
| 810 | + "Stick width": {}, | |
| 811 | + "Strength": {}, | |
| 812 | + "Strength · %.2f": {}, | |
| 813 | + "String width": {}, | |
| 814 | + "Stripe width": {}, | |
| 815 | + "Strobe sensitivity": {}, | |
| 816 | + "Strobe sensitivity for all visualizers": {}, | |
| 817 | + "Strobe strength": {}, | |
| 818 | + "Structure scale": {}, | |
| 819 | + "Studio": {}, | |
| 820 | + "Studio timeline is invalid": {}, | |
| 821 | + "Studio visualization": {}, | |
| 822 | + "Studio · Section %lld of %lld · Esc to exit": {}, | |
| 823 | + "Surface thickness": {}, | |
| 824 | + "Surprise me": {}, | |
| 825 | + "Swell scale": {}, | |
| 826 | + "Swipe left or right to change the visualizer while keeping the current song. Double-tap to favorite the visualizer.": {}, | |
| 827 | + "Swirl scale": {}, | |
| 828 | + "Sync history needs recovery before enabling iCloud. Local files and the unreadable history are preserved.": {}, | |
| 829 | + "Sync needs attention: %@. Local data was kept; Sync now retries.": {}, | |
| 830 | + "Sync now": {}, | |
| 831 | + "Sync with iCloud": {}, | |
| 832 | + "Syncing with iCloud Drive…": {}, | |
| 833 | + "THANKS FOR LISTENING": {}, | |
| 834 | + "Tail sections may be trimmed or repeated to fit the song.": {}, | |
| 835 | + "Tap a song’s heart in Radio to save it here.": {}, | |
| 836 | + "Tap a visualizer’s heart in the Library to add it here.": {}, | |
| 837 | + "Tap an effect’s heart to add it to Favorites.": {}, | |
| 838 | + "Tap the heart beside a song's title in Radio to save it here.": {}, | |
| 839 | + "Tap to reveal the controls while you listen.": {}, | |
| 840 | + "Terms of use": {}, | |
| 841 | + "Terrain scale": {}, | |
| 842 | + "Texture provenance": {}, | |
| 843 | + "The backup contains a damaged or duplicate file.": {}, | |
| 844 | + "The backup contains an invalid project.": {}, | |
| 845 | + "The backup contains invalid favorite identities.": {}, | |
| 846 | + "The backup is too large.": {}, | |
| 847 | + "The backup workspace is already in use.": {}, | |
| 848 | + "The direct-download edition checks pulsecanvas.si for signed updates. System profiling is disabled.": {}, | |
| 849 | + "The favorites backup is too large.": {}, | |
| 850 | + "The full music library isn't available. Try refreshing stations.": {}, | |
| 851 | + "The output file must differ from the soundtrack": {}, | |
| 852 | + "The pending restore is invalid. Your previous data has been kept.": {}, | |
| 853 | + "The radio library could not be downloaded. Check your connection and catalog URL.": {}, | |
| 854 | + "The restore settings couldn't be saved. Your previous data is still in use.": {}, | |
| 855 | + "The soundtrack or rendered video track is missing": {}, | |
| 856 | + "This App Store edition includes %lld Metal visualizers. The projectM engine, OpenGL presets, and texture pack are not included.": {}, | |
| 857 | + "This backup exceeds 100 GB or 20,000 files. Nothing was exported.": {}, | |
| 858 | + "This backup exceeds 100 GB.": {}, | |
| 859 | + "This backup includes unsupported settings.": {}, | |
| 860 | + "This backup is too large.": {}, | |
| 861 | + "This favorite is no longer available in its radio library.": {}, | |
| 862 | + "This file has no audio samples.": {}, | |
| 863 | + "This folder couldn't be opened. Choose a downloaded music folder and try again.": {}, | |
| 864 | + "This preset supplies its own colors, shapes, waves, and feedback. Adjust motion and audio response below.": {}, | |
| 865 | + "This radio catalog is invalid. Choose a version 1 catalog with HTTPS audio URLs.": {}, | |
| 866 | + "This removes it from the synced project list on all devices. Existing local project and audio files are kept.": {}, | |
| 867 | + "This replaces the app’s saved data and preferences with the backup after you close and reopen PulseCanvas. Existing project files outside the app remain unchanged. Export a current backup first if you want to keep both.": {}, | |
| 868 | + "This replaces the chosen visualizers or scene lengths throughout your Studio timeline.": {}, | |
| 869 | + "This song is no longer available in Radio.": {}, | |
| 870 | + "This timeline has %lld sections and %lld available visualizers. Use longer sections or add visualizers to randomize without repeats.": {}, | |
| 871 | + "Tile size": {}, | |
| 872 | + "Too many backup files.": {}, | |
| 873 | + "Too many entries in a local music catalog.": {}, | |
| 874 | + "Trace width": {}, | |
| 875 | + "Trail width": {}, | |
| 876 | + "Try Again": {}, | |
| 877 | + "Try a new sequence": {}, | |
| 878 | + "Try again": {}, | |
| 879 | + "Try another search.": {}, | |
| 880 | + "Try the included music or discover a station in Radio.": {}, | |
| 881 | + "Tunnels": {}, | |
| 882 | + "Turn sound into moving art with PulseCanvas Studio. A few basics, then the canvas is yours.": {}, | |
| 883 | + "Turn strobe off everywhere and retain individual flash settings.": {}, | |
| 884 | + "Unfavorite %@": {}, | |
| 885 | + "Unfavorite song": {}, | |
| 886 | + "Unfavorite song %@": {}, | |
| 887 | + "Unfavorite visualizer": {}, | |
| 888 | + "Update %@ is available. Click to install.": {}, | |
| 889 | + "Updates": {}, | |
| 890 | + "Use %@": {}, | |
| 891 | + "Use %@ in Studio": {}, | |
| 892 | + "Use ZIP export for this music library.": {}, | |
| 893 | + "Use at playhead": {}, | |
| 894 | + "Use favorite %@": {}, | |
| 895 | + "Use favorites first, then unused library visuals. Each visualizer appears once.": {}, | |
| 896 | + "Use only your visualizer pool. Small pools repeat to fill the timeline.": {}, | |
| 897 | + "Use this pool": {}, | |
| 898 | + "Vault scale": {}, | |
| 899 | + "Vessel width": {}, | |
| 900 | + "Video encoder stopped": {}, | |
| 901 | + "Video encoder timed out": {}, | |
| 902 | + "Video encoding failed": {}, | |
| 903 | + "Video export progress": {}, | |
| 904 | + "Video format is unavailable": {}, | |
| 905 | + "Video saved": {}, | |
| 906 | + "Viewing settings": {}, | |
| 907 | + "Visual style": {}, | |
| 908 | + "Visualizer": {}, | |
| 909 | + "Visualizer favorited": {}, | |
| 910 | + "Visualizer order, soundtrack and saved styles stay unchanged.": {}, | |
| 911 | + "Visualizer order, soundtrack, and saved settings stay.": {}, | |
| 912 | + "Visualizer pool": {}, | |
| 913 | + "Visualizer saved": {}, | |
| 914 | + "Visualizer · Esc to exit": {}, | |
| 915 | + "Visualizers": {}, | |
| 916 | + "Visuals respond to the rhythm as you listen.": {}, | |
| 917 | + "Volume": {}, | |
| 918 | + "Watch the music move": {}, | |
| 919 | + "Watch this visualizer full screen with the soundtrack. Escape returns to the editor.": {}, | |
| 920 | + "Wave scale": {}, | |
| 921 | + "Waveform": {}, | |
| 922 | + "Welcome": {}, | |
| 923 | + "Welcome to PulseCanvas Studio": {}, | |
| 924 | + "White flash shader is missing": {}, | |
| 925 | + "White flashes follow rapid high-frequency attacks in the soundtrack.": {}, | |
| 926 | + "Workspace": {}, | |
| 927 | + "YOUR VIDEO, SAVED": {}, | |
| 928 | + "Your Apple Account changed. Confirm iCloud sync again before merging local data with this account.": {}, | |
| 929 | + "Your Apple Account changed. Local data was kept. Confirm iCloud sync again to use the current account.": {}, | |
| 930 | + "Your current Studio project and app-managed files are included. Add older projects saved elsewhere to include them and their soundtracks. Downloaded public Radio caches, exported videos, sign-in data and purchase records are excluded.": {}, | |
| 931 | + "Your current visualizer choices will be replaced.": {}, | |
| 932 | + "Your data": {}, | |
| 933 | + "Your music.\nYour visual world.": {}, | |
| 934 | + "Your radio library will appear here when it finishes loading.": {}, | |
| 935 | + "Your video is ready": {}, | |
| 936 | + "Zero turns off music response while smooth visualization motion and zoom continue. Increase for beat-driven waves, local swelling, liquid deformation, and motion.": {}, | |
| 937 | + "Zoom speed": {}, | |
| 938 | + "bars": {}, | |
| 939 | + "https://www.patreon.com/posts/pack-nestdrop-91682111": {}, | |
| 940 | + "iCloud": { | |
| 941 | + "shouldTranslate": false | |
| 942 | + }, | |
| 943 | + "iCloud Drive is unavailable. Sign in to iCloud and use an iCloud-enabled signed build. Your local data is safe.": {}, | |
| 944 | + "iCloud projects (%lld)": {}, | |
| 945 | + "iCloud sync history couldn't be read. Sync is off; local data and the original history were kept.": {}, | |
| 946 | + "iCloud sync is off. Local files and existing iCloud copies are kept.": {}, | |
| 947 | + "iCloud sync is off. Your data stays on this device.": {}, | |
| 948 | + "projectM 4.2.0 is included under LGPL 2.1 or later. Engine source and rebuild instructions accompany the matching source package.": {}, | |
| 949 | + "projectM engine": {} | |
| 950 | + }, | |
| 951 | + "version": "1.0" | |
| 952 | + } |
PulseCanvas.xcodeproj/project.pbxproj added
| 1 | + // !$*UTF8*$! | |
| 2 | + { | |
| 3 | + "archiveVersion" = 1; | |
| 4 | + "classes" = { | |
| 5 | + }; | |
| 6 | + "objectVersion" = 56; | |
| 7 | + "objects" = { | |
| 8 | + "D86646D49B9BAADCCA5D281C" = { | |
| 9 | + "isa" = "PBXFileReference"; | |
| 10 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 11 | + "path" = "Sources/PulseCanvas/AppLifecycle.swift"; | |
| 12 | + "sourceTree" = "<group>"; | |
| 13 | + }; | |
| 14 | + "D061672D180E0CC713D8F100" = { | |
| 15 | + "isa" = "PBXFileReference"; | |
| 16 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 17 | + "path" = "Sources/PulseCanvas/AudioAnalysis.swift"; | |
| 18 | + "sourceTree" = "<group>"; | |
| 19 | + }; | |
| 20 | + "7E1F3D8976A0AE0EF6B1CFC0" = { | |
| 21 | + "isa" = "PBXFileReference"; | |
| 22 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 23 | + "path" = "Sources/PulseCanvas/AudioController.swift"; | |
| 24 | + "sourceTree" = "<group>"; | |
| 25 | + }; | |
| 26 | + "C206A182BBE4A737E9AD134E" = { | |
| 27 | + "isa" = "PBXFileReference"; | |
| 28 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 29 | + "path" = "Sources/PulseCanvas/BundledSoundtrack.swift"; | |
| 30 | + "sourceTree" = "<group>"; | |
| 31 | + }; | |
| 32 | + "AD6CBDCBF5BC1A861917A40A" = { | |
| 33 | + "isa" = "PBXFileReference"; | |
| 34 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 35 | + "path" = "Sources/PulseCanvas/CanvasPreviewLayout.swift"; | |
| 36 | + "sourceTree" = "<group>"; | |
| 37 | + }; | |
| 38 | + "413823572A414825D1DA4580" = { | |
| 39 | + "isa" = "PBXFileReference"; | |
| 40 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 41 | + "path" = "Sources/PulseCanvas/CloudProjectPackage.swift"; | |
| 42 | + "sourceTree" = "<group>"; | |
| 43 | + }; | |
| 44 | + "07928D013502A7AEB5C6EB03" = { | |
| 45 | + "isa" = "PBXFileReference"; | |
| 46 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 47 | + "path" = "Sources/PulseCanvas/CloudSyncAppData.swift"; | |
| 48 | + "sourceTree" = "<group>"; | |
| 49 | + }; | |
| 50 | + "AB03A0B65DCF1AD6BE5612B3" = { | |
| 51 | + "isa" = "PBXFileReference"; | |
| 52 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 53 | + "path" = "Sources/PulseCanvas/CloudSyncLedger.swift"; | |
| 54 | + "sourceTree" = "<group>"; | |
| 55 | + }; | |
| 56 | + "119DE12F5D045816EDEC9843" = { | |
| 57 | + "isa" = "PBXFileReference"; | |
| 58 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 59 | + "path" = "Sources/PulseCanvas/CloudSyncService.swift"; | |
| 60 | + "sourceTree" = "<group>"; | |
| 61 | + }; | |
| 62 | + "900F718AA064255994CD45B8" = { | |
| 63 | + "isa" = "PBXFileReference"; | |
| 64 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 65 | + "path" = "Sources/PulseCanvas/CloudSyncView.swift"; | |
| 66 | + "sourceTree" = "<group>"; | |
| 67 | + }; | |
| 68 | + "3A4073EA821A833AE027E7E9" = { | |
| 69 | + "isa" = "PBXFileReference"; | |
| 70 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 71 | + "path" = "Sources/PulseCanvas/ExportOverlayView.swift"; | |
| 72 | + "sourceTree" = "<group>"; | |
| 73 | + }; | |
| 74 | + "4652E379F9220B1BF60E12B9" = { | |
| 75 | + "isa" = "PBXFileReference"; | |
| 76 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 77 | + "path" = "Sources/PulseCanvas/NativeEffects.swift"; | |
| 78 | + "sourceTree" = "<group>"; | |
| 79 | + }; | |
| 80 | + "100CD0DC00C64B0B646E69DC" = { | |
| 81 | + "isa" = "PBXFileReference"; | |
| 82 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 83 | + "path" = "Sources/PulseCanvas/OriginalGeometry.swift"; | |
| 84 | + "sourceTree" = "<group>"; | |
| 85 | + }; | |
| 86 | + "2DF77FDA9C8372B7840DB84B" = { | |
| 87 | + "isa" = "PBXFileReference"; | |
| 88 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 89 | + "path" = "Sources/PulseCanvas/ProjectMPresets.swift"; | |
| 90 | + "sourceTree" = "<group>"; | |
| 91 | + }; | |
| 92 | + "C21BFB46BEED9116F0743542" = { | |
| 93 | + "isa" = "PBXFileReference"; | |
| 94 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 95 | + "path" = "Sources/PulseCanvas/PulseCanvasApp.swift"; | |
| 96 | + "sourceTree" = "<group>"; | |
| 97 | + }; | |
| 98 | + "267585C701FE24385C4A7730" = { | |
| 99 | + "isa" = "PBXFileReference"; | |
| 100 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 101 | + "path" = "Sources/PulseCanvas/PulseCanvasOnboarding.swift"; | |
| 102 | + "sourceTree" = "<group>"; | |
| 103 | + }; | |
| 104 | + "CED40C63C78F355A3E299D3F" = { | |
| 105 | + "isa" = "PBXFileReference"; | |
| 106 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 107 | + "path" = "Sources/PulseCanvas/RadioController.swift"; | |
| 108 | + "sourceTree" = "<group>"; | |
| 109 | + }; | |
| 110 | + "A49A1847A6C656BBBFECDB8E" = { | |
| 111 | + "isa" = "PBXFileReference"; | |
| 112 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 113 | + "path" = "Sources/PulseCanvas/RadioLibrary.swift"; | |
| 114 | + "sourceTree" = "<group>"; | |
| 115 | + }; | |
| 116 | + "A7107BA039EA8BCCF0F232A8" = { | |
| 117 | + "isa" = "PBXFileReference"; | |
| 118 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 119 | + "path" = "Sources/PulseCanvas/RadioView.swift"; | |
| 120 | + "sourceTree" = "<group>"; | |
| 121 | + }; | |
| 122 | + "CB8C52BD5C2A06B60EC6768B" = { | |
| 123 | + "isa" = "PBXFileReference"; | |
| 124 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 125 | + "path" = "Sources/PulseCanvas/SecurityScopedAccess.swift"; | |
| 126 | + "sourceTree" = "<group>"; | |
| 127 | + }; | |
| 128 | + "4C15E8BE8F01FC4E793E0EE1" = { | |
| 129 | + "isa" = "PBXFileReference"; | |
| 130 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 131 | + "path" = "Sources/PulseCanvas/SocialExportController.swift"; | |
| 132 | + "sourceTree" = "<group>"; | |
| 133 | + }; | |
| 134 | + "4CFE272A94D11EA39270BB02" = { | |
| 135 | + "isa" = "PBXFileReference"; | |
| 136 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 137 | + "path" = "Sources/PulseCanvas/StrobeDetector.swift"; | |
| 138 | + "sourceTree" = "<group>"; | |
| 139 | + }; | |
| 140 | + "445C690F1C4291BAEB5B0FED" = { | |
| 141 | + "isa" = "PBXFileReference"; | |
| 142 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 143 | + "path" = "Sources/PulseCanvas/StudioControls.swift"; | |
| 144 | + "sourceTree" = "<group>"; | |
| 145 | + }; | |
| 146 | + "7D367B139647CEA90F768A9B" = { | |
| 147 | + "isa" = "PBXFileReference"; | |
| 148 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 149 | + "path" = "Sources/PulseCanvas/StudioMusicPicker.swift"; | |
| 150 | + "sourceTree" = "<group>"; | |
| 151 | + }; | |
| 152 | + "D730C93684B8416B6A61FE2F" = { | |
| 153 | + "isa" = "PBXFileReference"; | |
| 154 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 155 | + "path" = "Sources/PulseCanvas/StudioPresentation.swift"; | |
| 156 | + "sourceTree" = "<group>"; | |
| 157 | + }; | |
| 158 | + "591380AEFE7045781F426D5E" = { | |
| 159 | + "isa" = "PBXFileReference"; | |
| 160 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 161 | + "path" = "Sources/PulseCanvas/StudioProjectDocument.swift"; | |
| 162 | + "sourceTree" = "<group>"; | |
| 163 | + }; | |
| 164 | + "C2CBF2E084321F2ECA296112" = { | |
| 165 | + "isa" = "PBXFileReference"; | |
| 166 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 167 | + "path" = "Sources/PulseCanvas/StudioStore.swift"; | |
| 168 | + "sourceTree" = "<group>"; | |
| 169 | + }; | |
| 170 | + "3810E7AB9E8DF14917E34477" = { | |
| 171 | + "isa" = "PBXFileReference"; | |
| 172 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 173 | + "path" = "Sources/PulseCanvas/StudioTimeline.swift"; | |
| 174 | + "sourceTree" = "<group>"; | |
| 175 | + }; | |
| 176 | + "E8D8D27BF7F9E2754340E1A3" = { | |
| 177 | + "isa" = "PBXFileReference"; | |
| 178 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 179 | + "path" = "Sources/PulseCanvas/StudioTimelineView.swift"; | |
| 180 | + "sourceTree" = "<group>"; | |
| 181 | + }; | |
| 182 | + "352EAD9C8771D54832387F64" = { | |
| 183 | + "isa" = "PBXFileReference"; | |
| 184 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 185 | + "path" = "Sources/PulseCanvas/UserBackup.swift"; | |
| 186 | + "sourceTree" = "<group>"; | |
| 187 | + }; | |
| 188 | + "5F51F1A8C96EC80FB3DF1789" = { | |
| 189 | + "isa" = "PBXFileReference"; | |
| 190 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 191 | + "path" = "Sources/PulseCanvas/UserBackupView.swift"; | |
| 192 | + "sourceTree" = "<group>"; | |
| 193 | + }; | |
| 194 | + "BC590D1F9F12E8A8A3FD703F" = { | |
| 195 | + "isa" = "PBXFileReference"; | |
| 196 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 197 | + "path" = "Sources/PulseCanvas/UserBackupZIP.swift"; | |
| 198 | + "sourceTree" = "<group>"; | |
| 199 | + }; | |
| 200 | + "5209D7B8FE7DB3E851C09177" = { | |
| 201 | + "isa" = "PBXFileReference"; | |
| 202 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 203 | + "path" = "Sources/PulseCanvas/VisualPalette.swift"; | |
| 204 | + "sourceTree" = "<group>"; | |
| 205 | + }; | |
| 206 | + "E76D1B93B17DC49DF3364355" = { | |
| 207 | + "isa" = "PBXFileReference"; | |
| 208 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 209 | + "path" = "Sources/PulseCanvas/VisualPreset.swift"; | |
| 210 | + "sourceTree" = "<group>"; | |
| 211 | + }; | |
| 212 | + "2DC8FA731B0E69EFBE8C5F23" = { | |
| 213 | + "isa" = "PBXFileReference"; | |
| 214 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 215 | + "path" = "Sources/PulseCanvas/VisualizerBrowser.swift"; | |
| 216 | + "sourceTree" = "<group>"; | |
| 217 | + }; | |
| 218 | + "BDC70BBF14D9FA6AFF52EF57" = { | |
| 219 | + "isa" = "PBXFileReference"; | |
| 220 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 221 | + "path" = "Sources/PulseCanvas/VisualizerFavoriteGesture.swift"; | |
| 222 | + "sourceTree" = "<group>"; | |
| 223 | + }; | |
| 224 | + "60524849AAB9510D72A785E5" = { | |
| 225 | + "isa" = "PBXFileReference"; | |
| 226 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 227 | + "path" = "Sources/PulseCanvas/VisualizerPoolControls.swift"; | |
| 228 | + "sourceTree" = "<group>"; | |
| 229 | + }; | |
| 230 | + "708BBBB95AD63DC7E6DBA5CE" = { | |
| 231 | + "isa" = "PBXFileReference"; | |
| 232 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 233 | + "path" = "Sources/PulseCanvas/VisualizerPresetStrip.swift"; | |
| 234 | + "sourceTree" = "<group>"; | |
| 235 | + }; | |
| 236 | + "7958DCE0804231A319D26CD8" = { | |
| 237 | + "isa" = "PBXFileReference"; | |
| 238 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 239 | + "path" = "Sources/PulseCanvas/VisualizerRenderer.swift"; | |
| 240 | + "sourceTree" = "<group>"; | |
| 241 | + }; | |
| 242 | + "AEB3E1F4EFCEE89846DDB6F1" = { | |
| 243 | + "isa" = "PBXFileReference"; | |
| 244 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 245 | + "path" = "macOS/BundleResources.swift"; | |
| 246 | + "sourceTree" = "<group>"; | |
| 247 | + }; | |
| 248 | + "4B938F834BDD8BCB6DFD7691" = { | |
| 249 | + "isa" = "PBXFileReference"; | |
| 250 | + "lastKnownFileType" = "text.json.xcstrings"; | |
| 251 | + "path" = "Localization/Localizable.xcstrings"; | |
| 252 | + "sourceTree" = "<group>"; | |
| 253 | + }; | |
| 254 | + "DABBA78FD2CA1C70524016C7" = { | |
| 255 | + "isa" = "PBXFileReference"; | |
| 256 | + "lastKnownFileType" = "folder"; | |
| 257 | + "path" = ".build/store-resources/Resources"; | |
| 258 | + "sourceTree" = "<group>"; | |
| 259 | + }; | |
| 260 | + "5CEB2FADE0103A495626491F" = { | |
| 261 | + "isa" = "PBXFileReference"; | |
| 262 | + "lastKnownFileType" = "image.icns"; | |
| 263 | + "path" = ".build/store-resources/AppIcon.icns"; | |
| 264 | + "sourceTree" = "<group>"; | |
| 265 | + }; | |
| 266 | + "9CF1AB3B18887D6A6C066E75" = { | |
| 267 | + "isa" = "PBXFileReference"; | |
| 268 | + "lastKnownFileType" = "folder"; | |
| 269 | + "path" = ".build/store-resources/Legal"; | |
| 270 | + "sourceTree" = "<group>"; | |
| 271 | + }; | |
| 272 | + "0A5282C4EC48041B28F6D173" = { | |
| 273 | + "isa" = "PBXFileReference"; | |
| 274 | + "lastKnownFileType" = "text.xml"; | |
| 275 | + "path" = "macOS/PrivacyInfo.xcprivacy"; | |
| 276 | + "sourceTree" = "<group>"; | |
| 277 | + }; | |
| 278 | + "17EF7EA6E4B2C028C8FFD997" = { | |
| 279 | + "isa" = "PBXFileReference"; | |
| 280 | + "lastKnownFileType" = "text.xcconfig"; | |
| 281 | + "path" = "macOS/Release.xcconfig"; | |
| 282 | + "sourceTree" = "<group>"; | |
| 283 | + }; | |
| 284 | + "46F0CB8365F54D638291EBCD" = { | |
| 285 | + "isa" = "PBXFileReference"; | |
| 286 | + "lastKnownFileType" = "text.xcconfig"; | |
| 287 | + "path" = "Version.xcconfig"; | |
| 288 | + "sourceTree" = "<group>"; | |
| 289 | + }; | |
| 290 | + "84D683A1A8B69C07FFB2CC3E" = { | |
| 291 | + "isa" = "PBXFileReference"; | |
| 292 | + "lastKnownFileType" = "text.plist.xml"; | |
| 293 | + "path" = "macOS/Info.plist"; | |
| 294 | + "sourceTree" = "<group>"; | |
| 295 | + }; | |
| 296 | + "C5CE7949C1B69A9E51043058" = { | |
| 297 | + "isa" = "PBXFileReference"; | |
| 298 | + "lastKnownFileType" = "text.plist.entitlements"; | |
| 299 | + "path" = "macOS/PulseCanvas.entitlements"; | |
| 300 | + "sourceTree" = "<group>"; | |
| 301 | + }; | |
| 302 | + "A8792157CB4F27FB949C035F" = { | |
| 303 | + "isa" = "PBXFileReference"; | |
| 304 | + "explicitFileType" = "wrapper.application"; | |
| 305 | + "path" = "PulseCanvas Studio.app"; | |
| 306 | + "sourceTree" = "BUILT_PRODUCTS_DIR"; | |
| 307 | + "includeInIndex" = 0; | |
| 308 | + }; | |
| 309 | + "0A3E27B8CA818264D75C8D81" = { | |
| 310 | + "isa" = "PBXGroup"; | |
| 311 | + "children" = ( | |
| 312 | + "A8792157CB4F27FB949C035F", | |
| 313 | + ); | |
| 314 | + "name" = "Products"; | |
| 315 | + "sourceTree" = "<group>"; | |
| 316 | + }; | |
| 317 | + "0D6E4079E36703EBD37C0072" = { | |
| 318 | + "isa" = "PBXGroup"; | |
| 319 | + "children" = ( | |
| 320 | + "D86646D49B9BAADCCA5D281C", | |
| 321 | + "D061672D180E0CC713D8F100", | |
| 322 | + "7E1F3D8976A0AE0EF6B1CFC0", | |
| 323 | + "C206A182BBE4A737E9AD134E", | |
| 324 | + "AD6CBDCBF5BC1A861917A40A", | |
| 325 | + "413823572A414825D1DA4580", | |
| 326 | + "07928D013502A7AEB5C6EB03", | |
| 327 | + "AB03A0B65DCF1AD6BE5612B3", | |
| 328 | + "119DE12F5D045816EDEC9843", | |
| 329 | + "900F718AA064255994CD45B8", | |
| 330 | + "3A4073EA821A833AE027E7E9", | |
| 331 | + "4652E379F9220B1BF60E12B9", | |
| 332 | + "100CD0DC00C64B0B646E69DC", | |
| 333 | + "2DF77FDA9C8372B7840DB84B", | |
| 334 | + "C21BFB46BEED9116F0743542", | |
| 335 | + "267585C701FE24385C4A7730", | |
| 336 | + "CED40C63C78F355A3E299D3F", | |
| 337 | + "A49A1847A6C656BBBFECDB8E", | |
| 338 | + "A7107BA039EA8BCCF0F232A8", | |
| 339 | + "CB8C52BD5C2A06B60EC6768B", | |
| 340 | + "4C15E8BE8F01FC4E793E0EE1", | |
| 341 | + "4CFE272A94D11EA39270BB02", | |
| 342 | + "445C690F1C4291BAEB5B0FED", | |
| 343 | + "7D367B139647CEA90F768A9B", | |
| 344 | + "D730C93684B8416B6A61FE2F", | |
| 345 | + "591380AEFE7045781F426D5E", | |
| 346 | + "C2CBF2E084321F2ECA296112", | |
| 347 | + "3810E7AB9E8DF14917E34477", | |
| 348 | + "E8D8D27BF7F9E2754340E1A3", | |
| 349 | + "352EAD9C8771D54832387F64", | |
| 350 | + "5F51F1A8C96EC80FB3DF1789", | |
| 351 | + "BC590D1F9F12E8A8A3FD703F", | |
| 352 | + "5209D7B8FE7DB3E851C09177", | |
| 353 | + "E76D1B93B17DC49DF3364355", | |
| 354 | + "2DC8FA731B0E69EFBE8C5F23", | |
| 355 | + "BDC70BBF14D9FA6AFF52EF57", | |
| 356 | + "60524849AAB9510D72A785E5", | |
| 357 | + "708BBBB95AD63DC7E6DBA5CE", | |
| 358 | + "7958DCE0804231A319D26CD8", | |
| 359 | + "AEB3E1F4EFCEE89846DDB6F1", | |
| 360 | + "4B938F834BDD8BCB6DFD7691", | |
| 361 | + "DABBA78FD2CA1C70524016C7", | |
| 362 | + "5CEB2FADE0103A495626491F", | |
| 363 | + "9CF1AB3B18887D6A6C066E75", | |
| 364 | + "0A5282C4EC48041B28F6D173", | |
| 365 | + "46F0CB8365F54D638291EBCD", | |
| 366 | + "17EF7EA6E4B2C028C8FFD997", | |
| 367 | + "84D683A1A8B69C07FFB2CC3E", | |
| 368 | + "C5CE7949C1B69A9E51043058", | |
| 369 | + "0A3E27B8CA818264D75C8D81", | |
| 370 | + ); | |
| 371 | + "sourceTree" = "<group>"; | |
| 372 | + }; | |
| 373 | + "45666D976BAB316D970EC459" = { | |
| 374 | + "isa" = "PBXShellScriptBuildPhase"; | |
| 375 | + "buildActionMask" = 2147483647; | |
| 376 | + "files" = ( | |
| 377 | + ); | |
| 378 | + "inputPaths" = ( | |
| 379 | + ); | |
| 380 | + "outputPaths" = ( | |
| 381 | + ); | |
| 382 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 383 | + "shellPath" = "/bin/bash"; | |
| 384 | + "shellScript" = "\"$SRCROOT/scripts/prepare-store-resources.sh\"\n"; | |
| 385 | + "name" = "Prepare Metal-only resources, icon and notices"; | |
| 386 | + "alwaysOutOfDate" = 1; | |
| 387 | + }; | |
| 388 | + "98B1A0EF3E95FE4A503FCA3F" = { | |
| 389 | + "isa" = "PBXBuildFile"; | |
| 390 | + "fileRef" = "D86646D49B9BAADCCA5D281C"; | |
| 391 | + }; | |
| 392 | + "D03D42F4A68816AE8C471677" = { | |
| 393 | + "isa" = "PBXBuildFile"; | |
| 394 | + "fileRef" = "D061672D180E0CC713D8F100"; | |
| 395 | + }; | |
| 396 | + "5A9DA0047F539373CD750217" = { | |
| 397 | + "isa" = "PBXBuildFile"; | |
| 398 | + "fileRef" = "7E1F3D8976A0AE0EF6B1CFC0"; | |
| 399 | + }; | |
| 400 | + "4E447B62A357FA71945F2C7A" = { | |
| 401 | + "isa" = "PBXBuildFile"; | |
| 402 | + "fileRef" = "C206A182BBE4A737E9AD134E"; | |
| 403 | + }; | |
| 404 | + "73E54E4F68C3C29893DBAD8B" = { | |
| 405 | + "isa" = "PBXBuildFile"; | |
| 406 | + "fileRef" = "AD6CBDCBF5BC1A861917A40A"; | |
| 407 | + }; | |
| 408 | + "E9653C0EF1AF556DE8D49873" = { | |
| 409 | + "isa" = "PBXBuildFile"; | |
| 410 | + "fileRef" = "413823572A414825D1DA4580"; | |
| 411 | + }; | |
| 412 | + "6BCAD6CE9055ABB8BDE99D3D" = { | |
| 413 | + "isa" = "PBXBuildFile"; | |
| 414 | + "fileRef" = "07928D013502A7AEB5C6EB03"; | |
| 415 | + }; | |
| 416 | + "5316D1BFE48A71EF8A4E8A29" = { | |
| 417 | + "isa" = "PBXBuildFile"; | |
| 418 | + "fileRef" = "AB03A0B65DCF1AD6BE5612B3"; | |
| 419 | + }; | |
| 420 | + "B37753D4AB949DB5681B16FB" = { | |
| 421 | + "isa" = "PBXBuildFile"; | |
| 422 | + "fileRef" = "119DE12F5D045816EDEC9843"; | |
| 423 | + }; | |
| 424 | + "D8602951BD2FFB1812BD21EE" = { | |
| 425 | + "isa" = "PBXBuildFile"; | |
| 426 | + "fileRef" = "900F718AA064255994CD45B8"; | |
| 427 | + }; | |
| 428 | + "86834B9344A07951CBBC0BE7" = { | |
| 429 | + "isa" = "PBXBuildFile"; | |
| 430 | + "fileRef" = "3A4073EA821A833AE027E7E9"; | |
| 431 | + }; | |
| 432 | + "300C1C6C7AC83D517D44ED14" = { | |
| 433 | + "isa" = "PBXBuildFile"; | |
| 434 | + "fileRef" = "4652E379F9220B1BF60E12B9"; | |
| 435 | + }; | |
| 436 | + "F11FE05286D083962ACFFC9E" = { | |
| 437 | + "isa" = "PBXBuildFile"; | |
| 438 | + "fileRef" = "100CD0DC00C64B0B646E69DC"; | |
| 439 | + }; | |
| 440 | + "9AAD59C9AF6056DDF96C21D9" = { | |
| 441 | + "isa" = "PBXBuildFile"; | |
| 442 | + "fileRef" = "2DF77FDA9C8372B7840DB84B"; | |
| 443 | + }; | |
| 444 | + "F63D8A506117BA23ABD7FB92" = { | |
| 445 | + "isa" = "PBXBuildFile"; | |
| 446 | + "fileRef" = "C21BFB46BEED9116F0743542"; | |
| 447 | + }; | |
| 448 | + "AF9CE3E468D5BC4C85C8FF68" = { | |
| 449 | + "isa" = "PBXBuildFile"; | |
| 450 | + "fileRef" = "267585C701FE24385C4A7730"; | |
| 451 | + }; | |
| 452 | + "97093D2BC86E4D8ABD384FFB" = { | |
| 453 | + "isa" = "PBXBuildFile"; | |
| 454 | + "fileRef" = "CED40C63C78F355A3E299D3F"; | |
| 455 | + }; | |
| 456 | + "437A5D46901E04F456D232F5" = { | |
| 457 | + "isa" = "PBXBuildFile"; | |
| 458 | + "fileRef" = "A49A1847A6C656BBBFECDB8E"; | |
| 459 | + }; | |
| 460 | + "2F22B5B3D3EBCB9655A17ACE" = { | |
| 461 | + "isa" = "PBXBuildFile"; | |
| 462 | + "fileRef" = "A7107BA039EA8BCCF0F232A8"; | |
| 463 | + }; | |
| 464 | + "DE69E89DD3EEAAD604860B0B" = { | |
| 465 | + "isa" = "PBXBuildFile"; | |
| 466 | + "fileRef" = "CB8C52BD5C2A06B60EC6768B"; | |
| 467 | + }; | |
| 468 | + "31AACDF3704BA6FDA1C24B2F" = { | |
| 469 | + "isa" = "PBXBuildFile"; | |
| 470 | + "fileRef" = "4C15E8BE8F01FC4E793E0EE1"; | |
| 471 | + }; | |
| 472 | + "2CA3823F37CFB4409025F7D9" = { | |
| 473 | + "isa" = "PBXBuildFile"; | |
| 474 | + "fileRef" = "4CFE272A94D11EA39270BB02"; | |
| 475 | + }; | |
| 476 | + "73350406688F45BC7A78DEA9" = { | |
| 477 | + "isa" = "PBXBuildFile"; | |
| 478 | + "fileRef" = "445C690F1C4291BAEB5B0FED"; | |
| 479 | + }; | |
| 480 | + "AAC473035B0539E8E791202F" = { | |
| 481 | + "isa" = "PBXBuildFile"; | |
| 482 | + "fileRef" = "7D367B139647CEA90F768A9B"; | |
| 483 | + }; | |
| 484 | + "036E8B061D198647F16F74AA" = { | |
| 485 | + "isa" = "PBXBuildFile"; | |
| 486 | + "fileRef" = "D730C93684B8416B6A61FE2F"; | |
| 487 | + }; | |
| 488 | + "125C9E8E31AE7245553DEA50" = { | |
| 489 | + "isa" = "PBXBuildFile"; | |
| 490 | + "fileRef" = "591380AEFE7045781F426D5E"; | |
| 491 | + }; | |
| 492 | + "711C0F30FD1616D636AA2959" = { | |
| 493 | + "isa" = "PBXBuildFile"; | |
| 494 | + "fileRef" = "C2CBF2E084321F2ECA296112"; | |
| 495 | + }; | |
| 496 | + "1857C14A0B38C2D8BBE2A813" = { | |
| 497 | + "isa" = "PBXBuildFile"; | |
| 498 | + "fileRef" = "3810E7AB9E8DF14917E34477"; | |
| 499 | + }; | |
| 500 | + "E13F13A9C228F2084DE33225" = { | |
| 501 | + "isa" = "PBXBuildFile"; | |
| 502 | + "fileRef" = "E8D8D27BF7F9E2754340E1A3"; | |
| 503 | + }; | |
| 504 | + "2074393C0363491D999BAE16" = { | |
| 505 | + "isa" = "PBXBuildFile"; | |
| 506 | + "fileRef" = "352EAD9C8771D54832387F64"; | |
| 507 | + }; | |
| 508 | + "2F53CCB0C5523BCC1AD41BDB" = { | |
| 509 | + "isa" = "PBXBuildFile"; | |
| 510 | + "fileRef" = "5F51F1A8C96EC80FB3DF1789"; | |
| 511 | + }; | |
| 512 | + "EE39D2C5ADC981818B9117E1" = { | |
| 513 | + "isa" = "PBXBuildFile"; | |
| 514 | + "fileRef" = "BC590D1F9F12E8A8A3FD703F"; | |
| 515 | + }; | |
| 516 | + "59F9215D16187F2AAD43D7B8" = { | |
| 517 | + "isa" = "PBXBuildFile"; | |
| 518 | + "fileRef" = "5209D7B8FE7DB3E851C09177"; | |
| 519 | + }; | |
| 520 | + "A7CE383E14BB29514D2DD0C2" = { | |
| 521 | + "isa" = "PBXBuildFile"; | |
| 522 | + "fileRef" = "E76D1B93B17DC49DF3364355"; | |
| 523 | + }; | |
| 524 | + "69442A0AA42CCF182DE4D40C" = { | |
| 525 | + "isa" = "PBXBuildFile"; | |
| 526 | + "fileRef" = "2DC8FA731B0E69EFBE8C5F23"; | |
| 527 | + }; | |
| 528 | + "3639C00CF5450A6B8B0ECFD1" = { | |
| 529 | + "isa" = "PBXBuildFile"; | |
| 530 | + "fileRef" = "BDC70BBF14D9FA6AFF52EF57"; | |
| 531 | + }; | |
| 532 | + "1E4F77C1404DCB61DFAB398B" = { | |
| 533 | + "isa" = "PBXBuildFile"; | |
| 534 | + "fileRef" = "60524849AAB9510D72A785E5"; | |
| 535 | + }; | |
| 536 | + "3B47F2807476B0478D4672B9" = { | |
| 537 | + "isa" = "PBXBuildFile"; | |
| 538 | + "fileRef" = "708BBBB95AD63DC7E6DBA5CE"; | |
| 539 | + }; | |
| 540 | + "80C0D081FE8F82B6B5025265" = { | |
| 541 | + "isa" = "PBXBuildFile"; | |
| 542 | + "fileRef" = "7958DCE0804231A319D26CD8"; | |
| 543 | + }; | |
| 544 | + "751BBC7AFA2EC0105700402A" = { | |
| 545 | + "isa" = "PBXBuildFile"; | |
| 546 | + "fileRef" = "AEB3E1F4EFCEE89846DDB6F1"; | |
| 547 | + }; | |
| 548 | + "878A52FC5FF6A57D50B7B870" = { | |
| 549 | + "isa" = "PBXSourcesBuildPhase"; | |
| 550 | + "buildActionMask" = 2147483647; | |
| 551 | + "files" = ( | |
| 552 | + "98B1A0EF3E95FE4A503FCA3F", | |
| 553 | + "D03D42F4A68816AE8C471677", | |
| 554 | + "5A9DA0047F539373CD750217", | |
| 555 | + "4E447B62A357FA71945F2C7A", | |
| 556 | + "73E54E4F68C3C29893DBAD8B", | |
| 557 | + "E9653C0EF1AF556DE8D49873", | |
| 558 | + "6BCAD6CE9055ABB8BDE99D3D", | |
| 559 | + "5316D1BFE48A71EF8A4E8A29", | |
| 560 | + "B37753D4AB949DB5681B16FB", | |
| 561 | + "D8602951BD2FFB1812BD21EE", | |
| 562 | + "86834B9344A07951CBBC0BE7", | |
| 563 | + "300C1C6C7AC83D517D44ED14", | |
| 564 | + "F11FE05286D083962ACFFC9E", | |
| 565 | + "9AAD59C9AF6056DDF96C21D9", | |
| 566 | + "F63D8A506117BA23ABD7FB92", | |
| 567 | + "AF9CE3E468D5BC4C85C8FF68", | |
| 568 | + "97093D2BC86E4D8ABD384FFB", | |
| 569 | + "437A5D46901E04F456D232F5", | |
| 570 | + "2F22B5B3D3EBCB9655A17ACE", | |
| 571 | + "DE69E89DD3EEAAD604860B0B", | |
| 572 | + "31AACDF3704BA6FDA1C24B2F", | |
| 573 | + "2CA3823F37CFB4409025F7D9", | |
| 574 | + "73350406688F45BC7A78DEA9", | |
| 575 | + "AAC473035B0539E8E791202F", | |
| 576 | + "036E8B061D198647F16F74AA", | |
| 577 | + "125C9E8E31AE7245553DEA50", | |
| 578 | + "711C0F30FD1616D636AA2959", | |
| 579 | + "1857C14A0B38C2D8BBE2A813", | |
| 580 | + "E13F13A9C228F2084DE33225", | |
| 581 | + "2074393C0363491D999BAE16", | |
| 582 | + "2F53CCB0C5523BCC1AD41BDB", | |
| 583 | + "EE39D2C5ADC981818B9117E1", | |
| 584 | + "59F9215D16187F2AAD43D7B8", | |
| 585 | + "A7CE383E14BB29514D2DD0C2", | |
| 586 | + "69442A0AA42CCF182DE4D40C", | |
| 587 | + "3639C00CF5450A6B8B0ECFD1", | |
| 588 | + "1E4F77C1404DCB61DFAB398B", | |
| 589 | + "3B47F2807476B0478D4672B9", | |
| 590 | + "80C0D081FE8F82B6B5025265", | |
| 591 | + "751BBC7AFA2EC0105700402A", | |
| 592 | + ); | |
| 593 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 594 | + }; | |
| 595 | + "BD360A10C929F703C02C4331" = { | |
| 596 | + "isa" = "PBXBuildFile"; | |
| 597 | + "fileRef" = "4B938F834BDD8BCB6DFD7691"; | |
| 598 | + }; | |
| 599 | + "53FDF00ABC9CF794AEAC820F" = { | |
| 600 | + "isa" = "PBXBuildFile"; | |
| 601 | + "fileRef" = "DABBA78FD2CA1C70524016C7"; | |
| 602 | + }; | |
| 603 | + "F324541CC5C84ED6B05C0455" = { | |
| 604 | + "isa" = "PBXBuildFile"; | |
| 605 | + "fileRef" = "5CEB2FADE0103A495626491F"; | |
| 606 | + }; | |
| 607 | + "DED41CB9A5DECC1FA0031082" = { | |
| 608 | + "isa" = "PBXBuildFile"; | |
| 609 | + "fileRef" = "9CF1AB3B18887D6A6C066E75"; | |
| 610 | + }; | |
| 611 | + "56C3256106C3A108001EC3FF" = { | |
| 612 | + "isa" = "PBXBuildFile"; | |
| 613 | + "fileRef" = "0A5282C4EC48041B28F6D173"; | |
| 614 | + }; | |
| 615 | + "41D311A605520FC7B8B9A980" = { | |
| 616 | + "isa" = "PBXResourcesBuildPhase"; | |
| 617 | + "buildActionMask" = 2147483647; | |
| 618 | + "files" = ( | |
| 619 | + "BD360A10C929F703C02C4331", | |
| 620 | + "53FDF00ABC9CF794AEAC820F", | |
| 621 | + "F324541CC5C84ED6B05C0455", | |
| 622 | + "DED41CB9A5DECC1FA0031082", | |
| 623 | + "56C3256106C3A108001EC3FF", | |
| 624 | + ); | |
| 625 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 626 | + }; | |
| 627 | + "E2AA269EB967A8853A258BFA" = { | |
| 628 | + "isa" = "PBXFrameworksBuildPhase"; | |
| 629 | + "buildActionMask" = 2147483647; | |
| 630 | + "files" = ( | |
| 631 | + "9B1266BC9A27D9D3E1D7EA9D", | |
| 632 | + ); | |
| 633 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 634 | + }; | |
| 635 | + "51E8202AFD2FC3EEE6DD9FDD" = { | |
| 636 | + "isa" = "XCBuildConfiguration"; | |
| 637 | + "buildSettings" = { | |
| 638 | + "SDKROOT" = "macosx"; | |
| 639 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 640 | + "SWIFT_OPTIMIZATION_LEVEL" = "-Onone"; | |
| 641 | + "DEBUG_INFORMATION_FORMAT" = "dwarf"; | |
| 642 | + "SWIFT_EMIT_LOC_STRINGS" = "NO"; | |
| 643 | + "SWIFT_ACTIVE_COMPILATION_CONDITIONS" = "$(inherited) DEBUG"; | |
| 644 | + }; | |
| 645 | + "name" = "Debug"; | |
| 646 | + "baseConfigurationReference" = "17EF7EA6E4B2C028C8FFD997"; | |
| 647 | + }; | |
| 648 | + "6FFB70182C414855445722B9" = { | |
| 649 | + "isa" = "XCBuildConfiguration"; | |
| 650 | + "buildSettings" = { | |
| 651 | + "SDKROOT" = "macosx"; | |
| 652 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 653 | + "SWIFT_OPTIMIZATION_LEVEL" = "-O"; | |
| 654 | + "DEBUG_INFORMATION_FORMAT" = "dwarf-with-dsym"; | |
| 655 | + "SWIFT_EMIT_LOC_STRINGS" = "NO"; | |
| 656 | + "SWIFT_ACTIVE_COMPILATION_CONDITIONS" = "$(inherited)"; | |
| 657 | + }; | |
| 658 | + "name" = "Release"; | |
| 659 | + "baseConfigurationReference" = "17EF7EA6E4B2C028C8FFD997"; | |
| 660 | + }; | |
| 661 | + "C5C73E6481A31CFC647F47AB" = { | |
| 662 | + "isa" = "XCConfigurationList"; | |
| 663 | + "buildConfigurations" = ( | |
| 664 | + "51E8202AFD2FC3EEE6DD9FDD", | |
| 665 | + "6FFB70182C414855445722B9", | |
| 666 | + ); | |
| 667 | + "defaultConfigurationIsVisible" = 0; | |
| 668 | + "defaultConfigurationName" = "Release"; | |
| 669 | + }; | |
| 670 | + "34A04005BCAF206EEC990BD9" = { | |
| 671 | + "isa" = "PBXNativeTarget"; | |
| 672 | + "buildConfigurationList" = "C5C73E6481A31CFC647F47AB"; | |
| 673 | + "buildPhases" = ( | |
| 674 | + "45666D976BAB316D970EC459", | |
| 675 | + "878A52FC5FF6A57D50B7B870", | |
| 676 | + "E2AA269EB967A8853A258BFA", | |
| 677 | + "41D311A605520FC7B8B9A980", | |
| 678 | + ); | |
| 679 | + "buildRules" = ( | |
| 680 | + ); | |
| 681 | + "dependencies" = ( | |
| 682 | + ); | |
| 683 | + "name" = "PulseCanvas"; | |
| 684 | + "productName" = "PulseCanvas Studio"; | |
| 685 | + "productReference" = "A8792157CB4F27FB949C035F"; | |
| 686 | + "productType" = "com.apple.product-type.application"; | |
| 687 | + "packageProductDependencies" = ( | |
| 688 | + "9B427405DFFC7306479BADEE", | |
| 689 | + ); | |
| 690 | + }; | |
| 691 | + "CBE79372575C6BD5A9131E8F" = { | |
| 692 | + "isa" = "XCBuildConfiguration"; | |
| 693 | + "buildSettings" = { | |
| 694 | + "SDKROOT" = "macosx"; | |
| 695 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 696 | + }; | |
| 697 | + "name" = "Debug"; | |
| 698 | + }; | |
| 699 | + "2D49EBE4C1EF4247FC7BA12F" = { | |
| 700 | + "isa" = "XCBuildConfiguration"; | |
| 701 | + "buildSettings" = { | |
| 702 | + "SDKROOT" = "macosx"; | |
| 703 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 704 | + }; | |
| 705 | + "name" = "Release"; | |
| 706 | + }; | |
| 707 | + "9879E227F5AD614B3D33074F" = { | |
| 708 | + "isa" = "XCConfigurationList"; | |
| 709 | + "buildConfigurations" = ( | |
| 710 | + "CBE79372575C6BD5A9131E8F", | |
| 711 | + "2D49EBE4C1EF4247FC7BA12F", | |
| 712 | + ); | |
| 713 | + "defaultConfigurationIsVisible" = 0; | |
| 714 | + "defaultConfigurationName" = "Release"; | |
| 715 | + }; | |
| 716 | + "244210E48437B6556980A702" = { | |
| 717 | + "isa" = "PBXProject"; | |
| 718 | + "attributes" = { | |
| 719 | + "LastUpgradeCheck" = "2700"; | |
| 720 | + "TargetAttributes" = { | |
| 721 | + "34A04005BCAF206EEC990BD9" = { | |
| 722 | + "CreatedOnToolsVersion" = "27.0"; | |
| 723 | + "ProvisioningStyle" = "Automatic"; | |
| 724 | + "SystemCapabilities" = { | |
| 725 | + "com.apple.Sandbox" = { | |
| 726 | + "enabled" = 1; | |
| 727 | + }; | |
| 728 | + "com.apple.iCloud" = { | |
| 729 | + "enabled" = 1; | |
| 730 | + }; | |
| 731 | + }; | |
| 732 | + }; | |
| 733 | + }; | |
| 734 | + }; | |
| 735 | + "buildConfigurationList" = "9879E227F5AD614B3D33074F"; | |
| 736 | + "compatibilityVersion" = "Xcode 14.0"; | |
| 737 | + "developmentRegion" = "en"; | |
| 738 | + "hasScannedForEncodings" = 0; | |
| 739 | + "knownRegions" = ( | |
| 740 | + "en", | |
| 741 | + "Base", | |
| 742 | + ); | |
| 743 | + "mainGroup" = "0D6E4079E36703EBD37C0072"; | |
| 744 | + "productRefGroup" = "0A3E27B8CA818264D75C8D81"; | |
| 745 | + "projectDirPath" = ""; | |
| 746 | + "projectRoot" = ""; | |
| 747 | + "targets" = ( | |
| 748 | + "34A04005BCAF206EEC990BD9", | |
| 749 | + ); | |
| 750 | + "packageReferences" = ( | |
| 751 | + "D50706B6923B46DFD8933125", | |
| 752 | + ); | |
| 753 | + }; | |
| 754 | + "D50706B6923B46DFD8933125" = { | |
| 755 | + "isa" = "XCRemoteSwiftPackageReference"; | |
| 756 | + "repositoryURL" = "https://github.com/weichsel/ZIPFoundation.git"; | |
| 757 | + "requirement" = { | |
| 758 | + "kind" = "exactVersion"; | |
| 759 | + "version" = "0.9.20"; | |
| 760 | + }; | |
| 761 | + }; | |
| 762 | + "9B427405DFFC7306479BADEE" = { | |
| 763 | + "isa" = "XCSwiftPackageProductDependency"; | |
| 764 | + "package" = "D50706B6923B46DFD8933125"; | |
| 765 | + "productName" = "ZIPFoundation"; | |
| 766 | + }; | |
| 767 | + "9B1266BC9A27D9D3E1D7EA9D" = { | |
| 768 | + "isa" = "PBXBuildFile"; | |
| 769 | + "productRef" = "9B427405DFFC7306479BADEE"; | |
| 770 | + }; | |
| 771 | + }; | |
| 772 | + "rootObject" = "244210E48437B6556980A702"; | |
| 773 | + } |
PulseCanvasMobile.xcodeproj/project.pbxproj added
| 1 | + // !$*UTF8*$! | |
| 2 | + { | |
| 3 | + "archiveVersion" = 1; | |
| 4 | + "classes" = { | |
| 5 | + }; | |
| 6 | + "objectVersion" = 56; | |
| 7 | + "objects" = { | |
| 8 | + "AB03A0B65DCF1AD6BE5612B3" = { | |
| 9 | + "isa" = "PBXFileReference"; | |
| 10 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 11 | + "path" = "Sources/PulseCanvas/CloudSyncLedger.swift"; | |
| 12 | + "sourceTree" = "<group>"; | |
| 13 | + }; | |
| 14 | + "413823572A414825D1DA4580" = { | |
| 15 | + "isa" = "PBXFileReference"; | |
| 16 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 17 | + "path" = "Sources/PulseCanvas/CloudProjectPackage.swift"; | |
| 18 | + "sourceTree" = "<group>"; | |
| 19 | + }; | |
| 20 | + "07928D013502A7AEB5C6EB03" = { | |
| 21 | + "isa" = "PBXFileReference"; | |
| 22 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 23 | + "path" = "Sources/PulseCanvas/CloudSyncAppData.swift"; | |
| 24 | + "sourceTree" = "<group>"; | |
| 25 | + }; | |
| 26 | + "119DE12F5D045816EDEC9843" = { | |
| 27 | + "isa" = "PBXFileReference"; | |
| 28 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 29 | + "path" = "Sources/PulseCanvas/CloudSyncService.swift"; | |
| 30 | + "sourceTree" = "<group>"; | |
| 31 | + }; | |
| 32 | + "900F718AA064255994CD45B8" = { | |
| 33 | + "isa" = "PBXFileReference"; | |
| 34 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 35 | + "path" = "Sources/PulseCanvas/CloudSyncView.swift"; | |
| 36 | + "sourceTree" = "<group>"; | |
| 37 | + }; | |
| 38 | + "352EAD9C8771D54832387F64" = { | |
| 39 | + "isa" = "PBXFileReference"; | |
| 40 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 41 | + "path" = "Sources/PulseCanvas/UserBackup.swift"; | |
| 42 | + "sourceTree" = "<group>"; | |
| 43 | + }; | |
| 44 | + "BC590D1F9F12E8A8A3FD703F" = { | |
| 45 | + "isa" = "PBXFileReference"; | |
| 46 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 47 | + "path" = "Sources/PulseCanvas/UserBackupZIP.swift"; | |
| 48 | + "sourceTree" = "<group>"; | |
| 49 | + }; | |
| 50 | + "5F51F1A8C96EC80FB3DF1789" = { | |
| 51 | + "isa" = "PBXFileReference"; | |
| 52 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 53 | + "path" = "Sources/PulseCanvas/UserBackupView.swift"; | |
| 54 | + "sourceTree" = "<group>"; | |
| 55 | + }; | |
| 56 | + "267585C701FE24385C4A7730" = { | |
| 57 | + "isa" = "PBXFileReference"; | |
| 58 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 59 | + "path" = "Sources/PulseCanvas/PulseCanvasOnboarding.swift"; | |
| 60 | + "sourceTree" = "<group>"; | |
| 61 | + }; | |
| 62 | + "BDC70BBF14D9FA6AFF52EF57" = { | |
| 63 | + "isa" = "PBXFileReference"; | |
| 64 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 65 | + "path" = "Sources/PulseCanvas/VisualizerFavoriteGesture.swift"; | |
| 66 | + "sourceTree" = "<group>"; | |
| 67 | + }; | |
| 68 | + "E76D1B93B17DC49DF3364355" = { | |
| 69 | + "isa" = "PBXFileReference"; | |
| 70 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 71 | + "path" = "Sources/PulseCanvas/VisualPreset.swift"; | |
| 72 | + "sourceTree" = "<group>"; | |
| 73 | + }; | |
| 74 | + "5209D7B8FE7DB3E851C09177" = { | |
| 75 | + "isa" = "PBXFileReference"; | |
| 76 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 77 | + "path" = "Sources/PulseCanvas/VisualPalette.swift"; | |
| 78 | + "sourceTree" = "<group>"; | |
| 79 | + }; | |
| 80 | + "100CD0DC00C64B0B646E69DC" = { | |
| 81 | + "isa" = "PBXFileReference"; | |
| 82 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 83 | + "path" = "Sources/PulseCanvas/OriginalGeometry.swift"; | |
| 84 | + "sourceTree" = "<group>"; | |
| 85 | + }; | |
| 86 | + "4652E379F9220B1BF60E12B9" = { | |
| 87 | + "isa" = "PBXFileReference"; | |
| 88 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 89 | + "path" = "Sources/PulseCanvas/NativeEffects.swift"; | |
| 90 | + "sourceTree" = "<group>"; | |
| 91 | + }; | |
| 92 | + "2DF77FDA9C8372B7840DB84B" = { | |
| 93 | + "isa" = "PBXFileReference"; | |
| 94 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 95 | + "path" = "Sources/PulseCanvas/ProjectMPresets.swift"; | |
| 96 | + "sourceTree" = "<group>"; | |
| 97 | + }; | |
| 98 | + "4CFE272A94D11EA39270BB02" = { | |
| 99 | + "isa" = "PBXFileReference"; | |
| 100 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 101 | + "path" = "Sources/PulseCanvas/StrobeDetector.swift"; | |
| 102 | + "sourceTree" = "<group>"; | |
| 103 | + }; | |
| 104 | + "7958DCE0804231A319D26CD8" = { | |
| 105 | + "isa" = "PBXFileReference"; | |
| 106 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 107 | + "path" = "Sources/PulseCanvas/VisualizerRenderer.swift"; | |
| 108 | + "sourceTree" = "<group>"; | |
| 109 | + }; | |
| 110 | + "D061672D180E0CC713D8F100" = { | |
| 111 | + "isa" = "PBXFileReference"; | |
| 112 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 113 | + "path" = "Sources/PulseCanvas/AudioAnalysis.swift"; | |
| 114 | + "sourceTree" = "<group>"; | |
| 115 | + }; | |
| 116 | + "3810E7AB9E8DF14917E34477" = { | |
| 117 | + "isa" = "PBXFileReference"; | |
| 118 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 119 | + "path" = "Sources/PulseCanvas/StudioTimeline.swift"; | |
| 120 | + "sourceTree" = "<group>"; | |
| 121 | + }; | |
| 122 | + "60524849AAB9510D72A785E5" = { | |
| 123 | + "isa" = "PBXFileReference"; | |
| 124 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 125 | + "path" = "Sources/PulseCanvas/VisualizerPoolControls.swift"; | |
| 126 | + "sourceTree" = "<group>"; | |
| 127 | + }; | |
| 128 | + "A49A1847A6C656BBBFECDB8E" = { | |
| 129 | + "isa" = "PBXFileReference"; | |
| 130 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 131 | + "path" = "Sources/PulseCanvas/RadioLibrary.swift"; | |
| 132 | + "sourceTree" = "<group>"; | |
| 133 | + }; | |
| 134 | + "7D367B139647CEA90F768A9B" = { | |
| 135 | + "isa" = "PBXFileReference"; | |
| 136 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 137 | + "path" = "Sources/PulseCanvas/StudioMusicPicker.swift"; | |
| 138 | + "sourceTree" = "<group>"; | |
| 139 | + }; | |
| 140 | + "C2CBF2E084321F2ECA296112" = { | |
| 141 | + "isa" = "PBXFileReference"; | |
| 142 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 143 | + "path" = "Sources/PulseCanvas/StudioStore.swift"; | |
| 144 | + "sourceTree" = "<group>"; | |
| 145 | + }; | |
| 146 | + "4C15E8BE8F01FC4E793E0EE1" = { | |
| 147 | + "isa" = "PBXFileReference"; | |
| 148 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 149 | + "path" = "Sources/PulseCanvas/SocialExportController.swift"; | |
| 150 | + "sourceTree" = "<group>"; | |
| 151 | + }; | |
| 152 | + "CB8C52BD5C2A06B60EC6768B" = { | |
| 153 | + "isa" = "PBXFileReference"; | |
| 154 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 155 | + "path" = "Sources/PulseCanvas/SecurityScopedAccess.swift"; | |
| 156 | + "sourceTree" = "<group>"; | |
| 157 | + }; | |
| 158 | + "7E1F3D8976A0AE0EF6B1CFC0" = { | |
| 159 | + "isa" = "PBXFileReference"; | |
| 160 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 161 | + "path" = "Sources/PulseCanvas/AudioController.swift"; | |
| 162 | + "sourceTree" = "<group>"; | |
| 163 | + }; | |
| 164 | + "CED40C63C78F355A3E299D3F" = { | |
| 165 | + "isa" = "PBXFileReference"; | |
| 166 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 167 | + "path" = "Sources/PulseCanvas/RadioController.swift"; | |
| 168 | + "sourceTree" = "<group>"; | |
| 169 | + }; | |
| 170 | + "C206A182BBE4A737E9AD134E" = { | |
| 171 | + "isa" = "PBXFileReference"; | |
| 172 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 173 | + "path" = "Sources/PulseCanvas/BundledSoundtrack.swift"; | |
| 174 | + "sourceTree" = "<group>"; | |
| 175 | + }; | |
| 176 | + "AEB3E1F4EFCEE89846DDB6F1" = { | |
| 177 | + "isa" = "PBXFileReference"; | |
| 178 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 179 | + "path" = "macOS/BundleResources.swift"; | |
| 180 | + "sourceTree" = "<group>"; | |
| 181 | + }; | |
| 182 | + "DE845A1EC8D791553BCC9754" = { | |
| 183 | + "isa" = "PBXFileReference"; | |
| 184 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 185 | + "path" = "mobile/MobileEditor.swift"; | |
| 186 | + "sourceTree" = "<group>"; | |
| 187 | + }; | |
| 188 | + "9D781BF6366C1AF7AE94F24C" = { | |
| 189 | + "isa" = "PBXFileReference"; | |
| 190 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 191 | + "path" = "mobile/MobileExport.swift"; | |
| 192 | + "sourceTree" = "<group>"; | |
| 193 | + }; | |
| 194 | + "A7A21CCBCFB8D45D1CDE5DF3" = { | |
| 195 | + "isa" = "PBXFileReference"; | |
| 196 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 197 | + "path" = "mobile/MobilePlaybackSession.swift"; | |
| 198 | + "sourceTree" = "<group>"; | |
| 199 | + }; | |
| 200 | + "F4748FB9737120A753F31D62" = { | |
| 201 | + "isa" = "PBXFileReference"; | |
| 202 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 203 | + "path" = "mobile/MobilePresentation.swift"; | |
| 204 | + "sourceTree" = "<group>"; | |
| 205 | + }; | |
| 206 | + "0181158CA6D4BB2EF64C0409" = { | |
| 207 | + "isa" = "PBXFileReference"; | |
| 208 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 209 | + "path" = "mobile/MobileProject.swift"; | |
| 210 | + "sourceTree" = "<group>"; | |
| 211 | + }; | |
| 212 | + "6213414714095BAA46062B29" = { | |
| 213 | + "isa" = "PBXFileReference"; | |
| 214 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 215 | + "path" = "mobile/MobileRadio.swift"; | |
| 216 | + "sourceTree" = "<group>"; | |
| 217 | + }; | |
| 218 | + "5012E6D93EFF080A93D6EDCE" = { | |
| 219 | + "isa" = "PBXFileReference"; | |
| 220 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 221 | + "path" = "mobile/MobileWorkspace.swift"; | |
| 222 | + "sourceTree" = "<group>"; | |
| 223 | + }; | |
| 224 | + "2E97B00487C11CD7193B0847" = { | |
| 225 | + "isa" = "PBXFileReference"; | |
| 226 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 227 | + "path" = "mobile/PulseCanvasMobileApp.swift"; | |
| 228 | + "sourceTree" = "<group>"; | |
| 229 | + }; | |
| 230 | + "4B938F834BDD8BCB6DFD7691" = { | |
| 231 | + "isa" = "PBXFileReference"; | |
| 232 | + "lastKnownFileType" = "text.json.xcstrings"; | |
| 233 | + "path" = "Localization/Localizable.xcstrings"; | |
| 234 | + "sourceTree" = "<group>"; | |
| 235 | + }; | |
| 236 | + "58B93EBF9D77801602DBED7F" = { | |
| 237 | + "isa" = "PBXFileReference"; | |
| 238 | + "lastKnownFileType" = "folder"; | |
| 239 | + "path" = "Sources/PulseCanvas/Resources/Onboarding"; | |
| 240 | + "sourceTree" = "<group>"; | |
| 241 | + }; | |
| 242 | + "9B792A85727D80D5A1AF3DEB" = { | |
| 243 | + "isa" = "PBXFileReference"; | |
| 244 | + "lastKnownFileType" = "folder.assetcatalog"; | |
| 245 | + "path" = "mobile/Assets.xcassets"; | |
| 246 | + "sourceTree" = "<group>"; | |
| 247 | + }; | |
| 248 | + "7DA70401A1572AAF33CFD9C4" = { | |
| 249 | + "isa" = "PBXFileReference"; | |
| 250 | + "lastKnownFileType" = "folder"; | |
| 251 | + "path" = ".build/mobile-resources/NativeAssets"; | |
| 252 | + "sourceTree" = "<group>"; | |
| 253 | + }; | |
| 254 | + "B65D6B361E275BD76958F3A4" = { | |
| 255 | + "isa" = "PBXFileReference"; | |
| 256 | + "lastKnownFileType" = "folder"; | |
| 257 | + "path" = ".build/mobile-resources/Legal"; | |
| 258 | + "sourceTree" = "<group>"; | |
| 259 | + }; | |
| 260 | + "0A5282C4EC48041B28F6D173" = { | |
| 261 | + "isa" = "PBXFileReference"; | |
| 262 | + "lastKnownFileType" = "text.xml"; | |
| 263 | + "path" = "macOS/PrivacyInfo.xcprivacy"; | |
| 264 | + "sourceTree" = "<group>"; | |
| 265 | + }; | |
| 266 | + "D2623FCE5CA50D234D849F2C" = { | |
| 267 | + "isa" = "PBXFileReference"; | |
| 268 | + "lastKnownFileType" = "text.xcconfig"; | |
| 269 | + "path" = "mobile/Release.xcconfig"; | |
| 270 | + "sourceTree" = "<group>"; | |
| 271 | + }; | |
| 272 | + "B3C02FE219F063016B2FE64C" = { | |
| 273 | + "isa" = "PBXFileReference"; | |
| 274 | + "lastKnownFileType" = "text.plist.xml"; | |
| 275 | + "path" = "mobile/Info.plist"; | |
| 276 | + "sourceTree" = "<group>"; | |
| 277 | + }; | |
| 278 | + "A8792157CB4F27FB949C035F" = { | |
| 279 | + "isa" = "PBXFileReference"; | |
| 280 | + "explicitFileType" = "wrapper.application"; | |
| 281 | + "path" = "PulseCanvas Mobile.app"; | |
| 282 | + "sourceTree" = "BUILT_PRODUCTS_DIR"; | |
| 283 | + }; | |
| 284 | + "A2C3BDDFC3480F0356F9813B" = { | |
| 285 | + "isa" = "PBXFileReference"; | |
| 286 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 287 | + "path" = "mobile/UITests/PulseCanvasMobileUITests.swift"; | |
| 288 | + "sourceTree" = "<group>"; | |
| 289 | + }; | |
| 290 | + "673AA0EC81EFB7A77EF7232A" = { | |
| 291 | + "isa" = "PBXFileReference"; | |
| 292 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 293 | + "path" = "mobile/UITests/PulseCanvasOnboardingUITests.swift"; | |
| 294 | + "sourceTree" = "<group>"; | |
| 295 | + }; | |
| 296 | + "9F63878049D400944738EB5F" = { | |
| 297 | + "isa" = "PBXFileReference"; | |
| 298 | + "explicitFileType" = "wrapper.cfbundle"; | |
| 299 | + "path" = "PulseCanvasMobileUITests.xctest"; | |
| 300 | + "sourceTree" = "BUILT_PRODUCTS_DIR"; | |
| 301 | + }; | |
| 302 | + "0A3E27B8CA818264D75C8D81" = { | |
| 303 | + "isa" = "PBXGroup"; | |
| 304 | + "children" = ( | |
| 305 | + "A8792157CB4F27FB949C035F", | |
| 306 | + "9F63878049D400944738EB5F", | |
| 307 | + ); | |
| 308 | + "name" = "Products"; | |
| 309 | + "sourceTree" = "<group>"; | |
| 310 | + }; | |
| 311 | + "46F0CB8365F54D638291EBCD" = { | |
| 312 | + "isa" = "PBXFileReference"; | |
| 313 | + "lastKnownFileType" = "text.xcconfig"; | |
| 314 | + "path" = "Version.xcconfig"; | |
| 315 | + "sourceTree" = "<group>"; | |
| 316 | + }; | |
| 317 | + "0D6E4079E36703EBD37C0072" = { | |
| 318 | + "isa" = "PBXGroup"; | |
| 319 | + "children" = ( | |
| 320 | + "AB03A0B65DCF1AD6BE5612B3", | |
| 321 | + "413823572A414825D1DA4580", | |
| 322 | + "07928D013502A7AEB5C6EB03", | |
| 323 | + "119DE12F5D045816EDEC9843", | |
| 324 | + "900F718AA064255994CD45B8", | |
| 325 | + "352EAD9C8771D54832387F64", | |
| 326 | + "BC590D1F9F12E8A8A3FD703F", | |
| 327 | + "5F51F1A8C96EC80FB3DF1789", | |
| 328 | + "267585C701FE24385C4A7730", | |
| 329 | + "BDC70BBF14D9FA6AFF52EF57", | |
| 330 | + "E76D1B93B17DC49DF3364355", | |
| 331 | + "5209D7B8FE7DB3E851C09177", | |
| 332 | + "100CD0DC00C64B0B646E69DC", | |
| 333 | + "4652E379F9220B1BF60E12B9", | |
| 334 | + "2DF77FDA9C8372B7840DB84B", | |
| 335 | + "4CFE272A94D11EA39270BB02", | |
| 336 | + "7958DCE0804231A319D26CD8", | |
| 337 | + "D061672D180E0CC713D8F100", | |
| 338 | + "3810E7AB9E8DF14917E34477", | |
| 339 | + "60524849AAB9510D72A785E5", | |
| 340 | + "A49A1847A6C656BBBFECDB8E", | |
| 341 | + "7D367B139647CEA90F768A9B", | |
| 342 | + "C2CBF2E084321F2ECA296112", | |
| 343 | + "4C15E8BE8F01FC4E793E0EE1", | |
| 344 | + "CB8C52BD5C2A06B60EC6768B", | |
| 345 | + "7E1F3D8976A0AE0EF6B1CFC0", | |
| 346 | + "CED40C63C78F355A3E299D3F", | |
| 347 | + "C206A182BBE4A737E9AD134E", | |
| 348 | + "AEB3E1F4EFCEE89846DDB6F1", | |
| 349 | + "DE845A1EC8D791553BCC9754", | |
| 350 | + "9D781BF6366C1AF7AE94F24C", | |
| 351 | + "A7A21CCBCFB8D45D1CDE5DF3", | |
| 352 | + "F4748FB9737120A753F31D62", | |
| 353 | + "0181158CA6D4BB2EF64C0409", | |
| 354 | + "6213414714095BAA46062B29", | |
| 355 | + "5012E6D93EFF080A93D6EDCE", | |
| 356 | + "2E97B00487C11CD7193B0847", | |
| 357 | + "A2C3BDDFC3480F0356F9813B", | |
| 358 | + "673AA0EC81EFB7A77EF7232A", | |
| 359 | + "4B938F834BDD8BCB6DFD7691", | |
| 360 | + "58B93EBF9D77801602DBED7F", | |
| 361 | + "9B792A85727D80D5A1AF3DEB", | |
| 362 | + "7DA70401A1572AAF33CFD9C4", | |
| 363 | + "B65D6B361E275BD76958F3A4", | |
| 364 | + "0A5282C4EC48041B28F6D173", | |
| 365 | + "46F0CB8365F54D638291EBCD", | |
| 366 | + "D2623FCE5CA50D234D849F2C", | |
| 367 | + "B3C02FE219F063016B2FE64C", | |
| 368 | + "0A3E27B8CA818264D75C8D81", | |
| 369 | + ); | |
| 370 | + "sourceTree" = "<group>"; | |
| 371 | + }; | |
| 372 | + "45666D976BAB316D970EC459" = { | |
| 373 | + "isa" = "PBXShellScriptBuildPhase"; | |
| 374 | + "buildActionMask" = 2147483647; | |
| 375 | + "files" = ( | |
| 376 | + ); | |
| 377 | + "inputPaths" = ( | |
| 378 | + ); | |
| 379 | + "outputPaths" = ( | |
| 380 | + ); | |
| 381 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 382 | + "shellPath" = "/bin/bash"; | |
| 383 | + "shellScript" = "\"$SRCROOT/scripts/prepare-mobile-resources.sh\"\n"; | |
| 384 | + "name" = "Prepare native Metal resources only"; | |
| 385 | + "alwaysOutOfDate" = 1; | |
| 386 | + }; | |
| 387 | + "5316D1BFE48A71EF8A4E8A29" = { | |
| 388 | + "isa" = "PBXBuildFile"; | |
| 389 | + "fileRef" = "AB03A0B65DCF1AD6BE5612B3"; | |
| 390 | + }; | |
| 391 | + "E9653C0EF1AF556DE8D49873" = { | |
| 392 | + "isa" = "PBXBuildFile"; | |
| 393 | + "fileRef" = "413823572A414825D1DA4580"; | |
| 394 | + }; | |
| 395 | + "6BCAD6CE9055ABB8BDE99D3D" = { | |
| 396 | + "isa" = "PBXBuildFile"; | |
| 397 | + "fileRef" = "07928D013502A7AEB5C6EB03"; | |
| 398 | + }; | |
| 399 | + "B37753D4AB949DB5681B16FB" = { | |
| 400 | + "isa" = "PBXBuildFile"; | |
| 401 | + "fileRef" = "119DE12F5D045816EDEC9843"; | |
| 402 | + }; | |
| 403 | + "D8602951BD2FFB1812BD21EE" = { | |
| 404 | + "isa" = "PBXBuildFile"; | |
| 405 | + "fileRef" = "900F718AA064255994CD45B8"; | |
| 406 | + }; | |
| 407 | + "2074393C0363491D999BAE16" = { | |
| 408 | + "isa" = "PBXBuildFile"; | |
| 409 | + "fileRef" = "352EAD9C8771D54832387F64"; | |
| 410 | + }; | |
| 411 | + "EE39D2C5ADC981818B9117E1" = { | |
| 412 | + "isa" = "PBXBuildFile"; | |
| 413 | + "fileRef" = "BC590D1F9F12E8A8A3FD703F"; | |
| 414 | + }; | |
| 415 | + "2F53CCB0C5523BCC1AD41BDB" = { | |
| 416 | + "isa" = "PBXBuildFile"; | |
| 417 | + "fileRef" = "5F51F1A8C96EC80FB3DF1789"; | |
| 418 | + }; | |
| 419 | + "AF9CE3E468D5BC4C85C8FF68" = { | |
| 420 | + "isa" = "PBXBuildFile"; | |
| 421 | + "fileRef" = "267585C701FE24385C4A7730"; | |
| 422 | + }; | |
| 423 | + "3639C00CF5450A6B8B0ECFD1" = { | |
| 424 | + "isa" = "PBXBuildFile"; | |
| 425 | + "fileRef" = "BDC70BBF14D9FA6AFF52EF57"; | |
| 426 | + }; | |
| 427 | + "A7CE383E14BB29514D2DD0C2" = { | |
| 428 | + "isa" = "PBXBuildFile"; | |
| 429 | + "fileRef" = "E76D1B93B17DC49DF3364355"; | |
| 430 | + }; | |
| 431 | + "59F9215D16187F2AAD43D7B8" = { | |
| 432 | + "isa" = "PBXBuildFile"; | |
| 433 | + "fileRef" = "5209D7B8FE7DB3E851C09177"; | |
| 434 | + }; | |
| 435 | + "F11FE05286D083962ACFFC9E" = { | |
| 436 | + "isa" = "PBXBuildFile"; | |
| 437 | + "fileRef" = "100CD0DC00C64B0B646E69DC"; | |
| 438 | + }; | |
| 439 | + "300C1C6C7AC83D517D44ED14" = { | |
| 440 | + "isa" = "PBXBuildFile"; | |
| 441 | + "fileRef" = "4652E379F9220B1BF60E12B9"; | |
| 442 | + }; | |
| 443 | + "9AAD59C9AF6056DDF96C21D9" = { | |
| 444 | + "isa" = "PBXBuildFile"; | |
| 445 | + "fileRef" = "2DF77FDA9C8372B7840DB84B"; | |
| 446 | + }; | |
| 447 | + "2CA3823F37CFB4409025F7D9" = { | |
| 448 | + "isa" = "PBXBuildFile"; | |
| 449 | + "fileRef" = "4CFE272A94D11EA39270BB02"; | |
| 450 | + }; | |
| 451 | + "80C0D081FE8F82B6B5025265" = { | |
| 452 | + "isa" = "PBXBuildFile"; | |
| 453 | + "fileRef" = "7958DCE0804231A319D26CD8"; | |
| 454 | + }; | |
| 455 | + "D03D42F4A68816AE8C471677" = { | |
| 456 | + "isa" = "PBXBuildFile"; | |
| 457 | + "fileRef" = "D061672D180E0CC713D8F100"; | |
| 458 | + }; | |
| 459 | + "1857C14A0B38C2D8BBE2A813" = { | |
| 460 | + "isa" = "PBXBuildFile"; | |
| 461 | + "fileRef" = "3810E7AB9E8DF14917E34477"; | |
| 462 | + }; | |
| 463 | + "1E4F77C1404DCB61DFAB398B" = { | |
| 464 | + "isa" = "PBXBuildFile"; | |
| 465 | + "fileRef" = "60524849AAB9510D72A785E5"; | |
| 466 | + }; | |
| 467 | + "437A5D46901E04F456D232F5" = { | |
| 468 | + "isa" = "PBXBuildFile"; | |
| 469 | + "fileRef" = "A49A1847A6C656BBBFECDB8E"; | |
| 470 | + }; | |
| 471 | + "AAC473035B0539E8E791202F" = { | |
| 472 | + "isa" = "PBXBuildFile"; | |
| 473 | + "fileRef" = "7D367B139647CEA90F768A9B"; | |
| 474 | + }; | |
| 475 | + "711C0F30FD1616D636AA2959" = { | |
| 476 | + "isa" = "PBXBuildFile"; | |
| 477 | + "fileRef" = "C2CBF2E084321F2ECA296112"; | |
| 478 | + }; | |
| 479 | + "31AACDF3704BA6FDA1C24B2F" = { | |
| 480 | + "isa" = "PBXBuildFile"; | |
| 481 | + "fileRef" = "4C15E8BE8F01FC4E793E0EE1"; | |
| 482 | + }; | |
| 483 | + "DE69E89DD3EEAAD604860B0B" = { | |
| 484 | + "isa" = "PBXBuildFile"; | |
| 485 | + "fileRef" = "CB8C52BD5C2A06B60EC6768B"; | |
| 486 | + }; | |
| 487 | + "5A9DA0047F539373CD750217" = { | |
| 488 | + "isa" = "PBXBuildFile"; | |
| 489 | + "fileRef" = "7E1F3D8976A0AE0EF6B1CFC0"; | |
| 490 | + }; | |
| 491 | + "97093D2BC86E4D8ABD384FFB" = { | |
| 492 | + "isa" = "PBXBuildFile"; | |
| 493 | + "fileRef" = "CED40C63C78F355A3E299D3F"; | |
| 494 | + }; | |
| 495 | + "4E447B62A357FA71945F2C7A" = { | |
| 496 | + "isa" = "PBXBuildFile"; | |
| 497 | + "fileRef" = "C206A182BBE4A737E9AD134E"; | |
| 498 | + }; | |
| 499 | + "751BBC7AFA2EC0105700402A" = { | |
| 500 | + "isa" = "PBXBuildFile"; | |
| 501 | + "fileRef" = "AEB3E1F4EFCEE89846DDB6F1"; | |
| 502 | + }; | |
| 503 | + "AC2F4451CB9919318F01F120" = { | |
| 504 | + "isa" = "PBXBuildFile"; | |
| 505 | + "fileRef" = "DE845A1EC8D791553BCC9754"; | |
| 506 | + }; | |
| 507 | + "96A5ECF8A9CB4411AE98C2AB" = { | |
| 508 | + "isa" = "PBXBuildFile"; | |
| 509 | + "fileRef" = "9D781BF6366C1AF7AE94F24C"; | |
| 510 | + }; | |
| 511 | + "8FD1AEB62693E4D6DCC5C8B8" = { | |
| 512 | + "isa" = "PBXBuildFile"; | |
| 513 | + "fileRef" = "A7A21CCBCFB8D45D1CDE5DF3"; | |
| 514 | + }; | |
| 515 | + "5B61321407F395B90905B216" = { | |
| 516 | + "isa" = "PBXBuildFile"; | |
| 517 | + "fileRef" = "F4748FB9737120A753F31D62"; | |
| 518 | + }; | |
| 519 | + "8B9D882918D7B9C05D5903CF" = { | |
| 520 | + "isa" = "PBXBuildFile"; | |
| 521 | + "fileRef" = "0181158CA6D4BB2EF64C0409"; | |
| 522 | + }; | |
| 523 | + "F66B0C32CA7E1E36201E42A5" = { | |
| 524 | + "isa" = "PBXBuildFile"; | |
| 525 | + "fileRef" = "6213414714095BAA46062B29"; | |
| 526 | + }; | |
| 527 | + "D6813CDC91708163D9F99A01" = { | |
| 528 | + "isa" = "PBXBuildFile"; | |
| 529 | + "fileRef" = "5012E6D93EFF080A93D6EDCE"; | |
| 530 | + }; | |
| 531 | + "C442F06D5FBE68B0E73A2026" = { | |
| 532 | + "isa" = "PBXBuildFile"; | |
| 533 | + "fileRef" = "2E97B00487C11CD7193B0847"; | |
| 534 | + }; | |
| 535 | + "878A52FC5FF6A57D50B7B870" = { | |
| 536 | + "isa" = "PBXSourcesBuildPhase"; | |
| 537 | + "buildActionMask" = 2147483647; | |
| 538 | + "files" = ( | |
| 539 | + "5316D1BFE48A71EF8A4E8A29", | |
| 540 | + "E9653C0EF1AF556DE8D49873", | |
| 541 | + "6BCAD6CE9055ABB8BDE99D3D", | |
| 542 | + "B37753D4AB949DB5681B16FB", | |
| 543 | + "D8602951BD2FFB1812BD21EE", | |
| 544 | + "2074393C0363491D999BAE16", | |
| 545 | + "EE39D2C5ADC981818B9117E1", | |
| 546 | + "2F53CCB0C5523BCC1AD41BDB", | |
| 547 | + "AF9CE3E468D5BC4C85C8FF68", | |
| 548 | + "3639C00CF5450A6B8B0ECFD1", | |
| 549 | + "A7CE383E14BB29514D2DD0C2", | |
| 550 | + "59F9215D16187F2AAD43D7B8", | |
| 551 | + "F11FE05286D083962ACFFC9E", | |
| 552 | + "300C1C6C7AC83D517D44ED14", | |
| 553 | + "9AAD59C9AF6056DDF96C21D9", | |
| 554 | + "2CA3823F37CFB4409025F7D9", | |
| 555 | + "80C0D081FE8F82B6B5025265", | |
| 556 | + "D03D42F4A68816AE8C471677", | |
| 557 | + "1857C14A0B38C2D8BBE2A813", | |
| 558 | + "1E4F77C1404DCB61DFAB398B", | |
| 559 | + "437A5D46901E04F456D232F5", | |
| 560 | + "AAC473035B0539E8E791202F", | |
| 561 | + "711C0F30FD1616D636AA2959", | |
| 562 | + "31AACDF3704BA6FDA1C24B2F", | |
| 563 | + "DE69E89DD3EEAAD604860B0B", | |
| 564 | + "5A9DA0047F539373CD750217", | |
| 565 | + "97093D2BC86E4D8ABD384FFB", | |
| 566 | + "4E447B62A357FA71945F2C7A", | |
| 567 | + "751BBC7AFA2EC0105700402A", | |
| 568 | + "AC2F4451CB9919318F01F120", | |
| 569 | + "96A5ECF8A9CB4411AE98C2AB", | |
| 570 | + "8FD1AEB62693E4D6DCC5C8B8", | |
| 571 | + "5B61321407F395B90905B216", | |
| 572 | + "8B9D882918D7B9C05D5903CF", | |
| 573 | + "F66B0C32CA7E1E36201E42A5", | |
| 574 | + "D6813CDC91708163D9F99A01", | |
| 575 | + "C442F06D5FBE68B0E73A2026", | |
| 576 | + ); | |
| 577 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 578 | + }; | |
| 579 | + "E2AA269EB967A8853A258BFA" = { | |
| 580 | + "isa" = "PBXFrameworksBuildPhase"; | |
| 581 | + "buildActionMask" = 2147483647; | |
| 582 | + "files" = ( | |
| 583 | + "9B1266BC9A27D9D3E1D7EA9D", | |
| 584 | + ); | |
| 585 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 586 | + }; | |
| 587 | + "BD360A10C929F703C02C4331" = { | |
| 588 | + "isa" = "PBXBuildFile"; | |
| 589 | + "fileRef" = "4B938F834BDD8BCB6DFD7691"; | |
| 590 | + }; | |
| 591 | + "3E690DB03FA3E95A14237948" = { | |
| 592 | + "isa" = "PBXBuildFile"; | |
| 593 | + "fileRef" = "58B93EBF9D77801602DBED7F"; | |
| 594 | + }; | |
| 595 | + "5612D96B9F3E2668CFB2DEBC" = { | |
| 596 | + "isa" = "PBXBuildFile"; | |
| 597 | + "fileRef" = "9B792A85727D80D5A1AF3DEB"; | |
| 598 | + }; | |
| 599 | + "62CA23DD705C316F7907B012" = { | |
| 600 | + "isa" = "PBXBuildFile"; | |
| 601 | + "fileRef" = "7DA70401A1572AAF33CFD9C4"; | |
| 602 | + }; | |
| 603 | + "AF9C7F82DD383C8411B02378" = { | |
| 604 | + "isa" = "PBXBuildFile"; | |
| 605 | + "fileRef" = "B65D6B361E275BD76958F3A4"; | |
| 606 | + }; | |
| 607 | + "56C3256106C3A108001EC3FF" = { | |
| 608 | + "isa" = "PBXBuildFile"; | |
| 609 | + "fileRef" = "0A5282C4EC48041B28F6D173"; | |
| 610 | + }; | |
| 611 | + "41D311A605520FC7B8B9A980" = { | |
| 612 | + "isa" = "PBXResourcesBuildPhase"; | |
| 613 | + "buildActionMask" = 2147483647; | |
| 614 | + "files" = ( | |
| 615 | + "BD360A10C929F703C02C4331", | |
| 616 | + "3E690DB03FA3E95A14237948", | |
| 617 | + "5612D96B9F3E2668CFB2DEBC", | |
| 618 | + "62CA23DD705C316F7907B012", | |
| 619 | + "AF9C7F82DD383C8411B02378", | |
| 620 | + "56C3256106C3A108001EC3FF", | |
| 621 | + ); | |
| 622 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 623 | + }; | |
| 624 | + "F1D4E4051FA27B04C65CABEE" = { | |
| 625 | + "isa" = "XCBuildConfiguration"; | |
| 626 | + "buildSettings" = { | |
| 627 | + "SDKROOT" = "iphoneos"; | |
| 628 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 629 | + "SWIFT_OPTIMIZATION_LEVEL" = "-Onone"; | |
| 630 | + "SWIFT_EMIT_LOC_STRINGS" = "NO"; | |
| 631 | + "SWIFT_ACTIVE_COMPILATION_CONDITIONS" = "$(inherited) DEBUG"; | |
| 632 | + }; | |
| 633 | + "name" = "Debug"; | |
| 634 | + "baseConfigurationReference" = "D2623FCE5CA50D234D849F2C"; | |
| 635 | + }; | |
| 636 | + "E35D5516D100FF5C69B6611C" = { | |
| 637 | + "isa" = "XCBuildConfiguration"; | |
| 638 | + "buildSettings" = { | |
| 639 | + "SDKROOT" = "iphoneos"; | |
| 640 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 641 | + "SWIFT_OPTIMIZATION_LEVEL" = "-O"; | |
| 642 | + "SWIFT_EMIT_LOC_STRINGS" = "NO"; | |
| 643 | + "SWIFT_ACTIVE_COMPILATION_CONDITIONS" = "$(inherited)"; | |
| 644 | + }; | |
| 645 | + "name" = "Release"; | |
| 646 | + "baseConfigurationReference" = "D2623FCE5CA50D234D849F2C"; | |
| 647 | + }; | |
| 648 | + "88A9304AEA126CFA946C4524" = { | |
| 649 | + "isa" = "XCConfigurationList"; | |
| 650 | + "buildConfigurations" = ( | |
| 651 | + "F1D4E4051FA27B04C65CABEE", | |
| 652 | + "E35D5516D100FF5C69B6611C", | |
| 653 | + ); | |
| 654 | + "defaultConfigurationIsVisible" = 0; | |
| 655 | + "defaultConfigurationName" = "Release"; | |
| 656 | + }; | |
| 657 | + "34A04005BCAF206EEC990BD9" = { | |
| 658 | + "isa" = "PBXNativeTarget"; | |
| 659 | + "buildConfigurationList" = "88A9304AEA126CFA946C4524"; | |
| 660 | + "buildPhases" = ( | |
| 661 | + "45666D976BAB316D970EC459", | |
| 662 | + "878A52FC5FF6A57D50B7B870", | |
| 663 | + "E2AA269EB967A8853A258BFA", | |
| 664 | + "41D311A605520FC7B8B9A980", | |
| 665 | + ); | |
| 666 | + "buildRules" = ( | |
| 667 | + ); | |
| 668 | + "dependencies" = ( | |
| 669 | + ); | |
| 670 | + "name" = "PulseCanvasMobile"; | |
| 671 | + "productName" = "PulseCanvas Mobile"; | |
| 672 | + "productReference" = "A8792157CB4F27FB949C035F"; | |
| 673 | + "productType" = "com.apple.product-type.application"; | |
| 674 | + "packageProductDependencies" = ( | |
| 675 | + "9B427405DFFC7306479BADEE", | |
| 676 | + ); | |
| 677 | + }; | |
| 678 | + "35B7C0CC0F21DA3F0F098A64" = { | |
| 679 | + "isa" = "PBXContainerItemProxy"; | |
| 680 | + "containerPortal" = "244210E48437B6556980A702"; | |
| 681 | + "proxyType" = 1; | |
| 682 | + "remoteGlobalIDString" = "34A04005BCAF206EEC990BD9"; | |
| 683 | + "remoteInfo" = "PulseCanvasMobile"; | |
| 684 | + }; | |
| 685 | + "292AEBA4095B45D3A6BCF782" = { | |
| 686 | + "isa" = "XCBuildConfiguration"; | |
| 687 | + "buildSettings" = { | |
| 688 | + "SDKROOT" = "iphoneos"; | |
| 689 | + "SUPPORTED_PLATFORMS" = "iphoneos iphonesimulator"; | |
| 690 | + "TARGETED_DEVICE_FAMILY" = "1,2"; | |
| 691 | + "IPHONEOS_DEPLOYMENT_TARGET" = "18.0"; | |
| 692 | + "SWIFT_VERSION" = "5.0"; | |
| 693 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 694 | + "GENERATE_INFOPLIST_FILE" = "YES"; | |
| 695 | + "CODE_SIGN_STYLE" = "Automatic"; | |
| 696 | + "DEVELOPMENT_TEAM" = "22HV69L32T"; | |
| 697 | + "PRODUCT_BUNDLE_IDENTIFIER" = "com.protomota.pulsecanvas.mobile.uitests"; | |
| 698 | + "PRODUCT_NAME" = "PulseCanvasMobileUITests"; | |
| 699 | + "TEST_TARGET_NAME" = "PulseCanvasMobile"; | |
| 700 | + "SWIFT_OPTIMIZATION_LEVEL" = "-Onone"; | |
| 701 | + }; | |
| 702 | + "name" = "Debug"; | |
| 703 | + }; | |
| 704 | + "830D981C3E358C225481E7AF" = { | |
| 705 | + "isa" = "XCBuildConfiguration"; | |
| 706 | + "buildSettings" = { | |
| 707 | + "SDKROOT" = "iphoneos"; | |
| 708 | + "SUPPORTED_PLATFORMS" = "iphoneos iphonesimulator"; | |
| 709 | + "TARGETED_DEVICE_FAMILY" = "1,2"; | |
| 710 | + "IPHONEOS_DEPLOYMENT_TARGET" = "18.0"; | |
| 711 | + "SWIFT_VERSION" = "5.0"; | |
| 712 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 713 | + "GENERATE_INFOPLIST_FILE" = "YES"; | |
| 714 | + "CODE_SIGN_STYLE" = "Automatic"; | |
| 715 | + "DEVELOPMENT_TEAM" = "22HV69L32T"; | |
| 716 | + "PRODUCT_BUNDLE_IDENTIFIER" = "com.protomota.pulsecanvas.mobile.uitests"; | |
| 717 | + "PRODUCT_NAME" = "PulseCanvasMobileUITests"; | |
| 718 | + "TEST_TARGET_NAME" = "PulseCanvasMobile"; | |
| 719 | + "SWIFT_OPTIMIZATION_LEVEL" = "-O"; | |
| 720 | + }; | |
| 721 | + "name" = "Release"; | |
| 722 | + }; | |
| 723 | + "B8C2E164F3D09CAB62B28174" = { | |
| 724 | + "isa" = "XCConfigurationList"; | |
| 725 | + "buildConfigurations" = ( | |
| 726 | + "292AEBA4095B45D3A6BCF782", | |
| 727 | + "830D981C3E358C225481E7AF", | |
| 728 | + ); | |
| 729 | + "defaultConfigurationIsVisible" = 0; | |
| 730 | + "defaultConfigurationName" = "Debug"; | |
| 731 | + }; | |
| 732 | + "2F3183DBE1A5747E14453DBC" = { | |
| 733 | + "isa" = "PBXBuildFile"; | |
| 734 | + "fileRef" = "A2C3BDDFC3480F0356F9813B"; | |
| 735 | + }; | |
| 736 | + "D89667C3E555528283693C42" = { | |
| 737 | + "isa" = "PBXBuildFile"; | |
| 738 | + "fileRef" = "673AA0EC81EFB7A77EF7232A"; | |
| 739 | + }; | |
| 740 | + "B0DA16B5A57B77452D9B6EB5" = { | |
| 741 | + "isa" = "PBXSourcesBuildPhase"; | |
| 742 | + "buildActionMask" = 2147483647; | |
| 743 | + "files" = ( | |
| 744 | + "2F3183DBE1A5747E14453DBC", | |
| 745 | + "D89667C3E555528283693C42", | |
| 746 | + ); | |
| 747 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 748 | + }; | |
| 749 | + "14601C0A5E377A66092CCC2E" = { | |
| 750 | + "isa" = "PBXFrameworksBuildPhase"; | |
| 751 | + "buildActionMask" = 2147483647; | |
| 752 | + "files" = ( | |
| 753 | + ); | |
| 754 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 755 | + }; | |
| 756 | + "299D5CFB3FD7410E61F5107B" = { | |
| 757 | + "isa" = "PBXResourcesBuildPhase"; | |
| 758 | + "buildActionMask" = 2147483647; | |
| 759 | + "files" = ( | |
| 760 | + ); | |
| 761 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 762 | + }; | |
| 763 | + "8157BA2106F6223041554826" = { | |
| 764 | + "isa" = "PBXTargetDependency"; | |
| 765 | + "target" = "34A04005BCAF206EEC990BD9"; | |
| 766 | + "targetProxy" = "35B7C0CC0F21DA3F0F098A64"; | |
| 767 | + }; | |
| 768 | + "9E53AA71467D2DE08E504D40" = { | |
| 769 | + "isa" = "PBXNativeTarget"; | |
| 770 | + "buildConfigurationList" = "B8C2E164F3D09CAB62B28174"; | |
| 771 | + "buildPhases" = ( | |
| 772 | + "B0DA16B5A57B77452D9B6EB5", | |
| 773 | + "14601C0A5E377A66092CCC2E", | |
| 774 | + "299D5CFB3FD7410E61F5107B", | |
| 775 | + ); | |
| 776 | + "buildRules" = ( | |
| 777 | + ); | |
| 778 | + "dependencies" = ( | |
| 779 | + "8157BA2106F6223041554826", | |
| 780 | + ); | |
| 781 | + "name" = "PulseCanvasMobileUITests"; | |
| 782 | + "productName" = "PulseCanvasMobileUITests"; | |
| 783 | + "productReference" = "9F63878049D400944738EB5F"; | |
| 784 | + "productType" = "com.apple.product-type.bundle.ui-testing"; | |
| 785 | + }; | |
| 786 | + "E2EDCD14762CC2F70971BC55" = { | |
| 787 | + "isa" = "XCBuildConfiguration"; | |
| 788 | + "buildSettings" = { | |
| 789 | + "SDKROOT" = "iphoneos"; | |
| 790 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 791 | + }; | |
| 792 | + "name" = "Debug"; | |
| 793 | + }; | |
| 794 | + "E49449A51B1C1B61FFEBC152" = { | |
| 795 | + "isa" = "XCBuildConfiguration"; | |
| 796 | + "buildSettings" = { | |
| 797 | + "SDKROOT" = "iphoneos"; | |
| 798 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 799 | + }; | |
| 800 | + "name" = "Release"; | |
| 801 | + }; | |
| 802 | + "54972615C880599A4265A739" = { | |
| 803 | + "isa" = "XCConfigurationList"; | |
| 804 | + "buildConfigurations" = ( | |
| 805 | + "E2EDCD14762CC2F70971BC55", | |
| 806 | + "E49449A51B1C1B61FFEBC152", | |
| 807 | + ); | |
| 808 | + "defaultConfigurationIsVisible" = 0; | |
| 809 | + "defaultConfigurationName" = "Release"; | |
| 810 | + }; | |
| 811 | + "244210E48437B6556980A702" = { | |
| 812 | + "isa" = "PBXProject"; | |
| 813 | + "attributes" = { | |
| 814 | + "LastUpgradeCheck" = "2700"; | |
| 815 | + "TargetAttributes" = { | |
| 816 | + "34A04005BCAF206EEC990BD9" = { | |
| 817 | + "SystemCapabilities" = { | |
| 818 | + "com.apple.iCloud" = { | |
| 819 | + "enabled" = 1; | |
| 820 | + }; | |
| 821 | + }; | |
| 822 | + }; | |
| 823 | + "9E53AA71467D2DE08E504D40" = { | |
| 824 | + "TestTargetID" = "34A04005BCAF206EEC990BD9"; | |
| 825 | + }; | |
| 826 | + }; | |
| 827 | + }; | |
| 828 | + "buildConfigurationList" = "54972615C880599A4265A739"; | |
| 829 | + "compatibilityVersion" = "Xcode 14.0"; | |
| 830 | + "developmentRegion" = "en"; | |
| 831 | + "hasScannedForEncodings" = 0; | |
| 832 | + "knownRegions" = ( | |
| 833 | + "en", | |
| 834 | + "Base", | |
| 835 | + ); | |
| 836 | + "mainGroup" = "0D6E4079E36703EBD37C0072"; | |
| 837 | + "productRefGroup" = "0A3E27B8CA818264D75C8D81"; | |
| 838 | + "projectDirPath" = ""; | |
| 839 | + "projectRoot" = ""; | |
| 840 | + "targets" = ( | |
| 841 | + "34A04005BCAF206EEC990BD9", | |
| 842 | + "9E53AA71467D2DE08E504D40", | |
| 843 | + ); | |
| 844 | + "packageReferences" = ( | |
| 845 | + "D50706B6923B46DFD8933125", | |
| 846 | + ); | |
| 847 | + }; | |
| 848 | + "D50706B6923B46DFD8933125" = { | |
| 849 | + "isa" = "XCRemoteSwiftPackageReference"; | |
| 850 | + "repositoryURL" = "https://github.com/weichsel/ZIPFoundation.git"; | |
| 851 | + "requirement" = { | |
| 852 | + "kind" = "exactVersion"; | |
| 853 | + "version" = "0.9.20"; | |
| 854 | + }; | |
| 855 | + }; | |
| 856 | + "9B427405DFFC7306479BADEE" = { | |
| 857 | + "isa" = "XCSwiftPackageProductDependency"; | |
| 858 | + "package" = "D50706B6923B46DFD8933125"; | |
| 859 | + "productName" = "ZIPFoundation"; | |
| 860 | + }; | |
| 861 | + "9B1266BC9A27D9D3E1D7EA9D" = { | |
| 862 | + "isa" = "PBXBuildFile"; | |
| 863 | + "productRef" = "9B427405DFFC7306479BADEE"; | |
| 864 | + }; | |
| 865 | + }; | |
| 866 | + "rootObject" = "244210E48437B6556980A702"; | |
| 867 | + } |
PulseCanvasVision.xcodeproj/project.pbxproj added
| 1 | + // !$*UTF8*$! | |
| 2 | + { | |
| 3 | + "archiveVersion" = 1; | |
| 4 | + "classes" = { | |
| 5 | + }; | |
| 6 | + "objectVersion" = 56; | |
| 7 | + "objects" = { | |
| 8 | + "AB03A0B65DCF1AD6BE5612B3" = { | |
| 9 | + "isa" = "PBXFileReference"; | |
| 10 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 11 | + "path" = "Sources/PulseCanvas/CloudSyncLedger.swift"; | |
| 12 | + "sourceTree" = "<group>"; | |
| 13 | + }; | |
| 14 | + "413823572A414825D1DA4580" = { | |
| 15 | + "isa" = "PBXFileReference"; | |
| 16 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 17 | + "path" = "Sources/PulseCanvas/CloudProjectPackage.swift"; | |
| 18 | + "sourceTree" = "<group>"; | |
| 19 | + }; | |
| 20 | + "07928D013502A7AEB5C6EB03" = { | |
| 21 | + "isa" = "PBXFileReference"; | |
| 22 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 23 | + "path" = "Sources/PulseCanvas/CloudSyncAppData.swift"; | |
| 24 | + "sourceTree" = "<group>"; | |
| 25 | + }; | |
| 26 | + "119DE12F5D045816EDEC9843" = { | |
| 27 | + "isa" = "PBXFileReference"; | |
| 28 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 29 | + "path" = "Sources/PulseCanvas/CloudSyncService.swift"; | |
| 30 | + "sourceTree" = "<group>"; | |
| 31 | + }; | |
| 32 | + "900F718AA064255994CD45B8" = { | |
| 33 | + "isa" = "PBXFileReference"; | |
| 34 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 35 | + "path" = "Sources/PulseCanvas/CloudSyncView.swift"; | |
| 36 | + "sourceTree" = "<group>"; | |
| 37 | + }; | |
| 38 | + "352EAD9C8771D54832387F64" = { | |
| 39 | + "isa" = "PBXFileReference"; | |
| 40 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 41 | + "path" = "Sources/PulseCanvas/UserBackup.swift"; | |
| 42 | + "sourceTree" = "<group>"; | |
| 43 | + }; | |
| 44 | + "BC590D1F9F12E8A8A3FD703F" = { | |
| 45 | + "isa" = "PBXFileReference"; | |
| 46 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 47 | + "path" = "Sources/PulseCanvas/UserBackupZIP.swift"; | |
| 48 | + "sourceTree" = "<group>"; | |
| 49 | + }; | |
| 50 | + "5F51F1A8C96EC80FB3DF1789" = { | |
| 51 | + "isa" = "PBXFileReference"; | |
| 52 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 53 | + "path" = "Sources/PulseCanvas/UserBackupView.swift"; | |
| 54 | + "sourceTree" = "<group>"; | |
| 55 | + }; | |
| 56 | + "267585C701FE24385C4A7730" = { | |
| 57 | + "isa" = "PBXFileReference"; | |
| 58 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 59 | + "path" = "Sources/PulseCanvas/PulseCanvasOnboarding.swift"; | |
| 60 | + "sourceTree" = "<group>"; | |
| 61 | + }; | |
| 62 | + "E76D1B93B17DC49DF3364355" = { | |
| 63 | + "isa" = "PBXFileReference"; | |
| 64 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 65 | + "path" = "Sources/PulseCanvas/VisualPreset.swift"; | |
| 66 | + "sourceTree" = "<group>"; | |
| 67 | + }; | |
| 68 | + "5209D7B8FE7DB3E851C09177" = { | |
| 69 | + "isa" = "PBXFileReference"; | |
| 70 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 71 | + "path" = "Sources/PulseCanvas/VisualPalette.swift"; | |
| 72 | + "sourceTree" = "<group>"; | |
| 73 | + }; | |
| 74 | + "100CD0DC00C64B0B646E69DC" = { | |
| 75 | + "isa" = "PBXFileReference"; | |
| 76 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 77 | + "path" = "Sources/PulseCanvas/OriginalGeometry.swift"; | |
| 78 | + "sourceTree" = "<group>"; | |
| 79 | + }; | |
| 80 | + "4652E379F9220B1BF60E12B9" = { | |
| 81 | + "isa" = "PBXFileReference"; | |
| 82 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 83 | + "path" = "Sources/PulseCanvas/NativeEffects.swift"; | |
| 84 | + "sourceTree" = "<group>"; | |
| 85 | + }; | |
| 86 | + "2DF77FDA9C8372B7840DB84B" = { | |
| 87 | + "isa" = "PBXFileReference"; | |
| 88 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 89 | + "path" = "Sources/PulseCanvas/ProjectMPresets.swift"; | |
| 90 | + "sourceTree" = "<group>"; | |
| 91 | + }; | |
| 92 | + "4CFE272A94D11EA39270BB02" = { | |
| 93 | + "isa" = "PBXFileReference"; | |
| 94 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 95 | + "path" = "Sources/PulseCanvas/StrobeDetector.swift"; | |
| 96 | + "sourceTree" = "<group>"; | |
| 97 | + }; | |
| 98 | + "7958DCE0804231A319D26CD8" = { | |
| 99 | + "isa" = "PBXFileReference"; | |
| 100 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 101 | + "path" = "Sources/PulseCanvas/VisualizerRenderer.swift"; | |
| 102 | + "sourceTree" = "<group>"; | |
| 103 | + }; | |
| 104 | + "D061672D180E0CC713D8F100" = { | |
| 105 | + "isa" = "PBXFileReference"; | |
| 106 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 107 | + "path" = "Sources/PulseCanvas/AudioAnalysis.swift"; | |
| 108 | + "sourceTree" = "<group>"; | |
| 109 | + }; | |
| 110 | + "3810E7AB9E8DF14917E34477" = { | |
| 111 | + "isa" = "PBXFileReference"; | |
| 112 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 113 | + "path" = "Sources/PulseCanvas/StudioTimeline.swift"; | |
| 114 | + "sourceTree" = "<group>"; | |
| 115 | + }; | |
| 116 | + "60524849AAB9510D72A785E5" = { | |
| 117 | + "isa" = "PBXFileReference"; | |
| 118 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 119 | + "path" = "Sources/PulseCanvas/VisualizerPoolControls.swift"; | |
| 120 | + "sourceTree" = "<group>"; | |
| 121 | + }; | |
| 122 | + "A49A1847A6C656BBBFECDB8E" = { | |
| 123 | + "isa" = "PBXFileReference"; | |
| 124 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 125 | + "path" = "Sources/PulseCanvas/RadioLibrary.swift"; | |
| 126 | + "sourceTree" = "<group>"; | |
| 127 | + }; | |
| 128 | + "7D367B139647CEA90F768A9B" = { | |
| 129 | + "isa" = "PBXFileReference"; | |
| 130 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 131 | + "path" = "Sources/PulseCanvas/StudioMusicPicker.swift"; | |
| 132 | + "sourceTree" = "<group>"; | |
| 133 | + }; | |
| 134 | + "C2CBF2E084321F2ECA296112" = { | |
| 135 | + "isa" = "PBXFileReference"; | |
| 136 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 137 | + "path" = "Sources/PulseCanvas/StudioStore.swift"; | |
| 138 | + "sourceTree" = "<group>"; | |
| 139 | + }; | |
| 140 | + "4C15E8BE8F01FC4E793E0EE1" = { | |
| 141 | + "isa" = "PBXFileReference"; | |
| 142 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 143 | + "path" = "Sources/PulseCanvas/SocialExportController.swift"; | |
| 144 | + "sourceTree" = "<group>"; | |
| 145 | + }; | |
| 146 | + "CB8C52BD5C2A06B60EC6768B" = { | |
| 147 | + "isa" = "PBXFileReference"; | |
| 148 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 149 | + "path" = "Sources/PulseCanvas/SecurityScopedAccess.swift"; | |
| 150 | + "sourceTree" = "<group>"; | |
| 151 | + }; | |
| 152 | + "AEB3E1F4EFCEE89846DDB6F1" = { | |
| 153 | + "isa" = "PBXFileReference"; | |
| 154 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 155 | + "path" = "macOS/BundleResources.swift"; | |
| 156 | + "sourceTree" = "<group>"; | |
| 157 | + }; | |
| 158 | + "89C50894961A786737934E7B" = { | |
| 159 | + "isa" = "PBXFileReference"; | |
| 160 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 161 | + "path" = "visionOS/PulseCanvasVisionApp.swift"; | |
| 162 | + "sourceTree" = "<group>"; | |
| 163 | + }; | |
| 164 | + "CD0B7AD613C4E32D4FA778B6" = { | |
| 165 | + "isa" = "PBXFileReference"; | |
| 166 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 167 | + "path" = "visionOS/VisionImmersiveView.swift"; | |
| 168 | + "sourceTree" = "<group>"; | |
| 169 | + }; | |
| 170 | + "1854CD73DE41430109C5A268" = { | |
| 171 | + "isa" = "PBXFileReference"; | |
| 172 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 173 | + "path" = "visionOS/VisionInfoView.swift"; | |
| 174 | + "sourceTree" = "<group>"; | |
| 175 | + }; | |
| 176 | + "FEE1896A5C756DFF96389CC6" = { | |
| 177 | + "isa" = "PBXFileReference"; | |
| 178 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 179 | + "path" = "visionOS/VisionLaunchOptions.swift"; | |
| 180 | + "sourceTree" = "<group>"; | |
| 181 | + }; | |
| 182 | + "038813F19FA1E4A37CCCA0C4" = { | |
| 183 | + "isa" = "PBXFileReference"; | |
| 184 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 185 | + "path" = "visionOS/VisionLookPreset.swift"; | |
| 186 | + "sourceTree" = "<group>"; | |
| 187 | + }; | |
| 188 | + "423B784DC51F6993045C572F" = { | |
| 189 | + "isa" = "PBXFileReference"; | |
| 190 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 191 | + "path" = "visionOS/VisionPresentation.swift"; | |
| 192 | + "sourceTree" = "<group>"; | |
| 193 | + }; | |
| 194 | + "8319DBF80F0A1AE2BD7EE172" = { | |
| 195 | + "isa" = "PBXFileReference"; | |
| 196 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 197 | + "path" = "visionOS/VisionProject.swift"; | |
| 198 | + "sourceTree" = "<group>"; | |
| 199 | + }; | |
| 200 | + "E382BFD990FD584F51A98000" = { | |
| 201 | + "isa" = "PBXFileReference"; | |
| 202 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 203 | + "path" = "visionOS/VisionProjectInterchange.swift"; | |
| 204 | + "sourceTree" = "<group>"; | |
| 205 | + }; | |
| 206 | + "5CBC6EB79F154CE84C2F54E6" = { | |
| 207 | + "isa" = "PBXFileReference"; | |
| 208 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 209 | + "path" = "visionOS/VisionSession.swift"; | |
| 210 | + "sourceTree" = "<group>"; | |
| 211 | + }; | |
| 212 | + "1074610367B0B6A094EA470C" = { | |
| 213 | + "isa" = "PBXFileReference"; | |
| 214 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 215 | + "path" = "visionOS/VisionStudio.swift"; | |
| 216 | + "sourceTree" = "<group>"; | |
| 217 | + }; | |
| 218 | + "EEFDDCD6F5AB50CA168FA1B8" = { | |
| 219 | + "isa" = "PBXFileReference"; | |
| 220 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 221 | + "path" = "visionOS/VisionStudioView.swift"; | |
| 222 | + "sourceTree" = "<group>"; | |
| 223 | + }; | |
| 224 | + "DFFC0D2FA6679F312F11941D" = { | |
| 225 | + "isa" = "PBXFileReference"; | |
| 226 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 227 | + "path" = "visionOS/VisionVideoExportView.swift"; | |
| 228 | + "sourceTree" = "<group>"; | |
| 229 | + }; | |
| 230 | + "0DA04F35AB86E5951F47166B" = { | |
| 231 | + "isa" = "PBXFileReference"; | |
| 232 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 233 | + "path" = "visionOS/VisionVideoFile.swift"; | |
| 234 | + "sourceTree" = "<group>"; | |
| 235 | + }; | |
| 236 | + "0C8CC87581FC28D19B7207E0" = { | |
| 237 | + "isa" = "PBXFileReference"; | |
| 238 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 239 | + "path" = "visionOS/VisionVideoSavePicker.swift"; | |
| 240 | + "sourceTree" = "<group>"; | |
| 241 | + }; | |
| 242 | + "4B938F834BDD8BCB6DFD7691" = { | |
| 243 | + "isa" = "PBXFileReference"; | |
| 244 | + "lastKnownFileType" = "text.json.xcstrings"; | |
| 245 | + "path" = "Localization/Localizable.xcstrings"; | |
| 246 | + "sourceTree" = "<group>"; | |
| 247 | + }; | |
| 248 | + "58B93EBF9D77801602DBED7F" = { | |
| 249 | + "isa" = "PBXFileReference"; | |
| 250 | + "lastKnownFileType" = "folder"; | |
| 251 | + "path" = "Sources/PulseCanvas/Resources/Onboarding"; | |
| 252 | + "sourceTree" = "<group>"; | |
| 253 | + }; | |
| 254 | + "5DE058E997E17FB6E1C96D5F" = { | |
| 255 | + "isa" = "PBXFileReference"; | |
| 256 | + "lastKnownFileType" = "folder.assetcatalog"; | |
| 257 | + "path" = "visionOS/Assets.xcassets"; | |
| 258 | + "sourceTree" = "<group>"; | |
| 259 | + }; | |
| 260 | + "C2C9DC46EEABB4403C4F54B6" = { | |
| 261 | + "isa" = "PBXFileReference"; | |
| 262 | + "lastKnownFileType" = "folder"; | |
| 263 | + "path" = ".build/vision-resources/NativeAssets"; | |
| 264 | + "sourceTree" = "<group>"; | |
| 265 | + }; | |
| 266 | + "74BF9E81D47C493AB795ED7C" = { | |
| 267 | + "isa" = "PBXFileReference"; | |
| 268 | + "lastKnownFileType" = "folder"; | |
| 269 | + "path" = ".build/vision-resources/Legal"; | |
| 270 | + "sourceTree" = "<group>"; | |
| 271 | + }; | |
| 272 | + "0A5282C4EC48041B28F6D173" = { | |
| 273 | + "isa" = "PBXFileReference"; | |
| 274 | + "lastKnownFileType" = "text.xml"; | |
| 275 | + "path" = "macOS/PrivacyInfo.xcprivacy"; | |
| 276 | + "sourceTree" = "<group>"; | |
| 277 | + }; | |
| 278 | + "98C8D67F698DEFBBE6078282" = { | |
| 279 | + "isa" = "PBXFileReference"; | |
| 280 | + "lastKnownFileType" = "text.xcconfig"; | |
| 281 | + "path" = "visionOS/Release.xcconfig"; | |
| 282 | + "sourceTree" = "<group>"; | |
| 283 | + }; | |
| 284 | + "5AF284F2C7145EF8CEDAC41B" = { | |
| 285 | + "isa" = "PBXFileReference"; | |
| 286 | + "lastKnownFileType" = "text.plist.xml"; | |
| 287 | + "path" = "visionOS/Info.plist"; | |
| 288 | + "sourceTree" = "<group>"; | |
| 289 | + }; | |
| 290 | + "A8792157CB4F27FB949C035F" = { | |
| 291 | + "isa" = "PBXFileReference"; | |
| 292 | + "explicitFileType" = "wrapper.application"; | |
| 293 | + "path" = "PulseCanvas Vision.app"; | |
| 294 | + "sourceTree" = "BUILT_PRODUCTS_DIR"; | |
| 295 | + }; | |
| 296 | + "0938440A5586EF11FC09A444" = { | |
| 297 | + "isa" = "PBXFileReference"; | |
| 298 | + "lastKnownFileType" = "sourcecode.swift"; | |
| 299 | + "path" = "visionOS/UITests/PulseCanvasVisionUITests.swift"; | |
| 300 | + "sourceTree" = "<group>"; | |
| 301 | + }; | |
| 302 | + "9F63878049D400944738EB5F" = { | |
| 303 | + "isa" = "PBXFileReference"; | |
| 304 | + "explicitFileType" = "wrapper.cfbundle"; | |
| 305 | + "path" = "PulseCanvasVisionUITests.xctest"; | |
| 306 | + "sourceTree" = "BUILT_PRODUCTS_DIR"; | |
| 307 | + }; | |
| 308 | + "0A3E27B8CA818264D75C8D81" = { | |
| 309 | + "isa" = "PBXGroup"; | |
| 310 | + "children" = ( | |
| 311 | + "A8792157CB4F27FB949C035F", | |
| 312 | + "9F63878049D400944738EB5F", | |
| 313 | + ); | |
| 314 | + "name" = "Products"; | |
| 315 | + "sourceTree" = "<group>"; | |
| 316 | + }; | |
| 317 | + "46F0CB8365F54D638291EBCD" = { | |
| 318 | + "isa" = "PBXFileReference"; | |
| 319 | + "lastKnownFileType" = "text.xcconfig"; | |
| 320 | + "path" = "Version.xcconfig"; | |
| 321 | + "sourceTree" = "<group>"; | |
| 322 | + }; | |
| 323 | + "0D6E4079E36703EBD37C0072" = { | |
| 324 | + "isa" = "PBXGroup"; | |
| 325 | + "children" = ( | |
| 326 | + "AB03A0B65DCF1AD6BE5612B3", | |
| 327 | + "413823572A414825D1DA4580", | |
| 328 | + "07928D013502A7AEB5C6EB03", | |
| 329 | + "119DE12F5D045816EDEC9843", | |
| 330 | + "900F718AA064255994CD45B8", | |
| 331 | + "352EAD9C8771D54832387F64", | |
| 332 | + "BC590D1F9F12E8A8A3FD703F", | |
| 333 | + "5F51F1A8C96EC80FB3DF1789", | |
| 334 | + "267585C701FE24385C4A7730", | |
| 335 | + "E76D1B93B17DC49DF3364355", | |
| 336 | + "5209D7B8FE7DB3E851C09177", | |
| 337 | + "100CD0DC00C64B0B646E69DC", | |
| 338 | + "4652E379F9220B1BF60E12B9", | |
| 339 | + "2DF77FDA9C8372B7840DB84B", | |
| 340 | + "4CFE272A94D11EA39270BB02", | |
| 341 | + "7958DCE0804231A319D26CD8", | |
| 342 | + "D061672D180E0CC713D8F100", | |
| 343 | + "3810E7AB9E8DF14917E34477", | |
| 344 | + "60524849AAB9510D72A785E5", | |
| 345 | + "A49A1847A6C656BBBFECDB8E", | |
| 346 | + "7D367B139647CEA90F768A9B", | |
| 347 | + "C2CBF2E084321F2ECA296112", | |
| 348 | + "4C15E8BE8F01FC4E793E0EE1", | |
| 349 | + "CB8C52BD5C2A06B60EC6768B", | |
| 350 | + "AEB3E1F4EFCEE89846DDB6F1", | |
| 351 | + "89C50894961A786737934E7B", | |
| 352 | + "CD0B7AD613C4E32D4FA778B6", | |
| 353 | + "1854CD73DE41430109C5A268", | |
| 354 | + "FEE1896A5C756DFF96389CC6", | |
| 355 | + "038813F19FA1E4A37CCCA0C4", | |
| 356 | + "423B784DC51F6993045C572F", | |
| 357 | + "8319DBF80F0A1AE2BD7EE172", | |
| 358 | + "E382BFD990FD584F51A98000", | |
| 359 | + "5CBC6EB79F154CE84C2F54E6", | |
| 360 | + "1074610367B0B6A094EA470C", | |
| 361 | + "EEFDDCD6F5AB50CA168FA1B8", | |
| 362 | + "DFFC0D2FA6679F312F11941D", | |
| 363 | + "0DA04F35AB86E5951F47166B", | |
| 364 | + "0C8CC87581FC28D19B7207E0", | |
| 365 | + "0938440A5586EF11FC09A444", | |
| 366 | + "4B938F834BDD8BCB6DFD7691", | |
| 367 | + "58B93EBF9D77801602DBED7F", | |
| 368 | + "5DE058E997E17FB6E1C96D5F", | |
| 369 | + "C2C9DC46EEABB4403C4F54B6", | |
| 370 | + "74BF9E81D47C493AB795ED7C", | |
| 371 | + "0A5282C4EC48041B28F6D173", | |
| 372 | + "46F0CB8365F54D638291EBCD", | |
| 373 | + "98C8D67F698DEFBBE6078282", | |
| 374 | + "5AF284F2C7145EF8CEDAC41B", | |
| 375 | + "0A3E27B8CA818264D75C8D81", | |
| 376 | + ); | |
| 377 | + "sourceTree" = "<group>"; | |
| 378 | + }; | |
| 379 | + "45666D976BAB316D970EC459" = { | |
| 380 | + "isa" = "PBXShellScriptBuildPhase"; | |
| 381 | + "buildActionMask" = 2147483647; | |
| 382 | + "files" = ( | |
| 383 | + ); | |
| 384 | + "inputPaths" = ( | |
| 385 | + ); | |
| 386 | + "outputPaths" = ( | |
| 387 | + ); | |
| 388 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 389 | + "shellPath" = "/bin/bash"; | |
| 390 | + "shellScript" = "\"$SRCROOT/scripts/prepare-vision-resources.sh\"\n"; | |
| 391 | + "name" = "Prepare native Metal resources only"; | |
| 392 | + "alwaysOutOfDate" = 1; | |
| 393 | + }; | |
| 394 | + "5316D1BFE48A71EF8A4E8A29" = { | |
| 395 | + "isa" = "PBXBuildFile"; | |
| 396 | + "fileRef" = "AB03A0B65DCF1AD6BE5612B3"; | |
| 397 | + }; | |
| 398 | + "E9653C0EF1AF556DE8D49873" = { | |
| 399 | + "isa" = "PBXBuildFile"; | |
| 400 | + "fileRef" = "413823572A414825D1DA4580"; | |
| 401 | + }; | |
| 402 | + "6BCAD6CE9055ABB8BDE99D3D" = { | |
| 403 | + "isa" = "PBXBuildFile"; | |
| 404 | + "fileRef" = "07928D013502A7AEB5C6EB03"; | |
| 405 | + }; | |
| 406 | + "B37753D4AB949DB5681B16FB" = { | |
| 407 | + "isa" = "PBXBuildFile"; | |
| 408 | + "fileRef" = "119DE12F5D045816EDEC9843"; | |
| 409 | + }; | |
| 410 | + "D8602951BD2FFB1812BD21EE" = { | |
| 411 | + "isa" = "PBXBuildFile"; | |
| 412 | + "fileRef" = "900F718AA064255994CD45B8"; | |
| 413 | + }; | |
| 414 | + "2074393C0363491D999BAE16" = { | |
| 415 | + "isa" = "PBXBuildFile"; | |
| 416 | + "fileRef" = "352EAD9C8771D54832387F64"; | |
| 417 | + }; | |
| 418 | + "EE39D2C5ADC981818B9117E1" = { | |
| 419 | + "isa" = "PBXBuildFile"; | |
| 420 | + "fileRef" = "BC590D1F9F12E8A8A3FD703F"; | |
| 421 | + }; | |
| 422 | + "2F53CCB0C5523BCC1AD41BDB" = { | |
| 423 | + "isa" = "PBXBuildFile"; | |
| 424 | + "fileRef" = "5F51F1A8C96EC80FB3DF1789"; | |
| 425 | + }; | |
| 426 | + "AF9CE3E468D5BC4C85C8FF68" = { | |
| 427 | + "isa" = "PBXBuildFile"; | |
| 428 | + "fileRef" = "267585C701FE24385C4A7730"; | |
| 429 | + }; | |
| 430 | + "A7CE383E14BB29514D2DD0C2" = { | |
| 431 | + "isa" = "PBXBuildFile"; | |
| 432 | + "fileRef" = "E76D1B93B17DC49DF3364355"; | |
| 433 | + }; | |
| 434 | + "59F9215D16187F2AAD43D7B8" = { | |
| 435 | + "isa" = "PBXBuildFile"; | |
| 436 | + "fileRef" = "5209D7B8FE7DB3E851C09177"; | |
| 437 | + }; | |
| 438 | + "F11FE05286D083962ACFFC9E" = { | |
| 439 | + "isa" = "PBXBuildFile"; | |
| 440 | + "fileRef" = "100CD0DC00C64B0B646E69DC"; | |
| 441 | + }; | |
| 442 | + "300C1C6C7AC83D517D44ED14" = { | |
| 443 | + "isa" = "PBXBuildFile"; | |
| 444 | + "fileRef" = "4652E379F9220B1BF60E12B9"; | |
| 445 | + }; | |
| 446 | + "9AAD59C9AF6056DDF96C21D9" = { | |
| 447 | + "isa" = "PBXBuildFile"; | |
| 448 | + "fileRef" = "2DF77FDA9C8372B7840DB84B"; | |
| 449 | + }; | |
| 450 | + "2CA3823F37CFB4409025F7D9" = { | |
| 451 | + "isa" = "PBXBuildFile"; | |
| 452 | + "fileRef" = "4CFE272A94D11EA39270BB02"; | |
| 453 | + }; | |
| 454 | + "80C0D081FE8F82B6B5025265" = { | |
| 455 | + "isa" = "PBXBuildFile"; | |
| 456 | + "fileRef" = "7958DCE0804231A319D26CD8"; | |
| 457 | + }; | |
| 458 | + "D03D42F4A68816AE8C471677" = { | |
| 459 | + "isa" = "PBXBuildFile"; | |
| 460 | + "fileRef" = "D061672D180E0CC713D8F100"; | |
| 461 | + }; | |
| 462 | + "1857C14A0B38C2D8BBE2A813" = { | |
| 463 | + "isa" = "PBXBuildFile"; | |
| 464 | + "fileRef" = "3810E7AB9E8DF14917E34477"; | |
| 465 | + }; | |
| 466 | + "1E4F77C1404DCB61DFAB398B" = { | |
| 467 | + "isa" = "PBXBuildFile"; | |
| 468 | + "fileRef" = "60524849AAB9510D72A785E5"; | |
| 469 | + }; | |
| 470 | + "437A5D46901E04F456D232F5" = { | |
| 471 | + "isa" = "PBXBuildFile"; | |
| 472 | + "fileRef" = "A49A1847A6C656BBBFECDB8E"; | |
| 473 | + }; | |
| 474 | + "AAC473035B0539E8E791202F" = { | |
| 475 | + "isa" = "PBXBuildFile"; | |
| 476 | + "fileRef" = "7D367B139647CEA90F768A9B"; | |
| 477 | + }; | |
| 478 | + "711C0F30FD1616D636AA2959" = { | |
| 479 | + "isa" = "PBXBuildFile"; | |
| 480 | + "fileRef" = "C2CBF2E084321F2ECA296112"; | |
| 481 | + }; | |
| 482 | + "31AACDF3704BA6FDA1C24B2F" = { | |
| 483 | + "isa" = "PBXBuildFile"; | |
| 484 | + "fileRef" = "4C15E8BE8F01FC4E793E0EE1"; | |
| 485 | + }; | |
| 486 | + "DE69E89DD3EEAAD604860B0B" = { | |
| 487 | + "isa" = "PBXBuildFile"; | |
| 488 | + "fileRef" = "CB8C52BD5C2A06B60EC6768B"; | |
| 489 | + }; | |
| 490 | + "751BBC7AFA2EC0105700402A" = { | |
| 491 | + "isa" = "PBXBuildFile"; | |
| 492 | + "fileRef" = "AEB3E1F4EFCEE89846DDB6F1"; | |
| 493 | + }; | |
| 494 | + "5D40AE704E511176C5DF5A8E" = { | |
| 495 | + "isa" = "PBXBuildFile"; | |
| 496 | + "fileRef" = "89C50894961A786737934E7B"; | |
| 497 | + }; | |
| 498 | + "9B9C7F1384F6883379FC34D3" = { | |
| 499 | + "isa" = "PBXBuildFile"; | |
| 500 | + "fileRef" = "CD0B7AD613C4E32D4FA778B6"; | |
| 501 | + }; | |
| 502 | + "B97BA47B9ED21D34C628D9D7" = { | |
| 503 | + "isa" = "PBXBuildFile"; | |
| 504 | + "fileRef" = "1854CD73DE41430109C5A268"; | |
| 505 | + }; | |
| 506 | + "C9BA7F277F3D1631A6F76FBA" = { | |
| 507 | + "isa" = "PBXBuildFile"; | |
| 508 | + "fileRef" = "FEE1896A5C756DFF96389CC6"; | |
| 509 | + }; | |
| 510 | + "423EB9B902DA957AE39D9B50" = { | |
| 511 | + "isa" = "PBXBuildFile"; | |
| 512 | + "fileRef" = "038813F19FA1E4A37CCCA0C4"; | |
| 513 | + }; | |
| 514 | + "DB74D5BE500089E74A7764DD" = { | |
| 515 | + "isa" = "PBXBuildFile"; | |
| 516 | + "fileRef" = "423B784DC51F6993045C572F"; | |
| 517 | + }; | |
| 518 | + "EDD4738D4B7AD97BBAB17E54" = { | |
| 519 | + "isa" = "PBXBuildFile"; | |
| 520 | + "fileRef" = "8319DBF80F0A1AE2BD7EE172"; | |
| 521 | + }; | |
| 522 | + "F9D5713DD3AAC240D75CBA9F" = { | |
| 523 | + "isa" = "PBXBuildFile"; | |
| 524 | + "fileRef" = "E382BFD990FD584F51A98000"; | |
| 525 | + }; | |
| 526 | + "1073493A205D84D7717D3DC3" = { | |
| 527 | + "isa" = "PBXBuildFile"; | |
| 528 | + "fileRef" = "5CBC6EB79F154CE84C2F54E6"; | |
| 529 | + }; | |
| 530 | + "D5EA31B0949757348F1FFD2B" = { | |
| 531 | + "isa" = "PBXBuildFile"; | |
| 532 | + "fileRef" = "1074610367B0B6A094EA470C"; | |
| 533 | + }; | |
| 534 | + "DCBFE6E73C2E763A7A3093F7" = { | |
| 535 | + "isa" = "PBXBuildFile"; | |
| 536 | + "fileRef" = "EEFDDCD6F5AB50CA168FA1B8"; | |
| 537 | + }; | |
| 538 | + "B3C7BF0017EA13F33B0A3ECE" = { | |
| 539 | + "isa" = "PBXBuildFile"; | |
| 540 | + "fileRef" = "DFFC0D2FA6679F312F11941D"; | |
| 541 | + }; | |
| 542 | + "B3AE542D97F29FA6604969E7" = { | |
| 543 | + "isa" = "PBXBuildFile"; | |
| 544 | + "fileRef" = "0DA04F35AB86E5951F47166B"; | |
| 545 | + }; | |
| 546 | + "EC23EF1C46289A7151FA3E28" = { | |
| 547 | + "isa" = "PBXBuildFile"; | |
| 548 | + "fileRef" = "0C8CC87581FC28D19B7207E0"; | |
| 549 | + }; | |
| 550 | + "878A52FC5FF6A57D50B7B870" = { | |
| 551 | + "isa" = "PBXSourcesBuildPhase"; | |
| 552 | + "buildActionMask" = 2147483647; | |
| 553 | + "files" = ( | |
| 554 | + "5316D1BFE48A71EF8A4E8A29", | |
| 555 | + "E9653C0EF1AF556DE8D49873", | |
| 556 | + "6BCAD6CE9055ABB8BDE99D3D", | |
| 557 | + "B37753D4AB949DB5681B16FB", | |
| 558 | + "D8602951BD2FFB1812BD21EE", | |
| 559 | + "2074393C0363491D999BAE16", | |
| 560 | + "EE39D2C5ADC981818B9117E1", | |
| 561 | + "2F53CCB0C5523BCC1AD41BDB", | |
| 562 | + "AF9CE3E468D5BC4C85C8FF68", | |
| 563 | + "A7CE383E14BB29514D2DD0C2", | |
| 564 | + "59F9215D16187F2AAD43D7B8", | |
| 565 | + "F11FE05286D083962ACFFC9E", | |
| 566 | + "300C1C6C7AC83D517D44ED14", | |
| 567 | + "9AAD59C9AF6056DDF96C21D9", | |
| 568 | + "2CA3823F37CFB4409025F7D9", | |
| 569 | + "80C0D081FE8F82B6B5025265", | |
| 570 | + "D03D42F4A68816AE8C471677", | |
| 571 | + "1857C14A0B38C2D8BBE2A813", | |
| 572 | + "1E4F77C1404DCB61DFAB398B", | |
| 573 | + "437A5D46901E04F456D232F5", | |
| 574 | + "AAC473035B0539E8E791202F", | |
| 575 | + "711C0F30FD1616D636AA2959", | |
| 576 | + "31AACDF3704BA6FDA1C24B2F", | |
| 577 | + "DE69E89DD3EEAAD604860B0B", | |
| 578 | + "751BBC7AFA2EC0105700402A", | |
| 579 | + "5D40AE704E511176C5DF5A8E", | |
| 580 | + "9B9C7F1384F6883379FC34D3", | |
| 581 | + "B97BA47B9ED21D34C628D9D7", | |
| 582 | + "C9BA7F277F3D1631A6F76FBA", | |
| 583 | + "423EB9B902DA957AE39D9B50", | |
| 584 | + "DB74D5BE500089E74A7764DD", | |
| 585 | + "EDD4738D4B7AD97BBAB17E54", | |
| 586 | + "F9D5713DD3AAC240D75CBA9F", | |
| 587 | + "1073493A205D84D7717D3DC3", | |
| 588 | + "D5EA31B0949757348F1FFD2B", | |
| 589 | + "DCBFE6E73C2E763A7A3093F7", | |
| 590 | + "B3C7BF0017EA13F33B0A3ECE", | |
| 591 | + "B3AE542D97F29FA6604969E7", | |
| 592 | + "EC23EF1C46289A7151FA3E28", | |
| 593 | + ); | |
| 594 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 595 | + }; | |
| 596 | + "E2AA269EB967A8853A258BFA" = { | |
| 597 | + "isa" = "PBXFrameworksBuildPhase"; | |
| 598 | + "buildActionMask" = 2147483647; | |
| 599 | + "files" = ( | |
| 600 | + "9B1266BC9A27D9D3E1D7EA9D", | |
| 601 | + ); | |
| 602 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 603 | + }; | |
| 604 | + "BD360A10C929F703C02C4331" = { | |
| 605 | + "isa" = "PBXBuildFile"; | |
| 606 | + "fileRef" = "4B938F834BDD8BCB6DFD7691"; | |
| 607 | + }; | |
| 608 | + "3E690DB03FA3E95A14237948" = { | |
| 609 | + "isa" = "PBXBuildFile"; | |
| 610 | + "fileRef" = "58B93EBF9D77801602DBED7F"; | |
| 611 | + }; | |
| 612 | + "2D7895A1E2294744321D631F" = { | |
| 613 | + "isa" = "PBXBuildFile"; | |
| 614 | + "fileRef" = "5DE058E997E17FB6E1C96D5F"; | |
| 615 | + }; | |
| 616 | + "EC74FBEC6AC5E1009BAB2F25" = { | |
| 617 | + "isa" = "PBXBuildFile"; | |
| 618 | + "fileRef" = "C2C9DC46EEABB4403C4F54B6"; | |
| 619 | + }; | |
| 620 | + "DCCB0BA9E0E0EC365CD60623" = { | |
| 621 | + "isa" = "PBXBuildFile"; | |
| 622 | + "fileRef" = "74BF9E81D47C493AB795ED7C"; | |
| 623 | + }; | |
| 624 | + "56C3256106C3A108001EC3FF" = { | |
| 625 | + "isa" = "PBXBuildFile"; | |
| 626 | + "fileRef" = "0A5282C4EC48041B28F6D173"; | |
| 627 | + }; | |
| 628 | + "41D311A605520FC7B8B9A980" = { | |
| 629 | + "isa" = "PBXResourcesBuildPhase"; | |
| 630 | + "buildActionMask" = 2147483647; | |
| 631 | + "files" = ( | |
| 632 | + "BD360A10C929F703C02C4331", | |
| 633 | + "3E690DB03FA3E95A14237948", | |
| 634 | + "2D7895A1E2294744321D631F", | |
| 635 | + "EC74FBEC6AC5E1009BAB2F25", | |
| 636 | + "DCCB0BA9E0E0EC365CD60623", | |
| 637 | + "56C3256106C3A108001EC3FF", | |
| 638 | + ); | |
| 639 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 640 | + }; | |
| 641 | + "F1D4E4051FA27B04C65CABEE" = { | |
| 642 | + "isa" = "XCBuildConfiguration"; | |
| 643 | + "buildSettings" = { | |
| 644 | + "SDKROOT" = "xros"; | |
| 645 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 646 | + "SWIFT_OPTIMIZATION_LEVEL" = "-Onone"; | |
| 647 | + "SWIFT_EMIT_LOC_STRINGS" = "NO"; | |
| 648 | + "SWIFT_ACTIVE_COMPILATION_CONDITIONS" = "$(inherited) DEBUG"; | |
| 649 | + }; | |
| 650 | + "name" = "Debug"; | |
| 651 | + "baseConfigurationReference" = "98C8D67F698DEFBBE6078282"; | |
| 652 | + }; | |
| 653 | + "E35D5516D100FF5C69B6611C" = { | |
| 654 | + "isa" = "XCBuildConfiguration"; | |
| 655 | + "buildSettings" = { | |
| 656 | + "SDKROOT" = "xros"; | |
| 657 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 658 | + "SWIFT_OPTIMIZATION_LEVEL" = "-O"; | |
| 659 | + "SWIFT_EMIT_LOC_STRINGS" = "NO"; | |
| 660 | + "SWIFT_ACTIVE_COMPILATION_CONDITIONS" = "$(inherited)"; | |
| 661 | + }; | |
| 662 | + "name" = "Release"; | |
| 663 | + "baseConfigurationReference" = "98C8D67F698DEFBBE6078282"; | |
| 664 | + }; | |
| 665 | + "88A9304AEA126CFA946C4524" = { | |
| 666 | + "isa" = "XCConfigurationList"; | |
| 667 | + "buildConfigurations" = ( | |
| 668 | + "F1D4E4051FA27B04C65CABEE", | |
| 669 | + "E35D5516D100FF5C69B6611C", | |
| 670 | + ); | |
| 671 | + "defaultConfigurationIsVisible" = 0; | |
| 672 | + "defaultConfigurationName" = "Release"; | |
| 673 | + }; | |
| 674 | + "34A04005BCAF206EEC990BD9" = { | |
| 675 | + "isa" = "PBXNativeTarget"; | |
| 676 | + "buildConfigurationList" = "88A9304AEA126CFA946C4524"; | |
| 677 | + "buildPhases" = ( | |
| 678 | + "45666D976BAB316D970EC459", | |
| 679 | + "878A52FC5FF6A57D50B7B870", | |
| 680 | + "E2AA269EB967A8853A258BFA", | |
| 681 | + "41D311A605520FC7B8B9A980", | |
| 682 | + ); | |
| 683 | + "buildRules" = ( | |
| 684 | + ); | |
| 685 | + "dependencies" = ( | |
| 686 | + ); | |
| 687 | + "name" = "PulseCanvasVision"; | |
| 688 | + "productName" = "PulseCanvas Vision"; | |
| 689 | + "productReference" = "A8792157CB4F27FB949C035F"; | |
| 690 | + "productType" = "com.apple.product-type.application"; | |
| 691 | + "packageProductDependencies" = ( | |
| 692 | + "9B427405DFFC7306479BADEE", | |
| 693 | + ); | |
| 694 | + }; | |
| 695 | + "35B7C0CC0F21DA3F0F098A64" = { | |
| 696 | + "isa" = "PBXContainerItemProxy"; | |
| 697 | + "containerPortal" = "244210E48437B6556980A702"; | |
| 698 | + "proxyType" = 1; | |
| 699 | + "remoteGlobalIDString" = "34A04005BCAF206EEC990BD9"; | |
| 700 | + "remoteInfo" = "PulseCanvasVision"; | |
| 701 | + }; | |
| 702 | + "292AEBA4095B45D3A6BCF782" = { | |
| 703 | + "isa" = "XCBuildConfiguration"; | |
| 704 | + "buildSettings" = { | |
| 705 | + "SDKROOT" = "xros"; | |
| 706 | + "SUPPORTED_PLATFORMS" = "xros xrsimulator"; | |
| 707 | + "TARGETED_DEVICE_FAMILY" = "7"; | |
| 708 | + "XROS_DEPLOYMENT_TARGET" = "2.0"; | |
| 709 | + "SWIFT_VERSION" = "5.0"; | |
| 710 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 711 | + "GENERATE_INFOPLIST_FILE" = "YES"; | |
| 712 | + "CODE_SIGN_STYLE" = "Automatic"; | |
| 713 | + "DEVELOPMENT_TEAM" = "22HV69L32T"; | |
| 714 | + "PRODUCT_BUNDLE_IDENTIFIER" = "com.protomota.pulsecanvas.uitests"; | |
| 715 | + "PRODUCT_NAME" = "PulseCanvasVisionUITests"; | |
| 716 | + "TEST_TARGET_NAME" = "PulseCanvasVision"; | |
| 717 | + "SWIFT_OPTIMIZATION_LEVEL" = "-Onone"; | |
| 718 | + }; | |
| 719 | + "name" = "Debug"; | |
| 720 | + }; | |
| 721 | + "830D981C3E358C225481E7AF" = { | |
| 722 | + "isa" = "XCBuildConfiguration"; | |
| 723 | + "buildSettings" = { | |
| 724 | + "SDKROOT" = "xros"; | |
| 725 | + "SUPPORTED_PLATFORMS" = "xros xrsimulator"; | |
| 726 | + "TARGETED_DEVICE_FAMILY" = "7"; | |
| 727 | + "XROS_DEPLOYMENT_TARGET" = "2.0"; | |
| 728 | + "SWIFT_VERSION" = "5.0"; | |
| 729 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 730 | + "GENERATE_INFOPLIST_FILE" = "YES"; | |
| 731 | + "CODE_SIGN_STYLE" = "Automatic"; | |
| 732 | + "DEVELOPMENT_TEAM" = "22HV69L32T"; | |
| 733 | + "PRODUCT_BUNDLE_IDENTIFIER" = "com.protomota.pulsecanvas.uitests"; | |
| 734 | + "PRODUCT_NAME" = "PulseCanvasVisionUITests"; | |
| 735 | + "TEST_TARGET_NAME" = "PulseCanvasVision"; | |
| 736 | + "SWIFT_OPTIMIZATION_LEVEL" = "-O"; | |
| 737 | + }; | |
| 738 | + "name" = "Release"; | |
| 739 | + }; | |
| 740 | + "B8C2E164F3D09CAB62B28174" = { | |
| 741 | + "isa" = "XCConfigurationList"; | |
| 742 | + "buildConfigurations" = ( | |
| 743 | + "292AEBA4095B45D3A6BCF782", | |
| 744 | + "830D981C3E358C225481E7AF", | |
| 745 | + ); | |
| 746 | + "defaultConfigurationIsVisible" = 0; | |
| 747 | + "defaultConfigurationName" = "Debug"; | |
| 748 | + }; | |
| 749 | + "F4F165C86664D0DF903FF23B" = { | |
| 750 | + "isa" = "PBXBuildFile"; | |
| 751 | + "fileRef" = "0938440A5586EF11FC09A444"; | |
| 752 | + }; | |
| 753 | + "B0DA16B5A57B77452D9B6EB5" = { | |
| 754 | + "isa" = "PBXSourcesBuildPhase"; | |
| 755 | + "buildActionMask" = 2147483647; | |
| 756 | + "files" = ( | |
| 757 | + "F4F165C86664D0DF903FF23B", | |
| 758 | + ); | |
| 759 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 760 | + }; | |
| 761 | + "14601C0A5E377A66092CCC2E" = { | |
| 762 | + "isa" = "PBXFrameworksBuildPhase"; | |
| 763 | + "buildActionMask" = 2147483647; | |
| 764 | + "files" = ( | |
| 765 | + ); | |
| 766 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 767 | + }; | |
| 768 | + "299D5CFB3FD7410E61F5107B" = { | |
| 769 | + "isa" = "PBXResourcesBuildPhase"; | |
| 770 | + "buildActionMask" = 2147483647; | |
| 771 | + "files" = ( | |
| 772 | + ); | |
| 773 | + "runOnlyForDeploymentPostprocessing" = 0; | |
| 774 | + }; | |
| 775 | + "8157BA2106F6223041554826" = { | |
| 776 | + "isa" = "PBXTargetDependency"; | |
| 777 | + "target" = "34A04005BCAF206EEC990BD9"; | |
| 778 | + "targetProxy" = "35B7C0CC0F21DA3F0F098A64"; | |
| 779 | + }; | |
| 780 | + "9E53AA71467D2DE08E504D40" = { | |
| 781 | + "isa" = "PBXNativeTarget"; | |
| 782 | + "buildConfigurationList" = "B8C2E164F3D09CAB62B28174"; | |
| 783 | + "buildPhases" = ( | |
| 784 | + "B0DA16B5A57B77452D9B6EB5", | |
| 785 | + "14601C0A5E377A66092CCC2E", | |
| 786 | + "299D5CFB3FD7410E61F5107B", | |
| 787 | + ); | |
| 788 | + "buildRules" = ( | |
| 789 | + ); | |
| 790 | + "dependencies" = ( | |
| 791 | + "8157BA2106F6223041554826", | |
| 792 | + ); | |
| 793 | + "name" = "PulseCanvasVisionUITests"; | |
| 794 | + "productName" = "PulseCanvasVisionUITests"; | |
| 795 | + "productReference" = "9F63878049D400944738EB5F"; | |
| 796 | + "productType" = "com.apple.product-type.bundle.ui-testing"; | |
| 797 | + }; | |
| 798 | + "E2EDCD14762CC2F70971BC55" = { | |
| 799 | + "isa" = "XCBuildConfiguration"; | |
| 800 | + "buildSettings" = { | |
| 801 | + "SDKROOT" = "xros"; | |
| 802 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 803 | + }; | |
| 804 | + "name" = "Debug"; | |
| 805 | + }; | |
| 806 | + "E49449A51B1C1B61FFEBC152" = { | |
| 807 | + "isa" = "XCBuildConfiguration"; | |
| 808 | + "buildSettings" = { | |
| 809 | + "SDKROOT" = "xros"; | |
| 810 | + "CLANG_ENABLE_MODULES" = "YES"; | |
| 811 | + }; | |
| 812 | + "name" = "Release"; | |
| 813 | + }; | |
| 814 | + "54972615C880599A4265A739" = { | |
| 815 | + "isa" = "XCConfigurationList"; | |
| 816 | + "buildConfigurations" = ( | |
| 817 | + "E2EDCD14762CC2F70971BC55", | |
| 818 | + "E49449A51B1C1B61FFEBC152", | |
| 819 | + ); | |
| 820 | + "defaultConfigurationIsVisible" = 0; | |
| 821 | + "defaultConfigurationName" = "Release"; | |
| 822 | + }; | |
| 823 | + "244210E48437B6556980A702" = { | |
| 824 | + "isa" = "PBXProject"; | |
| 825 | + "attributes" = { | |
| 826 | + "LastUpgradeCheck" = "2700"; | |
| 827 | + "TargetAttributes" = { | |
| 828 | + "34A04005BCAF206EEC990BD9" = { | |
| 829 | + "SystemCapabilities" = { | |
| 830 | + "com.apple.iCloud" = { | |
| 831 | + "enabled" = 1; | |
| 832 | + }; | |
| 833 | + }; | |
| 834 | + }; | |
| 835 | + "9E53AA71467D2DE08E504D40" = { | |
| 836 | + "TestTargetID" = "34A04005BCAF206EEC990BD9"; | |
| 837 | + }; | |
| 838 | + }; | |
| 839 | + }; | |
| 840 | + "buildConfigurationList" = "54972615C880599A4265A739"; | |
| 841 | + "compatibilityVersion" = "Xcode 14.0"; | |
| 842 | + "developmentRegion" = "en"; | |
| 843 | + "hasScannedForEncodings" = 0; | |
| 844 | + "knownRegions" = ( | |
| 845 | + "en", | |
| 846 | + "Base", | |
| 847 | + ); | |
| 848 | + "mainGroup" = "0D6E4079E36703EBD37C0072"; | |
| 849 | + "productRefGroup" = "0A3E27B8CA818264D75C8D81"; | |
| 850 | + "projectDirPath" = ""; | |
| 851 | + "projectRoot" = ""; | |
| 852 | + "targets" = ( | |
| 853 | + "34A04005BCAF206EEC990BD9", | |
| 854 | + "9E53AA71467D2DE08E504D40", | |
| 855 | + ); | |
| 856 | + "packageReferences" = ( | |
| 857 | + "D50706B6923B46DFD8933125", | |
| 858 | + ); | |
| 859 | + }; | |
| 860 | + "D50706B6923B46DFD8933125" = { | |
| 861 | + "isa" = "XCRemoteSwiftPackageReference"; | |
| 862 | + "repositoryURL" = "https://github.com/weichsel/ZIPFoundation.git"; | |
| 863 | + "requirement" = { | |
| 864 | + "kind" = "exactVersion"; | |
| 865 | + "version" = "0.9.20"; | |
| 866 | + }; | |
| 867 | + }; | |
| 868 | + "9B427405DFFC7306479BADEE" = { | |
| 869 | + "isa" = "XCSwiftPackageProductDependency"; | |
| 870 | + "package" = "D50706B6923B46DFD8933125"; | |
| 871 | + "productName" = "ZIPFoundation"; | |
| 872 | + }; | |
| 873 | + "9B1266BC9A27D9D3E1D7EA9D" = { | |
| 874 | + "isa" = "PBXBuildFile"; | |
| 875 | + "productRef" = "9B427405DFFC7306479BADEE"; | |
| 876 | + }; | |
| 877 | + }; | |
| 878 | + "rootObject" = "244210E48437B6556980A702"; | |
| 879 | + } |
README.md added
| 1 | + <div align="center"> | |
| 2 | + | |
| 3 | + <img src="assets/app-icon/PulseCanvas-Octagon.png" width="80" alt="PulseCanvas app icon"> | |
| 4 | + | |
| 5 | + # PulseCanvas Studio | |
| 6 | + | |
| 7 | + ### Your music. Your visual world. | |
| 8 | + | |
| 9 | + **Turn a soundtrack into moving art. Made on your Mac.** | |
| 10 | + | |
| 11 | + Free app · Open source, public domain (Unlicense) · Two Mac editions · Beat-aligned scenes · Up to 4K at 60 fps | |
| 12 | + | |
| 13 | + [Explore the visuals](#find-your-signature-look) · [Meet Studio](#give-your-song-a-visual-story) · [Make a video](#from-beat-to-video) · [Build the app](#build-it-on-your-mac) | |
| 14 | + | |
| 15 | + </div> | |
| 16 | + | |
| 17 | +  | |
| 18 | + | |
| 19 | + <sub>Cover: conceptual campaign artwork. The interface images below are real app screenshots.</sub> | |
| 20 | + | |
| 21 | + Want to help build, test, or document the app? Read the [contribution guide](CONTRIBUTING.md). | |
| 22 | + | |
| 23 | + ## Give your music something to look like | |
| 24 | + | |
| 25 | + A tunnel that pulls you into the next drop. Liquid folds that ripple with the rhythm. A field of glowing particles that comes alive as the track builds. | |
| 26 | + | |
| 27 | + PulseCanvas Studio is a native macOS visualizer and video creator. Bring a song, find a look, shape the motion, and arrange a visual journey. Then save a finished MP4 with your music—or enjoy the whole thing in full-screen presentation mode. | |
| 28 | + | |
| 29 | + Make a music video, a vertical clip, a release teaser, or a backdrop for your next set. No account. No subscription. Every feature and export is free. | |
| 30 | + | |
| 31 | + | 336 native visualizers | 7,766 ProjectM effects | 5 canvas shapes | Up to 4K · 60 fps | | |
| 32 | + | :---: | :---: | :---: | :---: | | |
| 33 | + | Particles, tunnels, liquid forms, and geometry | A searchable library of thousands of looks | Wide, phone, portrait, landscape, and square | MP4 video with your soundtrack | | |
| 34 | + | |
| 35 | + ## Find your signature look | |
| 36 | + | |
| 37 | + Start with **Event Horizon**, **Ribbon Foundry**, **Chrome Metaballs**, **Octagon Vault**, or **Mercury Fold**. Explore lensed black holes, forged ribbons, liquid chrome, hyperbolic tilings, gothic naves, ferrofluid crowns, connected honeycomb tunnels, night drives, wind-farm roads, drone light shows and kinetic mirror walls. The full list is in [docs/NATIVE_VISUALIZERS.md](docs/NATIVE_VISUALIZERS.md). The direct-download edition also includes the ProjectM library for thousands more effects. The App Store edition focuses on the 336 native Metal styles. | |
| 38 | + | |
| 39 | + - **Find it fast.** Search names and original creator titles, browse categories and folders, and save favorites with a heart. | |
| 40 | + - **Make it yours.** Shape motion, zoom, Chaos, brightness, blur, and camera framing. Native designs also offer color palettes and controls for their particular forms; ProjectM effects retain their own colors and structures. | |
| 41 | + - **Follow the music.** Chaos adjusts how strongly the visuals respond to the soundtrack. Turn it up for more active motion; set it to zero for smooth procedural animation without music-driven pulses. | |
| 42 | + - **Discover something unexpected.** Shuffle to another visualizer with its saved look, or roll the dice to randomize the current visual settings. | |
| 43 | + | |
| 44 | +  | |
| 45 | + | |
| 46 | + Every visualizer has a deliberate default look. Choose blue, green, warm, violet or multicolor palettes, then let your track drive waves, reflections, cells and particles. | |
| 47 | + | |
| 48 | + ## Give your song a visual story | |
| 49 | + | |
| 50 | + **Studio** brings multiple visualizers together on a timeline. Import your soundtrack and PulseCanvas detects a beat grid for scene changes. Choose a visualizer for each section and decide how many musical bars it should play: four bars here, one bar there, two for the next moment. | |
| 51 | + | |
| 52 | +  | |
| 53 | + | |
| 54 | + | In Studio | What you can do | | |
| 55 | + | --- | --- | | |
| 56 | + | **Bars per scene** | Give each section its own length; later sections follow the beat grid. | | |
| 57 | + | **Loop a section** | Preview a scene repeatedly while you try different visualizers and styles. | | |
| 58 | + | **Use at playhead** | Assign the visualizer you are watching to the current point in the song. | | |
| 59 | + | **Randomize timeline** | Generate visualizer assignments without duplicates, using favorites first and unused library visuals for the remaining clips; randomize bar lengths too if desired. | | |
| 60 | + | **Apply to all** | Share Chaos, motion speed, zoom speed, bar lengths, and strobe choices across the video. | | |
| 61 | + | **Save your project** | Reopen your timeline and visual settings in a `.pulsecanvas` project. | | |
| 62 | + | |
| 63 | + Each scene uses its visualizer’s saved appearance settings, so a look stays consistent wherever you use it. Imported audio remains linked to its original file; keep that file available when reopening a project. | |
| 64 | + | |
| 65 | + ## Listen to Radio | |
| 66 | + | |
| 67 | + Open **Radio** beside **Library** in the top toolbar. Radio has its own player and visual sequence; it does not edit your Studio timeline or use saved Studio appearance settings. Visuals shuffle through your available favorites before repeating, falling back to the library when you have no favorites. **Randomize** switches the current visualizer immediately using the same favorites-first pool, without seeking the song or changing bar timing. Choose **1, 2, 4, 8, or 16 bars per visualizer** (four by default). Songs advance automatically and the station loops. **Present** fills the display without aspect-ratio controls; playback controls fade and reappear on pointer movement. Escape returns to windowed radio. Returning to the editor restores your previous soundtrack and position, paused. | |
| 68 | + | |
| 69 | + Closing the last main window stops playback and quits the app. Minimize keeps playback running. | |
| 70 | + | |
| 71 | + Radio has its own volume preference, initially 70%. It remembers the chosen level between songs and sessions; leaving Radio restores the editor's previous volume. | |
| 72 | + | |
| 73 | + The initial **All Music** station includes every radio track. A versioned `stations.json` directory points each stable station ID to its own track catalog; the player shows a station selector only when more than one station is available. Genre stations can reuse the same audio objects. The app refreshes these public static JSON files whenever Radio opens, so new songs and stations require no API or app release. Radio downloads and verifies audio locally, analyzes it off the main thread, and prepares the next track while the current track plays. | |
| 74 | + | |
| 75 | + For local development, run `python3 scripts/prepare-radio-library.py --handoff /path/to/HANDOFF.md --output build/radio`. A development bundle with `PulseCanvasRadioDeveloperMode` set to true exposes Radio → Library source → Open local library; choose `build/radio`. Originals are not modified. `bash scripts/test-radio.sh build/radio/catalog.json` validates playlist transitions, favorites, isolated visuals, station switching, cache integrity, and all prepared songs. `scripts/upload-radio-r2.py --help` describes the R2 upload environment variables; credentials never enter the app or catalogs. | |
| 76 | + | |
| 77 | + The radio bucket is managed in the [Cloudflare R2 dashboard](https://dash.cloudflare.com/36090598a0df96b2a7bafd9119b3a15b/r2/default/buckets/pulsecanvas-radio). Its production entry point is [radio.pulsecanvas.si/stations.json](https://radio.pulsecanvas.si/stations.json). Cloudflare recommends a custom domain for production access; `r2.dev` endpoints are for development. See [Cloudflare's public bucket documentation](https://developers.cloudflare.com/r2/buckets/public-buckets/). | |
| 78 | + | |
| 79 | + ## From beat to video | |
| 80 | + | |
| 81 | + Choose a canvas that fits the destination. Create widescreen videos for YouTube, vertical clips for TikTok and Reels, or square posts for your feed. PulseCanvas exports the MP4; you choose where to share it. | |
| 82 | + | |
| 83 | + | Canvas | Shape | Maximum export dimensions | | |
| 84 | + | --- | --- | --- | | |
| 85 | + | **Wide** | 16:9 | 3840 × 2160 | | |
| 86 | + | **Phone** | 9:16 | 2160 × 3840 | | |
| 87 | + | **Landscape** | 4:3 | 2880 × 2160 | | |
| 88 | + | **Portrait** | 3:4 | 2160 × 2880 | | |
| 89 | + | **Square** | 1:1 | 2160 × 2160 | | |
| 90 | + | |
| 91 | + Choose **24, 30, or 60 fps** and a 720-, 1080-, or 2160-pixel shorter edge. Export includes the entire soundtrack as stereo AAC audio in an H.264 MP4. A live frame preview, progress bar, and estimated time keep you informed while the video renders. The file saves directly to your chosen location, with **Show in Finder** when it is ready. | |
| 92 | + | |
| 93 | + Metal powers native rendering, and the encoder requests hardware acceleration where supported. Preview playback speed does not drop frames from the exported video. | |
| 94 | + | |
| 95 | + ## Agent access on Mac | |
| 96 | + | |
| 97 | + In Creators Edition for Mac, use Settings → Agent access to connect Claude Code or Codex, authorize folders, and choose which local operations an agent can perform. Agents can work with favorites, load a local song, edit a Studio project and render a video. See the [agent setup and tool reference](docs/development/pulsecanvas-mcp.md). | |
| 98 | + | |
| 99 | + ## Or just press Present | |
| 100 | + | |
| 101 | + Watch one visualizer full screen, or play the whole Studio timeline with automatic scene changes. Match the project’s aspect ratio or fill the display. Controls fade during playback; press **Space** to pause and **Escape** to return to the editor. | |
| 102 | + | |
| 103 | + ## Your first video in five steps | |
| 104 | + | |
| 105 | + 1. **Bring the music.** Try the bundled soundtrack, or choose **Replace audio** to import your own. | |
| 106 | + 2. **Find a look.** Open **Library**, browse the effects, and heart the ones you love. | |
| 107 | + 3. **Set the mood.** Adjust the visual controls or roll the dice for a fresh style. | |
| 108 | + 4. **Build the journey.** In **Studio**, choose your scenes and their bar lengths—or randomize the timeline. | |
| 109 | + 5. **Save the video.** Pick the canvas, resolution, and frame rate in **Project settings**, then click **Save video** and choose a destination. | |
| 110 | + | |
| 111 | + Want the details? The [user guide](docs/USER_GUIDE.md) covers every control, section playback, presentation, export, and current limitations. | |
| 112 | + | |
| 113 | + ## Get PulseCanvas | |
| 114 | + | |
| 115 | + Visit **[pulsecanvas.ai](https://pulsecanvas.ai/)** for the project website, or build from the source below. A dedicated [download and installation page](https://pulsecanvas.ai/download/) is being prepared for the signed, notarized direct edition. The Mac App Store edition is in testing and is not publicly available yet. | |
| 116 | + | |
| 117 | + | Edition | Visual library | Updates | | |
| 118 | + | --- | --- | --- | | |
| 119 | + | **Mac App Store** | 336 native Metal visualizers; excludes projectM, OpenGL presets and the external texture pack | Apple distribution | | |
| 120 | + | **Direct download** | 336 native visualizers plus 7,766 original presets | Signed Sparkle updates; system profiling disabled | | |
| 121 | + | |
| 122 | + Both editions support Studio, native visual settings and video export. Native projects can move between editions; full-library projects require the direct edition. Preferences for the full preset library remain separate so the Metal edition does not overwrite them. | |
| 123 | + | |
| 124 | + The app is free, and its source is open and in the public domain (Unlicense); see [Licensing and credits](#licensing-and-credits) for the separate application, engine, and asset terms. The projectM licensing warning applies to the full-library edition; the Store package excludes that engine and its presets/textures. This exclusion does not establish rights clearance for assets in the direct edition. | |
| 125 | + | |
| 126 | + ## Build it on your Mac | |
| 127 | + | |
| 128 | + Requires **macOS 14 or later**, a Metal-capable Mac, [Python 3](https://www.python.org/downloads/macos/), [CMake](https://cmake.org/download/), and [Xcode](https://developer.apple.com/xcode/resources/) with the Metal toolchain. The current build has been checked on Apple silicon with Xcode 27 and Swift 6.4. The bundled ProjectM engine is built from the included source. | |
| 129 | + | |
| 130 | + ```sh | |
| 131 | + git clone https://github.com/projectatomai/pulsecanvas.git | |
| 132 | + cd pulsecanvas | |
| 133 | + ./scripts/build-app.sh | |
| 134 | + open "build/PulseCanvas Studio.app" | |
| 135 | + ``` | |
| 136 | + | |
| 137 | + If Xcode reports a missing Metal toolchain, install its official component with `xcodebuild -downloadComponent MetalToolchain`. The script builds the engines, compiles shaders, packages resources, and signs a local development app. It does not publish a release. | |
| 138 | + | |
| 139 | + <details> | |
| 140 | + <summary><strong>For contributors: documentation and verification</strong></summary> | |
| 141 | + | |
| 142 | + - [User guide and controls](docs/USER_GUIDE.md) | |
| 143 | + - [Rendering architecture](docs/RENDERING.md) | |
| 144 | + - [Edition builds, updates and release checks](docs/DISTRIBUTION.md) | |
| 145 | + - [ProjectM integration and source](third_party/PROJECTM.md) | |
| 146 | + - [Preset compatibility inventory](docs/preset-compatibility.json) | |
| 147 | + - [Attribution and packaging verification](docs/preset-provenance-verification.md) | |
| 148 | + | |
| 149 | + Useful checks include: | |
| 150 | + | |
| 151 | + ```sh | |
| 152 | + ./scripts/test-store-edition.sh | |
| 153 | + ./scripts/test-studio.sh | |
| 154 | + ./scripts/test-chaos.sh | |
| 155 | + ./scripts/test-projectm-integration.sh | |
| 156 | + ./scripts/test-social-export.sh | |
| 157 | + python3 scripts/test-preset-provenance.py | |
| 158 | + python3 scripts/preset-provenance.py | |
| 159 | + ``` | |
| 160 | + | |
| 161 | + The [user guide](docs/USER_GUIDE.md#checks) lists the wider rendering, playback, and export checks. Provenance checks verify the actual bundled subset, hashes, original metadata, notices, and texture inventory. Rendering checks cannot judge every aesthetic issue or establish asset permissions. | |
| 162 | + | |
| 163 | + </details> | |
| 164 | + | |
| 165 | + ## Free to use. Open source. | |
| 166 | + | |
| 167 | + Use the official PulseCanvas app for personal projects or paid creative work. Every feature and export is free. Your video output is yours; music, presets, textures and other material still need their own applicable permissions. | |
| 168 | + | |
| 169 | + PulseCanvas's original application code, native shaders, build scripts and documentation are open source and in the public domain under [The Unlicense](LICENSE). Use them, change them, ship them, sell them. | |
| 170 | + | |
| 171 | + Third-party code, dependencies and assets keep their own terms. The Unlicense on PulseCanvas code does not relicense them or establish permission to redistribute them. | |
| 172 | + | |
| 173 | + ## A Project ATOM project. Supported by people. | |
| 174 | + | |
| 175 | + If PulseCanvas helps you make something you love, share the project, [send feedback](https://projectatom.ai/apps?app=pulsecanvas#feedback), or leave a rating. Your feedback helps the PulseCanvas team keep building. Every feature and export stays free. | |
| 176 | + | |
| 177 | + [Website](https://pulsecanvas.ai/) · [Support](https://pulsecanvas.ai/support/) · [public domain (Unlicense)](LICENSE) | |
| 178 | + | |
| 179 | + ## Licensing and credits | |
| 180 | + | |
| 181 | + | Material | License or provenance | | |
| 182 | + | --- | --- | | |
| 183 | + | **Original application code, native shaders, build scripts and documentation** | [public domain (Unlicense)](LICENSE), with required third-party rights preserved. | | |
| 184 | + | **App branding, icon, screenshots and campaign artwork** | Brand assets are distinct from the effect library. [README artwork sources](assets/readme/README.md) distinguish conceptual artwork from real app captures. The application license grants no trademark rights or endorsement. | | |
| 185 | + | **projectM engine — Creators edition** | Its own LGPL terms, notices, corresponding source and rebuild/relink instructions in [third_party/PROJECTM.md](third_party/PROJECTM.md). | | |
| 186 | + | **Imported presets and textures — Creators edition** | Their original notices and separate [provenance record](Sources/PulseCanvas/Resources/ProjectM/Provenance.md); individual permissions remain unresolved. | | |
| 187 | + | **Bundled or imported music** | Separate from the application-code license; no blanket grant for soundtrack reuse or redistribution. Use material you have permission to use. | | |
| 188 | + | |
| 189 | + The **application**, **projectM engine**, **presets**, and **textures** have separate terms and provenance. Third-party licenses and notices, including required LGPL modification and relinking rights, remain intact. See [licensing](docs/licensing.md) and [engine sources and notices](third_party/PROJECTM.md). | |
| 190 | + | |
| 191 | + **Cream of the Crop pack curated by ISOSCELES** | |
| 192 | + | |
| 193 | + [https://www.patreon.com/posts/pack-nestdrop-91682111](https://www.patreon.com/posts/pack-nestdrop-91682111) | |
| 194 | + | |
| 195 | + The exact credit and link also appear in the app’s **Legal & Credits** window. The [preset and texture provenance record](Sources/PulseCanvas/Resources/ProjectM/Provenance.md) retains unchanged upstream README and LICENSE text, pinned commits, original filenames and creator metadata, and SHA-256 manifests for the actual **7,766 presets** and **67 texture images**. Individual preset and texture permissions remain unresolved; attribution alone does not settle them. | |
| 196 | + | |
| 197 | + [Official projectM licensing guidance](https://github.com/projectM-visualizer/projectm/wiki/projectM-Licensing#apple-store-compatibility) explicitly states incompatibility with Apple’s stores, including macOS, and recommends standalone distribution subject to LGPL terms. This remains an unresolved Apple-store blocker for a package containing that engine. The Metal Store package excludes it entirely. Dynamic linking, a wrapper license, and a matching source archive do not resolve the warning for the full-library package. Existing engine-source and rebuild-compliance work is preserved; the full status is in [rights and release blockers](docs/app-store/RIGHTS-RESOLUTION.md). | |
| 198 | + | |
| 199 | + ## Vision Pro development | |
| 200 | + | |
| 201 | + A native visionOS prototype now pairs an editable Studio timeline with a curved | |
| 202 | + immersive screen, sharing the 336 native Metal effects and audio analysis. | |
| 203 | + See [Vision Pro setup and current limits](docs/VISION_PRO.md). This is an early | |
| 204 | + TestFlight target; no production Vision Pro App Store release has been submitted. | |
| 205 | + | |
| 206 | + The latest [community-library audit](docs/LIBRARY_REFRESH.md) accounts for every | |
| 207 | + upstream preset and preserves all completed owner reviews. Collection, category | |
| 208 | + and folder filters live in Library; the top preset strip stays flat. | |
| 209 | + | |
| 210 | + --- | |
| 211 | + | |
| 212 | + <p align="center"> | |
| 213 | + <a href="https://projectatom.ai/"><img src="docs/readme/atom-credit.png" width="92" height="40" alt="Project ATOM"></a> | |
| 214 | + </p> | |
| 215 | + | |
| 216 | + <p align="center"><strong>A <a href="https://projectatom.ai/">Project ATOM</a> project.</strong> Free apps, open source and public domain (Unlicense).</p> | |
| 217 | + | |
| 218 | + <p align="center"> | |
| 219 | + <a href="https://opentalon.ai">OpenTalon</a> · | |
| 220 | + <a href="https://inkspring.ai">Inkspring</a> · | |
| 221 | + <a href="https://jotley.ai">Jotley</a> · | |
| 222 | + <a href="https://glimmertoday.com">Glimmer</a> · | |
| 223 | + <a href="https://pulsecanvas.ai">PulseCanvas</a> · | |
| 224 | + <a href="https://voxley.si">Voxley</a> · | |
| 225 | + <a href="https://textley.ai">Textley</a> · | |
| 226 | + <a href="https://graphley.ai">Graphley</a> · | |
| 227 | + <a href="https://bucksley.ai">Bucksley</a> | |
| 228 | + </p> | |
| 229 | + | |
| 230 | + <p align="center"><a href="https://projectatom.ai/apps">All our apps</a> · <a href="https://projectatom.ai/">Project ATOM</a></p> |
Sources/PulseCanvas/AudioAnalysis.swift added
| 1 | + import Accelerate | |
| 2 | + import AVFoundation | |
| 3 | + import Foundation | |
| 4 | + import simd | |
| 5 | + | |
| 6 | + struct SongSegmentation { | |
| 7 | + let boundaries: [Double] | |
| 8 | + let bpm: Double? | |
| 9 | + } | |
| 10 | + | |
| 11 | + struct AudioFeatures { | |
| 12 | + var bands: [Float] | |
| 13 | + var pulse: Float | |
| 14 | + var momentum: Float = 0 | |
| 15 | + var beatMotionTime: Double = 0 | |
| 16 | + var treblePulse: Float = 0 | |
| 17 | + var trebleAttackTime: Double? = nil | |
| 18 | + /// Smoothed low, low-mid, high-mid and high levels, normalized per song (0...1). | |
| 19 | + var envelopes = SIMD4<Float>(repeating: 0) | |
| 20 | + /// Attack envelope with a short rise and ~0.25 s fall, for fluid element motion. | |
| 21 | + var swell: Float = 0 | |
| 22 | + static let silence = AudioFeatures(bands: [Float](repeating: 0, count: 32), pulse: 0) | |
| 23 | + } | |
| 24 | + | |
| 25 | + /// Source PCM is sampled at the playhead, before preview volume. Both preview | |
| 26 | + /// and export use this bounded, stateless window, including on backwards seeks. | |
| 27 | + final class SoundtrackAnalyzer { | |
| 28 | + private let file: AVAudioFile | |
| 29 | + private let length = 2048 | |
| 30 | + private let setup: FFTSetup | |
| 31 | + private let window: [Float] | |
| 32 | + private let rhythm: RhythmTimeline | |
| 33 | + private var segmentationPlans: [Int: SongSegmentation] = [:] | |
| 34 | + var sampleRate: Double { file.processingFormat.sampleRate } | |
| 35 | + var duration: Double { Double(file.length) / sampleRate } | |
| 36 | + | |
| 37 | + init(url: URL) throws { | |
| 38 | + file = try AVAudioFile(forReading: url, commonFormat: .pcmFormatFloat32, interleaved: false) | |
| 39 | + guard file.length > 0, file.processingFormat.sampleRate > 80, | |
| 40 | + let setup = vDSP_create_fftsetup(11, FFTRadix(kFFTRadix2)) else { | |
| 41 | + throw AudioAnalysisError(String(localized: "Soundtrack contains no readable PCM samples")) | |
| 42 | + } | |
| 43 | + self.setup = setup | |
| 44 | + var values = [Float](repeating: 0, count: length) | |
| 45 | + vDSP_hann_window(&values, vDSP_Length(length), Int32(vDSP_HANN_NORM)) | |
| 46 | + window = values | |
| 47 | + rhythm = try RhythmTimeline(file: file) | |
| 48 | + } | |
| 49 | + deinit { vDSP_destroy_fftsetup(setup) } | |
| 50 | + | |
| 51 | + /// Stereo PCM at 44.1 kHz, the sample rate expected by Milkdrop presets. | |
| 52 | + /// It is read before preview volume and used by preview and offline export. | |
| 53 | + func pcm(at time: Double, count: Int = 1024) throws -> [Float] { | |
| 54 | + guard time.isFinite, time >= 0 else { return [] } | |
| 55 | + let windowStart = (time - Double(count) / 44100) * sampleRate | |
| 56 | + let first = max(0, Int(floor(windowStart))) | |
| 57 | + let required = Int(ceil(Double(count) * sampleRate / 44100)) + 2 | |
| 58 | + let available = min(required, Int(file.length) - first) | |
| 59 | + guard available > 0, let buffer = AVAudioPCMBuffer(pcmFormat: file.processingFormat, frameCapacity: AVAudioFrameCount(available)) else { return [] } | |
| 60 | + file.framePosition = AVAudioFramePosition(first); try file.read(into: buffer) | |
| 61 | + guard let channels = buffer.floatChannelData else { return [] } | |
| 62 | + var result = [Float](repeating: 0, count: count * 2) | |
| 63 | + for index in 0..<count { | |
| 64 | + let position = windowStart + Double(index) * sampleRate / 44100 - Double(first) | |
| 65 | + guard position >= 0 else {continue} | |
| 66 | + let lower = Int(position), upper = lower + 1, fraction = Float(position - Double(lower)) | |
| 67 | + guard lower >= 0, upper < Int(buffer.frameLength) else {continue} | |
| 68 | + for channel in 0..<2 { | |
| 69 | + let samples = channels[min(channel, Int(buffer.format.channelCount) - 1)] | |
| 70 | + result[index * 2 + channel] = samples[lower] * (1 - fraction) + samples[upper] * fraction | |
| 71 | + } | |
| 72 | + } | |
| 73 | + return result | |
| 74 | + } | |
| 75 | + | |
| 76 | + func segmentPlan(beatsPerSection: Int = 16) -> SongSegmentation { | |
| 77 | + let beats = max(1, beatsPerSection) | |
| 78 | + if let cached = segmentationPlans[beats] { return cached } | |
| 79 | + let plan = rhythm.segmentPlan(duration: Double(file.length) / sampleRate, beatsPerSection: beats) | |
| 80 | + segmentationPlans[beats] = plan | |
| 81 | + return plan | |
| 82 | + } | |
| 83 | + | |
| 84 | + func frame(at time: Double, clipStart: Double, clipEnd: Double, frameInterval: Double = 1.0 / 60) throws -> AudioFeatures { | |
| 85 | + guard time.isFinite, clipStart.isFinite, clipEnd.isFinite, time >= 0 else { return .silence } | |
| 86 | + let center = Int((time * sampleRate).rounded()) | |
| 87 | + let fftStart = center - length / 2 | |
| 88 | + let first = max(0, fftStart) | |
| 89 | + let last = min(Int(file.length), center + length / 2) | |
| 90 | + guard last > first, | |
| 91 | + let buffer = AVAudioPCMBuffer(pcmFormat: file.processingFormat, frameCapacity: AVAudioFrameCount(last - first)) else { return .silence } | |
| 92 | + file.framePosition = AVAudioFramePosition(first) | |
| 93 | + try file.read(into: buffer) | |
| 94 | + guard let channels = buffer.floatChannelData else { throw AudioAnalysisError(String(localized: "Cannot read soundtrack PCM")) } | |
| 95 | + let channelCount = Int(buffer.format.channelCount) | |
| 96 | + let frameCount = Int(buffer.frameLength) | |
| 97 | + var power = [Float](repeating: 0, count: length / 2) | |
| 98 | + for channel in 0..<channelCount { | |
| 99 | + var samples = [Float](repeating: 0, count: length) | |
| 100 | + for i in 0..<length { | |
| 101 | + let source = fftStart + i, offset = source - first | |
| 102 | + if offset >= 0 && offset < frameCount && source >= Int(clipStart * sampleRate) && source < Int(clipEnd * sampleRate) { | |
| 103 | + samples[i] = channels[channel][offset] * window[i] | |
| 104 | + } | |
| 105 | + } | |
| 106 | + var real = [Float](repeating: 0, count: length / 2) | |
| 107 | + var imaginary = real, channelPower = real | |
| 108 | + real.withUnsafeMutableBufferPointer { re in | |
| 109 | + imaginary.withUnsafeMutableBufferPointer { im in | |
| 110 | + var split = DSPSplitComplex(realp: re.baseAddress!, imagp: im.baseAddress!) | |
| 111 | + samples.withUnsafeBufferPointer { input in | |
| 112 | + input.baseAddress!.withMemoryRebound(to: DSPComplex.self, capacity: length / 2) { | |
| 113 | + vDSP_ctoz($0, 2, &split, 1, vDSP_Length(length / 2)) | |
| 114 | + } | |
| 115 | + } | |
| 116 | + vDSP_fft_zrip(setup, &split, 1, 11, FFTDirection(FFT_FORWARD)) | |
| 117 | + split.imagp[0] = 0 | |
| 118 | + vDSP_zvmags(&split, 1, &channelPower, 1, vDSP_Length(length / 2)) | |
| 119 | + } | |
| 120 | + } | |
| 121 | + for bin in power.indices { power[bin] += channelPower[bin] / Float(channelCount) } | |
| 122 | + } | |
| 123 | + let maximum = min(16_000, sampleRate / 2) | |
| 124 | + var bands = [Float](repeating: 0, count: 32) | |
| 125 | + for band in bands.indices { | |
| 126 | + let lower = 40 * pow(maximum / 40, Double(band) / 32) | |
| 127 | + let upper = 40 * pow(maximum / 40, Double(band + 1) / 32) | |
| 128 | + let firstBin = min(length / 2 - 1, max(1, Int(lower * Double(length) / sampleRate))) | |
| 129 | + let lastBin = min(length / 2 - 1, max(firstBin, Int(upper * Double(length) / sampleRate))) | |
| 130 | + let amplitude = sqrt(power[firstBin...lastBin].max() ?? 0) / Float(length) | |
| 131 | + // Keep musical dynamics; the old -70...0 dB mapping flattened loud music. | |
| 132 | + bands[band] = min(1, pow(max(0, amplitude - 0.0005) * 5, 0.6)) | |
| 133 | + } | |
| 134 | + let reaction = rhythm.at(time, frameInterval: frameInterval) | |
| 135 | + let (envelopes, swell) = rhythm.envelopes(at: time) | |
| 136 | + return AudioFeatures(bands: bands, pulse: reaction.pulse, momentum: reaction.momentum, beatMotionTime: reaction.beatMotionTime, treblePulse: reaction.treblePulse, trebleAttackTime: reaction.trebleAttackTime, envelopes: envelopes, swell: swell) | |
| 137 | + } | |
| 138 | + | |
| 139 | + } | |
| 140 | + | |
| 141 | + struct AudioAnalysisError: LocalizedError { | |
| 142 | + let message: String | |
| 143 | + init(_ message: String) { self.message = message } | |
| 144 | + var errorDescription: String? { message } | |
| 145 | + } | |
| 146 | + | |
| 147 | + /// Detect actual attacks once from continuous PCM, then read them on the source timeline. | |
| 148 | + /// No running tempo, frame-history dependency, or resetting filter at each preview frame. | |
| 149 | + private struct RhythmTimeline { | |
| 150 | + struct Attack { let time: Double; let strength: Float } | |
| 151 | + let attacks: [Attack] | |
| 152 | + let trebleAttacks: [Attack] | |
| 153 | + let hopSeconds: Double | |
| 154 | + let momentum: [Float] | |
| 155 | + let motionTimes: [Double] | |
| 156 | + /// Per-hop smoothed band levels and attack swell, computed once so every frame is a | |
| 157 | + /// pure function of soundtrack time (identical in preview, Studio and export). | |
| 158 | + let bandEnvelopes: [SIMD4<Float>] | |
| 159 | + let swells: [Float] | |
| 160 | + | |
| 161 | + init(file: AVAudioFile) throws { | |
| 162 | + let rate = file.processingFormat.sampleRate | |
| 163 | + let hop = max(1, Int((rate * 0.01).rounded())) | |
| 164 | + hopSeconds = Double(hop) / rate | |
| 165 | + let channelCount = Int(file.processingFormat.channelCount) | |
| 166 | + let capacity = AVAudioFrameCount(hop * 100) | |
| 167 | + guard let buffer = AVAudioPCMBuffer(pcmFormat: file.processingFormat, frameCapacity: capacity) else { | |
| 168 | + throw AudioAnalysisError(String(localized: "Cannot allocate rhythm analysis buffer")) | |
| 169 | + } | |
| 170 | + var bass = [Float](), body = [Float](), treble = [Float]() | |
| 171 | + var bandEnergy = [SIMD4<Float>]() | |
| 172 | + // Crossovers match the renderer's 32-band groups: 123, 552 and 2960 Hz. | |
| 173 | + let crossovers = SIMD3<Float>(Float(1 - exp(-2 * Double.pi * 123 / rate)), Float(1 - exp(-2 * Double.pi * 552 / rate)), Float(1 - exp(-2 * Double.pi * 2960 / rate))) | |
| 174 | + var splitA = [SIMD3<Float>](repeating: .zero, count: channelCount), splitB = splitA | |
| 175 | + var lower = [Float](repeating: 0, count: channelCount), lower2 = lower, upper = lower | |
| 176 | + var high2 = lower, high3 = lower, high4 = lower | |
| 177 | + let lowCoefficient = Float(1 - exp(-2 * Double.pi * 180 / rate)) | |
| 178 | + let highCoefficient = Float(1 - exp(-2 * Double.pi * 1800 / rate)) | |
| 179 | + file.framePosition = 0 | |
| 180 | + while file.framePosition < file.length { | |
| 181 | + try Task.checkCancellation() | |
| 182 | + try file.read(into: buffer, frameCount: capacity) | |
| 183 | + guard let samples = buffer.floatChannelData, buffer.frameLength > 0 else { break } | |
| 184 | + let count = Int(buffer.frameLength) | |
| 185 | + for first in stride(from: 0, to: count, by: hop) { | |
| 186 | + let last = min(count, first + hop) | |
| 187 | + var lo: Float = 0, mid: Float = 0, hi: Float = 0 | |
| 188 | + var split = SIMD4<Float>(repeating: 0) | |
| 189 | + for channel in 0..<channelCount { | |
| 190 | + for index in first..<last { | |
| 191 | + let sample = samples[channel][index] | |
| 192 | + splitA[channel] += crossovers * (SIMD3(repeating: sample) - splitA[channel]) | |
| 193 | + splitB[channel] += crossovers * (splitA[channel] - splitB[channel]) | |
| 194 | + let lows = splitB[channel] | |
| 195 | + let parts = SIMD4(lows.x, lows.y - lows.x, lows.z - lows.y, sample - lows.z) | |
| 196 | + split += parts * parts | |
| 197 | + lower[channel] += lowCoefficient * (sample - lower[channel]) | |
| 198 | + lower2[channel] += lowCoefficient * (lower[channel] - lower2[channel]) | |
| 199 | + upper[channel] += highCoefficient * (sample - upper[channel]) | |
| 200 | + let middle = upper[channel] - lower[channel] | |
| 201 | + // Four high-pass stages reject low-frequency leakage at a bass onset. | |
| 202 | + let high1 = sample - upper[channel] | |
| 203 | + high2[channel] += highCoefficient * (high1 - high2[channel]) | |
| 204 | + let highSecond = high1 - high2[channel] | |
| 205 | + high3[channel] += highCoefficient * (highSecond - high3[channel]) | |
| 206 | + let highThird = highSecond - high3[channel] | |
| 207 | + high4[channel] += highCoefficient * (highThird - high4[channel]) | |
| 208 | + let high = highThird - high4[channel] | |
| 209 | + lo += lower2[channel] * lower2[channel]; mid += middle * middle; hi += high * high | |
| 210 | + } | |
| 211 | + } | |
| 212 | + let divisor = Float((last - first) * channelCount) | |
| 213 | + bass.append(lo / divisor); body.append(mid / divisor); treble.append(hi / divisor) | |
| 214 | + bandEnergy.append(split / divisor) | |
| 215 | + } | |
| 216 | + } | |
| 217 | + var events = [Attack](), hats = [Attack](), drive = [Float](repeating: 0, count: bass.count) | |
| 218 | + var lastKick = -Double.infinity, lastSnare = lastKick, lastHat = lastKick | |
| 219 | + var baseline = SIMD3<Float>(repeating: 0), previous = baseline | |
| 220 | + var currentMomentum: Float = 0 | |
| 221 | + for tick in bass.indices { | |
| 222 | + let start = max(0, tick - 2), divisor = Float(tick - start + 1) | |
| 223 | + let envelope = SIMD3(sqrt(bass[start...tick].reduce(0,+) / divisor), | |
| 224 | + sqrt(body[start...tick].reduce(0,+) / divisor), | |
| 225 | + sqrt(treble[max(0,tick-1)...tick].reduce(0,+) / Float(min(tick+1,2)))) | |
| 226 | + let rise = Self.simdMaxZero(envelope - previous) | |
| 227 | + let timestamp = max(0, Double(tick + 1) * hopSeconds - 0.008) | |
| 228 | + let kick = rise.x > max(0.0012, baseline.x * 0.20) && envelope.x > baseline.x * 1.3 && timestamp - lastKick > 0.085 | |
| 229 | + let snare = rise.y > max(0.0025, baseline.y * 0.32) && envelope.y > baseline.y * 1.5 && | |
| 230 | + envelope.z > max(0.001, envelope.y * 0.08) && timestamp - lastSnare > 0.075 | |
| 231 | + let hat = rise.z > max(0.001, baseline.z * 0.4) && envelope.z > baseline.z * 1.5 && rise.z > rise.x * 0.10 && timestamp - lastHat > 0.035 | |
| 232 | + var strength: Float = 0 | |
| 233 | + if kick { strength = min(1, rise.x / max(0.003, baseline.x * 0.65)); lastKick = timestamp } | |
| 234 | + if snare { strength = max(strength, min(1, rise.y / max(0.005, baseline.y * 0.8))); lastSnare = timestamp } | |
| 235 | + if hat { | |
| 236 | + let hatStrength = min(1, rise.z / max(0.0015, baseline.z * 0.8)) | |
| 237 | + hats.append(Attack(time: timestamp, strength: hatStrength)) | |
| 238 | + strength = max(strength, hatStrength * 0.42); lastHat = timestamp | |
| 239 | + } | |
| 240 | + // A short silent lead-in has no synthetic pulse; only measured rises add drive. | |
| 241 | + if strength > 0.08 { events.append(Attack(time: timestamp, strength: strength)) } | |
| 242 | + currentMomentum = min(1, currentMomentum * Float(exp(-hopSeconds / 0.7)) + strength * 0.24) | |
| 243 | + drive[tick] = currentMomentum | |
| 244 | + baseline += (envelope - baseline) * Float(1 - exp(-hopSeconds / 0.22)) | |
| 245 | + previous = envelope | |
| 246 | + } | |
| 247 | + attacks = events; trebleAttacks = hats; momentum = drive | |
| 248 | + (bandEnvelopes, swells) = Self.smoothedLevels(energy: bandEnergy, attacks: events, hop: hopSeconds) | |
| 249 | + var accumulated = [0.0] | |
| 250 | + accumulated.reserveCapacity(drive.count + 1) | |
| 251 | + for value in drive { accumulated.append(accumulated.last! + Double(value) * hopSeconds) } | |
| 252 | + motionTimes = accumulated | |
| 253 | + } | |
| 254 | + | |
| 255 | + /// Normalizes each band against its own loud passages (95th percentile of non-silent | |
| 256 | + /// hops), so dynamics within a song are kept, then applies a rise/fall follower. | |
| 257 | + private static func smoothedLevels(energy: [SIMD4<Float>], attacks: [Attack], hop: Double) -> ([SIMD4<Float>], [Float]) { | |
| 258 | + guard !energy.isEmpty else { return ([], []) } | |
| 259 | + let amplitudes = energy.map { $0.replacing(with: 0, where: $0 .< 0).squareRoot() } | |
| 260 | + var reference = SIMD4<Float>(repeating: 1) | |
| 261 | + for band in 0..<4 { | |
| 262 | + let audible = amplitudes.map { $0[band] }.filter { $0 > 1e-4 }.sorted() | |
| 263 | + reference[band] = audible.isEmpty ? 1 : max(1e-4, audible[min(audible.count - 1, Int(Double(audible.count) * 0.95))]) | |
| 264 | + } | |
| 265 | + // Resolve short subdivisions without holding most of a beat. | |
| 266 | + let rise = Float(1 - exp(-hop / 0.018)), fall = Float(1 - exp(-hop / 0.095)) | |
| 267 | + var envelopes = [SIMD4<Float>](), level = SIMD4<Float>(repeating: 0) | |
| 268 | + envelopes.reserveCapacity(amplitudes.count) | |
| 269 | + for amplitude in amplitudes { | |
| 270 | + let target = simd_min(amplitude / reference, SIMD4<Float>(repeating: 1.15)) * 0.87 | |
| 271 | + for band in 0..<4 { level[band] += (target[band] - level[band]) * (target[band] > level[band] ? rise : fall) } | |
| 272 | + envelopes.append(level) | |
| 273 | + } | |
| 274 | + var raw = [Float](repeating: 0, count: energy.count) | |
| 275 | + for attack in attacks { | |
| 276 | + let first = max(0, Int(attack.time / hop)) | |
| 277 | + for tick in first..<min(raw.count, first + Int(0.35 / hop)) { | |
| 278 | + let age = max(0, Double(tick) * hop - attack.time) | |
| 279 | + raw[tick] = max(raw[tick], attack.strength * Float(exp(-age / 0.065))) | |
| 280 | + } | |
| 281 | + } | |
| 282 | + let attackRise = Float(1 - exp(-hop / 0.02)), attackFall = Float(1 - exp(-hop / 0.25)) | |
| 283 | + var swells = [Float](), swell: Float = 0 | |
| 284 | + swells.reserveCapacity(raw.count) | |
| 285 | + for value in raw { | |
| 286 | + swell += (value - swell) * (value > swell ? attackRise : attackFall) | |
| 287 | + swells.append(swell) | |
| 288 | + } | |
| 289 | + return (envelopes, swells) | |
| 290 | + } | |
| 291 | + | |
| 292 | + func envelopes(at time: Double) -> (SIMD4<Float>, Float) { | |
| 293 | + guard !bandEnvelopes.isEmpty, time.isFinite, time >= 0 else { return (SIMD4<Float>(repeating: 0), 0) } | |
| 294 | + let position = min(Double(bandEnvelopes.count - 1), time / hopSeconds) | |
| 295 | + let tick = Int(position), next = min(bandEnvelopes.count - 1, tick + 1) | |
| 296 | + let fraction = Float(position - Double(tick)) | |
| 297 | + let envelope = bandEnvelopes[tick] + (bandEnvelopes[next] - bandEnvelopes[tick]) * fraction | |
| 298 | + return (envelope, swells[tick] + (swells[next] - swells[tick]) * fraction) | |
| 299 | + } | |
| 300 | + | |
| 301 | + func at(_ time: Double, frameInterval: Double) -> (pulse: Float, momentum: Float, beatMotionTime: Double, treblePulse: Float, trebleAttackTime: Double?) { | |
| 302 | + // Binary search keeps lookup cheap even for long soundtracks. | |
| 303 | + var low = 0, high = attacks.count | |
| 304 | + while low < high { let mid = (low + high) / 2; if attacks[mid].time <= time { low = mid + 1 } else { high = mid } } | |
| 305 | + var pulse: Float = 0, index = low - 1 | |
| 306 | + while index >= 0 { | |
| 307 | + let attack = attacks[index], age = time - attack.time | |
| 308 | + if age > 0.32 { break } | |
| 309 | + pulse = max(pulse, attack.strength * Float(exp(-age / 0.065))) | |
| 310 | + index -= 1 | |
| 311 | + } | |
| 312 | + let tick = max(0, min(momentum.count - 1, Int(time / hopSeconds))) | |
| 313 | + var hatLow = 0, hatHigh = trebleAttacks.count | |
| 314 | + while hatLow < hatHigh { let mid = (hatLow + hatHigh) / 2; if trebleAttacks[mid].time <= time { hatLow = mid + 1 } else { hatHigh = mid } } | |
| 315 | + var treble: Float = 0, hatIndex = hatLow - 1 | |
| 316 | + let duration = max(0.025, min(0.1, frameInterval.isFinite ? frameInterval : 1.0 / 60)) | |
| 317 | + while hatIndex >= 0 && time - trebleAttacks[hatIndex].time < duration { | |
| 318 | + treble = max(treble, trebleAttacks[hatIndex].strength); hatIndex -= 1 | |
| 319 | + } | |
| 320 | + let lastHat = hatLow - 1 | |
| 321 | + let attackTime = lastHat >= 0 ? trebleAttacks[lastHat].time : nil | |
| 322 | + if let attackTime, time - attackTime < 0.1 { treble = trebleAttacks[lastHat].strength } | |
| 323 | + let position = min(Double(momentum.count), max(0, time / hopSeconds)) | |
| 324 | + let motion = momentum.isEmpty ? 0 : motionTimes[tick] + Double(momentum[tick]) * hopSeconds * (position - Double(tick)) | |
| 325 | + return (pulse, momentum.isEmpty ? 0 : momentum[tick], motion, treble, attackTime) | |
| 326 | + } | |
| 327 | + func segmentPlan(duration: Double, beatsPerSection: Int) -> SongSegmentation { | |
| 328 | + let strong = attacks.filter { $0.strength >= 0.55 } | |
| 329 | + var period = 0.5, detectedBPM: Double? = nil, phase = 0.0 | |
| 330 | + if strong.count >= 4 && duration >= 2 { | |
| 331 | + var impulses = [Float](repeating: 0, count: momentum.count) | |
| 332 | + for attack in strong { | |
| 333 | + let index = min(impulses.count - 1, Int(attack.time / hopSeconds)) | |
| 334 | + if index >= 0 { impulses[index] = max(impulses[index], attack.strength) } | |
| 335 | + } | |
| 336 | + var bestScore: Float = 0 | |
| 337 | + for lag in Int(0.3 / hopSeconds)...Int(1.0 / hopSeconds) where lag < impulses.count { | |
| 338 | + var score: Float = 0 | |
| 339 | + for i in lag..<impulses.count where impulses[i] > 0 { | |
| 340 | + let lo = max(0, i - lag - 2), hi = min(impulses.count - 1, i - lag + 2) | |
| 341 | + score += impulses[i] * (impulses[lo...hi].max() ?? 0) | |
| 342 | + } | |
| 343 | + let candidate = Double(lag) * hopSeconds | |
| 344 | + score *= Float(exp(-pow(log(candidate / 0.5), 2) / 0.5)) | |
| 345 | + if score > bestScore { bestScore = score; period = candidate } | |
| 346 | + } | |
| 347 | + if bestScore > 1 { | |
| 348 | + detectedBPM = 60 / period | |
| 349 | + var phases = [Float](repeating: 0, count: 64) | |
| 350 | + for attack in strong { | |
| 351 | + let fraction = attack.time / period - floor(attack.time / period) | |
| 352 | + let bin = Int(fraction * 64) % 64 | |
| 353 | + for offset in -2...2 { phases[(bin + offset + 64) % 64] += attack.strength * Float(3 - abs(offset)) } | |
| 354 | + } | |
| 355 | + phase = Double(phases.indices.max(by: { phases[$0] < phases[$1] }) ?? 0) / 64 * period | |
| 356 | + } | |
| 357 | + } | |
| 358 | + let spacing = period * Double(max(1, beatsPerSection)) | |
| 359 | + var points = [0.0], target = phase + spacing | |
| 360 | + while target < duration - 0.5 { | |
| 361 | + let nearby = strong.filter { abs($0.time - target) < period * 0.18 } | |
| 362 | + let cue = nearby.min(by: { abs($0.time-target) < abs($1.time-target) })?.time ?? target | |
| 363 | + if cue > points.last! + 0.5 { points.append(cue) } | |
| 364 | + target += spacing | |
| 365 | + } | |
| 366 | + points.append(duration) | |
| 367 | + return SongSegmentation(boundaries: points, bpm: detectedBPM) | |
| 368 | + } | |
| 369 | + private static func simdMaxZero(_ value: SIMD3<Float>) -> SIMD3<Float> { | |
| 370 | + SIMD3(max(0,value.x),max(0,value.y),max(0,value.z)) | |
| 371 | + } | |
| 372 | + } |
Sources/PulseCanvas/CloudSyncService.swift added
| 1 | + import Combine | |
| 2 | + import Foundation | |
| 3 | + | |
| 4 | + @MainActor final class CloudSyncService: ObservableObject { | |
| 5 | + static let shared = CloudSyncService() | |
| 6 | + nonisolated static let containerID = "iCloud.com.protomota.pulsecanvas" | |
| 7 | + static let enabledKey = "PulseCanvas.iCloud.enabled.v1" | |
| 8 | + @Published private(set) var enabled: Bool | |
| 9 | + @Published private(set) var busy = false | |
| 10 | + @Published private(set) var status = String(localized: "iCloud sync is off. Your data stays on this device.") | |
| 11 | + @Published private(set) var projects: [CloudSyncChange] = [] | |
| 12 | + @Published private(set) var lastSync: Date? | |
| 13 | + private struct DiskState: Codable { | |
| 14 | + var ledger = CloudSyncLedger() | |
| 15 | + var account: String? | |
| 16 | + var projectHashes: [String: String] = [:] | |
| 17 | + var projectBases: [String: String] = [:] | |
| 18 | + var needsApplication = false | |
| 19 | + } | |
| 20 | + private var state = DiskState() | |
| 21 | + private var root: URL? | |
| 22 | + private var query: NSMetadataQuery? | |
| 23 | + private var observers: [NSObjectProtocol] = [] | |
| 24 | + private var queryObservers: [NSObjectProtocol] = [] | |
| 25 | + private var localTask: Task<Void, Never>? | |
| 26 | + private var periodic: Task<Void, Never>? | |
| 27 | + private var started = false | |
| 28 | + private var applying = false | |
| 29 | + private var generation = UUID() | |
| 30 | + private var again = false | |
| 31 | + private var confirmedAccountMerge = false | |
| 32 | + private var connecting = false | |
| 33 | + private var projectFailures: [String] = [] | |
| 34 | + private var invalidHistory = false | |
| 35 | + private let defaults: UserDefaults | |
| 36 | + private let support: URL | |
| 37 | + private var stateURL: URL { support.appendingPathComponent("CloudSync/state.json") } | |
| 38 | + private var workRoot: URL { support.appendingPathComponent("CloudSync/Work", isDirectory: true) } | |
| 39 | + private var changesFolder: URL? { root?.appendingPathComponent("PulseCanvasData/Changes", isDirectory: true) } | |
| 40 | + private var assetsFolder: URL? { root?.appendingPathComponent("Documents/Projects", isDirectory: true) } | |
| 41 | + private var audioFolder: URL? { root?.appendingPathComponent("Documents/Audio", isDirectory: true) } | |
| 42 | + | |
| 43 | + init(defaults: UserDefaults = .standard, support: URL? = nil) { | |
| 44 | + self.defaults = defaults | |
| 45 | + self.support = support ?? UserDataStorage.support | |
| 46 | + enabled = defaults.bool(forKey: Self.enabledKey) | |
| 47 | + if FileManager.default.fileExists(atPath: stateURL.path) { | |
| 48 | + do { | |
| 49 | + let saved = try JSONDecoder().decode(DiskState.self, from: Data(contentsOf: stateURL)) | |
| 50 | + _ = try CloudSyncLedger.read(CloudSyncLedger.encoded(saved.ledger)) | |
| 51 | + try saved.ledger.events.values.forEach(CloudSyncAppData.validate) | |
| 52 | + state = saved | |
| 53 | + } catch { | |
| 54 | + invalidHistory = true | |
| 55 | + enabled = false | |
| 56 | + defaults.set(false, forKey: Self.enabledKey) | |
| 57 | + status = String(localized: "iCloud sync history couldn't be read. Sync is off; local data and the original history were kept.") | |
| 58 | + } | |
| 59 | + } | |
| 60 | + } | |
| 61 | + func start() { | |
| 62 | + guard !started else { return }; started = true | |
| 63 | + observers.append(NotificationCenter.default.addObserver(forName: .pulseCanvasUserDataChanged, object: nil, queue: .main) { [weak self] _ in | |
| 64 | + Task { @MainActor in self?.localChanged() } | |
| 65 | + }) | |
| 66 | + observers.append(NotificationCenter.default.addObserver(forName: .NSUbiquityIdentityDidChange, object: nil, queue: .main) { [weak self] _ in | |
| 67 | + Task { @MainActor in | |
| 68 | + self?.setEnabled(false) | |
| 69 | + self?.status = String(localized: "Your Apple Account changed. Local data was kept. Confirm iCloud sync again to use the current account.") | |
| 70 | + } | |
| 71 | + }) | |
| 72 | + if enabled { connect() } | |
| 73 | + } | |
| 74 | + func setEnabled(_ value: Bool) { | |
| 75 | + guard !value || !invalidHistory else { | |
| 76 | + status = String(localized: "Sync history needs recovery before enabling iCloud. Local files and the unreadable history are preserved.") | |
| 77 | + return | |
| 78 | + } | |
| 79 | + confirmedAccountMerge = value | |
| 80 | + enabled = value; defaults.set(value, forKey: Self.enabledKey) | |
| 81 | + generation = UUID(); localTask?.cancel(); periodic?.cancel(); query?.stop(); query = nil; root = nil | |
| 82 | + queryObservers.forEach { NotificationCenter.default.removeObserver($0) }; queryObservers = [] | |
| 83 | + connecting = false | |
| 84 | + if value { start(); connect() } | |
| 85 | + else { status = String(localized: "iCloud sync is off. Local files and existing iCloud copies are kept."); projects = [] } | |
| 86 | + } | |
| 87 | + private func connect() { | |
| 88 | + guard enabled, root == nil, !connecting else { return } | |
| 89 | + connecting = true | |
| 90 | + status = String(localized: "Connecting to iCloud Drive…") | |
| 91 | + let ticket = generation | |
| 92 | + Task { | |
| 93 | + defer { if generation == ticket { connecting = false } } | |
| 94 | + let result = await Task.detached { () -> (URL?, Data?) in | |
| 95 | + let token = FileManager.default.ubiquityIdentityToken | |
| 96 | + let identity = token.flatMap { try? NSKeyedArchiver.archivedData(withRootObject: $0, requiringSecureCoding: true) } | |
| 97 | + return (FileManager.default.url(forUbiquityContainerIdentifier: Self.containerID), identity) | |
| 98 | + }.value | |
| 99 | + guard enabled, generation == ticket else { return } | |
| 100 | + guard let url = result.0, let identity = result.1 else { | |
| 101 | + status = String(localized: "iCloud Drive is unavailable. Sign in to iCloud and use an iCloud-enabled signed build. Your local data is safe.") | |
| 102 | + return | |
| 103 | + } | |
| 104 | + let account = CloudSyncLedger.digest(identity) | |
| 105 | + if state.account != account { | |
| 106 | + if state.account != nil && !confirmedAccountMerge { | |
| 107 | + setEnabled(false) | |
| 108 | + status = String(localized: "Your Apple Account changed. Confirm iCloud sync again before merging local data with this account.") | |
| 109 | + return | |
| 110 | + } | |
| 111 | + // Never upload the previous account's event history into a new one. | |
| 112 | + // Enabling the toggle explicitly confirms merging current local choices. | |
| 113 | + if state.account != nil { | |
| 114 | + let archive = stateURL.deletingLastPathComponent().appendingPathComponent("PreviousAccount-" + UUID().uuidString + ".json") | |
| 115 | + do { try CloudSyncLedger.encoded(state).write(to: archive, options: .atomic) } | |
| 116 | + catch { status = String(localized: "Couldn't preserve the previous account's sync history. Local data was kept."); return } | |
| 117 | + } | |
| 118 | + state = DiskState(); state.account = account | |
| 119 | + } | |
| 120 | + confirmedAccountMerge = false | |
| 121 | + root = url | |
| 122 | + do { | |
| 123 | + try FileManager.default.createDirectory(at: changesFolder!, withIntermediateDirectories: true) | |
| 124 | + try FileManager.default.createDirectory(at: assetsFolder!, withIntermediateDirectories: true) | |
| 125 | + try FileManager.default.createDirectory(at: audioFolder!, withIntermediateDirectories: true) | |
| 126 | + try save() | |
| 127 | + try watch() | |
| 128 | + startPeriodicChecks() | |
| 129 | + } catch { root = nil; query?.stop(); query = nil; status = String(localized: "Couldn't prepare iCloud sync: \(error.localizedDescription)") } | |
| 130 | + } | |
| 131 | + } | |
| 132 | + private func startPeriodicChecks() { | |
| 133 | + periodic?.cancel() | |
| 134 | + periodic = Task { [weak self] in | |
| 135 | + while !Task.isCancelled { | |
| 136 | + self?.syncNow() | |
| 137 | + do { try await Task.sleep(for: .seconds(30)) } catch { return } | |
| 138 | + } | |
| 139 | + } | |
| 140 | + } | |
| 141 | + private func watch() throws { | |
| 142 | + guard let changesFolder, let assetsFolder else { return } | |
| 143 | + let query = NSMetadataQuery() | |
| 144 | + query.searchScopes = [NSMetadataQueryUbiquitousDataScope, NSMetadataQueryUbiquitousDocumentsScope] | |
| 145 | + query.predicate = NSPredicate(format: "%K BEGINSWITH %@ OR %K BEGINSWITH %@", NSMetadataItemPathKey, | |
| 146 | + changesFolder.path + "/", NSMetadataItemPathKey, assetsFolder.path + "/") | |
| 147 | + for name in [Notification.Name.NSMetadataQueryDidFinishGathering, .NSMetadataQueryDidUpdate] { | |
| 148 | + queryObservers.append(NotificationCenter.default.addObserver(forName: name, object: query, queue: .main) { [weak self] _ in | |
| 149 | + Task { @MainActor in self?.syncNow() } | |
| 150 | + }) | |
| 151 | + } | |
| 152 | + self.query = query | |
| 153 | + guard query.start() else { throw CocoaError(.fileReadUnknown) } | |
| 154 | + } | |
| 155 | + private func localChanged() { | |
| 156 | + guard !applying, enabled else { return } | |
| 157 | + localTask?.cancel() | |
| 158 | + localTask = Task { [weak self] in | |
| 159 | + do { try await Task.sleep(for: .seconds(2)) } catch { return } | |
| 160 | + self?.syncNow() | |
| 161 | + } | |
| 162 | + } | |
| 163 | + private func save() throws { | |
| 164 | + try FileManager.default.createDirectory(at: stateURL.deletingLastPathComponent(), withIntermediateDirectories: true) | |
| 165 | + try CloudSyncLedger.encoded(state).write(to: stateURL, options: .atomic) | |
| 166 | + } | |
| 167 | + private func observeLocal() throws { | |
| 168 | + let snapshot = try CloudSyncAppData.snapshot(defaults: defaults) | |
| 169 | + var scope = snapshot.scope | |
| 170 | + for identity in state.ledger.baseline.keys where identity.hasPrefix("songFavorite:") { | |
| 171 | + if let event = state.ledger.heads[identity], let change = state.ledger.events[event], CloudSyncAppData.canDeleteSong(change) { | |
| 172 | + scope.insert(identity) | |
| 173 | + } | |
| 174 | + } | |
| 175 | + try state.ledger.observe(snapshot.values, scope: scope) | |
| 176 | + } | |
| 177 | + func syncNow() { | |
| 178 | + guard enabled else { return } | |
| 179 | + guard root != nil else { connect(); return } | |
| 180 | + if busy { again = true; return } | |
| 181 | + busy = true; status = String(localized: "Syncing with iCloud Drive…") | |
| 182 | + let ticket = generation | |
| 183 | + Task { | |
| 184 | + defer { | |
| 185 | + busy = false | |
| 186 | + if again { again = false; if enabled { syncNow() } } | |
| 187 | + } | |
| 188 | + do { | |
| 189 | + try observeLocal(); try save() | |
| 190 | + query?.disableUpdates() | |
| 191 | + let items = query?.results as? [NSMetadataItem] ?? [] | |
| 192 | + query?.enableUpdates() | |
| 193 | + let urls = items.compactMap { $0.value(forAttribute: NSMetadataItemURLKey) as? URL } | |
| 194 | + .filter { $0.deletingLastPathComponent().resolvingSymlinksInPath() == changesFolder?.resolvingSymlinksInPath() } | |
| 195 | + .filter { UUID(uuidString: $0.deletingPathExtension().lastPathComponent) != nil && state.ledger.events[$0.deletingPathExtension().lastPathComponent] == nil } | |
| 196 | + let incoming = try await Task.detached { | |
| 197 | + try urls.compactMap { url -> CloudSyncChange? in | |
| 198 | + guard try Self.downloaded(url) else { return nil } | |
| 199 | + let data = try Self.coordinatedRead(url) | |
| 200 | + guard data.count < 3_000_000 else { throw CocoaError(.fileReadCorruptFile) } | |
| 201 | + let change = try JSONDecoder().decode(CloudSyncChange.self, from: data) | |
| 202 | + guard change.event == url.deletingPathExtension().lastPathComponent else { throw CocoaError(.fileReadCorruptFile) } | |
| 203 | + return change | |
| 204 | + } | |
| 205 | + }.value | |
| 206 | + guard enabled, generation == ticket else { return } | |
| 207 | + try incoming.forEach(CloudSyncAppData.validate) | |
| 208 | + // Capture edits made while downloads were in flight before applying | |
| 209 | + // remote heads, so an async fetch cannot overwrite an unseen local edit. | |
| 210 | + try observeLocal() | |
| 211 | + let ready = state.ledger.readyChanges(incoming) | |
| 212 | + try state.ledger.merge(ready) | |
| 213 | + state.needsApplication = state.needsApplication || !ready.isEmpty | |
| 214 | + try save() // durable before changing the app's live choices | |
| 215 | + if state.needsApplication { | |
| 216 | + applying = true | |
| 217 | + defer { applying = false } | |
| 218 | + try CloudSyncAppData.apply(state.ledger.current.filter { $0.kind != .project }, defaults: defaults) | |
| 219 | + state.ledger.baseline = try CloudSyncAppData.snapshot(defaults: defaults).values | |
| 220 | + state.needsApplication = false | |
| 221 | + try save() | |
| 222 | + } | |
| 223 | + try await uploadProjects(ticket: ticket) | |
| 224 | + guard enabled, generation == ticket, let folder = changesFolder else { return } | |
| 225 | + let pending = state.ledger.pending.compactMap { state.ledger.events[$0] } | |
| 226 | + for change in pending { | |
| 227 | + guard enabled, generation == ticket else { return } | |
| 228 | + let data = try CloudSyncLedger.encoded(change) | |
| 229 | + let destination = folder.appendingPathComponent(change.event + ".json") | |
| 230 | + try await Task.detached { try Self.writeImmutable(data, to: destination) }.value | |
| 231 | + state.ledger.pending.remove(change.event) | |
| 232 | + } | |
| 233 | + // One checkpoint per batch. A crash replays immutable writes safely | |
| 234 | + // without rewriting the entire history for every favorite. | |
| 235 | + try save() | |
| 236 | + projects = state.ledger.current.filter { change in | |
| 237 | + guard change.kind == .project, !change.deleted, | |
| 238 | + let info = try? JSONDecoder().decode(CloudProjectInfo.self, from: change.payload) else { return false } | |
| 239 | + return info.isAvailableInEdition | |
| 240 | + }.sorted { $0.order > $1.order } | |
| 241 | + lastSync = Date() | |
| 242 | + status = projectFailures.isEmpty ? "Changes saved to iCloud Drive. Apple transfers them when a connection is available." | |
| 243 | + : "Other changes saved. \(projectFailures.count) project(s) need attention: \(projectFailures[0])" | |
| 244 | + if ready.count < incoming.count { status += " Waiting for earlier changes to finish downloading." } | |
| 245 | + } catch { | |
| 246 | + status = String(localized: "Sync needs attention: \(error.localizedDescription). Local data was kept; Sync now retries.") | |
| 247 | + } | |
| 248 | + } | |
| 249 | + } | |
| 250 | + | |
| 251 | + private func uploadProjects(ticket: UUID) async throws { | |
| 252 | + guard let folder = assetsFolder, let audioFolder else { return } | |
| 253 | + projectFailures = [] | |
| 254 | + for url in UserBackup.savedProjects() where url.deletingLastPathComponent().lastPathComponent == "Projects" { | |
| 255 | + guard enabled, generation == ticket else { return } | |
| 256 | + let work = workRoot.appendingPathComponent(UUID().uuidString) | |
| 257 | + defer { try? FileManager.default.removeItem(at: work) } | |
| 258 | + do { | |
| 259 | + guard (try url.resourceValues(forKeys: [.fileSizeKey]).fileSize ?? Int.max) < 8_000_000 else { throw CocoaError(.fileReadCorruptFile) } | |
| 260 | + let fingerprint = try Data(contentsOf: url) | |
| 261 | + let digest = try CloudProjectPackage.fingerprint(fingerprint) | |
| 262 | + if state.projectHashes[url.lastPathComponent] == digest { continue } | |
| 263 | + let key = try CloudProjectPackage.key(for: fingerprint, filename: url.lastPathComponent) | |
| 264 | + let result = try await Task.detached { | |
| 265 | + try CloudProjectPackage.make(fingerprint, filename: url.lastPathComponent, key: key, in: work) | |
| 266 | + }.value | |
| 267 | + guard enabled, generation == ticket else { return } | |
| 268 | + let destination = folder.appendingPathComponent(result.info.asset) | |
| 269 | + try await Task.detached { | |
| 270 | + if let audio = result.audio, let info = result.info.audio { | |
| 271 | + try Self.copyImmutable(audio, to: audioFolder.appendingPathComponent(info.asset)) | |
| 272 | + } | |
| 273 | + try Self.copyImmutable(result.project, to: destination) | |
| 274 | + }.value | |
| 275 | + guard enabled, generation == ticket else { return } | |
| 276 | + let revision = try state.ledger.editProject(key: key, payload: CloudSyncLedger.encoded(result.info), basedOn: state.projectBases[key]) | |
| 277 | + state.projectBases[key] = revision?.event ?? state.ledger.heads["project:" + key] | |
| 278 | + state.projectHashes[url.lastPathComponent] = digest; try save() | |
| 279 | + } catch { projectFailures.append("\(url.lastPathComponent): \(error.localizedDescription)") } | |
| 280 | + } | |
| 281 | + } | |
| 282 | + func openProject(_ change: CloudSyncChange) async throws -> Data { | |
| 283 | + guard enabled, let folder = assetsFolder else { throw CocoaError(.fileReadNoPermission) } | |
| 284 | + let info = try JSONDecoder().decode(CloudProjectInfo.self, from: change.payload).validated() | |
| 285 | + guard projects.contains(change), info.isAvailableInEdition else { throw CocoaError(.fileReadNoPermission) } | |
| 286 | + let source = folder.appendingPathComponent(info.asset) | |
| 287 | + let audio = info.audio.flatMap { audioFolder?.appendingPathComponent($0.asset) } | |
| 288 | + let destination = support.appendingPathComponent("CloudProjects/" + UUID().uuidString, isDirectory: true) | |
| 289 | + guard try Self.downloaded(source), try audio.map({ try Self.downloaded($0) }) ?? true else { | |
| 290 | + status = String(localized: "Downloading this project from iCloud. Try Open again when the download finishes.") | |
| 291 | + throw CocoaError(.fileReadUnknown) | |
| 292 | + } | |
| 293 | + let data = try await Task.detached { | |
| 294 | + try CloudProjectPackage.open(info, key: change.key, project: source, audio: audio, destination: destination) | |
| 295 | + }.value | |
| 296 | + try UserBackup.rememberProject(data, name: info.title + ".pulsecanvas") | |
| 297 | + state.projectBases[change.key] = change.event | |
| 298 | + try save() | |
| 299 | + return data | |
| 300 | + } | |
| 301 | + func removeProject(_ change: CloudSyncChange) { | |
| 302 | + guard enabled, projects.contains(change) else { return } | |
| 303 | + do { | |
| 304 | + _ = try state.ledger.edit(.project, key: change.key, payload: nil) | |
| 305 | + try save(); syncNow() | |
| 306 | + } catch { status = String(localized: "Couldn't remove the cloud project: \(error.localizedDescription)") } | |
| 307 | + } | |
| 308 | + | |
| 309 | + nonisolated static func downloaded(_ url: URL) throws -> Bool { | |
| 310 | + if !FileManager.default.fileExists(atPath: url.path) { | |
| 311 | + try? FileManager.default.startDownloadingUbiquitousItem(at: url) | |
| 312 | + return false | |
| 313 | + } | |
| 314 | + let values = try url.resourceValues(forKeys: [.isUbiquitousItemKey, .ubiquitousItemDownloadingStatusKey]) | |
| 315 | + if values.isUbiquitousItem == true && values.ubiquitousItemDownloadingStatus != .current && values.ubiquitousItemDownloadingStatus != .downloaded { | |
| 316 | + try FileManager.default.startDownloadingUbiquitousItem(at: url); return false | |
| 317 | + } | |
| 318 | + return true | |
| 319 | + } | |
| 320 | + nonisolated static func coordinatedRead(_ url: URL) throws -> Data { | |
| 321 | + var error: NSError?, result: Result<Data, Error>? | |
| 322 | + NSFileCoordinator().coordinate(readingItemAt: url, options: .withoutChanges, error: &error) { location in | |
| 323 | + result = Result { try Data(contentsOf: location) } | |
| 324 | + } | |
| 325 | + if let error { throw error } | |
| 326 | + guard let result else { throw CocoaError(.fileReadUnknown) } | |
| 327 | + return try result.get() | |
| 328 | + } | |
| 329 | + nonisolated static func writeImmutable(_ data: Data, to url: URL) throws { | |
| 330 | + var error: NSError?, failure: Error? | |
| 331 | + NSFileCoordinator().coordinate(writingItemAt: url, options: .forReplacing, error: &error) { location in | |
| 332 | + do { | |
| 333 | + if FileManager.default.fileExists(atPath: location.path) { | |
| 334 | + guard try Data(contentsOf: location) == data else { throw CocoaError(.fileWriteFileExists) } | |
| 335 | + } else { try data.write(to: location, options: .atomic) } | |
| 336 | + } catch { failure = error } | |
| 337 | + } | |
| 338 | + if let error { throw error }; if let failure { throw failure } | |
| 339 | + } | |
| 340 | + nonisolated static func copyImmutable(_ source: URL, to url: URL) throws { | |
| 341 | + var error: NSError?, failure: Error? | |
| 342 | + NSFileCoordinator().coordinate(writingItemAt: url, options: .forReplacing, error: &error) { location in | |
| 343 | + do { | |
| 344 | + if !FileManager.default.fileExists(atPath: location.path) { try FileManager.default.copyItem(at: source, to: location) } | |
| 345 | + guard try CloudProjectPackage.hashFile(location) == location.deletingPathExtension().lastPathComponent else { throw CocoaError(.fileReadCorruptFile) } | |
| 346 | + } catch { failure = error } | |
| 347 | + } | |
| 348 | + if let error { throw error }; if let failure { throw failure } | |
| 349 | + } | |
| 350 | + } |
Sources/PulseCanvas/NativeEffects.swift added
| 1 | + import Foundation | |
| 2 | + | |
| 3 | + /// One native visualizer. Its index in `NativeEffects.all` is its permanent scene ID: | |
| 4 | + /// saved projects, favorites and Studio timelines store `native:<index>`, so entries | |
| 5 | + /// are only ever appended. External presets follow the native catalog. | |
| 6 | + struct NativeEffect: Sendable { | |
| 7 | + /// Default appearance for a newly opened effect. Saved settings always win. | |
| 8 | + struct Look: Sendable { | |
| 9 | + var palette = 0 | |
| 10 | + var size: Float = 1 | |
| 11 | + var speed: Float = 1 | |
| 12 | + var zoomSpeed: Float = 1 | |
| 13 | + var brightness: Float = 1.15 | |
| 14 | + var fog: Float = 0.5 | |
| 15 | + var detail: Float = 0.6 | |
| 16 | + var chaos: Float = 0.6 | |
| 17 | + var zoom: Float = 1 | |
| 18 | + } | |
| 19 | + | |
| 20 | + let name: String | |
| 21 | + let icon: String | |
| 22 | + /// Fragment function `<shader>Fragment` in `file`; nil for the original mesh, point and spatial families. | |
| 23 | + let shader: String? | |
| 24 | + let file: String? | |
| 25 | + /// Label for the shared size control. | |
| 26 | + let sizeLabel: String | |
| 27 | + /// Label for the detail control, when the design uses it. | |
| 28 | + let detailLabel: String? | |
| 29 | + /// The design moves through its own space for Zoom speed, so no post-zoom pass is applied. | |
| 30 | + let travels: Bool | |
| 31 | + let look: Look | |
| 32 | + /// Set when a design has been withdrawn. Its ID stays reserved, and saved projects, | |
| 33 | + /// favorites and timelines that name it open this design instead. | |
| 34 | + var replacement: Int? = nil | |
| 35 | + | |
| 36 | + static func original(_ name: String, icon: String, size: String = "Particle size", detail: String? = nil, travels: Bool = false, look: Look) -> NativeEffect { | |
| 37 | + NativeEffect(name: name, icon: icon, shader: nil, file: nil, sizeLabel: size, detailLabel: detail, travels: travels, look: look) | |
| 38 | + } | |
| 39 | + | |
| 40 | + static func retired(_ name: String, icon: String, replacement: Int) -> NativeEffect { | |
| 41 | + NativeEffect(name: name, icon: icon, shader: nil, file: nil, sizeLabel: "Particle size", detailLabel: nil, travels: false, look: Look(), replacement: replacement) | |
| 42 | + } | |
| 43 | + | |
| 44 | + static func metal(_ name: String, icon: String, _ shader: String, in file: String, size: String, detail: String? = nil, travels: Bool = true, look: Look) -> NativeEffect { | |
| 45 | + NativeEffect(name: name, icon: icon, shader: shader, file: file, sizeLabel: size, detailLabel: detail, travels: travels, look: look) | |
| 46 | + } | |
| 47 | + } | |
| 48 | + | |
| 49 | + enum NativeEffects { | |
| 50 | + // Compatibility with retained development tools. | |
| 51 | + static var activeScenes: [Int] { activeIDs } | |
| 52 | + static var activeCount: Int { activeIDs.count } | |
| 53 | + /// Native effect sources, each compiled after NativeCommon.metal. | |
| 54 | + static let shaderFiles = ["NativeFlow.metal", "NativeStructure.metal", "NativeGeometry.metal", "NativeParticles.metal", "NativeNature.metal", | |
| 55 | + "NativeTunnels.metal", "NativeWormholes.metal", "NativeDrive.metal", "NativeDance.metal", "NativeRave.metal", "NativeExpansionDrive.metal", "NativeExpansionDance.metal", "NativeExpansionVoyage.metal", "NativeExpansionPassage.metal", "NativeExpansionFestival.metal", | |
| 56 | + "NativeExpansionBore.metal", "NativeExpansionPortal.metal", "NativeExpansionKinetic.metal", "NativeExpansionFlight.metal", "NativeExpansionMaterial.metal", "NativeExpansionCosmos.metal", | |
| 57 | + "NativeExpansionFractal.metal", "NativeExpansionFractalTunnel.metal", | |
| 58 | + "NativeExpansionPortalII.metal", "NativeExpansionFlightII.metal", "NativeExpansionMaterialII.metal", "NativeExpansionCosmosII.metal", | |
| 59 | + "NativeExpansionAtmospheric.metal"] | |
| 60 | + /// Projects saved before the catalog grew store external presets from this index. | |
| 61 | + static let legacyCount = 31 | |
| 62 | + | |
| 63 | + private static let flow = "NativeFlow.metal", structure = "NativeStructure.metal", geometry = "NativeGeometry.metal" | |
| 64 | + private static let particles = "NativeParticles.metal", nature = "NativeNature.metal" | |
| 65 | + private static let tunnels = "NativeTunnels.metal", wormholes = "NativeWormholes.metal", drive = "NativeDrive.metal" | |
| 66 | + private static let dance = "NativeDance.metal", rave = "NativeRave.metal" | |
| 67 | + private static let driveExpansion = "NativeExpansionDrive.metal" | |
| 68 | + private static let danceExpansion = "NativeExpansionDance.metal" | |
| 69 | + private static let voyageExpansion = "NativeExpansionVoyage.metal" | |
| 70 | + private static let passageExpansion = "NativeExpansionPassage.metal" | |
| 71 | + private static let festivalExpansion = "NativeExpansionFestival.metal" | |
| 72 | + private static let boreExpansion = "NativeExpansionBore.metal" | |
| 73 | + private static let portalExpansion = "NativeExpansionPortal.metal" | |
| 74 | + private static let kineticExpansion = "NativeExpansionKinetic.metal" | |
| 75 | + private static let flightExpansion = "NativeExpansionFlight.metal" | |
| 76 | + private static let materialExpansion = "NativeExpansionMaterial.metal" | |
| 77 | + private static let cosmosExpansion = "NativeExpansionCosmos.metal" | |
| 78 | + private static let fractalExpansion = "NativeExpansionFractal.metal" | |
| 79 | + private static let fractalTunnelExpansion = "NativeExpansionFractalTunnel.metal" | |
| 80 | + private static let portalIIExpansion = "NativeExpansionPortalII.metal" | |
| 81 | + private static let flightIIExpansion = "NativeExpansionFlightII.metal" | |
| 82 | + private static let materialIIExpansion = "NativeExpansionMaterialII.metal" | |
| 83 | + private static let cosmosIIExpansion = "NativeExpansionCosmosII.metal" | |
| 84 | + static let atmospheric = "NativeExpansionAtmospheric.metal" | |
| 85 | + private typealias L = NativeEffect.Look | |
| 86 | + /// Released designs keep their original Chaos and zoom-speed defaults; only exposure, | |
| 87 | + /// fog and palette are tuned so each opens with an attractive look. | |
| 88 | + private static func legacy(_ palette: Int, _ brightness: Float, fog: Float = 0.5, size: Float = 1, zoom: Float = 1) -> L { | |
| 89 | + L(palette: palette, size: size, speed: 1, zoomSpeed: 1.5, brightness: brightness, fog: fog, detail: 0.6, chaos: 0.5, zoom: zoom) | |
| 90 | + } | |
| 91 | + | |
| 92 | + static let all: [NativeEffect] = [ | |
| 93 | + // Red Finder labels in the review folder are the keeper list. Withdrawn IDs | |
| 94 | + // remain reserved so existing projects resolve to an offered effect. | |
| 95 | + .retired("Prism Wake", icon: "pyramid", replacement: 20), | |
| 96 | + .retired("Lumen Veil", icon: "sun.haze", replacement: 10), | |
| 97 | + .retired("Pulse Well", icon: "circle.circle", replacement: 22), | |
| 98 | + .retired("Velvet Passage", icon: "torus", replacement: 29), | |
| 99 | + .retired("Bead Surge", icon: "circle.grid.hex", replacement: 101), | |
| 100 | + .retired("Facet Flow", icon: "diamond", replacement: 23), | |
| 101 | + .retired("Glass Current", icon: "circle.square", replacement: 29), | |
| 102 | + .retired("Contour Flux", icon: "waveform.path", replacement: 17), | |
| 103 | + .retired("Recursive Corridor", icon: "square.stack.3d.up", replacement: 22), | |
| 104 | + .retired("Spiral Tide", icon: "hurricane", replacement: 25), | |
| 105 | + .original("Aurora Fold", icon: "sun.horizon", travels: true, look: legacy(4, 1.4, fog: 0.3)), | |
| 106 | + .retired("Petal Passage", icon: "rosette", replacement: 15), | |
| 107 | + .original("Pearl Terrain", icon: "circle.hexagongrid", travels: true, look: legacy(3, 1.2, fog: 0.4)), | |
| 108 | + .retired("Vapor Run", icon: "wind", replacement: 10), | |
| 109 | + .retired("Scatter Flight", icon: "point.3.connected.trianglepath.dotted", replacement: 101), | |
| 110 | + .original(OriginalGeometry.Scene.audioMandala.title, icon: "asterisk", look: legacy(2, 2)), | |
| 111 | + .original(OriginalGeometry.Scene.orbitalRings.title, icon: "atom", look: legacy(3, 2)), | |
| 112 | + .original(OriginalGeometry.Scene.ribbonWave.title, icon: "wave.3.right", look: legacy(1, 1.9)), | |
| 113 | + .original(OriginalGeometry.Scene.spectralHelix.title, icon: "infinity", look: legacy(0, 1.7, size: 1.6, zoom: 1.05)), | |
| 114 | + .original(OriginalGeometry.Scene.particleFountain.title, icon: "burst", look: legacy(2, 1.8, size: 1.6, zoom: 1.05)), | |
| 115 | + .original(OriginalGeometry.Scene.pulseGrid.title, icon: "square.grid.3x3", look: legacy(3, 1.8)), | |
| 116 | + .original(OriginalGeometry.Scene.harmonicBloom.title, icon: "snowflake", look: legacy(4, 1.3)), | |
| 117 | + .original("Octagon Vault", icon: "circle.hexagonpath", size: "Line width", travels: true, look: legacy(1, 1.2)), | |
| 118 | + .original("Mercury Fold", icon: "drop", size: "Surface thickness", detail: "Liquid detail", look: legacy(3, 1.2)), | |
| 119 | + .original("Voltage Weave", icon: "bolt.horizontal", travels: true, look: legacy(0, 1)), | |
| 120 | + .original("Ink Cyclone", icon: "tornado", travels: true, look: legacy(2, 1)), | |
| 121 | + .original("Prism Rain", icon: "rainbow", travels: true, look: legacy(1, 1.3)), | |
| 122 | + .original("Monolith Rush", icon: "cube", travels: true, look: legacy(3, 1.2)), | |
| 123 | + .original("Halo Engine", icon: "circle.dotted.circle", size: "Ring thickness", travels: true, look: legacy(2, 1.3)), | |
| 124 | + .original("Tidal Glass", icon: "water.waves", travels: true, look: legacy(3, 1.1)), | |
| 125 | + .retired("Grid Vortex", icon: "squareshape.dashed.squareshape", replacement: 22), | |
| 126 | + .metal("Silk Cascade", icon: "scribble", "silkCascade", in: flow, size: "Fold scale", detail: "Sheen", look: L(palette: 3, size: 1.1, speed: 0.8, zoomSpeed: 0.6)), | |
| 127 | + .metal("Chrome Reef", icon: "circle.hexagongrid.fill", "chromeReef", in: structure, size: "Coral scale", look: L(palette: 3, speed: 0.8, zoomSpeed: 0.9)), | |
| 128 | + .metal("Ribbon Foundry", icon: "scribble.variable", "ribbonFoundry", in: flow, size: "Ribbon width", look: L(palette: 2, speed: 0.9, zoomSpeed: 0.8)), | |
| 129 | + .retired("Electric Orchard", icon: "tree", replacement: 101), | |
| 130 | + .retired("Glass Mosaic", icon: "rectangle.split.3x3", replacement: 101), | |
| 131 | + .retired("Graviton Petals", icon: "camera.macro", replacement: 101), | |
| 132 | + .retired("Ion Cathedral", icon: "building.columns", replacement: 101), | |
| 133 | + .retired("Velvet Circuit", icon: "cpu", replacement: 101), | |
| 134 | + .retired("Lunar Loom", icon: "moon", replacement: 101), | |
| 135 | + .retired("Lava Estuary", icon: "flame", replacement: 101), | |
| 136 | + .retired("Photon Rapids", icon: "sparkles", replacement: 101), | |
| 137 | + .metal("Sonic Topography", icon: "map", "sonicTopography", in: nature, size: "Terrain scale", look: L(palette: 4, speed: 0.8, zoomSpeed: 1)), | |
| 138 | + .metal("Prismatic Dunes", icon: "mountain.2", "prismaticDunes", in: nature, size: "Dune scale", look: L(palette: 2, speed: 0.7, zoomSpeed: 1, fog: 0.4)), | |
| 139 | + .retired("Honeycomb Tide", icon: "hexagon", replacement: 101), | |
| 140 | + .retired("Nebula Nursery", icon: "sparkle", replacement: 101), | |
| 141 | + .metal("Crystal Orchard", icon: "triangle", "crystalOrchard", in: nature, size: "Crystal size", look: L(palette: 3, speed: 0.75, zoomSpeed: 0.9)), | |
| 142 | + .metal("Opal Tessera", icon: "seal", "opalTessera", in: geometry, size: "Tile size", look: L(palette: 1, speed: 0.75, zoomSpeed: 0.6)), | |
| 143 | + .metal("Velvet Nebula", icon: "cloud", "velvetNebula", in: nature, size: "Pillar scale", look: L(palette: 2, speed: 0.6, zoomSpeed: 0.7, fog: 0.55)), | |
| 144 | + .retired("Arc Foundry", icon: "bolt.circle", replacement: 101), | |
| 145 | + .metal("Magnetic Ballet", icon: "oval", "magneticBallet", in: particles, size: "Field density", look: L(palette: 3, speed: 0.8, zoomSpeed: 0.6)), | |
| 146 | + .retired("Paper Cascades", icon: "square.3.layers.3d", replacement: 101), | |
| 147 | + .retired("Diamond Undertow", icon: "rhombus", replacement: 101), | |
| 148 | + .retired("Fractal Canopy", icon: "arrow.triangle.branch", replacement: 101), | |
| 149 | + .retired("Gyroscopic Garden", icon: "rotate.3d", replacement: 101), | |
| 150 | + .retired("Bubble Choir", icon: "bubbles.and.sparkles", replacement: 101), | |
| 151 | + .retired("Laser Origami", icon: "paperplane", replacement: 101), | |
| 152 | + .retired("Echo Lanterns", icon: "lightbulb", replacement: 101), | |
| 153 | + .retired("Kelp Cathedral", icon: "leaf", replacement: 101), | |
| 154 | + .retired("Solar Filigree", icon: "sun.max", replacement: 101), | |
| 155 | + .metal("Mandel Bloom", icon: "circle.dashed", "mandelBloom", in: geometry, size: "Bloom scale", detail: "Fractal detail", look: L(palette: 0, speed: 0.7, zoomSpeed: 0.6)), | |
| 156 | + .metal("Menger Nave", icon: "square.grid.3x3.fill", "mengerNave", in: geometry, size: "Vault scale", look: L(palette: 2, speed: 0.8, zoomSpeed: 1, fog: 0.45)), | |
| 157 | + .retired("Apollonian Foam", icon: "circle.grid.3x3", replacement: 101), | |
| 158 | + .retired("Hyperbolic Rosette", icon: "smallcircle.filled.circle", replacement: 101), | |
| 159 | + .metal("Quasicrystal Bloom", icon: "staroflife", "quasicrystalBloom", in: geometry, size: "Wave scale", look: L(palette: 0, speed: 0.8, zoomSpeed: 0.7)), | |
| 160 | + .retired("Tesseract Garden", icon: "cube.transparent", replacement: 101), | |
| 161 | + .retired("Harmonograph", icon: "lasso", replacement: 101), | |
| 162 | + .retired("Moire Engine", icon: "circle.lefthalf.filled", replacement: 101), | |
| 163 | + .retired("Riley Undulation", icon: "line.3.horizontal", replacement: 101), | |
| 164 | + .retired("Kaleido Chamber", icon: "camera.aperture", replacement: 101), | |
| 165 | + .retired("Girih Lattice", icon: "star", replacement: 101), | |
| 166 | + .retired("Gear Works", icon: "gearshape.2", replacement: 101), | |
| 167 | + .metal("Piston Hall", icon: "engine.combustion", "pistonHall", in: structure, size: "Piston scale", look: L(palette: 3, speed: 0.9, zoomSpeed: 0.9, fog: 0.45)), | |
| 168 | + .retired("Orrery Engine", icon: "globe", replacement: 101), | |
| 169 | + .metal("Space Frame", icon: "square.split.diagonal.2x2", "spaceFrame", in: structure, size: "Beam width", look: L(palette: 3, speed: 0.8, zoomSpeed: 1.2, fog: 0.5)), | |
| 170 | + .retired("Brutalist Shift", icon: "building.2", replacement: 101), | |
| 171 | + .retired("Rose Window", icon: "rays", replacement: 101), | |
| 172 | + .retired("Zen Rake", icon: "line.3.horizontal.decrease", replacement: 101), | |
| 173 | + .retired("Ferrofluid Crown", icon: "drop.fill", replacement: 101), | |
| 174 | + .metal("Windowpane Drizzle", icon: "cloud.rain", "windowpaneDrizzle", in: flow, size: "Drop size", look: L(palette: 1, speed: 0.8, zoomSpeed: 0.6)), | |
| 175 | + .metal("Ink Bloom", icon: "paintbrush", "inkBloom", in: flow, size: "Plume scale", look: L(palette: 3, speed: 0.7, zoomSpeed: 0.6)), | |
| 176 | + .metal("Oil Marble", icon: "swirl.circle.righthalf.filled", "oilMarble", in: flow, size: "Swirl scale", look: L(palette: 1, speed: 0.7, zoomSpeed: 0.6)), | |
| 177 | + .retired("Chladni Sand", icon: "dot.radiowaves.left.and.right", replacement: 101), | |
| 178 | + .metal("Ripple Tank", icon: "circle.dotted", "rippleTank", in: flow, size: "Wave scale", look: L(palette: 3, speed: 0.8, zoomSpeed: 0.6)), | |
| 179 | + .metal("Chrome Metaballs", icon: "drop.circle", "chromeMetaballs", in: flow, size: "Blob size", look: L(palette: 0, speed: 0.8, zoomSpeed: 0.7)), | |
| 180 | + .metal("Ocean Swell", icon: "wave.3.forward", "oceanSwell", in: flow, size: "Swell scale", look: L(palette: 3, speed: 0.8, zoomSpeed: 0.9, fog: 0.45)), | |
| 181 | + .metal("Plexus Constellations", icon: "point.3.filled.connected.trianglepath.dotted", "plexusConstellations", in: particles, size: "Star size", look: L(palette: 3, speed: 0.7, zoomSpeed: 0.9)), | |
| 182 | + .retired("Murmuration", icon: "bird", replacement: 101), | |
| 183 | + .metal("Ring Shepherds", icon: "circle.grid.cross", "ringShepherds", in: particles, size: "Ringlet width", look: L(palette: 2, speed: 0.7, zoomSpeed: 0.7)), | |
| 184 | + .retired("Pendulum Wave", icon: "metronome", replacement: 101), | |
| 185 | + .retired("Firework Garden", icon: "fireworks", replacement: 101), | |
| 186 | + .metal("Event Horizon", icon: "smallcircle.circle", "eventHorizon", in: particles, size: "Disk width", look: L(palette: 2, speed: 0.7, zoomSpeed: 0.6)), | |
| 187 | + .metal("Atom Lattice", icon: "circle.grid.3x3.fill", "atomLattice", in: structure, size: "Atom size", look: L(palette: 1, speed: 0.8, zoomSpeed: 1.1, fog: 0.5)), | |
| 188 | + .retired("Mitosis Garden", icon: "allergens", replacement: 101), | |
| 189 | + .retired("Neural Bloom", icon: "brain", replacement: 101), | |
| 190 | + .retired("Jellyfish Abyss", icon: "umbrella", replacement: 101), | |
| 191 | + .retired("Glacier Rift", icon: "snowflake.circle", replacement: 101), | |
| 192 | + .retired("Firefly Meadow", icon: "moon.zzz", replacement: 101), | |
| 193 | + .metal("Synth Horizon", icon: "sunset", "synthHorizon", in: structure, size: "Grid scale", look: L(palette: 1, speed: 0.9, zoomSpeed: 1.2)), | |
| 194 | + .retired("Neon Calligraphy", icon: "signature", replacement: 101), | |
| 195 | + .metal("Plasma Bore", icon: "circle.dashed.inset.filled", "plasmaBore", in: tunnels, size: "Plasma scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, fog: 0.45)), | |
| 196 | + .metal("LED Corridor", icon: "square.grid.4x3.fill", "ledCorridor", in: tunnels, size: "Pixel size", look: L(palette: 1, speed: 1, zoomSpeed: 1.4, fog: 0.4)), | |
| 197 | + .metal("Prism Shaft", icon: "triangle.fill", "prismShaft", in: tunnels, size: "Facet scale", look: L(palette: 0, speed: 0.9, zoomSpeed: 1.2, fog: 0.45)), | |
| 198 | + .metal("Hyperloop", icon: "tram.tunnel.fill", "hyperloop", in: tunnels, size: "Ring spacing", look: L(palette: 3, speed: 1.1, zoomSpeed: 1.6, fog: 0.35)), | |
| 199 | + .metal("Barrel Wave", icon: "wave.3.left", "barrelWave", in: tunnels, size: "Curl scale", look: L(palette: 3, speed: 0.9, zoomSpeed: 1.1, fog: 0.4)), | |
| 200 | + .metal("Magma Tube", icon: "flame.fill", "magmaTube", in: tunnels, size: "Crust scale", look: L(palette: 2, speed: 0.8, zoomSpeed: 1, fog: 0.45)), | |
| 201 | + .metal("Data Conduit", icon: "memorychip", "dataConduit", in: tunnels, size: "Trace width", look: L(palette: 4, speed: 1, zoomSpeed: 1.5, fog: 0.4)), | |
| 202 | + .metal("Helix Stair", icon: "stairs", "helixStair", in: tunnels, size: "Step size", look: L(palette: 0, speed: 0.8, zoomSpeed: 1, fog: 0.5)), | |
| 203 | + .retired("Mirror Regress", icon: "rectangle.on.rectangle", replacement: 101), | |
| 204 | + .metal("Laser Bore", icon: "bolt.horizontal.fill", "laserBore", in: tunnels, size: "Beam width", look: L(palette: 1, speed: 1.1, zoomSpeed: 1.4, fog: 0.35)), | |
| 205 | + .metal("Twist Checker", icon: "checkerboard.rectangle", "twistChecker", in: tunnels, size: "Tile size", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, fog: 0.4)), | |
| 206 | + .metal("Foam Tube", icon: "bubbles.and.sparkles.fill", "foamTube", in: tunnels, size: "Bubble size", look: L(palette: 1, speed: 0.9, zoomSpeed: 1.1, fog: 0.45)), | |
| 207 | + .metal("Polygon Stack", icon: "pentagon", "polygonStack", in: tunnels, size: "Edge width", look: L(palette: 0, speed: 1, zoomSpeed: 1.2, fog: 0.4)), | |
| 208 | + .metal("Gyroid Caverns", icon: "aqi.medium", "gyroidCaverns", in: tunnels, size: "Cavern scale", look: L(palette: 0, speed: 0.8, zoomSpeed: 1, fog: 0.55)), | |
| 209 | + .metal("Spectrum Bore", icon: "chart.bar.fill", "spectrumBore", in: tunnels, size: "Bar width", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, fog: 0.4)), | |
| 210 | + .retired("Ribbon Vortex", icon: "wind", replacement: 101), | |
| 211 | + .retired("Gate Run", icon: "building.columns.fill", replacement: 101), | |
| 212 | + .metal("Storm Eye", icon: "cloud.bolt.fill", "stormEye", in: wormholes, size: "Cloud scale", look: L(palette: 3, speed: 0.9, zoomSpeed: 1.2, fog: 0.4)), | |
| 213 | + .metal("Sonar Pipe", icon: "dot.radiowaves.forward", "sonarPipe", in: wormholes, size: "Ring spacing", look: L(palette: 3, speed: 0.9, zoomSpeed: 1.2, fog: 0.45)), | |
| 214 | + .metal("Cube Helix", icon: "cube.fill", "cubeHelix", in: wormholes, size: "Cube size", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, fog: 0.45)), | |
| 215 | + .metal("Phyllo Tube", icon: "camera.filters", "phylloTube", in: wormholes, size: "Dot size", look: L(palette: 4, speed: 0.9, zoomSpeed: 1.1, fog: 0.4)), | |
| 216 | + .metal("Tesla Tube", icon: "bolt.fill", "teslaTube", in: wormholes, size: "Arc width", look: L(palette: 4, speed: 1, zoomSpeed: 1.2, fog: 0.4)), | |
| 217 | + .metal("Fold Tunnel", icon: "paperplane.fill", "foldTunnel", in: wormholes, size: "Fold scale", look: L(palette: 4, speed: 0.9, zoomSpeed: 1.1, fog: 0.45)), | |
| 218 | + .metal("Vector Tube", icon: "cylinder.split.1x2", "vectorTube", in: wormholes, size: "Line width", look: L(palette: 1, speed: 1.1, zoomSpeed: 1.5, fog: 0.35)), | |
| 219 | + .metal("Orbital Corridor", icon: "rectangle.split.3x1", "orbitalCorridor", in: wormholes, size: "Panel scale", look: L(palette: 3, speed: 0.9, zoomSpeed: 1.2, fog: 0.5)), | |
| 220 | + .metal("Mirrorball Tunnel", icon: "square.grid.3x3.square", "mirrorballTunnel", in: wormholes, size: "Tile size", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, fog: 0.4)), | |
| 221 | + .retired("Fractal Throat", icon: "triangle.circle", replacement: 101), | |
| 222 | + .metal("Chroma Pipe", icon: "capsule.fill", "chromaPipe", in: wormholes, size: "Ring width", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, fog: 0.35)), | |
| 223 | + .retired("Coral Burrow", icon: "leaf.fill", replacement: 101), | |
| 224 | + .metal("Rainbow Slide", icon: "figure.pool.swim", "rainbowSlide", in: wormholes, size: "Slide width", look: L(palette: 1, speed: 1.1, zoomSpeed: 1.6, fog: 0.3)), | |
| 225 | + .metal("Pulse Arteries", icon: "heart.fill", "pulseArteries", in: wormholes, size: "Vessel width", look: L(palette: 2, speed: 0.9, zoomSpeed: 1.2, fog: 0.45)), | |
| 226 | + .metal("Zebra Warp", icon: "line.3.horizontal.circle", "zebraWarp", in: wormholes, size: "Stripe width", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, fog: 0.35)), | |
| 227 | + .metal("Pixel Tunnel", icon: "square.grid.2x2.fill", "pixelTunnel", in: wormholes, size: "Pixel size", look: L(palette: 1, speed: 1, zoomSpeed: 1.4, fog: 0.35)), | |
| 228 | + .metal("Geode Passage", icon: "diamond.fill", "geodePassage", in: wormholes, size: "Crystal size", look: L(palette: 3, speed: 0.8, zoomSpeed: 1, fog: 0.5)), | |
| 229 | + .retired("Night Highway", icon: "car.fill", replacement: 101), | |
| 230 | + .retired("Neon Boulevard", icon: "building.2.crop.circle", replacement: 101), | |
| 231 | + .retired("Desert Interstate", icon: "sun.dust.fill", replacement: 101), | |
| 232 | + .retired("Mountain Switchbacks", icon: "mountain.2.fill", replacement: 101), | |
| 233 | + .retired("Sodium Tunnel", icon: "lightbulb.fill", replacement: 101), | |
| 234 | + .retired("Coastal Cruise", icon: "beach.umbrella", replacement: 101), | |
| 235 | + .retired("Long Exposure", icon: "timelapse", replacement: 101), | |
| 236 | + .metal("Neon Trails", icon: "bicycle", "neonTrails", in: drive, size: "Trail width", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, fog: 0.35)), | |
| 237 | + .retired("Rally Forest", icon: "tree.fill", replacement: 101), | |
| 238 | + .retired("Bridge Run", icon: "road.lanes", replacement: 101), | |
| 239 | + .retired("Coaster Loop", icon: "point.topleft.down.curvedto.point.bottomright.up", replacement: 101), | |
| 240 | + .retired("Hover Lanes", icon: "airplane", replacement: 101), | |
| 241 | + .retired("Bullet Train", icon: "tram.fill", replacement: 101), | |
| 242 | + .retired("Apex Chase", icon: "flag.checkered", replacement: 101), | |
| 243 | + .retired("Snow Drive", icon: "cloud.snow.fill", replacement: 101), | |
| 244 | + .retired("Dashboard Glow", icon: "gauge.with.dots.needle.67percent", replacement: 101), | |
| 245 | + .retired("Midnight Skyline", icon: "building.2.fill", replacement: 101), | |
| 246 | + .retired("Orbit Freeway", icon: "infinity.circle", replacement: 101), | |
| 247 | + .retired("Canyon Run", icon: "map.fill", replacement: 101), | |
| 248 | + .retired("Interchange", icon: "arrow.triangle.swap", replacement: 101), | |
| 249 | + .retired("Lean Angle", icon: "scooter", replacement: 101), | |
| 250 | + .retired("Runway Rush", icon: "airplane.departure", replacement: 101), | |
| 251 | + .retired("Wake Racer", icon: "sailboat.fill", replacement: 101), | |
| 252 | + .retired("Bobsled Chute", icon: "figure.skiing.downhill", replacement: 101), | |
| 253 | + .retired("Rail Rush", icon: "train.side.front.car", replacement: 101), | |
| 254 | + .retired("Starlane Convoy", icon: "moon.stars.fill", replacement: 101), | |
| 255 | + .retired("Marquee Strip", icon: "star.circle.fill", replacement: 101), | |
| 256 | + .retired("Sky Causeway", icon: "cloud.sun.fill", replacement: 101), | |
| 257 | + .retired("Turbine Road", icon: "wind.circle.fill", replacement: 101), | |
| 258 | + .retired("Chevron Rush", icon: "chevron.right.2", replacement: 101), | |
| 259 | + .retired("Street Circuit", icon: "flag.2.crossed.fill", replacement: 101), | |
| 260 | + .retired("Glider Valley", icon: "paperplane.circle.fill", replacement: 101), | |
| 261 | + .retired("Rocket Sled", icon: "bolt.car.fill", replacement: 101), | |
| 262 | + .retired("Groove Tiles", icon: "square.grid.3x3.topleft.filled", replacement: 101), | |
| 263 | + .retired("Mirror Ball", icon: "light.beacon.max", replacement: 101), | |
| 264 | + .retired("Drone Ballet", icon: "airplane.circle", replacement: 101), | |
| 265 | + .retired("Ribbon Gymnast", icon: "figure.gymnastics", replacement: 101), | |
| 266 | + .retired("Laser Haze", icon: "line.3.crossed.swirl.circle", replacement: 101), | |
| 267 | + .retired("Moving Heads", icon: "light.cylindrical.ceiling.fill", replacement: 101), | |
| 268 | + .retired("Conga Orbs", icon: "ellipsis.circle.fill", replacement: 101), | |
| 269 | + .retired("Headspin", icon: "arrow.triangle.2.circlepath", replacement: 101), | |
| 270 | + .retired("Waltz Pairs", icon: "figure.socialdance", replacement: 101), | |
| 271 | + .metal("Pigment Burst", icon: "paintpalette.fill", "pigmentBurst", in: dance, size: "Cloud scale", look: L(palette: 1, speed: 0.9, zoomSpeed: 1, brightness: 1, fog: 0.4)), | |
| 272 | + .retired("Pirouette Bloom", icon: "seal.fill", replacement: 101), | |
| 273 | + .metal("Stretch Membrane", icon: "hand.raised.fill", "stretchMembrane", in: dance, size: "Bulge size", look: L(palette: 0, speed: 1, zoomSpeed: 1, brightness: 1, fog: 0.4)), | |
| 274 | + .metal("Kinetic Mirrors", icon: "squares.below.rectangle", "kineticMirrors", in: dance, size: "Tile size", look: L(palette: 1, speed: 1, zoomSpeed: 1, fog: 0.4)), | |
| 275 | + .metal("Fire Dance", icon: "flame.circle", "fireDance", in: dance, size: "Flame size", look: L(palette: 2, speed: 1, zoomSpeed: 1, fog: 0.4)), | |
| 276 | + .retired("Chiffon Swirl", icon: "hurricane", replacement: 101), | |
| 277 | + .metal("Fountain Show", icon: "humidity.fill", "fountainShow", in: dance, size: "Jet width", look: L(palette: 3, speed: 1, zoomSpeed: 1, fog: 0.4)), | |
| 278 | + .metal("Glowstick Rave", icon: "wand.and.stars", "glowstickRave", in: dance, size: "Stick width", look: L(palette: 4, speed: 1.1, zoomSpeed: 1, fog: 0.4)), | |
| 279 | + .metal("Smoke Rings", icon: "smoke.fill", "smokeRings", in: rave, size: "Ring size", look: L(palette: 3, speed: 1, zoomSpeed: 1.1, fog: 0.45)), | |
| 280 | + .metal("Wand Orbs", icon: "camera.metering.spot", "wandOrbs", in: rave, size: "Orb size", look: L(palette: 1, speed: 1, zoomSpeed: 1, fog: 0.4)), | |
| 281 | + .retired("Faraday Dish", icon: "aqi.low", replacement: 101), | |
| 282 | + .metal("String Resonance", icon: "guitars.fill", "stringResonance", in: rave, size: "String width", look: L(palette: 2, speed: 1, zoomSpeed: 1, fog: 0.4)), | |
| 283 | + .metal("Light Bars", icon: "rectangle.split.1x2.fill", "lightBars", in: rave, size: "Bar width", look: L(palette: 4, speed: 1, zoomSpeed: 1, fog: 0.45)), | |
| 284 | + .metal("Sequin Curtain", icon: "rectangle.grid.3x2.fill", "sequinCurtain", in: rave, size: "Sequin size", look: L(palette: 1, speed: 1, zoomSpeed: 1, fog: 0.4)), | |
| 285 | + .retired("Torsion Wave", icon: "wave.3.backward", replacement: 101), | |
| 286 | + .retired("Spin Paint", icon: "paintbrush.pointed.fill", replacement: 101), | |
| 287 | + .metal("Stadium Wave", icon: "wave.3.right.circle.fill", "stadiumWave", in: rave, size: "Ball size", look: L(palette: 1, speed: 1, zoomSpeed: 1.1, fog: 0.35)), | |
| 288 | + .metal("Liquid Floor", icon: "drop.circle.fill", "liquidFloor", in: rave, size: "Ripple scale", look: L(palette: 3, speed: 1, zoomSpeed: 1, brightness: 1.2, fog: 0.4)), | |
| 289 | + .retired("Confetti Storm", icon: "party.popper.fill", replacement: 101), | |
| 290 | + .retired("Bokeh Club", icon: "circle.hexagonpath.fill", replacement: 101), | |
| 291 | + .retired("Persistence Fans", icon: "fan.fill", replacement: 101), | |
| 292 | + .metal("Domino Run", icon: "square.stack.3d.forward.dottedline.fill", "dominoRun", in: rave, size: "Domino size", look: L(palette: 1, speed: 1.1, zoomSpeed: 1.3, fog: 0.35)), | |
| 293 | + .retired("Aerial Silks", icon: "figure.climbing", replacement: 101), | |
| 294 | + .retired("Hula Hoops", icon: "smallcircle.filled.circle.fill", replacement: 101), | |
| 295 | + .retired("Chromatic Speedway", icon: "road.lanes", replacement: 101), | |
| 296 | + .metal("Iridescent Raceway", icon: "speedometer", "iridescentRaceway", in: driveExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.0, brightness: 1.35, fog: 0.25)), | |
| 297 | + .metal("Cobalt Catapult", icon: "arrow.up.forward", "cobaltCatapult", in: driveExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.1, brightness: 1.35, fog: 0.25)), | |
| 298 | + .metal("Tangerine Rocket", icon: "airplane", "tangerineRocket", in: driveExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.5, brightness: 1.35, fog: 0.25)), | |
| 299 | + .metal("Prismatic Overdrive", icon: "pentagon", "prismaticOverdrive", in: driveExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.2, brightness: 1.35, fog: 0.25)), | |
| 300 | + .metal("Scarlet Slipstream", icon: "flag.2.crossed", "scarletSlipstream", in: driveExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.0, brightness: 1.35, fog: 0.25)), | |
| 301 | + .metal("Laser Autobahn", icon: "steeringwheel", "laserAutobahn", in: driveExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.2, brightness: 1.35, fog: 0.25)), | |
| 302 | + .metal("Rainbow Riptide", icon: "sailboat", "rainbowRiptide", in: driveExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.1, brightness: 1.35, fog: 0.25)), | |
| 303 | + .metal("Electric Switchback", icon: "arrow.triangle.swap", "electricSwitchback", in: driveExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.0, brightness: 1.35, fog: 0.25)), | |
| 304 | + .metal("Disco Transit", icon: "train.side.front.car", "discoTransit", in: driveExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.2, brightness: 1.35, fog: 0.25)), | |
| 305 | + .metal("Velvet Samba", icon: "figure.dance", "velvetSamba", in: danceExpansion, size: "Form scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0.6, brightness: 1.3, fog: 0.25)), | |
| 306 | + .metal("Neon Caper", icon: "figure.step.training", "neonCaper", in: danceExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.6, brightness: 1.3, fog: 0.25)), | |
| 307 | + .metal("Carnival Pulse", icon: "party.popper", "carnivalPulse", in: danceExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.6, brightness: 1.3, fog: 0.25)), | |
| 308 | + .metal("Ribbon Rumba", icon: "figure.flexibility", "ribbonRumba", in: danceExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0.6, brightness: 1.3, fog: 0.25)), | |
| 309 | + .metal("Elastic Jive", icon: "figure.jumprope", "elasticJive", in: danceExpansion, size: "Form scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0.6, brightness: 1.3, fog: 0.25)), | |
| 310 | + .metal("Liquid Tango", icon: "figure.2", "liquidTango", in: danceExpansion, size: "Form scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0.6, brightness: 1.3, fog: 0.25)), | |
| 311 | + .metal("Prism Pirouette", icon: "figure.gymnastics", "prismPirouette", in: danceExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.6, brightness: 1.3, fog: 0.25)), | |
| 312 | + .retired("Orbit Salsa", icon: "figure.socialdance", replacement: 101), | |
| 313 | + .metal("Molten Mambo", icon: "flame.circle", "moltenMambo", in: danceExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0.6, brightness: 1.3, fog: 0.25)), | |
| 314 | + .retired("Vivid Foxtrot", icon: "figure.walk.motion", replacement: 101), | |
| 315 | + .metal("Fuchsia Flyway", icon: "road.lanes", "fuchsiaFlyway", in: voyageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 316 | + .metal("Amber Aqueduct", icon: "water.waves", "amberAqueduct", in: voyageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 317 | + .metal("Photon Overpass", icon: "arrow.triangle.merge", "photonOverpass", in: voyageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 318 | + .metal("Indigo Escalator", icon: "stairs", "indigoEscalator", in: voyageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 319 | + .metal("Solar Slalom", icon: "flag.checkered", "solarSlalom", in: voyageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 320 | + .metal("Glacial Sprint", icon: "mountain.2", "glacialSprint", in: voyageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 321 | + .metal("Velour Velocity", icon: "sailboat", "velvetVoyage", in: voyageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 322 | + .metal("Plasma Rally", icon: "bolt.shield", "plasmaRally", in: voyageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 323 | + .metal("Crystal Causeway", icon: "triangle.fill", "crystalCauseway", in: voyageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 324 | + .metal("Luminous Lift", icon: "arrow.up.square", "luminousLift", in: voyageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 325 | + .metal("Arc Jetstream", icon: "wind", "arcJetstream", in: voyageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 326 | + .metal("Ruby Rollway", icon: "circle.rectangle.filled.pattern.diagonalline", "rubyRollway", in: voyageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 327 | + .metal("Neon Regatta", icon: "ferry", "neonRegatta", in: voyageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 328 | + .metal("Radiant Runway", icon: "airplane.departure", "radiantRunway", in: voyageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 329 | + .metal("Electric Viaduct", icon: "building.columns", "electricViaduct", in: voyageExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 330 | + .metal("Orbit Express", icon: "tram", "orbitExpress", in: voyageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 331 | + .metal("Molten Highway", icon: "flame", "moltenHighway", in: voyageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 332 | + .metal("Violet Flight", icon: "paperplane.fill", "violetFlight", in: voyageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 333 | + .metal("Emerald Launch", icon: "leaf.circle", "emeraldLaunch", in: voyageExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 334 | + .metal("Coral Driftway", icon: "fish", "coralDriftway", in: voyageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 335 | + .metal("Azure Ascent", icon: "arrow.up.forward.square", "azureAscent", in: voyageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 336 | + .metal("Festival Cruise", icon: "party.popper", "festivalCruise", in: voyageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 337 | + .metal("Quantum Sled", icon: "arrow.down.right.and.arrow.up.left", "quantumSled", in: voyageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 338 | + .metal("Citrus Surge", icon: "drop.circle.fill", "citrusSurge", in: voyageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 339 | + .metal("Starlight Pursuit", icon: "sparkles", "starlightPursuit", in: voyageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 340 | + .metal("Saffron Spindle", icon: "rays", "saffronSpindle", in: passageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 341 | + .metal("Opaline Iris", icon: "camera.aperture", "opalineIris", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 342 | + .metal("Electric Helicoid", icon: "arrow.triangle.2.circlepath", "electricHelicoid", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 343 | + .metal("Ultramarine Arcade", icon: "building.columns", "ultramarineArcade", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 344 | + .metal("Fuchsia Furnace", icon: "gearshape", "fuchsiaFurnace", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 345 | + .metal("Amber Aperture", icon: "squareshape", "amberAperture", in: passageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 346 | + .metal("Aurora Corkscrew", icon: "tornado", "auroraCorkscrew", in: passageExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 347 | + .metal("Prism Portals", icon: "triangle", "prismPortals", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 348 | + .metal("Magenta Conduit", icon: "cpu", "magentaConduit", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 349 | + .metal("Verdant Spiral", icon: "leaf.fill", "verdantSpiral", in: passageExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 350 | + .metal("Sapphire Cascade", icon: "water.waves", "sapphireCascade", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 351 | + .metal("Garnet Gallery", icon: "diamond", "garnetGallery", in: passageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 352 | + .metal("Luminous Nautilus", icon: "tornado", "luminousNautilus", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 353 | + .metal("Indigo Infinity", icon: "infinity", "indigoInfinity", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 354 | + .metal("Golden Gyre", icon: "sun.max.fill", "goldenGyre", in: passageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 355 | + .metal("Fluid Odyssey", icon: "drop.triangle", "liquidLabyrinth", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 356 | + .metal("Photon Petals", icon: "camera.macro", "photonPetals", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 357 | + .retired("Neon Needle", icon: "pencil.tip", replacement: 270), | |
| 358 | + .metal("Astral Torque", icon: "circle.dotted.circle", "celestialCoil", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 359 | + .metal("Chrome Comet", icon: "sparkle", "chromeComet", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 360 | + .metal("Candy Cathedral", icon: "building.columns.circle", "candyCathedral", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 361 | + .metal("Scarlet Siphon", icon: "drop.fill", "scarletSiphon", in: passageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 362 | + .metal("Emerald Echo", icon: "octagon", "emeraldEcho", in: passageExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 363 | + .metal("Arctic Raceway", icon: "snowflake", "arcticRaceway", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 364 | + .metal("Plasma Passage", icon: "allergens", "plasmaPassage", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 365 | + .metal("Violet Velocity", icon: "arrow.forward.square", "violetVelocity", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 366 | + .metal("Tangerine Turbine", icon: "fanblades", "tangerineTurbine", in: passageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 367 | + .metal("Cerulean Shell", icon: "fossil.shell", "ceruleanShell", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 368 | + .metal("Disco Helix", icon: "hexagon.fill", "discoHelix", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 369 | + .metal("Iridescent Descent", icon: "square.3.layers.3d", "iridescentDescent", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 370 | + .metal("Solar Serpent", icon: "scribble.variable", "solarSerpent", in: passageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 371 | + .metal("Rainbow Reactor", icon: "atom", "rainbowReactor", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 372 | + .retired("Velvet Wormhole", icon: "curtains.closed", replacement: 270), | |
| 373 | + .metal("Crystal Carousel", icon: "cube.transparent", "crystalCarousel", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 374 | + .metal("Neon Maelstrom", icon: "hurricane", "neonMaelstrom", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 375 | + .metal("Radiant Rondo", icon: "circle.grid.cross", "radiantRondo", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 376 | + .metal("Fuchsia Fandango", icon: "figure.dance", "fuchsiaFandango", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 377 | + .metal("Satin Shuffle", icon: "shuffle", "satinShuffle", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 378 | + .metal("Chromatic Charleston", icon: "figure.step.training", "chromaticCharleston", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 379 | + .metal("Prismatic Polka", icon: "triangle.circle", "prismaticPolka", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 380 | + .metal("Neon Bolero", icon: "rectangle.on.rectangle.angled", "neonBolero", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 4, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 381 | + .metal("Pearlescent Swing", icon: "circle.hexagongrid.fill", "pearlescentSwing", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 382 | + .metal("Solar Sway", icon: "sun.haze.fill", "solarSway", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 383 | + .metal("Liquid Limbo", icon: "checkerboard.rectangle", "liquidLimbo", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 384 | + .metal("Violet Vogue", icon: "figure.flexibility", "violetVogue", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 385 | + .metal("Disco Ripple", icon: "circle.dotted", "discoRipple", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 386 | + .metal("Gilded Groove", icon: "waveform.path", "gildedGroove", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 387 | + .metal("Aurora Waltz", icon: "sparkles.square.filled.on.square", "auroraWaltz", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 4, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 388 | + .metal("Elastic Anthem", icon: "allergens", "elasticAnthem", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 389 | + .metal("Crimson Cadence", icon: "fan", "crimsonCadence", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 390 | + .metal("Sapphire Stomp", icon: "wave.3.right", "sapphireStomp", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 391 | + .metal("Coral Crescendo", icon: "camera.macro", "coralCrescendo", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 392 | + .metal("Electric Encore", icon: "point.3.connected.trianglepath.dotted", "electricEncore", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 393 | + .metal("Luminous Lockstep", icon: "diamond.fill", "luminousLockstep", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 4, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 394 | + .metal("Festival Finale", icon: "party.popper.fill", "festivalFinale", in: festivalExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 395 | + .metal("Serpent Bore", icon: "lasso", "serpentBore", in: boreExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 396 | + .metal("Ringworld Drift", icon: "circle.bottomhalf.filled", "ringworldDrift", in: boreExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 397 | + .metal("Twin Bore", icon: "circle.circle", "twinBore", in: boreExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 398 | + .metal("Coil Run", icon: "rotate.3d", "coilRun", in: boreExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.2, fog: 0.25)), | |
| 399 | + .metal("Bellows Passage", icon: "rectangle.compress.vertical", "bellowsPassage", in: boreExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 400 | + .metal("Branching Bore", icon: "arrow.triangle.branch", "branchingBore", in: boreExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.5, fog: 0.25)), | |
| 401 | + .metal("Skyward Shaft", icon: "arrow.up.to.line", "skywardShaft", in: boreExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 402 | + .metal("Veil Passage", icon: "curtains.open", "veilPassage", in: boreExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 403 | + .metal("Glass Pipeworks", icon: "pipe.and.drop", "glassPipeworks", in: boreExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 404 | + .metal("Möbius Ride", icon: "infinity.circle", "mobiusRide", in: boreExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 405 | + .metal("Chainmail Bore", icon: "link", "chainmailBore", in: portalExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 406 | + .metal("Feather Vault", icon: "leaf", "featherVault", in: portalExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 407 | + .metal("Tartan Tube", icon: "squareshape.split.3x3", "tartanTube", in: portalExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 408 | + .metal("Herringbone Hall", icon: "chevron.up.chevron.down", "herringboneHall", in: portalExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 409 | + .metal("Quilted Pipe", icon: "square.grid.3x3.middle.filled", "quiltedPipe", in: portalIIExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 410 | + .metal("Lace Funnel", icon: "seal.fill", "laceFunnel", in: portalExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 411 | + .metal("Zipper Run", icon: "arrow.left.and.right", "zipperRun", in: portalExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 412 | + .metal("Cable Knit Tube", icon: "line.3.crossed.swirl.circle", "cableKnitTube", in: portalExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 413 | + .metal("Basket Weave Burrow", icon: "basket", "basketWeaveBurrow", in: portalExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 414 | + .metal("Louvre Tunnel", icon: "blinds.horizontal.open", "louvreTunnel", in: portalExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 415 | + .metal("Pin Art", icon: "pin.fill", "pinArt", in: kineticExpansion, size: "Form scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 416 | + .metal("Kinetic Rain", icon: "cloud.drizzle", "kineticRain", in: kineticExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 417 | + .metal("Plasma Globe", icon: "globe.desk", "plasmaGlobe", in: kineticExpansion, size: "Form scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 418 | + .metal("Jacob's Ladder", icon: "bolt.ring.closed", "jacobsLadder", in: kineticExpansion, size: "Form scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 419 | + // Not red-tagged in the owner's review; opens Pin Art like the 1.0.3 build. | |
| 420 | + .retired("Hanging Mobile", icon: "scalemass", replacement: 320), | |
| 421 | + .metal("Prism Carousel", icon: "triangle.lefthalf.filled", "prismCarousel", in: kineticExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 422 | + .metal("Cone Splash", icon: "speaker.wave.2", "coneSplash", in: kineticExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 423 | + .metal("Wind Tunnel", icon: "wind.circle", "windTunnel", in: kineticExpansion, size: "Form scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 424 | + .metal("Tensegrity Pulse", icon: "perspective", "tensegrityPulse", in: kineticExpansion, size: "Form scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 425 | + .metal("Shadow Modulator", icon: "light.max", "shadowModulator", in: kineticExpansion, size: "Form scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 426 | + .metal("Canopy Flight", icon: "lightbulb.2", "canopyFlight", in: flightExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 427 | + .metal("Strata Glide", icon: "square.stack.3d.down.forward", "strataGlide", in: flightExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 428 | + .metal("Pillar Forest", icon: "chart.bar.xaxis", "pillarForest", in: flightExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 429 | + .metal("Parallax Express", icon: "rectangle.3.group", "parallaxExpress", in: flightExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 430 | + .metal("Delta Flyover", icon: "point.topleft.down.to.point.bottomright.curvepath", "deltaFlyover", in: flightExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 431 | + .metal("Aurora Overpass", icon: "moon.stars", "auroraOverpass", in: flightExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 432 | + .metal("Cascade Climb", icon: "water.waves.and.arrow.up", "cascadeClimb", in: flightExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 433 | + .metal("Night Orbit", icon: "globe", "nightOrbit", in: flightExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 434 | + .metal("Comet Chase", icon: "star.circle", "cometChase", in: flightExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 435 | + .metal("Cloud Sea", icon: "cloud.fill", "cloudSea", in: flightExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 436 | + .metal("Acrylic Cells", icon: "paintpalette", "acrylicCells", in: materialExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 437 | + .metal("Molten Glass", icon: "flask", "moltenGlass", in: materialExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 438 | + .metal("Liquid Crystal", icon: "circle.lefthalf.filled", "liquidCrystal", in: materialExpansion, size: "Form scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 439 | + .metal("Incense Drift", icon: "smoke", "incenseDrift", in: materialExpansion, size: "Form scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 440 | + .metal("Shibori Bloom", icon: "circle.grid.2x2", "shiboriBloom", in: materialExpansion, size: "Form scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 441 | + .metal("Heat Haze", icon: "thermometer.sun", "heatHaze", in: materialExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 442 | + .metal("Gel Overlap", icon: "square.on.square", "gelOverlap", in: materialExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 443 | + .metal("Holo Foil", icon: "rectangle.portrait.on.rectangle.portrait.angled", "holoFoil", in: materialExpansion, size: "Form scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 444 | + .metal("Opal Fire", icon: "suit.diamond", "opalFire", in: materialExpansion, size: "Form scale", travels: false, look: L(palette: 4, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 445 | + .metal("Raku Crackle", icon: "rectangle.dashed", "rakuCrackle", in: materialExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0.4, brightness: 1.35, fog: 0.25)), | |
| 446 | + .metal("Pulsar Beacon", icon: "light.beacon.max", "pulsarBeacon", in: cosmosExpansion, size: "Structure scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0.6, brightness: 1.35, fog: 0.25)), | |
| 447 | + .metal("Twin Suns", icon: "sun.and.horizon", "twinSuns", in: cosmosExpansion, size: "Structure scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0.6, brightness: 1.35, fog: 0.25)), | |
| 448 | + .metal("Supernova Shell", icon: "staroflife.circle", "supernovaShell", in: cosmosExpansion, size: "Structure scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.6, brightness: 1.35, fog: 0.25)), | |
| 449 | + .metal("Galaxy Collision", icon: "hurricane.circle", "galaxyCollision", in: cosmosExpansion, size: "Structure scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0.6, brightness: 1.35, fog: 0.25)), | |
| 450 | + .metal("Solar Prominence", icon: "sun.dust", "solarProminence", in: cosmosExpansion, size: "Structure scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0.6, brightness: 1.35, fog: 0.25)), | |
| 451 | + .metal("Quasar Jet", icon: "arrow.up.and.down", "quasarJet", in: cosmosExpansion, size: "Structure scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0.6, brightness: 1.35, fog: 0.25)), | |
| 452 | + .metal("Ring Plane Run", icon: "circle.and.line.horizontal", "ringPlaneRun", in: cosmosExpansion, size: "Structure scale", travels: false, look: L(palette: 4, speed: 1, zoomSpeed: 0.6, brightness: 1.35, fog: 0.25)), | |
| 453 | + .metal("Magnetosphere", icon: "dot.radiowaves.left.and.right", "magnetosphere", in: cosmosExpansion, size: "Structure scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0.6, brightness: 1.35, fog: 0.25)), | |
| 454 | + .metal("Nebular Filaments", icon: "network", "cosmicWeb", in: cosmosExpansion, size: "Structure scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0.6, brightness: 1.35, fog: 0.25)), | |
| 455 | + .metal("Einstein Ring", icon: "smallcircle.filled.circle", "einsteinRing", in: cosmosExpansion, size: "Structure scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0.6, brightness: 1.35, fog: 0.25)), | |
| 456 | + .metal("Julia Dive", icon: "arrow.down.right.and.arrow.up.left.circle", "juliaDive", in: fractalExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 457 | + .metal("Julia Braid", icon: "arrow.triangle.2.circlepath.circle", "juliaBraid", in: fractalExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 458 | + .metal("Newton Vortex", icon: "tornado.circle", "newtonVortex", in: fractalExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 459 | + .metal("Phoenix Spiral", icon: "bird", "phoenixSpiral", in: fractalExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 460 | + .metal("Droste Fractal", icon: "square.on.square.dashed", "drosteFractal", in: fractalExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 461 | + .metal("Mandelbrot Wormhole", icon: "circle.circle.fill", "mandelbrotWormhole", in: fractalTunnelExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 462 | + .metal("Burning Ship Abyss", icon: "sailboat.circle", "burningShipAbyss", in: fractalTunnelExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 463 | + .metal("Fractal Double Helix", icon: "point.forward.to.point.capsulepath", "fractalDoubleHelix", in: fractalTunnelExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 464 | + .metal("Quaternion Bloom", icon: "circle.hexagonpath.fill", "quaternionBloom", in: fractalTunnelExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 465 | + .metal("Loxodrome Fractal", icon: "arrow.uturn.down.circle", "loxodromeFractal", in: fractalTunnelExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 466 | + .metal("Cascade Climb II", icon: "water.waves.and.arrow.up", "cascadeClimbII", in: flightIIExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.4, brightness: 1.2, fog: 0.25)), | |
| 467 | + .metal("Night Orbit II", icon: "globe", "nightOrbitII", in: flightIIExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 468 | + .metal("Cloud Sea II", icon: "cloud.fill", "cloudSeaII", in: flightIIExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.4, brightness: 1.35, fog: 0.25)), | |
| 469 | + .metal("Acrylic Cells II", icon: "paintpalette", "acrylicCellsII", in: materialIIExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0, brightness: 1.35, fog: 0.25)), | |
| 470 | + .metal("Molten Glass II", icon: "flask", "moltenGlassII", in: materialIIExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0, brightness: 1.35, fog: 0.25)), | |
| 471 | + .metal("Liquid Crystal II", icon: "circle.lefthalf.filled", "liquidCrystalII", in: materialIIExpansion, size: "Form scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0, brightness: 1.35, fog: 0.25)), | |
| 472 | + .metal("Incense Drift II", icon: "smoke", "incenseDriftII", in: materialIIExpansion, size: "Form scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0, brightness: 1.5, fog: 0.25)), | |
| 473 | + .metal("Heat Haze II", icon: "thermometer.sun", "heatHazeII", in: materialIIExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0, brightness: 1.35, fog: 0.25)), | |
| 474 | + .metal("Gel Overlap II", icon: "square.on.square", "gelOverlapII", in: materialIIExpansion, size: "Form scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0, brightness: 1.35, fog: 0.25)), | |
| 475 | + .metal("Holo Foil II", icon: "rectangle.portrait.on.rectangle.portrait.angled", "holoFoilII", in: materialIIExpansion, size: "Form scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0, brightness: 1.35, fog: 0.25)), | |
| 476 | + .metal("Opal Fire II", icon: "suit.diamond", "opalFireII", in: materialIIExpansion, size: "Form scale", travels: false, look: L(palette: 4, speed: 1, zoomSpeed: 0, brightness: 1.35, fog: 0.25)), | |
| 477 | + .metal("Raku Crackle II", icon: "rectangle.dashed", "rakuCrackleII", in: materialIIExpansion, size: "Form scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0, brightness: 1.35, fog: 0.25)), | |
| 478 | + .metal("Twin Suns II", icon: "sun.and.horizon", "twinSunsII", in: cosmosIIExpansion, size: "Structure scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0, brightness: 1.7, fog: 0.25)), | |
| 479 | + .metal("Supernova Shell II", icon: "staroflife.circle", "supernovaShellII", in: cosmosIIExpansion, size: "Structure scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0, brightness: 1.45, fog: 0.25)), | |
| 480 | + .metal("Galaxy Collision II", icon: "hurricane.circle", "galaxyCollisionII", in: cosmosIIExpansion, size: "Structure scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0, brightness: 1.6, fog: 0.25)), | |
| 481 | + .metal("Solar Prominence II", icon: "sun.dust", "solarProminenceII", in: cosmosIIExpansion, size: "Structure scale", travels: false, look: L(palette: 2, speed: 1, zoomSpeed: 0, brightness: 1.35, fog: 0.25)), | |
| 482 | + .metal("Quasar Jet II", icon: "arrow.up.and.down", "quasarJetII", in: cosmosIIExpansion, size: "Structure scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0, brightness: 1.35, fog: 0.25)), | |
| 483 | + .metal("Magnetosphere II", icon: "dot.radiowaves.left.and.right", "magnetosphereII", in: cosmosIIExpansion, size: "Structure scale", travels: false, look: L(palette: 3, speed: 1, zoomSpeed: 0, brightness: 1.35, fog: 0.25)), | |
| 484 | + .metal("Nebular Filaments II", icon: "network", "cosmicWebII", in: cosmosIIExpansion, size: "Structure scale", travels: false, look: L(palette: 0, speed: 1, zoomSpeed: 0, brightness: 1.35, fog: 0.25)), | |
| 485 | + .metal("Einstein Ring II", icon: "smallcircle.filled.circle", "einsteinRingII", in: cosmosIIExpansion, size: "Structure scale", travels: false, look: L(palette: 1, speed: 1, zoomSpeed: 0, brightness: 1.45, fog: 0.25)), | |
| 486 | + // Coaster versions (390–455): tunnels the owner picked to ride the roller-coaster course; | |
| 487 | + // the library lists each beside its original, which keeps its straight bore. | |
| 488 | + .metal("Plasma Bore Coaster", icon: "circle.dashed.inset.filled", "plasmaBoreCoaster", in: tunnels, size: "Plasma scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, fog: 0.45)), | |
| 489 | + .metal("LED Corridor Coaster", icon: "square.grid.4x3.fill", "ledCorridorCoaster", in: tunnels, size: "Pixel size", look: L(palette: 1, speed: 1, zoomSpeed: 1.4, fog: 0.4)), | |
| 490 | + .metal("Magma Tube Coaster", icon: "flame.fill", "magmaTubeCoaster", in: tunnels, size: "Crust scale", look: L(palette: 2, speed: 0.8, zoomSpeed: 1, fog: 0.45)), | |
| 491 | + .metal("Data Conduit Coaster", icon: "memorychip", "dataConduitCoaster", in: tunnels, size: "Trace width", look: L(palette: 4, speed: 1, zoomSpeed: 1.5, fog: 0.4)), | |
| 492 | + .metal("Helix Stair Coaster", icon: "stairs", "helixStairCoaster", in: tunnels, size: "Step size", look: L(palette: 0, speed: 0.8, zoomSpeed: 1, fog: 0.5)), | |
| 493 | + .metal("Laser Bore Coaster", icon: "bolt.horizontal.fill", "laserBoreCoaster", in: tunnels, size: "Beam width", look: L(palette: 1, speed: 1.1, zoomSpeed: 1.4, fog: 0.35)), | |
| 494 | + .metal("Twist Checker Coaster", icon: "checkerboard.rectangle", "twistCheckerCoaster", in: tunnels, size: "Tile size", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, fog: 0.4)), | |
| 495 | + .metal("Foam Tube Coaster", icon: "bubbles.and.sparkles.fill", "foamTubeCoaster", in: tunnels, size: "Bubble size", look: L(palette: 1, speed: 0.9, zoomSpeed: 1.1, fog: 0.45)), | |
| 496 | + .metal("Spectrum Bore Coaster", icon: "chart.bar.fill", "spectrumBoreCoaster", in: tunnels, size: "Bar width", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, fog: 0.4)), | |
| 497 | + .metal("Storm Eye Coaster", icon: "cloud.bolt.fill", "stormEyeCoaster", in: wormholes, size: "Cloud scale", look: L(palette: 3, speed: 0.9, zoomSpeed: 1.2, fog: 0.4)), | |
| 498 | + .metal("Sonar Pipe Coaster", icon: "dot.radiowaves.forward", "sonarPipeCoaster", in: wormholes, size: "Ring spacing", look: L(palette: 3, speed: 0.9, zoomSpeed: 1.2, fog: 0.45)), | |
| 499 | + .metal("Phyllo Tube Coaster", icon: "camera.filters", "phylloTubeCoaster", in: wormholes, size: "Dot size", look: L(palette: 4, speed: 0.9, zoomSpeed: 1.1, fog: 0.4)), | |
| 500 | + .metal("Tesla Tube Coaster", icon: "bolt.fill", "teslaTubeCoaster", in: wormholes, size: "Arc width", look: L(palette: 4, speed: 1, zoomSpeed: 1.2, fog: 0.4)), | |
| 501 | + .metal("Fold Tunnel Coaster", icon: "paperplane.fill", "foldTunnelCoaster", in: wormholes, size: "Fold scale", look: L(palette: 4, speed: 0.9, zoomSpeed: 1.1, fog: 0.45)), | |
| 502 | + .metal("Vector Tube Coaster", icon: "cylinder.split.1x2", "vectorTubeCoaster", in: wormholes, size: "Line width", look: L(palette: 1, speed: 1.1, zoomSpeed: 1.5, fog: 0.35)), | |
| 503 | + .metal("Mirrorball Tunnel Coaster", icon: "square.grid.3x3.square", "mirrorballTunnelCoaster", in: wormholes, size: "Tile size", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, fog: 0.4)), | |
| 504 | + .metal("Chroma Pipe Coaster", icon: "capsule.fill", "chromaPipeCoaster", in: wormholes, size: "Ring width", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, fog: 0.35)), | |
| 505 | + .metal("Rainbow Slide Coaster", icon: "figure.pool.swim", "rainbowSlideCoaster", in: wormholes, size: "Slide width", look: L(palette: 1, speed: 1.1, zoomSpeed: 1.6, fog: 0.3)), | |
| 506 | + .metal("Pulse Arteries Coaster", icon: "heart.fill", "pulseArteriesCoaster", in: wormholes, size: "Vessel width", look: L(palette: 2, speed: 0.9, zoomSpeed: 1.2, fog: 0.45)), | |
| 507 | + .metal("Pixel Tunnel Coaster", icon: "square.grid.2x2.fill", "pixelTunnelCoaster", in: wormholes, size: "Pixel size", look: L(palette: 1, speed: 1, zoomSpeed: 1.4, fog: 0.35)), | |
| 508 | + .metal("Geode Passage Coaster", icon: "diamond.fill", "geodePassageCoaster", in: wormholes, size: "Crystal size", look: L(palette: 3, speed: 0.8, zoomSpeed: 1, fog: 0.5)), | |
| 509 | + .metal("Saffron Spindle Coaster", icon: "rays", "saffronSpindleCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 510 | + .metal("Opaline Iris Coaster", icon: "camera.aperture", "opalineIrisCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 511 | + .metal("Electric Helicoid Coaster", icon: "arrow.triangle.2.circlepath", "electricHelicoidCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 512 | + .metal("Ultramarine Arcade Coaster", icon: "building.columns", "ultramarineArcadeCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 513 | + .metal("Fuchsia Furnace Coaster", icon: "gearshape", "fuchsiaFurnaceCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 514 | + .metal("Aurora Corkscrew Coaster", icon: "tornado", "auroraCorkscrewCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 515 | + .metal("Magenta Conduit Coaster", icon: "cpu", "magentaConduitCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 516 | + .metal("Sapphire Cascade Coaster", icon: "water.waves", "sapphireCascadeCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 517 | + .metal("Luminous Nautilus Coaster", icon: "tornado", "luminousNautilusCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 518 | + .metal("Golden Gyre Coaster", icon: "sun.max.fill", "goldenGyreCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 519 | + .metal("Fluid Odyssey Coaster", icon: "drop.triangle", "liquidLabyrinthCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 520 | + .metal("Astral Torque Coaster", icon: "circle.dotted.circle", "celestialCoilCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 521 | + .metal("Chrome Comet Coaster", icon: "sparkle", "chromeCometCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 522 | + .metal("Candy Cathedral Coaster", icon: "building.columns.circle", "candyCathedralCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 523 | + .metal("Scarlet Siphon Coaster", icon: "drop.fill", "scarletSiphonCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 524 | + .metal("Arctic Raceway Coaster", icon: "snowflake", "arcticRacewayCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 525 | + .metal("Plasma Passage Coaster", icon: "allergens", "plasmaPassageCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 526 | + .metal("Violet Velocity Coaster", icon: "arrow.forward.square", "violetVelocityCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 527 | + .metal("Cerulean Shell Coaster", icon: "fossil.shell", "ceruleanShellCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 528 | + .metal("Disco Helix Coaster", icon: "hexagon.fill", "discoHelixCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 529 | + .metal("Iridescent Descent Coaster", icon: "square.3.layers.3d", "iridescentDescentCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 530 | + .metal("Solar Serpent Coaster", icon: "scribble.variable", "solarSerpentCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 531 | + .metal("Rainbow Reactor Coaster", icon: "atom", "rainbowReactorCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 532 | + .metal("Crystal Carousel Coaster", icon: "cube.transparent", "crystalCarouselCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 533 | + .metal("Neon Maelstrom Coaster", icon: "hurricane", "neonMaelstromCoaster", in: passageExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 534 | + .metal("Ringworld Drift Coaster", icon: "circle.bottomhalf.filled", "ringworldDriftCoaster", in: boreExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 535 | + .metal("Twin Bore Coaster", icon: "circle.circle", "twinBoreCoaster", in: boreExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 536 | + .metal("Coil Run Coaster", icon: "rotate.3d", "coilRunCoaster", in: boreExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.2, fog: 0.25)), | |
| 537 | + .metal("Bellows Passage Coaster", icon: "rectangle.compress.vertical", "bellowsPassageCoaster", in: boreExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 538 | + .metal("Branching Bore Coaster", icon: "arrow.triangle.branch", "branchingBoreCoaster", in: boreExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.5, fog: 0.25)), | |
| 539 | + .metal("Skyward Shaft Coaster", icon: "arrow.up.to.line", "skywardShaftCoaster", in: boreExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 540 | + .metal("Veil Passage Coaster", icon: "curtains.open", "veilPassageCoaster", in: boreExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 541 | + .metal("Chainmail Bore Coaster", icon: "link", "chainmailBoreCoaster", in: portalExpansion, size: "Structure scale", look: L(palette: 3, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 542 | + .metal("Feather Vault Coaster", icon: "leaf", "featherVaultCoaster", in: portalExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 543 | + .metal("Tartan Tube Coaster", icon: "squareshape.split.3x3", "tartanTubeCoaster", in: portalExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 544 | + .metal("Herringbone Hall Coaster", icon: "chevron.up.chevron.down", "herringboneHallCoaster", in: portalExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 545 | + .metal("Quilted Pipe Coaster", icon: "square.grid.3x3.middle.filled", "quiltedPipeCoaster", in: portalIIExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 546 | + .metal("Lace Funnel Coaster", icon: "seal.fill", "laceFunnelCoaster", in: portalExpansion, size: "Structure scale", look: L(palette: 4, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 547 | + .metal("Zipper Run Coaster", icon: "arrow.left.and.right", "zipperRunCoaster", in: portalExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 548 | + .metal("Cable Knit Tube Coaster", icon: "line.3.crossed.swirl.circle", "cableKnitTubeCoaster", in: portalExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 549 | + .metal("Basket Weave Burrow Coaster", icon: "basket", "basketWeaveBurrowCoaster", in: portalExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 550 | + .metal("Louvre Tunnel Coaster", icon: "blinds.horizontal.open", "louvreTunnelCoaster", in: portalExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 551 | + .metal("Mandelbrot Wormhole Coaster", icon: "circle.circle.fill", "mandelbrotWormholeCoaster", in: fractalTunnelExpansion, size: "Structure scale", look: L(palette: 1, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 552 | + .metal("Burning Ship Abyss Coaster", icon: "sailboat.circle", "burningShipAbyssCoaster", in: fractalTunnelExpansion, size: "Structure scale", look: L(palette: 2, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 553 | + .metal("Fractal Double Helix Coaster", icon: "point.forward.to.point.capsulepath", "fractalDoubleHelixCoaster", in: fractalTunnelExpansion, size: "Structure scale", look: L(palette: 0, speed: 1, zoomSpeed: 1.3, brightness: 1.35, fog: 0.25)), | |
| 554 | + | |
| 555 | + // Atmospheric series (456–461). Saved scene IDs are append-only. | |
| 556 | + .metal("Backlit Rift", icon: "cloud.bolt", "smokeFrame", in: atmospheric, size: "Cloud scale", look: L(palette: 4, brightness: 1)), | |
| 557 | + .metal("Undersurface", icon: "water.waves", "undersurface", in: atmospheric, size: "Water depth", travels: false, look: L(palette: 3, zoomSpeed: 0, brightness: 1)), | |
| 558 | + .metal("Mercury Ribbon", icon: "drop.degreesign", "mercuryFold", in: atmospheric, size: "Ribbon scale", travels: false, look: L(palette: 3, zoomSpeed: 0, brightness: 1)), | |
| 559 | + .metal("Ember Front", icon: "sparkles", "emberFront", in: atmospheric, size: "Particle size", look: L(palette: 2, brightness: 1)), | |
| 560 | + .metal("Anvil Flyover", icon: "cloud.sun", "anvilFlyover", in: atmospheric, size: "Camera altitude", look: L(palette: 0, brightness: 1)), | |
| 561 | + .metal("Pigment Strata", icon: "paintbrush.pointed", "pigmentStrata", in: atmospheric, size: "Curl scale", travels: false, look: L(palette: 2, zoomSpeed: 0, brightness: 1)), | |
| 562 | + ] | |
| 563 | + | |
| 564 | + /// Studio's automatic timeline order: released and new designs interleaved so that | |
| 565 | + /// neighbouring sections differ in family, composition and color. | |
| 566 | + static let timelineOrder: [Int] = [ | |
| 567 | + 101, 425, 201, 91, 440, 300, 202, 100, 448, 426, 203, 427, 370, 310, 428, 184, 394, 453, 204, 33, | |
| 568 | + 320, 205, 429, 360, 206, 430, 117, 330, 207, 431, 84, 432, 371, 433, 208, 340, 441, 118, 434, 449, | |
| 569 | + 209, 435, 210, 350, 185, 211, 212, 301, 454, 98, 213, 372, 64, 311, 214, 215, 102, 321, 216, 361, | |
| 570 | + 22, 218, 331, 220, 373, 119, 221, 442, 341, 222, 405, 450, 223, 224, 351, 103, 225, 226, 302, 455, | |
| 571 | + 227, 374, 228, 229, 312, 120, 395, 230, 187, 322, 231, 362, 232, 233, 332, 375, 104, 234, 18, 342, | |
| 572 | + 235, 236, 451, 237, 352, 238, 239, 396, 61, 303, 376, 406, 240, 121, 241, 397, 313, 242, 188, 243, | |
| 573 | + 323, 244, 363, 31, 105, 377, 333, 246, 74, 247, 407, 343, 248, 249, 250, 353, 122, 251, 23, 408, | |
| 574 | + 378, 452, 304, 252, 398, 43, 253, 314, 189, 254, 255, 256, 364, 409, 25, 257, 379, 334, 106, 258, | |
| 575 | + 260, 344, 261, 123, 410, 411, 263, 354, 46, 264, 391, 265, 420, 380, 305, 266, 85, 390, 267, 315, | |
| 576 | + 268, 107, 443, 269, 325, 270, 365, 17, 399, 381, 271, 335, 272, 80, 273, 345, 400, 92, 274, 275, | |
| 577 | + 355, 276, 124, 382, 278, 306, 279, 141, 280, 316, 29, 281, 282, 436, 326, 283, 366, 383, 284, 285, | |
| 578 | + 444, 336, 81, 286, 21, 346, 287, 125, 288, 356, 60, 384, 289, 192, 307, 290, 291, 292, 401, 317, | |
| 579 | + 28, 293, 437, 109, 327, 294, 385, 367, 88, 445, 295, 337, 176, 296, 297, 347, 298, 299, 193, 357, | |
| 580 | + 386, 24, 42, 110, 308, 83, 127, 402, 72, 318, 86, 111, 178, 438, 328, 387, 26, 368, 16, 392, | |
| 581 | + 48, 446, 338, 412, 112, 413, 179, 19, 348, 414, 415, 129, 12, 113, 388, 416, 403, 358, 180, 27, | |
| 582 | + 130, 309, 197, 417, 10, 114, 439, 319, 15, 418, 131, 447, 79, 389, 329, 419, 182, 369, 132, 20, | |
| 583 | + 421, 393, 339, 47, 50, 183, 349, 422, 404, 32, 423, 133, 245, 424, 359, 259, | |
| 584 | + 456, 457, 458, 459, 460, 461, | |
| 585 | + ] | |
| 586 | + | |
| 587 | + static var names: [String] { all.map(\.name) } | |
| 588 | + /// Theme metadata for the shared filter. Permanent IDs and catalog order stay unchanged. | |
| 589 | + static func category(for scene: Int) -> String { | |
| 590 | + guard let effect = effect(resolved(scene)) else { return "Other native" } | |
| 591 | + switch effect.file { | |
| 592 | + case flow, materialExpansion, materialIIExpansion: return "Liquid & flow" | |
| 593 | + case atmospheric: | |
| 594 | + switch effect.shader { | |
| 595 | + case "smokeFrame": return "Tunnels" | |
| 596 | + case "emberFront": return "Particles" | |
| 597 | + case "anvilFlyover": return "Nature & space" | |
| 598 | + default: return "Liquid & flow" | |
| 599 | + } | |
| 600 | + case structure: return "Geometric" | |
| 601 | + case geometry: | |
| 602 | + return effect.shader.map { ["mandelBloom", "mengerNave"].contains($0) } == true ? "Fractal" : "Geometric" | |
| 603 | + case particles: return "Particles" | |
| 604 | + case nature, cosmosExpansion, cosmosIIExpansion: return "Nature & space" | |
| 605 | + case tunnels, wormholes, voyageExpansion, passageExpansion, boreExpansion, | |
| 606 | + portalExpansion, portalIIExpansion, fractalTunnelExpansion: return "Tunnels" | |
| 607 | + case drive, driveExpansion, flightExpansion, flightIIExpansion: return "Drive & flight" | |
| 608 | + case dance, rave, danceExpansion, festivalExpansion, kineticExpansion: return "Dancer" | |
| 609 | + case fractalExpansion: return "Fractal" | |
| 610 | + default: | |
| 611 | + switch resolved(scene) { | |
| 612 | + case 10, 23: return "Liquid & flow" | |
| 613 | + case 12, 16: return "Nature & space" | |
| 614 | + case 15, 20, 21: return "Geometric" | |
| 615 | + case 17, 18, 24: return "Waveform" | |
| 616 | + case 19, 26, 28: return "Particles" | |
| 617 | + case 22, 25, 27, 29: return "Tunnels" | |
| 618 | + default: return "Other native" | |
| 619 | + } | |
| 620 | + } | |
| 621 | + } | |
| 622 | + static func effect(_ scene: Int) -> NativeEffect? { all.indices.contains(scene) ? all[scene] : nil } | |
| 623 | + static func isRetired(_ scene: Int) -> Bool { effect(scene)?.replacement != nil } | |
| 624 | + /// The design shown for a scene ID: retired designs open their replacement. | |
| 625 | + static func resolved(_ scene: Int) -> Int { effect(scene)?.replacement ?? scene } | |
| 626 | + /// Native IDs offered in the library, timeline and random choices. | |
| 627 | + static let activeIDs: [Int] = all.indices.filter { all[$0].replacement == nil } | |
| 628 | + /// Designs with a Coaster version; the Coaster of `coasterSources[i]` is scene `firstCoaster + i`. | |
| 629 | + static let firstCoaster = 390 | |
| 630 | + static let coasterSources: [Int] = [100, 101, 105, 106, 107, 109, 110, 111, 114, 117, 118, 120, 121, 122, 123, 125, 127, 129, 130, 132, 133, 245, 246, 247, 248, 249, 251, 253, 255, 257, 259, 260, 263, 264, 265, 266, 268, 269, 270, 272, 273, 274, 275, 276, 278, 279, 301, 302, 303, 304, 305, 306, 307, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 365, 366, 367] | |
| 631 | + /// Library order: offered designs by ID, each Coaster version right after its original. | |
| 632 | + static let libraryOrder: [Int] = { | |
| 633 | + let coasters = Dictionary(uniqueKeysWithValues: coasterSources.enumerated().map { ($0.element, firstCoaster + $0.offset) }) | |
| 634 | + let coasterRange = firstCoaster..<(firstCoaster + coasterSources.count) | |
| 635 | + return activeIDs.filter { !coasterRange.contains($0) }.flatMap { [$0] + (coasters[$0].map { [$0] } ?? []) } | |
| 636 | + }() | |
| 637 | + /// The design a new session opens with. | |
| 638 | + static var defaultScene: Int { timelineOrder[0] } | |
| 639 | + } |
Sources/PulseCanvas/OriginalGeometry.swift added
| 1 | + import Foundation | |
| 2 | + import simd | |
| 3 | + | |
| 4 | + struct OriginalVertex: Sendable { | |
| 5 | + var position: SIMD3<Float> | |
| 6 | + var color: SIMD4<Float> | |
| 7 | + var uv: SIMD2<Float> | |
| 8 | + } | |
| 9 | + | |
| 10 | + /// Original PulseCanvas designs. Pure functions let preview, seeking and export | |
| 11 | + /// produce the same geometry for the same soundtrack spectrum and timestamp. | |
| 12 | + enum OriginalGeometry { | |
| 13 | + typealias Vertex = OriginalVertex | |
| 14 | + enum Primitive: Sendable { case points, triangles } | |
| 15 | + struct Mesh: Sendable { | |
| 16 | + var vertices: [Vertex] | |
| 17 | + var indices: [UInt32] | |
| 18 | + var primitive: Primitive | |
| 19 | + var pointSize: Float = 0.055 | |
| 20 | + } | |
| 21 | + enum Scene: Int, CaseIterable, Sendable { | |
| 22 | + case audioMandala = 15 | |
| 23 | + case orbitalRings = 16 | |
| 24 | + case ribbonWave = 17 | |
| 25 | + case spectralHelix = 18 | |
| 26 | + case particleFountain = 19 | |
| 27 | + case pulseGrid = 20 | |
| 28 | + case harmonicBloom = 21 | |
| 29 | + | |
| 30 | + var title: String { | |
| 31 | + switch self { | |
| 32 | + case .audioMandala: return "Lotus Resonance" | |
| 33 | + case .orbitalRings: return "Orbit Loom" | |
| 34 | + case .ribbonWave: return "Silk Current" | |
| 35 | + case .spectralHelix: return "Double Twist" | |
| 36 | + case .particleFountain: return "Arc Spray" | |
| 37 | + case .pulseGrid: return "Signal Tiles" | |
| 38 | + case .harmonicBloom: return "Resonant Shell" | |
| 39 | + } | |
| 40 | + } | |
| 41 | + } | |
| 42 | + static var sceneNames: [String] { Scene.allCases.map(\.title) } | |
| 43 | + | |
| 44 | + static func make(scene: Int, time: Float, spectrum: [Float], intensity: Float = 1, palette: Int = 0) -> Mesh { | |
| 45 | + let time = time.isFinite ? max(-100_000, min(100_000, time)) : 0 | |
| 46 | + let intensity = intensity.isFinite ? max(0, min(3, intensity)) : 1 | |
| 47 | + let audio = Audio(spectrum: spectrum, intensity: intensity) | |
| 48 | + switch Scene(rawValue: scene) { | |
| 49 | + case .audioMandala: return mandala(time: time, audio: audio, palette: palette) | |
| 50 | + case .orbitalRings: return orbits(time: time, audio: audio, palette: palette) | |
| 51 | + case .ribbonWave: return ribbons(time: time, audio: audio, palette: palette) | |
| 52 | + case .spectralHelix: return helix(time: time, audio: audio, palette: palette) | |
| 53 | + case .particleFountain: return fountain(time: time, audio: audio, palette: palette) | |
| 54 | + case .pulseGrid: return grid(time: time, audio: audio, palette: palette) | |
| 55 | + case .harmonicBloom: return bloom(time: time, audio: audio, palette: palette) | |
| 56 | + case nil: return Mesh(vertices: [], indices: [], primitive: .triangles) | |
| 57 | + } | |
| 58 | + } | |
| 59 | + | |
| 60 | + private struct Audio { | |
| 61 | + let bands: [Float] | |
| 62 | + let intensity: Float | |
| 63 | + init(spectrum: [Float], intensity: Float) { | |
| 64 | + bands = spectrum.isEmpty ? [0] : spectrum.map { $0.isFinite ? min(1, max(0, $0)) : 0 } | |
| 65 | + self.intensity = intensity | |
| 66 | + } | |
| 67 | + func at(_ position: Float) -> Float { | |
| 68 | + let index = max(0, min(1, position)) * Float(bands.count - 1) | |
| 69 | + let lower = Int(index), upper = min(lower + 1, bands.count - 1) | |
| 70 | + return (bands[lower] + (bands[upper] - bands[lower]) * (index - Float(lower))) * intensity | |
| 71 | + } | |
| 72 | + var bass: Float { | |
| 73 | + let count = max(1, bands.count / 5) | |
| 74 | + return bands.prefix(count).reduce(0, +) / Float(count) * intensity | |
| 75 | + } | |
| 76 | + } | |
| 77 | + | |
| 78 | + private static let turn = Float.pi * 2 | |
| 79 | + private static func color(_ phase: Float, energy: Float, palette: Int, alpha: Float = 1) -> SIMD4<Float> { | |
| 80 | + var result = VisualPalette.color(phase, palette: palette) | |
| 81 | + let light = min(1, 0.4 + energy * 0.6) | |
| 82 | + result.x *= light; result.y *= light; result.z *= light; result.w = alpha | |
| 83 | + return result | |
| 84 | + } | |
| 85 | + private static func vertex(_ position: SIMD3<Float>, phase: Float, energy: Float, palette: Int, uv: SIMD2<Float> = .zero) -> Vertex { | |
| 86 | + Vertex(position: position, color: color(phase, energy: energy, palette: palette), uv: uv) | |
| 87 | + } | |
| 88 | + private static func stripIndices(rows: Int, columns: Int) -> [UInt32] { | |
| 89 | + var result: [UInt32] = [] | |
| 90 | + result.reserveCapacity(rows * columns * 6) | |
| 91 | + for row in 0..<rows { | |
| 92 | + for column in 0..<columns { | |
| 93 | + let first = UInt32(row * (columns + 1) + column) | |
| 94 | + let next = first + UInt32(columns + 1) | |
| 95 | + result.append(contentsOf: [first, next, first + 1, first + 1, next, next + 1]) | |
| 96 | + } | |
| 97 | + } | |
| 98 | + return result | |
| 99 | + } | |
| 100 | + | |
| 101 | + /// Concentric rosettes with twelve petal lobes, radial bass breathing and | |
| 102 | + /// angle-local frequency displacement. The open center preserves its silhouette. | |
| 103 | + private static func mandala(time: Float, audio: Audio, palette: Int) -> Mesh { | |
| 104 | + let rings = 11, segments = 192 | |
| 105 | + var vertices: [Vertex] = [], indices: [UInt32] = [] | |
| 106 | + vertices.reserveCapacity(rings * (segments + 1) * 2) | |
| 107 | + for ring in 0..<rings { | |
| 108 | + let ringPosition = Float(ring) / Float(rings - 1) | |
| 109 | + let baseRadius = 1.1 + ringPosition * 9.2 | |
| 110 | + for side in 0...1 { | |
| 111 | + for segment in 0...segments { | |
| 112 | + let u = Float(segment) / Float(segments) | |
| 113 | + let angle = u * turn + time * (ring.isMultiple(of: 2) ? 0.07 : -0.05) | |
| 114 | + let band = audio.at((1 - cos(u * turn)) * 0.5) | |
| 115 | + let petal = cos(angle * 12 + time * 0.4 + ringPosition * .pi) | |
| 116 | + let radius = baseRadius + petal * (0.22 + band * 0.45) + audio.bass * 0.25 + Float(side) * (0.09 + band * 0.2) | |
| 117 | + let position = SIMD3(radius * cos(angle), radius * sin(angle), sin(angle * 6 + time * 0.6) * (0.15 + band * 0.4)) | |
| 118 | + vertices.append(vertex(position, phase: ringPosition * 0.5 + u * 0.25 + time * 0.015, energy: band, palette: palette, uv: SIMD2(u * 8, Float(side)))) | |
| 119 | + } | |
| 120 | + } | |
| 121 | + let start = UInt32(ring * (segments + 1) * 2) | |
| 122 | + for segment in 0..<segments { | |
| 123 | + let a = start + UInt32(segment), b = a + UInt32(segments + 1) | |
| 124 | + indices.append(contentsOf: [a, b, a + 1, a + 1, b, b + 1]) | |
| 125 | + } | |
| 126 | + } | |
| 127 | + return Mesh(vertices: vertices, indices: indices, primitive: .triangles) | |
| 128 | + } | |
| 129 | + | |
| 130 | + /// Tilted tubular rings orbit along different axes, with each arc swelling | |
| 131 | + /// from its own spectral band instead of a single global beat scalar. | |
| 132 | + private static func orbits(time: Float, audio: Audio, palette: Int) -> Mesh { | |
| 133 | + let rings = 7, segments = 144, tubeSegments = 8 | |
| 134 | + var vertices: [Vertex] = [], indices: [UInt32] = [] | |
| 135 | + for ring in 0..<rings { | |
| 136 | + let f = Float(ring) / Float(rings - 1) | |
| 137 | + let tilt = -1.1 + f * 2.2 + sin(time * 0.22 + f * turn) * 0.18 | |
| 138 | + let spin = time * (0.08 + f * 0.08) + f * .pi | |
| 139 | + let baseRadius = 3.2 + f * 7 | |
| 140 | + for segment in 0...segments { | |
| 141 | + let u = Float(segment) / Float(segments), angle = u * turn | |
| 142 | + let energy = audio.at((1 - cos(u * turn)) * 0.325 + f * 0.35) | |
| 143 | + let radius = baseRadius + energy * 0.65 + audio.bass * 0.25 | |
| 144 | + for edge in 0...tubeSegments { | |
| 145 | + let v = Float(edge) / Float(tubeSegments), tubeAngle = v * turn | |
| 146 | + let thickness = 0.07 + energy * 0.17 | |
| 147 | + let x = cos(angle) * (radius + cos(tubeAngle) * thickness) | |
| 148 | + let y = sin(angle) * (radius + cos(tubeAngle) * thickness) | |
| 149 | + let z = sin(tubeAngle) * thickness | |
| 150 | + let tiltedY = y * cos(tilt) - z * sin(tilt) | |
| 151 | + let tiltedZ = y * sin(tilt) + z * cos(tilt) | |
| 152 | + let position = SIMD3(x * cos(spin) - tiltedY * sin(spin), x * sin(spin) + tiltedY * cos(spin), tiltedZ) | |
| 153 | + vertices.append(vertex(position, phase: f * 0.7 + u * 0.35 + time * 0.012, energy: energy, palette: palette, uv: SIMD2(u * 6, v))) | |
| 154 | + } | |
| 155 | + } | |
| 156 | + let offset = UInt32(ring * (segments + 1) * (tubeSegments + 1)) | |
| 157 | + indices.append(contentsOf: stripIndices(rows: segments, columns: tubeSegments).map { $0 + offset }) | |
| 158 | + } | |
| 159 | + return Mesh(vertices: vertices, indices: indices, primitive: .triangles) | |
| 160 | + } | |
| 161 | + | |
| 162 | + /// Twisting silk sails flow in depth, with broad folds and frequency-driven crests. | |
| 163 | + private static func ribbons(time: Float, audio: Audio, palette: Int) -> Mesh { | |
| 164 | + let strips = 8, segments = 180, edges = 4 | |
| 165 | + var vertices: [Vertex] = [], indices: [UInt32] = [] | |
| 166 | + for strip in 0..<strips { | |
| 167 | + let f = Float(strip) / Float(strips) | |
| 168 | + for segment in 0...segments { | |
| 169 | + let u = Float(segment) / Float(segments), energy = audio.at(u) | |
| 170 | + let angle = f * turn + u * turn * 0.8 - time * 0.6 | |
| 171 | + let wave = sin(u * turn * 2.3 - time * 1.4 + f * 3) * (1.4 + energy * 2.2) | |
| 172 | + let radius = 6.5 + wave + audio.bass * 0.7 | |
| 173 | + for edge in 0...edges { | |
| 174 | + let across = Float(edge) / Float(edges) - 0.5 | |
| 175 | + let width = 1.2 + energy * 1.8 | |
| 176 | + let fold = sin(across * .pi * 2 + u * 8 - time) * width * 0.65 | |
| 177 | + let position = SIMD3(cos(angle) * radius - sin(angle) * across * width, | |
| 178 | + sin(angle) * radius + cos(angle) * across * width, | |
| 179 | + -18 + u * 36 + fold) | |
| 180 | + vertices.append(vertex(position, phase: u * 0.45 + f * 0.45 + time * 0.025, | |
| 181 | + energy: energy, palette: palette, uv: SIMD2(u * 6, Float(edge) / Float(edges)))) | |
| 182 | + } | |
| 183 | + } | |
| 184 | + let offset = UInt32(strip * (segments + 1) * (edges + 1)) | |
| 185 | + indices.append(contentsOf: stripIndices(rows: segments, columns: edges).map { $0 + offset }) | |
| 186 | + } | |
| 187 | + return Mesh(vertices: vertices, indices: indices, primitive: .triangles) | |
| 188 | + } | |
| 189 | + | |
| 190 | + /// Four substantial coils and discrete cross-rungs make a recognizable | |
| 191 | + /// double-helix ball sculpture, even in a narrow portrait preview. | |
| 192 | + private static func helix(time: Float, audio: Audio, palette: Int) -> Mesh { | |
| 193 | + let strands = 4, segments = 256, lanes = 1 | |
| 194 | + var vertices: [Vertex] = [] | |
| 195 | + vertices.reserveCapacity(strands * segments * lanes + 1408) | |
| 196 | + for strand in 0..<strands { | |
| 197 | + for segment in 0..<segments { | |
| 198 | + let u = Float(segment) / Float(segments - 1) | |
| 199 | + let energy = audio.at(u) | |
| 200 | + let angle = u * turn * 2.6 + Float(strand) * .pi / 2 + time * 0.95 | |
| 201 | + let radius = 3.15 + audio.bass * 0.75 + energy * 0.42 | |
| 202 | + let y = -10.3 + u * 20.6 | |
| 203 | + for lane in 0..<lanes { | |
| 204 | + let crossAngle = Float(lane) / Float(lanes) * turn | |
| 205 | + let thickness = 0.13 + energy * 0.045 | |
| 206 | + let laneRadius = radius + cos(crossAngle) * thickness | |
| 207 | + let ripple = sin(u * turn * 18 + time * 2.8) * energy * 0.08 | |
| 208 | + let position = SIMD3(cos(angle) * laneRadius + ripple, y + sin(crossAngle) * thickness, sin(angle) * laneRadius) | |
| 209 | + vertices.append(vertex(position, phase: u * 0.5 + Float(strand) * 0.17 + time * 0.018, energy: energy, palette: palette)) | |
| 210 | + } | |
| 211 | + } | |
| 212 | + } | |
| 213 | + // Open rungs bridge opposite coils; spacing keeps clear negative space | |
| 214 | + // between levels instead of turning the center into a solid cylinder. | |
| 215 | + for level in 0..<32 { | |
| 216 | + let u = (Float(level) + 0.5) / 32 | |
| 217 | + let energy = audio.at(u) | |
| 218 | + let y = -10.3 + u * 20.6 | |
| 219 | + let radius = 3.15 + audio.bass * 0.75 + energy * 0.42 | |
| 220 | + for pair in 0..<2 { | |
| 221 | + let angle = u * turn * 2.6 + Float(pair) * .pi / 2 + time * 0.95 | |
| 222 | + for sample in 0..<14 { | |
| 223 | + let across = -1 + Float(sample) / 13 * 2 | |
| 224 | + let position = SIMD3(cos(angle) * radius * across, y + sin(across * .pi) * energy * 0.12, sin(angle) * radius * across) | |
| 225 | + vertices.append(vertex(position, phase: u * 0.5 + Float(pair) * 0.17 + time * 0.018, energy: energy * 0.7, palette: palette)) | |
| 226 | + } | |
| 227 | + } | |
| 228 | + } | |
| 229 | + vertices.sort { $0.position.z < $1.position.z } | |
| 230 | + return Mesh(vertices: vertices, indices: [], primitive: .points, pointSize: 0.8) | |
| 231 | + } | |
| 232 | + | |
| 233 | + /// Eight connected swirling plumes rise through the full centered frame. | |
| 234 | + /// Ordered flow lanes retain a strong vase-shaped silhouette, while depth | |
| 235 | + /// separates foreground balls from the smaller background arms. | |
| 236 | + private static func fountain(time: Float, audio: Audio, palette: Int) -> Mesh { | |
| 237 | + let arms = 8, samples = 192, lanes = 1 | |
| 238 | + var vertices: [Vertex] = [] | |
| 239 | + vertices.reserveCapacity(arms * samples * lanes + 1024) | |
| 240 | + for arm in 0..<arms { | |
| 241 | + let armPhase = Float(arm) / Float(arms) | |
| 242 | + let phaseOffset = random(UInt32(arm) &+ 43) * 0.12 | |
| 243 | + for sample in 0..<samples { | |
| 244 | + let u = fraction(Float(sample) / Float(samples) + time * 0.055) | |
| 245 | + let energy = audio.at(armPhase * 0.55 + u * 0.45) | |
| 246 | + let belly = pow(max(0, sin(u * .pi)), 0.85) | |
| 247 | + let radius = 1.15 + belly * (5.3 + energy * 0.6) + u * 0.8 + audio.bass * 0.25 | |
| 248 | + let angle = armPhase * turn + u * turn * 0.8 + time * 0.2 + phaseOffset | |
| 249 | + let y = -10 + u * 20 | |
| 250 | + for lane in 0..<lanes { | |
| 251 | + let laneOffset = Float(lane) - Float(lanes - 1) * 0.5 | |
| 252 | + let laneRadius = radius + laneOffset * (0.12 + energy * 0.025) | |
| 253 | + let laneAngle = angle + laneOffset * 0.016 | |
| 254 | + let position = SIMD3(cos(laneAngle) * laneRadius, y + laneOffset * 0.025, sin(laneAngle) * laneRadius) | |
| 255 | + vertices.append(vertex(position, phase: armPhase * 0.8 + u * 0.25 + time * 0.018, energy: energy, palette: palette)) | |
| 256 | + } | |
| 257 | + } | |
| 258 | + } | |
| 259 | + // The central rising braid connects the outer plumes into one object, | |
| 260 | + // rather than leaving unrelated droplets scattered across the canvas. | |
| 261 | + for strand in 0..<4 { | |
| 262 | + for sample in 0..<192 { | |
| 263 | + let u = fraction(Float(sample) / 192 + time * 0.075) | |
| 264 | + let energy = audio.at(u) | |
| 265 | + let angle = Float(strand) * .pi / 2 - u * turn * 1.6 - time * 0.28 | |
| 266 | + let radius = 0.6 + sin(u * .pi) * (0.8 + audio.bass * 0.2) + energy * 0.12 | |
| 267 | + let position = SIMD3(cos(angle) * radius, -9.8 + u * 19.6, sin(angle) * radius) | |
| 268 | + vertices.append(vertex(position, phase: u * 0.45 + Float(strand) * 0.15 + time * 0.018, energy: energy, palette: palette)) | |
| 269 | + } | |
| 270 | + } | |
| 271 | + // Alpha-over sprites paint far layers before the near sphere surfaces. | |
| 272 | + vertices.sort { $0.position.z < $1.position.z } | |
| 273 | + return Mesh(vertices: vertices, indices: [], primitive: .points, pointSize: 1.0) | |
| 274 | + } | |
| 275 | + | |
| 276 | + /// A square field of isolated luminous tiles. Each frequency raises a row, | |
| 277 | + /// with travelling diagonal pulses driven by bass and local band energy. | |
| 278 | + private static func grid(time: Float, audio: Audio, palette: Int) -> Mesh { | |
| 279 | + let side = 32 | |
| 280 | + var vertices: [Vertex] = [], indices: [UInt32] = [] | |
| 281 | + vertices.reserveCapacity(side * side * 4) | |
| 282 | + for row in 0..<side { | |
| 283 | + let v = Float(row) / Float(side - 1) | |
| 284 | + for column in 0..<side { | |
| 285 | + let u = Float(column) / Float(side - 1) | |
| 286 | + let energy = audio.at(u) | |
| 287 | + let pulse = (sin((u + v) * turn * 2 - time * 1.5) + 1) * 0.5 | |
| 288 | + let z = energy * 2.8 + pulse * audio.bass * 1.2 - 1.4 | |
| 289 | + let x = -10.8 + u * 21.6, y = -10.8 + v * 21.6 | |
| 290 | + let size = 0.18 + 0.065 * energy + 0.05 * pulse | |
| 291 | + let offset = UInt32(vertices.count) | |
| 292 | + for corner in [SIMD2<Float>(-1, -1), SIMD2<Float>(1, -1), SIMD2<Float>(-1, 1), SIMD2<Float>(1, 1)] { | |
| 293 | + vertices.append(vertex(SIMD3(x + corner.x * size, y + corner.y * size, z), phase: u * 0.55 + v * 0.25 + time * 0.02, energy: energy + pulse * audio.bass * 0.2, palette: palette, uv: (corner + SIMD2(repeating: 1)) * 0.5)) | |
| 294 | + } | |
| 295 | + indices.append(contentsOf: [offset, offset + 1, offset + 2, offset + 2, offset + 1, offset + 3]) | |
| 296 | + } | |
| 297 | + } | |
| 298 | + return Mesh(vertices: vertices, indices: indices, primitive: .triangles) | |
| 299 | + } | |
| 300 | + | |
| 301 | + /// A closed three-dimensional flower with five major lobes, a twisting pole | |
| 302 | + /// and frequency-resolved petal ridges across its longitude. | |
| 303 | + private static func bloom(time: Float, audio: Audio, palette: Int) -> Mesh { | |
| 304 | + let rings = 40, segments = 96 | |
| 305 | + var vertices: [Vertex] = [] | |
| 306 | + vertices.reserveCapacity((rings + 1) * (segments + 1)) | |
| 307 | + for ring in 0...rings { | |
| 308 | + let v = Float(ring) / Float(rings), theta = v * .pi | |
| 309 | + for segment in 0...segments { | |
| 310 | + let u = Float(segment) / Float(segments), phi = u * turn | |
| 311 | + let energy = audio.at((1 - cos(u * turn)) * 0.5) | |
| 312 | + let petals = cos(phi * 5 + time * 0.3) * sin(theta) * sin(theta) | |
| 313 | + let radius = 6.6 + petals * (1.25 + energy * 0.6) + sin(theta * 8 - time * 0.75) * energy * 0.45 + audio.bass * 0.4 | |
| 314 | + let twist = phi + cos(theta) * (0.22 + sin(time * 0.2) * 0.15) | |
| 315 | + let position = SIMD3(sin(theta) * cos(twist) * radius, cos(theta) * radius * 1.2, sin(theta) * sin(twist) * radius) | |
| 316 | + vertices.append(vertex(position, phase: u * 0.7 + v * 0.3 + time * 0.015, energy: energy, palette: palette, uv: SIMD2(u * 4, v * 3))) | |
| 317 | + } | |
| 318 | + } | |
| 319 | + return Mesh(vertices: vertices, indices: stripIndices(rows: rings, columns: segments), primitive: .triangles) | |
| 320 | + } | |
| 321 | + | |
| 322 | + private static func fraction(_ value: Float) -> Float { value - floor(value) } | |
| 323 | + private static func random(_ seed: UInt32) -> Float { | |
| 324 | + var value = seed &+ 0x9e3779b9 | |
| 325 | + value = (value ^ (value >> 16)) &* 0x85ebca6b | |
| 326 | + value = (value ^ (value >> 13)) &* 0xc2b2ae35 | |
| 327 | + value ^= value >> 16 | |
| 328 | + return Float(value >> 8) / Float(1 << 24) | |
| 329 | + } | |
| 330 | + } |
Sources/PulseCanvas/ProjectMPresets.swift added
| 1 | + import Foundation | |
| 2 | + import Combine | |
| 3 | + | |
| 4 | + struct ProjectMError: LocalizedError { | |
| 5 | + let message: String | |
| 6 | + init(_ message: String) {self.message = message} | |
| 7 | + var errorDescription: String? {message} | |
| 8 | + } | |
| 9 | + | |
| 10 | + struct ProjectMPreset: Codable, Identifiable { | |
| 11 | + let id: String | |
| 12 | + let path: String | |
| 13 | + let title: String | |
| 14 | + let category: String | |
| 15 | + var originalTitle: String? = nil | |
| 16 | + var icon: String? = nil | |
| 17 | + } | |
| 18 | + | |
| 19 | + /// The shared group scopes browsing and fresh visualizer assignments. | |
| 20 | + enum VisualizerRandomizerGroup: Hashable, Codable { | |
| 21 | + case all | |
| 22 | + case favorites | |
| 23 | + case category(String) | |
| 24 | + case custom | |
| 25 | + | |
| 26 | + var title: String { | |
| 27 | + switch self { | |
| 28 | + case .all: return String(localized: "Randomize all") | |
| 29 | + case .favorites: return String(localized: "Randomize favorites") | |
| 30 | + case .category(let name): | |
| 31 | + let title = Bundle.main.localizedString(forKey: name, value: name, table: nil) | |
| 32 | + return String(localized: "Randomize \(title)") | |
| 33 | + case .custom: return String(localized: "Randomize pool") | |
| 34 | + } | |
| 35 | + } | |
| 36 | + } | |
| 37 | + | |
| 38 | + struct VisualizerPool: Codable, Equatable, Sendable { | |
| 39 | + var enabled = false | |
| 40 | + var collection = "" | |
| 41 | + var category = "" | |
| 42 | + var favoritesOnly = false | |
| 43 | + } | |
| 44 | + | |
| 45 | + @MainActor | |
| 46 | + final class ProjectMPresets: ObservableObject { | |
| 47 | + static let shared: ProjectMPresets = { | |
| 48 | + #if DEBUG && os(iOS) | |
| 49 | + if ProcessInfo.processInfo.arguments.contains("-PCMobileQA") { | |
| 50 | + let suite = "PulseCanvas.MobileVisualizers.QA" | |
| 51 | + let defaults = UserDefaults(suiteName: suite)! | |
| 52 | + defaults.removePersistentDomain(forName: suite) | |
| 53 | + return ProjectMPresets(defaults: defaults) | |
| 54 | + } | |
| 55 | + #endif | |
| 56 | + return ProjectMPresets() | |
| 57 | + }() | |
| 58 | + @Published private(set) var pool = VisualizerPool() | |
| 59 | + @Published private(set) var poolRevision = 0 | |
| 60 | + @Published private(set) var entries: [ProjectMPreset] = [] | |
| 61 | + private(set) var sceneNames: [String] = [] | |
| 62 | + @Published private(set) var favoriteIDs: Set<String> = [] | |
| 63 | + private var favoriteAppearances: [String: VisualPreset] = [:] | |
| 64 | + @Published private(set) var favoritesBackupError: String? | |
| 65 | + let favoritesBackupDirectory: URL? | |
| 66 | + #if os(visionOS) | |
| 67 | + private let backupEdition = "Vision-Pro" | |
| 68 | + #elseif os(iOS) | |
| 69 | + private let backupEdition = "iPhone-iPad" | |
| 70 | + #elseif STORE_BUILD | |
| 71 | + private let backupEdition = "Mac-App-Store" | |
| 72 | + #elseif LOCAL_BUILD | |
| 73 | + private let backupEdition = "Creators-Local" | |
| 74 | + #else | |
| 75 | + private let backupEdition = "Creators" | |
| 76 | + #endif | |
| 77 | + #if STORE_BUILD | |
| 78 | + private let poolKey = "PulseCanvas.metalVisualizerPool.v1" | |
| 79 | + #else | |
| 80 | + private let poolKey = "PulseCanvas.visualizerPool.v1" | |
| 81 | + #endif | |
| 82 | + private let defaults: UserDefaults | |
| 83 | + #if STORE_BUILD | |
| 84 | + private let favoritesKey = "PulseCanvas.metalEffectFavorites.v1" | |
| 85 | + #else | |
| 86 | + private let favoritesKey = "PulseCanvas.effectFavorites.v1" | |
| 87 | + #endif | |
| 88 | + let bundledRoot: URL | |
| 89 | + let importedRoot: URL | |
| 90 | + private var imported: [ProjectMPreset] = [] | |
| 91 | + private var importedIDs = Set<String>() | |
| 92 | + private var nativeCount: Int { RenderState.nativeSceneNames.count } | |
| 93 | + // Projects without stable identities predate expansion of the native catalog. | |
| 94 | + // Their external preset indices always start at 31, regardless of today's count. | |
| 95 | + private let legacyNativeCount = NativeEffects.legacyCount | |
| 96 | + private var scenesByID: [String: Int] = [:] | |
| 97 | + private var legacyIDs: [String] = [] | |
| 98 | + private(set) var retiredIDs: Set<String> = [] | |
| 99 | + let iconNames: [String] | |
| 100 | + private static let nativeIcons = NativeEffects.all.map(\.icon) | |
| 101 | + | |
| 102 | + init(importedRoot: URL? = nil, defaults: UserDefaults = .standard, favoritesBackupDirectory: URL? = nil) { | |
| 103 | + self.defaults = defaults | |
| 104 | + if let data = defaults.data(forKey: poolKey), data.count < 4096, | |
| 105 | + let saved = try? JSONDecoder().decode(VisualizerPool.self, from: data), | |
| 106 | + saved.collection.count < 100, saved.category.count < 200 { pool = saved } | |
| 107 | + let isolatedQA = Bundle.main.object(forInfoDictionaryKey: "PulseCanvasIsolatedTesting") as? Bool == true | |
| 108 | + self.favoritesBackupDirectory = favoritesBackupDirectory ?? (defaults === UserDefaults.standard && !isolatedQA | |
| 109 | + ? UserDataStorage.support.appendingPathComponent("Favorites Backups", isDirectory: true) : nil) | |
| 110 | + #if STORE_BUILD | |
| 111 | + bundledRoot = Bundle.module.resourceURL ?? URL(fileURLWithPath: "/missing-resources") | |
| 112 | + self.importedRoot = importedRoot ?? bundledRoot | |
| 113 | + iconNames = Self.nativeIcons | |
| 114 | + #else | |
| 115 | + bundledRoot = [Bundle.module.resourceURL?.appendingPathComponent("Resources/ProjectM"), Bundle.module.resourceURL?.appendingPathComponent("ProjectM"), URL(fileURLWithPath: FileManager.default.currentDirectoryPath).appendingPathComponent("Sources/PulseCanvas/Resources/ProjectM")].compactMap({$0}).first(where: {FileManager.default.fileExists(atPath: $0.appendingPathComponent("catalog.json").path)}) ?? URL(fileURLWithPath: "/missing-projectm") | |
| 116 | + iconNames = (try? PresetNaming(root: bundledRoot).icons).flatMap { $0.isEmpty ? nil : $0 } ?? ["sparkles"] | |
| 117 | + self.importedRoot = importedRoot ?? UserDataStorage.support.appendingPathComponent("ProjectM", isDirectory: true) | |
| 118 | + entries = (try? JSONDecoder().decode([ProjectMPreset].self, from: Data(contentsOf: bundledRoot.appendingPathComponent("catalog.json")))) ?? [] | |
| 119 | + imported = (try? JSONDecoder().decode([ProjectMPreset].self, from: Data(contentsOf: self.importedRoot.appendingPathComponent("imports.json")))) ?? [] | |
| 120 | + importedIDs = Set(imported.map(\.id)) | |
| 121 | + legacyIDs = (try? JSONDecoder().decode([String].self, from: Data(contentsOf: bundledRoot.appendingPathComponent("legacy-identities.json")))) ?? entries.map(\.id) | |
| 122 | + let retired = (try? JSONDecoder().decode([RetiredPreset].self, from: Data(contentsOf: bundledRoot.appendingPathComponent("retired-presets.json")))) ?? [] | |
| 123 | + retiredIDs = Set(retired.map(\.id)) | |
| 124 | + entries += imported | |
| 125 | + #endif | |
| 126 | + var savedFavorites = defaults.stringArray(forKey: favoritesKey) | |
| 127 | + #if STORE_BUILD | |
| 128 | + savedFavorites = savedFavorites ?? defaults.stringArray(forKey: "PulseCanvas.effectFavorites.v1") | |
| 129 | + #endif | |
| 130 | + #if LOCAL_BUILD | |
| 131 | + // Seed a fresh isolated test build once, without altering the installed app. | |
| 132 | + if savedFavorites == nil, defaults === UserDefaults.standard, !isolatedQA { | |
| 133 | + savedFavorites = ["com.protomota.pulsecanvas", "com.protomota.pulsecanvas.direct"].flatMap { | |
| 134 | + UserDefaults.standard.persistentDomain(forName: $0)?["PulseCanvas.effectFavorites.v1"] as? [String] ?? [] | |
| 135 | + } | |
| 136 | + defaults.set(savedFavorites, forKey: favoritesKey) | |
| 137 | + } | |
| 138 | + #endif | |
| 139 | + if let data = defaults.data(forKey: favoritesKey + ".appearances"), | |
| 140 | + let saved = try? JSONDecoder().decode([String: VisualPreset].self, from: data) { | |
| 141 | + favoriteAppearances = saved.filter { $0.value.isValid } | |
| 142 | + } | |
| 143 | + // An explicitly empty list stays empty; a missing preference can recover | |
| 144 | + // from this edition's last successful automatic backup. | |
| 145 | + if savedFavorites == nil, let directory = self.favoritesBackupDirectory, | |
| 146 | + let data = try? Data(contentsOf: directory.appendingPathComponent("Favorites-\(backupEdition).json")), | |
| 147 | + let backup = try? FavoritesBackup.read(data) { | |
| 148 | + savedFavorites = backup.favorites.map(\.id) | |
| 149 | + for favorite in backup.favorites { if let look = favorite.appearance { favoriteAppearances[favorite.id] = look } } | |
| 150 | + defaults.set(savedFavorites, forKey: favoritesKey) | |
| 151 | + } | |
| 152 | + let savedIDs = Set(savedFavorites ?? []) | |
| 153 | + rebuildNames() | |
| 154 | + favoriteIDs = savedIDs.intersection(availableFavoriteIDs) | |
| 155 | + favoriteAppearances = favoriteAppearances.filter { favoriteIDs.contains($0.key) } | |
| 156 | + if favoriteIDs != savedIDs { persistFavorites() } | |
| 157 | + else if !favoriteIDs.isEmpty { backUpFavorites() } | |
| 158 | + } | |
| 159 | + private func rebuildNames() { | |
| 160 | + sceneNames = RenderState.nativeSceneNames + entries.map(\.title) | |
| 161 | + scenesByID = Dictionary(uniqueKeysWithValues: entries.enumerated().map { ($0.element.id, $0.offset + nativeCount) }) | |
| 162 | + availableScenes = NativeEffects.libraryOrder + Array(nativeCount..<sceneNames.count) | |
| 163 | + categories = categories(in: "") | |
| 164 | + } | |
| 165 | + private var availableFavoriteIDs: Set<String> { Set(availableScenes.map { identity(for: $0) }) } | |
| 166 | + func identity(for scene: Int) -> String {preset(for: scene)?.id ?? "native:\(scene)"} | |
| 167 | + func isFavorite(_ scene: Int) -> Bool {favoriteIDs.contains(identity(for: scene))} | |
| 168 | + /// Every scene offered in the library, timeline and random choices. Retired native | |
| 169 | + /// designs keep their IDs for migration but are never offered. | |
| 170 | + private(set) var availableScenes: [Int] = [] | |
| 171 | + func icon(for scene: Int) -> String { | |
| 172 | + if Self.nativeIcons.indices.contains(scene) { return Self.nativeIcons[scene] } | |
| 173 | + return preset(for:scene)?.icon ?? iconNames[max(0,scene) % iconNames.count] | |
| 174 | + } | |
| 175 | + func toggleFavorite(_ scene: Int, appearance: VisualPreset? = nil) { | |
| 176 | + guard availableScenes.contains(scene) else { return } | |
| 177 | + let id = identity(for: scene) | |
| 178 | + if favoriteIDs.contains(id) { | |
| 179 | + favoriteIDs.remove(id); favoriteAppearances.removeValue(forKey: id) | |
| 180 | + } else { | |
| 181 | + favoriteIDs.insert(id) | |
| 182 | + favoriteAppearances[id] = appearance.flatMap { $0.isValid ? $0 : nil } ?? VisualPreset.defaults(for: scene) | |
| 183 | + } | |
| 184 | + persistFavorites() | |
| 185 | + } | |
| 186 | + | |
| 187 | + /// Gestures only add favorites. Repeating one preserves the originally saved look. | |
| 188 | + @discardableResult | |
| 189 | + func favorite(_ scene: Int, appearance: VisualPreset? = nil) -> Bool { | |
| 190 | + guard availableScenes.contains(scene) else { return false } | |
| 191 | + if !isFavorite(scene) { toggleFavorite(scene, appearance: appearance) } | |
| 192 | + return true | |
| 193 | + } | |
| 194 | + | |
| 195 | + /// Upgrade ID-only favorites once from the editor's existing saved looks. | |
| 196 | + /// Subsequent slider edits never rewrite an already saved favorite. | |
| 197 | + func migrateFavoriteAppearances(_ appearance: (Int) -> VisualPreset) { | |
| 198 | + var changed = false | |
| 199 | + for scene in availableScenes where isFavorite(scene) && favoriteAppearances[identity(for: scene)] == nil { | |
| 200 | + let value = appearance(scene) | |
| 201 | + if value.isValid { favoriteAppearances[identity(for: scene)] = value; changed = true } | |
| 202 | + } | |
| 203 | + if changed { persistFavorites() } | |
| 204 | + } | |
| 205 | + | |
| 206 | + func favoriteAppearance(for scene: Int) -> VisualPreset? { | |
| 207 | + guard isFavorite(scene) else { return nil } | |
| 208 | + if let saved = favoriteAppearances[identity(for: scene)] { return saved } | |
| 209 | + // Legacy favorites without a saved look migrate once, never on each selection. | |
| 210 | + let saved = VisualPreset.defaults(for: scene) | |
| 211 | + favoriteAppearances[identity(for: scene)] = saved | |
| 212 | + persistFavorites() | |
| 213 | + return saved | |
| 214 | + } | |
| 215 | + | |
| 216 | + func appearanceForSelection(_ scene: Int) -> VisualPreset { | |
| 217 | + favoriteAppearance(for: scene) ?? .randomized() | |
| 218 | + } | |
| 219 | + | |
| 220 | + func exportFavorites() throws -> Data { | |
| 221 | + try FavoritesBackup(ids: favoriteIDs, appearances: favoriteAppearances) { id in | |
| 222 | + if id.hasPrefix("native:"), let scene = Int(id.dropFirst(7)), sceneNames.indices.contains(scene) { return sceneNames[scene] } | |
| 223 | + return scenesByID[id].map { sceneNames[$0] } | |
| 224 | + }.encoded() | |
| 225 | + } | |
| 226 | + | |
| 227 | + /// Merge installed favorites. Removed designs must not reappear from a backup | |
| 228 | + /// or silently favorite a replacement the listener never selected. | |
| 229 | + @discardableResult | |
| 230 | + func importFavorites(_ data: Data) throws -> (added: Int, unavailable: Int) { | |
| 231 | + let backup = try FavoritesBackup.read(data) | |
| 232 | + let restored = Set(backup.favorites.map(\.id)) | |
| 233 | + let available = availableFavoriteIDs | |
| 234 | + let installed = restored.intersection(available) | |
| 235 | + let added = installed.subtracting(favoriteIDs).count | |
| 236 | + for favorite in backup.favorites where installed.contains(favorite.id) { | |
| 237 | + if let look = favorite.appearance { favoriteAppearances[favorite.id] = look } | |
| 238 | + } | |
| 239 | + favoriteIDs.formUnion(installed) | |
| 240 | + persistFavorites() | |
| 241 | + return (added, restored.subtracting(available).count) | |
| 242 | + } | |
| 243 | + | |
| 244 | + private func persistFavorites() { | |
| 245 | + if pool.enabled && pool.favoritesOnly { poolRevision &+= 1 } | |
| 246 | + favoriteAppearances = favoriteAppearances.filter { favoriteIDs.contains($0.key) } | |
| 247 | + defaults.set(favoriteIDs.sorted(), forKey: favoritesKey) | |
| 248 | + if let data = try? JSONEncoder().encode(favoriteAppearances) { defaults.set(data, forKey: favoritesKey + ".appearances") } | |
| 249 | + backUpFavorites() | |
| 250 | + NotificationCenter.default.post(name: .pulseCanvasUserDataChanged, object: nil) | |
| 251 | + } | |
| 252 | + | |
| 253 | + func applyCloudFavorites(_ favorites: [FavoritesBackup.Favorite], removed: Set<String>) { | |
| 254 | + let available = availableFavoriteIDs | |
| 255 | + favoriteIDs.subtract(removed.intersection(available)) | |
| 256 | + for favorite in favorites where available.contains(favorite.id) { | |
| 257 | + favoriteIDs.insert(favorite.id) | |
| 258 | + if let look = favorite.appearance, look.isValid { favoriteAppearances[favorite.id] = look } | |
| 259 | + } | |
| 260 | + persistFavorites() | |
| 261 | + } | |
| 262 | + | |
| 263 | + private func backUpFavorites() { | |
| 264 | + guard let directory = favoritesBackupDirectory else { return } | |
| 265 | + do { | |
| 266 | + try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) | |
| 267 | + let data = try exportFavorites() | |
| 268 | + let day = String(ISO8601DateFormatter().string(from: Date()).prefix(10)) | |
| 269 | + try data.write(to: directory.appendingPathComponent("Favorites-\(backupEdition)-\(day).json"), options: .atomic) | |
| 270 | + try data.write(to: directory.appendingPathComponent("Favorites-\(backupEdition).json"), options: .atomic) | |
| 271 | + favoritesBackupError = nil | |
| 272 | + } catch { favoritesBackupError = "Automatic favorites backup failed: \(error.localizedDescription)" } | |
| 273 | + } | |
| 274 | + func category(for scene: Int) -> String { | |
| 275 | + guard let preset = preset(for: scene) else {return NativeEffects.category(for: scene)} | |
| 276 | + return preset.category.hasPrefix("Imported") ? "Imported" : String(preset.category.split(separator: "/").first ?? "ProjectM") | |
| 277 | + } | |
| 278 | + func collection(for scene: Int) -> String { | |
| 279 | + guard let preset = preset(for: scene) else { return "Native Metal" } | |
| 280 | + return importedIDs.contains(preset.id) ? "Imported" : "Cream of the Crop" | |
| 281 | + } | |
| 282 | + var collections: [String] { | |
| 283 | + ["Native Metal", "Cream of the Crop", "Imported"].filter { collection in | |
| 284 | + availableScenes.contains { self.collection(for: $0) == collection } | |
| 285 | + } | |
| 286 | + } | |
| 287 | + private(set) var categories: [String] = [] | |
| 288 | + func categories(in collection: String) -> [String] { | |
| 289 | + Set(availableScenes.filter { collection.isEmpty || self.collection(for: $0) == collection } | |
| 290 | + .map { category(for: $0) }).sorted() | |
| 291 | + } | |
| 292 | + func folders(in category: String, collection: String = "") -> [String] { | |
| 293 | + guard !category.isEmpty else { return [] } | |
| 294 | + return Set(availableScenes.filter { | |
| 295 | + self.category(for: $0) == category && (collection.isEmpty || self.collection(for: $0) == collection) | |
| 296 | + }.compactMap { preset(for: $0)?.category }.filter { $0.contains("/") }).sorted() | |
| 297 | + } | |
| 298 | + /// The installed catalog remains intact for identities, migration and favorite backups. | |
| 299 | + /// This separate pool limits only discovery and new assignments. | |
| 300 | + var eligibleScenes: [Int] { scenes(in: pool) } | |
| 301 | + var favoritesFallbackMessage: String? { | |
| 302 | + guard pool.enabled, pool.favoritesOnly else { return nil } | |
| 303 | + let choices = scenes(in: pool) | |
| 304 | + guard !choices.isEmpty, !choices.contains(where: { isFavorite($0) }) else { return nil } | |
| 305 | + return pool.collection.isEmpty && pool.category.isEmpty | |
| 306 | + ? "No saved favorite visualizers yet. Playing random visualizers from the full library." | |
| 307 | + : String(localized: "No favorite visualizers in this group. Playing random visualizers from the group.") | |
| 308 | + } | |
| 309 | + func scenes(in pool: VisualizerPool) -> [Int] { | |
| 310 | + guard pool.enabled else { return availableScenes } | |
| 311 | + let group = availableScenes.filter { | |
| 312 | + (pool.collection.isEmpty || collection(for: $0) == pool.collection) | |
| 313 | + && (pool.category.isEmpty || category(for: $0) == pool.category) | |
| 314 | + } | |
| 315 | + guard pool.favoritesOnly else { return group } | |
| 316 | + let favorites = group.filter { isFavorite($0) } | |
| 317 | + // A discovery preference must not disable playback or Studio when no | |
| 318 | + // favorites exist. Keep category/collection limits and the saved choice. | |
| 319 | + return favorites.isEmpty ? group : favorites | |
| 320 | + } | |
| 321 | + var randomizerGroup: VisualizerRandomizerGroup { | |
| 322 | + guard pool.enabled else { return .all } | |
| 323 | + if pool.collection.isEmpty { | |
| 324 | + if pool.category.isEmpty { return pool.favoritesOnly ? .favorites : .all } | |
| 325 | + if !pool.favoritesOnly { return .category(pool.category) } | |
| 326 | + } | |
| 327 | + return .custom | |
| 328 | + } | |
| 329 | + func setRandomizerGroup(_ group: VisualizerRandomizerGroup) { | |
| 330 | + switch group { | |
| 331 | + case .all: setPool(VisualizerPool()) | |
| 332 | + case .favorites: setPool(VisualizerPool(enabled: true, favoritesOnly: true)) | |
| 333 | + case .category(let name): setPool(VisualizerPool(enabled: true, category: name)) | |
| 334 | + case .custom: break | |
| 335 | + } | |
| 336 | + } | |
| 337 | + func setPool(_ value: VisualizerPool) { | |
| 338 | + guard value != pool, value.collection.count < 100, value.category.count < 200 else { return } | |
| 339 | + pool = value | |
| 340 | + poolRevision &+= 1 | |
| 341 | + if let data = try? JSONEncoder().encode(value) { defaults.set(data, forKey: poolKey) } | |
| 342 | + } | |
| 343 | + var poolSummary: String { | |
| 344 | + guard pool.enabled else { return String(localized: "All visualizers") } | |
| 345 | + let labels = [pool.collection, pool.category, pool.favoritesOnly ? String(localized: "Favorites") : ""].filter { !$0.isEmpty } | |
| 346 | + return labels.isEmpty ? String(localized: "All visualizers") : labels.map { Bundle.main.localizedString(forKey: $0, value: $0, table: nil) }.joined(separator: " · ") | |
| 347 | + } | |
| 348 | + func filteredScenes(query: String = "", collection: String = "", category: String = "", | |
| 349 | + folder: String = "", favoritesOnly: Bool = false) -> [Int] { | |
| 350 | + let text = query.trimmingCharacters(in: .whitespacesAndNewlines) | |
| 351 | + return eligibleScenes.filter { scene in | |
| 352 | + (!favoritesOnly || isFavorite(scene)) | |
| 353 | + && (collection.isEmpty || self.collection(for: scene) == collection) | |
| 354 | + && (category.isEmpty || self.category(for: scene) == category) | |
| 355 | + && (folder.isEmpty || preset(for: scene)?.category == folder) | |
| 356 | + && (text.isEmpty || sceneNames[scene].localizedCaseInsensitiveContains(text) | |
| 357 | + || (preset(for: scene)?.originalTitle?.localizedCaseInsensitiveContains(text) ?? false) | |
| 358 | + || (preset(for: scene)?.category.localizedCaseInsensitiveContains(text) ?? false) | |
| 359 | + || self.category(for: scene).localizedCaseInsensitiveContains(text)) | |
| 360 | + } | |
| 361 | + } | |
| 362 | + func preset(for scene: Int) -> ProjectMPreset? { | |
| 363 | + let index = scene - nativeCount | |
| 364 | + return entries.indices.contains(index) ? entries[index] : nil | |
| 365 | + } | |
| 366 | + func url(for preset: ProjectMPreset) -> URL { | |
| 367 | + (importedIDs.contains(preset.id) ? importedRoot : bundledRoot.appendingPathComponent("Presets")).appendingPathComponent(preset.path) | |
| 368 | + } | |
| 369 | + func texturePaths(for preset: ProjectMPreset) -> [URL] { | |
| 370 | + [url(for: preset).deletingLastPathComponent(), importedRoot, bundledRoot.appendingPathComponent("Textures")] | |
| 371 | + } | |
| 372 | + func scene(for id: String) -> Int? { scenesByID[id] } | |
| 373 | + /// Resolve old numeric scenes by their stable identities before applying settings. | |
| 374 | + /// Retired effects and retired native designs open a replacement design; unavailable | |
| 375 | + /// user imports still report an error. | |
| 376 | + func migratedScene(_ scene: Int, identities: [Int: String]?) throws -> Int { | |
| 377 | + guard scene >= 0 else { throw ProjectMError("Invalid visualizer index: \(scene).") } | |
| 378 | + if let id = identities?[scene], id.hasPrefix("native:") { | |
| 379 | + guard let index = Int(id.dropFirst(7)), RenderState.nativeSceneNames.indices.contains(index) else { | |
| 380 | + throw ProjectMError("This project requires a native visualizer unavailable in this version: \(id).") | |
| 381 | + } | |
| 382 | + return NativeEffects.resolved(index) | |
| 383 | + } | |
| 384 | + if identities?[scene] == nil && scene < legacyNativeCount { return NativeEffects.resolved(scene) } | |
| 385 | + #if STORE_BUILD | |
| 386 | + throw ProjectMError("This project uses effects available only in the direct-download edition. Open it there to preserve its visualizers.") | |
| 387 | + #else | |
| 388 | + let index = scene - legacyNativeCount | |
| 389 | + let legacy = legacyIDs.indices.contains(index) ? legacyIDs[index] : imported.indices.contains(index - legacyIDs.count) ? imported[index - legacyIDs.count].id : nil | |
| 390 | + guard let id = identities == nil ? legacy : identities?[scene] else { throw ProjectMError("Missing identity for preset \(scene)") } | |
| 391 | + if let current = scenesByID[id] { return current } | |
| 392 | + if retiredIDs.contains(id) { return 22 } | |
| 393 | + throw ProjectMError("This project requires a custom visualizer that is not installed: \(id).") | |
| 394 | + #endif | |
| 395 | + } | |
| 396 | + func isRetiredScene(_ scene: Int, identities: [Int: String]?) -> Bool { | |
| 397 | + if let id = identities?[scene], id.hasPrefix("native:") { return Int(id.dropFirst(7)).map(NativeEffects.isRetired) ?? false } | |
| 398 | + if identities?[scene] == nil && scene < legacyNativeCount { return NativeEffects.isRetired(scene) } | |
| 399 | + let index = scene - legacyNativeCount | |
| 400 | + let id = identities == nil && legacyIDs.indices.contains(index) ? legacyIDs[index] : identities?[scene] | |
| 401 | + return id.map { retiredIDs.contains($0) } ?? false | |
| 402 | + } | |
| 403 | + func identities(for scenes: Set<Int>) -> [Int: String] { | |
| 404 | + Dictionary(uniqueKeysWithValues: scenes.filter { sceneNames.indices.contains($0) }.map { ($0, identity(for: $0)) }) | |
| 405 | + } | |
| 406 | + } | |
| 407 | + | |
| 408 | + private struct RetiredPreset: Decodable { let id: String } | |
| 409 | + | |
| 410 | + private struct PresetNaming: Decodable { | |
| 411 | + let icons: [String] | |
| 412 | + init(root: URL) throws {self = try JSONDecoder().decode(Self.self,from:Data(contentsOf:root.appendingPathComponent("naming.json")))} | |
| 413 | + } | |
| 414 | + | |
| 415 | + | |
| 416 | + /// Portable stable identities survive renamed effects and catalog reordering. | |
| 417 | + struct FavoritesBackup: Codable { | |
| 418 | + struct Favorite: Codable { | |
| 419 | + let id: String | |
| 420 | + let name: String? | |
| 421 | + var appearance: VisualPreset? = nil | |
| 422 | + } | |
| 423 | + let format: String | |
| 424 | + let version: Int | |
| 425 | + let savedAt: Date | |
| 426 | + let favorites: [Favorite] | |
| 427 | + | |
| 428 | + init(ids: Set<String>, appearances: [String: VisualPreset] = [:], name: (String) -> String?) { | |
| 429 | + format = "PulseCanvas Favorites" | |
| 430 | + version = 2 | |
| 431 | + savedAt = Date() | |
| 432 | + favorites = ids.sorted().map { Favorite(id: $0, name: name($0), appearance: appearances[$0]) } | |
| 433 | + } | |
| 434 | + | |
| 435 | + func encoded() throws -> Data { | |
| 436 | + let encoder = JSONEncoder() | |
| 437 | + encoder.outputFormatting = [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes] | |
| 438 | + encoder.dateEncodingStrategy = .iso8601 | |
| 439 | + return try encoder.encode(self) | |
| 440 | + } | |
| 441 | + | |
| 442 | + static func read(_ data: Data) throws -> Self { | |
| 443 | + guard data.count <= 10_000_000 else { throw invalid(String(localized: "The favorites backup is too large.")) } | |
| 444 | + let decoder = JSONDecoder() | |
| 445 | + decoder.dateDecodingStrategy = .iso8601 | |
| 446 | + let backup = try decoder.decode(Self.self, from: data) | |
| 447 | + guard backup.format == "PulseCanvas Favorites", (1...2).contains(backup.version) else { | |
| 448 | + throw invalid(String(localized: "Choose a supported PulseCanvas favorites backup.")) | |
| 449 | + } | |
| 450 | + guard backup.favorites.count <= 100_000, backup.favorites.allSatisfy({ | |
| 451 | + ($0.appearance?.isValid ?? true) && !$0.id.isEmpty && $0.id.utf8.count <= 4096 && !$0.id.unicodeScalars.contains(where: { CharacterSet.controlCharacters.contains($0) }) | |
| 452 | + }) else { throw invalid(String(localized: "The backup contains invalid favorite identities.")) } | |
| 453 | + return backup | |
| 454 | + } | |
| 455 | + | |
| 456 | + private static func invalid(_ message: String) -> NSError { | |
| 457 | + NSError(domain: "PulseCanvas.FavoritesBackup", code: 1, userInfo: [NSLocalizedDescriptionKey: message]) | |
| 458 | + } | |
| 459 | + } |
Sources/PulseCanvas/PulseCanvasApp.swift added
| 1 | + import AppKit | |
| 2 | + import AVFoundation | |
| 3 | + import Combine | |
| 4 | + import SwiftUI | |
| 5 | + import UniformTypeIdentifiers | |
| 6 | + | |
| 7 | + struct LegalCreditsView: View { | |
| 8 | + private var legalDirectory: URL? { | |
| 9 | + guard let resources = Bundle.main.resourceURL else { return nil } | |
| 10 | + let legal = resources.appendingPathComponent("Legal") | |
| 11 | + return FileManager.default.fileExists(atPath: legal.path) ? legal : resources | |
| 12 | + } | |
| 13 | + | |
| 14 | + var body: some View { | |
| 15 | + ScrollView { | |
| 16 | + VStack(alignment: .leading, spacing: 16) { | |
| 17 | + Text("Legal & Credits").font(.title2).accessibilityAddTraits(.isHeader) | |
| 18 | + Text("Application").font(.headline) | |
| 19 | + Text("PulseCanvas first-party code is open source and public domain (Unlicense). Third-party components and assets have separate terms.") | |
| 20 | + #if STORE_BUILD | |
| 21 | + Text("Metal edition").font(.headline) | |
| 22 | + Text("This App Store edition includes \(NativeEffects.activeIDs.count) Metal visualizers. The projectM engine, OpenGL presets, and texture pack are not included.") | |
| 23 | + #else | |
| 24 | + Text("projectM engine").font(.headline) | |
| 25 | + Text("projectM 4.2.0 is included under LGPL 2.1 or later. Engine source and rebuild instructions accompany the matching source package.") | |
| 26 | + Text("Preset provenance").font(.headline) | |
| 27 | + Text("Cream of the Crop pack curated by ISOSCELES") | |
| 28 | + Link("https://www.patreon.com/posts/pack-nestdrop-91682111", destination: URL(string: "https://www.patreon.com/posts/pack-nestdrop-91682111")!) | |
| 29 | + Text("\(ProjectMPresets.shared.entries.count.formatted()) presets are available from the curated library. Bundled originals retain their pinned Cream of the Crop provenance; user imports, if present, have separate origins. Display labels are separate from original filenames and creator metadata. Upstream assumes public domain where author licenses are missing; individual permissions remain unresolved. Attribution does not establish licensing clearance.") | |
| 30 | + Text("Texture provenance").font(.headline) | |
| 31 | + Text("67 images come from the Milkdrop texture pack. Its inclusion guidance does not document individual asset grants; those permissions remain unresolved separately from the presets.") | |
| 32 | + #if DIRECT_BUILD && canImport(Sparkle) && !LOCAL_BUILD | |
| 33 | + Text("Automatic updates").font(.headline) | |
| 34 | + Text("Sparkle provides signed updates for the direct-download edition. Update checks send only the information needed to deliver the app; system profiling is disabled.") | |
| 35 | + #endif | |
| 36 | + #endif | |
| 37 | + Button("Open licenses, notices & provenance") { | |
| 38 | + if let legalDirectory { NSWorkspace.shared.open(legalDirectory) } | |
| 39 | + } | |
| 40 | + }.padding(24).textSelection(.enabled) | |
| 41 | + }.frame(minWidth: 500, minHeight: 440) | |
| 42 | + } | |
| 43 | + } | |
| 44 | + | |
| 45 | + @main | |
| 46 | + enum PulseCanvasLauncher { | |
| 47 | + @MainActor static func main() { | |
| 48 | + #if DIRECT_BUILD && !STORE_BUILD | |
| 49 | + if Array(CommandLine.arguments.dropFirst()) == [PulseMCP.argument] { | |
| 50 | + PulseMCP.run() | |
| 51 | + return | |
| 52 | + } | |
| 53 | + #endif | |
| 54 | + PulseCanvasApp.main() | |
| 55 | + } | |
| 56 | + } | |
| 57 | + | |
| 58 | + struct PulseCanvasApp: App { | |
| 59 | + @NSApplicationDelegateAdaptor(AppLifecycle.self) private var lifecycle | |
| 60 | + @Environment(\.openWindow) private var openWindow | |
| 61 | + @StateObject private var render = { _ = UserBackup.startupError; return RenderState() }() | |
| 62 | + @StateObject private var audio = AudioController() | |
| 63 | + @StateObject private var radio = RadioController() | |
| 64 | + @StateObject private var studio = StudioStore() | |
| 65 | + @StateObject private var exporter = SocialExportController() | |
| 66 | + @StateObject private var presentation = StudioPresentationController() | |
| 67 | + #if DIRECT_BUILD && !STORE_BUILD | |
| 68 | + @StateObject private var agentAccess = PulseMCPAccess() | |
| 69 | + @StateObject private var agentService = PulseMCPService() | |
| 70 | + #endif | |
| 71 | + #if DIRECT_BUILD && canImport(Sparkle) && !LOCAL_BUILD | |
| 72 | + @StateObject private var updater = AppUpdater() | |
| 73 | + #endif | |
| 74 | + var body: some Scene { | |
| 75 | + WindowGroup("PulseCanvas Studio") { | |
| 76 | + CreatorView(render: render, audio: audio, radio: radio, studio: studio, exporter: exporter, presentation: presentation, lifecycle: lifecycle) | |
| 77 | + .preferredColorScheme(.dark) | |
| 78 | + .modifier(PulseCanvasOnboardingPresentation(onReplay: { audio.pause() })) | |
| 79 | + #if DIRECT_BUILD && canImport(Sparkle) && !LOCAL_BUILD | |
| 80 | + .environmentObject(updater) | |
| 81 | + #endif | |
| 82 | + .frame(minWidth: 1080, minHeight: 740) | |
| 83 | + .onReceive(audio.visualizationUpdated) { | |
| 84 | + let target = radio.isActive ? radio.visualizer : render | |
| 85 | + target.audioTrebleAttackTime = audio.trebleAttackTime | |
| 86 | + target.audioTreblePulse = audio.selectedURL == nil ? nil : audio.treblePulse | |
| 87 | + target.audioBeatMotionTime = audio.beatMotionTime | |
| 88 | + target.audioMomentum = audio.momentum | |
| 89 | + target.audioPulse = audio.beatPulse | |
| 90 | + target.audioBands = audio.spectrum | |
| 91 | + target.audioEnvelopes = audio.envelopes | |
| 92 | + target.audioSwell = audio.swell | |
| 93 | + target.playbackTime = audio.selectedURL == nil ? nil : audio.playbackSeconds | |
| 94 | + if radio.isActive { radio.follow(time: audio.playbackSeconds) } | |
| 95 | + else if !exporter.isExporting && presentation.followsStudioTimeline { studio.follow(time: audio.playbackSeconds, render: render) } | |
| 96 | + if target.scene >= RenderState.nativeSceneNames.count { target.audioPCM = audio.visualizationPCM(at: audio.playbackSeconds) } | |
| 97 | + } | |
| 98 | + .onAppear { | |
| 99 | + NSApplication.shared.setActivationPolicy(.regular) | |
| 100 | + studio.apply(to: render) | |
| 101 | + audio.loadDefaultSoundtrackIfNeeded() | |
| 102 | + radio.attach(audio: audio) | |
| 103 | + lifecycle.attach(audio: audio, radio: radio) | |
| 104 | + #if DIRECT_BUILD && !STORE_BUILD | |
| 105 | + agentAccess.host(agentService) | |
| 106 | + if agentAccess.hostRunning { | |
| 107 | + agentService.attach(access: agentAccess, audio: audio, studio: studio, radio: radio, | |
| 108 | + render: render, exporter: exporter) | |
| 109 | + } | |
| 110 | + #endif | |
| 111 | + CloudSyncService.shared.start() | |
| 112 | + } | |
| 113 | + .onReceive(NotificationCenter.default.publisher(for: .pulseCanvasCloudDataApplied)) { _ in | |
| 114 | + studio.reloadCloudPresets(); radio.reloadCloudFavorites() | |
| 115 | + if !audio.isPlaying { studio.apply(to: render) } | |
| 116 | + } | |
| 117 | + } | |
| 118 | + #if STORE_BUILD | |
| 119 | + .defaultSize(width: 1440, height: 900) | |
| 120 | + #else | |
| 121 | + .defaultSize(width: 1440, height: 940) | |
| 122 | + #endif | |
| 123 | + .commands { | |
| 124 | + CommandGroup(after: .appInfo) { | |
| 125 | + Button("Welcome to PulseCanvas Studio") { | |
| 126 | + audio.pause() | |
| 127 | + NotificationCenter.default.post(name: .pulseCanvasOnboarding, object: nil) | |
| 128 | + } | |
| 129 | + Button("Legal & Credits") { openWindow(id: "legal-credits") } | |
| 130 | + Button("Backup & Restore…") { openWindow(id: "user-backup") } | |
| 131 | + #if DIRECT_BUILD && canImport(Sparkle) && !LOCAL_BUILD | |
| 132 | + Button("Check for Updates…") { updater.checkForUpdates() }.disabled(!updater.canCheck) | |
| 133 | + #endif | |
| 134 | + } | |
| 135 | + CommandMenu("Preview") { | |
| 136 | + if presentation.isPresented { | |
| 137 | + Button("Exit presentation") { audio.pause(); presentation.dismiss() } | |
| 138 | + } else { | |
| 139 | + Button(audio.isPlaying ? "Pause soundtrack" : "Play soundtrack") { | |
| 140 | + if radio.isActive { radio.togglePlayback() } else { audio.playPause() } | |
| 141 | + }.keyboardShortcut(.space, modifiers: []) | |
| 142 | + if radio.isActive { | |
| 143 | + Button("Next radio song") { radio.next() }.keyboardShortcut(.rightArrow, modifiers: []) | |
| 144 | + Button("Randomize radio visualizer") { radio.randomizeCurrentVisualizer() }.keyboardShortcut("r", modifiers: [.command, .shift]) | |
| 145 | + } else { | |
| 146 | + Button("Next visualizer") { choose(1) }.keyboardShortcut(.rightArrow, modifiers: []) | |
| 147 | + Button("Previous visualizer") { choose(-1) }.keyboardShortcut(.leftArrow, modifiers: []) | |
| 148 | + Button("Random visualizer") { if !exporter.isExporting { studio.randomizeScene(render) } }.keyboardShortcut("r", modifiers: [.command, .shift]) | |
| 149 | + } | |
| 150 | + } | |
| 151 | + } | |
| 152 | + } | |
| 153 | + Settings { | |
| 154 | + Form { | |
| 155 | + #if DIRECT_BUILD && !STORE_BUILD | |
| 156 | + PulseMCPSettings(access: agentAccess) | |
| 157 | + #endif | |
| 158 | + Section("Onboarding") { | |
| 159 | + Button("Welcome to PulseCanvas Studio", systemImage: "sparkles") { | |
| 160 | + NSApp.keyWindow?.close() | |
| 161 | + audio.pause() | |
| 162 | + NotificationCenter.default.post(name: .pulseCanvasOnboarding, object: nil) | |
| 163 | + }.accessibilityIdentifier("settingsWelcomePulseCanvas") | |
| 164 | + Text("See the onboarding again, from the beginning.").font(.callout).foregroundStyle(.secondary) | |
| 165 | + } | |
| 166 | + Section("Your data") { | |
| 167 | + Button("Backup & Restore…", systemImage: "externaldrive") { openWindow(id: "user-backup") } | |
| 168 | + } | |
| 169 | + Section("iCloud") { | |
| 170 | + CloudSyncView(prepare: { radio.leave(); audio.pause() }, openProject: { data in | |
| 171 | + NotificationCenter.default.post(name: .pulseCanvasOpenBackupProject, object: data) | |
| 172 | + }) | |
| 173 | + } | |
| 174 | + #if DIRECT_BUILD && canImport(Sparkle) && !LOCAL_BUILD | |
| 175 | + Section("Updates") { | |
| 176 | + Toggle("Automatically check for updates", isOn: $updater.automaticChecks) | |
| 177 | + Text("The direct-download edition checks pulsecanvas.ai for signed updates. System profiling is disabled.").font(.callout).foregroundStyle(.secondary) | |
| 178 | + Button("Check for Updates…") { updater.checkForUpdates() }.disabled(!updater.canCheck) | |
| 179 | + } | |
| 180 | + #endif | |
| 181 | + }.formStyle(.grouped).padding(16).frame(width: 620, height: 650) | |
| 182 | + } | |
| 183 | + Window("Legal & Credits", id: "legal-credits") { | |
| 184 | + LegalCreditsView() | |
| 185 | + }.defaultSize(width: 560, height: 540) | |
| 186 | + Window("Backup & Restore", id: "user-backup") { | |
| 187 | + ScrollView { | |
| 188 | + UserBackupView(currentProject: { | |
| 189 | + studio.save(render) | |
| 190 | + return try studio.document(audio: audio, render: render, exporter: exporter).encoded() | |
| 191 | + }, prepare: { radio.leave(); audio.pause() }, openProject: { data in | |
| 192 | + NotificationCenter.default.post(name: .pulseCanvasOpenBackupProject, object: data) | |
| 193 | + }) | |
| 194 | + .padding(24).tint(Color(red: 0.95, green: 0.68, blue: 0.55)).controlSize(.large) | |
| 195 | + .disabled(exporter.isExporting) | |
| 196 | + }.frame(minWidth: 540, minHeight: 480).preferredColorScheme(.dark) | |
| 197 | + }.defaultSize(width: 620, height: 580) | |
| 198 | + } | |
| 199 | + private func choose(_ direction: Int) { | |
| 200 | + guard !exporter.isExporting else { return } | |
| 201 | + let choices = ProjectMPresets.shared.eligibleScenes | |
| 202 | + guard !choices.isEmpty else { return } | |
| 203 | + let position = choices.firstIndex(of: render.scene) ?? (direction > 0 ? -1 : 0) | |
| 204 | + studio.selectScene(choices[(position + direction + choices.count) % choices.count], render: render) | |
| 205 | + } | |
| 206 | + } | |
| 207 | + | |
| 208 | + @MainActor | |
| 209 | + struct CreatorView: View { | |
| 210 | + @Environment(\.openWindow) private var openWindow | |
| 211 | + #if DIRECT_BUILD && canImport(Sparkle) && !LOCAL_BUILD | |
| 212 | + @EnvironmentObject private var updater: AppUpdater | |
| 213 | + #endif | |
| 214 | + @ObservedObject var render: RenderState | |
| 215 | + @ObservedObject var audio: AudioController | |
| 216 | + @ObservedObject var radio: RadioController | |
| 217 | + @ObservedObject var studio: StudioStore | |
| 218 | + @ObservedObject var exporter: SocialExportController | |
| 219 | + @ObservedObject var presentation: StudioPresentationController | |
| 220 | + let lifecycle: AppLifecycle | |
| 221 | + @State private var message = "" | |
| 222 | + @ObservedObject private var presetLibrary = ProjectMPresets.shared | |
| 223 | + @State private var showVisualizerBrowser = false | |
| 224 | + @State private var showHelp = false | |
| 225 | + @State private var showProjectSettings = false | |
| 226 | + @State private var showRadio = false | |
| 227 | + @State private var showMusicPicker = false | |
| 228 | + private let accent = Color(red: 0.95, green: 0.68, blue: 0.55) | |
| 229 | + private let background = Color(red: 0.145, green: 0.12, blue: 0.16) | |
| 230 | + private let panel = Color(red: 0.20, green: 0.17, blue: 0.22) | |
| 231 | + | |
| 232 | + var body: some View { | |
| 233 | + ZStack { | |
| 234 | + if radio.isActive { | |
| 235 | + RadioPlayerView(radio: radio, audio: audio, render: radio.visualizer) | |
| 236 | + } else if presentation.isPresented { | |
| 237 | + StudioPresentationView(render: render, audio: audio, studio: studio, mode: presentation.mode, aspect: exporter.aspect) { | |
| 238 | + audio.pause(); presentation.dismiss() | |
| 239 | + } | |
| 240 | + } else { editor } | |
| 241 | + } | |
| 242 | + .background(StudioWindowReader(attach: { window in | |
| 243 | + presentation.attach(window); lifecycle.track(window) | |
| 244 | + }).frame(width: 0, height: 0)) | |
| 245 | + .onChange(of: presentation.isPresented) { _, active in if !active { audio.pause() } } | |
| 246 | + .onReceive(radio.soundtrackInstalled) { | |
| 247 | + if !radio.isActive { studio.timelineSoundtrack = audio.selectedURL } | |
| 248 | + message = "" | |
| 249 | + } | |
| 250 | + .onChange(of: audio.selectedURL) { _, url in | |
| 251 | + guard !radio.isActive else { return } | |
| 252 | + render.playbackTime = url == nil ? nil : audio.playbackSeconds | |
| 253 | + render.audioTreblePulse = url == nil ? nil : audio.treblePulse | |
| 254 | + if url != studio.timelineSoundtrack { | |
| 255 | + studio.timelineSoundtrack = url | |
| 256 | + studio.segments = []; studio.detectedBPM = nil; studio.generationSeed = nil | |
| 257 | + if studio.isStudio && url != nil { detectSegments() } | |
| 258 | + } | |
| 259 | + } | |
| 260 | + .onChange(of: exporter.isExporting) { _, exporting in if exporting { radio.pause() } } | |
| 261 | + .sheet(isPresented: $showRadio) { | |
| 262 | + RadioLibraryView(radio: radio) { showRadio = false } | |
| 263 | + .dismissOnOutsideClick { showRadio = false } | |
| 264 | + } | |
| 265 | + .sheet(isPresented: $showMusicPicker) { | |
| 266 | + StudioMusicPicker(source: radio.studioMusicSource, folderBookmark: radio.studioMusicFolderBookmark, | |
| 267 | + library: radio.studioMusicLibrary, favoriteIDs: Set(radio.favoriteSongs.map(\.id)), useSong: importLibrarySong, close: { showMusicPicker = false }) | |
| 268 | + .frame(width: 670, height: 620) | |
| 269 | + .dismissOnOutsideClick { showMusicPicker = false } | |
| 270 | + } | |
| 271 | + // Reconcile saved songs without opening Radio or starting playback. | |
| 272 | + .task { await radio.refreshFavoriteSongs() } | |
| 273 | + } | |
| 274 | + | |
| 275 | + private var editor: some View { | |
| 276 | + GeometryReader { space in | |
| 277 | + let compactness = min(1, max(0, (860 - space.size.height) / 120)) | |
| 278 | + VStack(spacing: 0) { | |
| 279 | + toolbar(compactness: compactness, narrow: space.size.width < 1250) | |
| 280 | + Divider() | |
| 281 | + visualizers(compactness: compactness) | |
| 282 | + Divider() | |
| 283 | + HStack(spacing: 0) { | |
| 284 | + VStack(spacing: 0) { | |
| 285 | + canvas | |
| 286 | + Divider() | |
| 287 | + if studio.isStudio { | |
| 288 | + StudioTimelineView(studio: studio, render: render, audio: audio, exporting: exporter.isExporting, present: presentStudio, compactness: compactness) | |
| 289 | + Divider() | |
| 290 | + } | |
| 291 | + SoundtrackControls(audio: audio, exporting: exporter.isExporting, | |
| 292 | + selectSoundtrack: selectSoundtrack, chooseMusic: { showMusicPicker = true }, compactness: compactness) | |
| 293 | + .padding(.horizontal, 20).padding(.vertical, 20 - 10 * compactness).background(panel) | |
| 294 | + } | |
| 295 | + Divider() | |
| 296 | + inspector.frame(width: 300) | |
| 297 | + } | |
| 298 | + Divider() | |
| 299 | + HStack { | |
| 300 | + Text(message.isEmpty ? (radio.isActive ? radio.status : audio.status) : message).lineLimit(1) | |
| 301 | + Spacer() | |
| 302 | + if !exporter.status.isEmpty { Text(exporter.status).lineLimit(1).foregroundStyle(exporter.didFail ? .red : .secondary) } | |
| 303 | + Text(presetLibrary.pool.enabled ? "\(presetLibrary.eligibleScenes.count) of \(presetLibrary.availableScenes.count) visualizers" : "\(presetLibrary.availableScenes.count) visualizers").foregroundStyle(.secondary) | |
| 304 | + }.font(.system(size: 11)).padding(.horizontal, 20).padding(.vertical, 9) | |
| 305 | + } | |
| 306 | + } | |
| 307 | + .background(background).tint(accent) | |
| 308 | + .onReceive(NotificationCenter.default.publisher(for: .pulseCanvasOpenBackupProject)) { notification in | |
| 309 | + if let data = notification.object as? Data { openProject(data) } | |
| 310 | + } | |
| 311 | + .onAppear { | |
| 312 | + if let id = UserDefaults.standard.string(forKey: UserBackup.activeKey), | |
| 313 | + UserDefaults.standard.string(forKey: "PulseCanvas.backup.openedSession.v1") != id, | |
| 314 | + let data = try? Data(contentsOf: UserBackup.documents.appendingPathComponent("Backup-current.pulsecanvas")) { | |
| 315 | + UserDefaults.standard.set(id, forKey: "PulseCanvas.backup.openedSession.v1") | |
| 316 | + openProject(data) | |
| 317 | + } | |
| 318 | + } | |
| 319 | + .overlay { ExportOverlayView(exporter: exporter) } | |
| 320 | + .sheet(isPresented: $showVisualizerBrowser) { | |
| 321 | + PulseCanvasLibraryView(radio: radio, selected: render.scene, | |
| 322 | + appearance: { $0 == render.scene ? studio.preset(render) : studio.presets[$0] ?? VisualPreset.defaults(for: $0) }, | |
| 323 | + choose: { scene in choose(scene); showVisualizerBrowser = false }, | |
| 324 | + dismiss: { showVisualizerBrowser = false }) | |
| 325 | + .dismissOnOutsideClick { showVisualizerBrowser = false } | |
| 326 | + } | |
| 327 | + .sheet(isPresented: $showProjectSettings) { projectSettings.dismissOnOutsideClick { showProjectSettings = false } } | |
| 328 | + .sheet(isPresented: $showHelp) { | |
| 329 | + VStack(alignment: .leading, spacing: 18) { | |
| 330 | + Text("Create a music visual").font(.title2) | |
| 331 | + Button("Welcome to PulseCanvas Studio") { | |
| 332 | + showHelp = false; audio.pause() | |
| 333 | + NotificationCenter.default.post(name: .pulseCanvasOnboarding, object: nil) | |
| 334 | + }.buttonStyle(StudioButtonStyle()) | |
| 335 | + Text("1. Choose a visualizer from the top row. Adjust its colors, motion, and camera on the right.") | |
| 336 | + Text("2. Add a soundtrack. Play or scrub it to preview how the visuals react to the music.") | |
| 337 | + Text("3. Open Project settings to choose your canvas shape and video quality. Save video lets you choose a folder and saves an MP4 with your full soundtrack and visuals.") | |
| 338 | + Text("Phone uses 9:16. Portrait uses 3:4.").foregroundStyle(.secondary) | |
| 339 | + DisclosureGroup("Privacy") { | |
| 340 | + Text("PulseCanvas processes music and videos locally on your Mac. Radio downloads its catalog and music from the library you choose; the hosting service receives ordinary network requests. Optional iCloud sync uploads your saved projects with their soundtracks, favorites and saved looks to your Apple Account. It is off until you enable it in Settings. Playback, volume, personal Radio albums and access bookmarks stay on this device. The app has no PulseCanvas account, usage analytics or advertising tracking and does not record your microphone. Ordinary project files reference audio; iCloud projects include a separate soundtrack copy.") | |
| 341 | + .font(.callout).foregroundStyle(.secondary) | |
| 342 | + } | |
| 343 | + Button("Legal & Credits") { openWindow(id: "legal-credits") } | |
| 344 | + .buttonStyle(StudioButtonStyle(compact: true)) | |
| 345 | + Button("Done") { showHelp = false }.buttonStyle(StudioButtonStyle(treatment: .primary)) | |
| 346 | + }.padding(30).frame(width: 500) | |
| 347 | + .dismissOnOutsideClick { showHelp = false } | |
| 348 | + } | |
| 349 | + } | |
| 350 | + | |
| 351 | + private func toolbar(compactness: CGFloat, narrow: Bool) -> some View { | |
| 352 | + HStack(spacing: 10) { | |
| 353 | + Button { studio.randomizeScene(render) } label: { | |
| 354 | + Label("Random visualizer", systemImage: "shuffle") | |
| 355 | + }.buttonStyle(StudioButtonStyle(treatment: .accent)) | |
| 356 | + .help("Pick a fresh visualizer look, or restore a saved favorite") | |
| 357 | + .disabled(!presetLibrary.eligibleScenes.contains { $0 != render.scene }) | |
| 358 | + VisualizerRandomizerPicker() | |
| 359 | + #if DIRECT_BUILD && canImport(Sparkle) && !LOCAL_BUILD | |
| 360 | + AppUpdateButton(updater: updater) | |
| 361 | + #endif | |
| 362 | + Spacer(minLength: 8) | |
| 363 | + Button { showVisualizerBrowser = true } label: { Label("Library", systemImage: "square.grid.2x2") } | |
| 364 | + .help("Browse categories and save favorites") | |
| 365 | + Button { showRadio = true } label: { Label("Radio", systemImage: "dot.radiowaves.left.and.right") } | |
| 366 | + .help("Listen with beat-aligned visuals from all, favorites, or a category") | |
| 367 | + Button { openProject() } label: { Label("Open project", systemImage: "folder") } | |
| 368 | + Button { saveProject() } label: { Label("Save project", systemImage: "square.and.arrow.down") } | |
| 369 | + Button { showProjectSettings = true } label: { Label("Project settings", systemImage: "gearshape") } | |
| 370 | + Button { startExport() } label: { Label("Save video", systemImage: "square.and.arrow.down") } | |
| 371 | + .buttonStyle(StudioButtonStyle(treatment: .primary)) | |
| 372 | + .help("Choose a destination and save your video as an MP4") | |
| 373 | + Button { showHelp = true } label: { | |
| 374 | + Image(systemName: "questionmark").font(.system(size: 17, weight: .semibold)) | |
| 375 | + } | |
| 376 | + .buttonStyle(StudioButtonStyle(circular: true)) | |
| 377 | + .help("How to create a video").accessibilityLabel("Help") | |
| 378 | + }.buttonStyle(StudioButtonStyle(compact: narrow)).lineLimit(1) | |
| 379 | + .padding(.horizontal, 22).padding(.vertical, 14 - 8 * compactness).disabled(exporter.isExporting) | |
| 380 | + } | |
| 381 | + | |
| 382 | + private func visualizers(compactness: CGFloat) -> some View { | |
| 383 | + HStack(spacing: 14) { | |
| 384 | + VStack(spacing: 1) { | |
| 385 | + Button("Visualizers") { radio.leave(); studio.isStudio = false } | |
| 386 | + .buttonStyle(StudioTabStyle(selected: !studio.isStudio)) | |
| 387 | + Button("Studio") { | |
| 388 | + studio.save(render); studio.isStudio = true | |
| 389 | + if studio.segments.isEmpty { detectSegments() } | |
| 390 | + studio.follow(time: audio.playbackSeconds, render: render) | |
| 391 | + }.buttonStyle(StudioTabStyle(selected: studio.isStudio)) | |
| 392 | + }.padding(2).frame(width: 100) | |
| 393 | + .background(.black.opacity(0.18), in: RoundedRectangle(cornerRadius: 8)) | |
| 394 | + .overlay(RoundedRectangle(cornerRadius: 8).strokeBorder(.white.opacity(0.12))) | |
| 395 | + .disabled(exporter.isExporting) | |
| 396 | + VisualizerPresetStrip(selected:render.scene, revealRequest: studio.visualizerRevealRequest, poolRevision: presetLibrary.poolRevision, accent:accent, background:background, choose:choose) | |
| 397 | + .equatable().frame(height: 90) | |
| 398 | + .overlay { | |
| 399 | + HStack(spacing: 0) { | |
| 400 | + Rectangle().frame(width: 1) | |
| 401 | + Spacer(minLength: 0) | |
| 402 | + Rectangle().frame(width: 1) | |
| 403 | + } | |
| 404 | + .frame(height: 62) | |
| 405 | + .offset(y: -8) | |
| 406 | + .foregroundStyle(.white.opacity(0.22)) | |
| 407 | + .allowsHitTesting(false) | |
| 408 | + .accessibilityHidden(true) | |
| 409 | + } | |
| 410 | + }.padding(.horizontal, 20).padding(.vertical, 8 - 4 * compactness).background(panel).disabled(exporter.isExporting) | |
| 411 | + } | |
| 412 | + | |
| 413 | + private var canvas: some View { | |
| 414 | + GeometryReader { space in | |
| 415 | + let layout = CanvasPreviewLayout(size: space.size, aspectRatio: exporter.aspect.aspectRatio) | |
| 416 | + ZStack { | |
| 417 | + ZStack { | |
| 418 | + Rectangle().fill(Color.black) | |
| 419 | + if !exporter.isExporting { | |
| 420 | + VisualizerView(state: render) | |
| 421 | + .modifier(VisualizerFavoriteGesture { | |
| 422 | + presetLibrary.favorite(render.scene, appearance: studio.preset(render)) | |
| 423 | + }) | |
| 424 | + } | |
| 425 | + }.frame(width: layout.preview.width, height: layout.preview.height) | |
| 426 | + .clipShape(RoundedRectangle(cornerRadius: 3)) | |
| 427 | + .overlay(RoundedRectangle(cornerRadius: 3).stroke(.white.opacity(0.12))) | |
| 428 | + .position(x: layout.preview.midX, y: layout.preview.midY) | |
| 429 | + VStack(spacing: 0) { | |
| 430 | + canvasHeader | |
| 431 | + .shadow(color: layout.overlaysChrome ? .black.opacity(0.8) : .clear, radius: 3, y: 1) | |
| 432 | + Spacer(minLength: 0) | |
| 433 | + canvasFooter | |
| 434 | + .shadow(color: layout.overlaysChrome ? .black.opacity(0.8) : .clear, radius: 3, y: 1) | |
| 435 | + }.padding(layout.padding) | |
| 436 | + }.frame(width: space.size.width, height: space.size.height).clipped() | |
| 437 | + }.frame(maxWidth: .infinity, maxHeight: .infinity) | |
| 438 | + } | |
| 439 | + | |
| 440 | + private var canvasHeader: some View { | |
| 441 | + HStack { | |
| 442 | + Button { presetLibrary.toggleFavorite(render.scene, appearance: studio.preset(render)) } label: { | |
| 443 | + Image(systemName: presetLibrary.isFavorite(render.scene) ? "heart.fill" : "heart") | |
| 444 | + }.buttonStyle(StudioButtonStyle(treatment: presetLibrary.isFavorite(render.scene) ? .accent : .quiet, compact: true, circular: true)) | |
| 445 | + .help(presetLibrary.isFavorite(render.scene) ? "Remove this visualizer from Favorites" : "Add this visualizer to Favorites") | |
| 446 | + .disabled(exporter.isExporting) | |
| 447 | + .accessibilityLabel(presetLibrary.isFavorite(render.scene) ? "Unfavorite visualizer" : "Favorite visualizer") | |
| 448 | + Text(RenderState.sceneNames[render.scene]).font(.system(size: 18, weight: .medium)).lineLimit(1) | |
| 449 | + Spacer() | |
| 450 | + if !studio.isStudio { | |
| 451 | + Button { useAtPlayhead() } label: { Label("Use at playhead", systemImage: "timeline.selection") } | |
| 452 | + .buttonStyle(StudioButtonStyle(compact: true)) | |
| 453 | + .help("Assign this visualizer to the Studio section at the current song position") | |
| 454 | + .disabled(audio.selectedURL == nil || exporter.isExporting) | |
| 455 | + Button { presentVisualizer() } label: { Label("Present", systemImage: "play.rectangle.fill") } | |
| 456 | + .buttonStyle(StudioButtonStyle(treatment: .primary, compact: true)) | |
| 457 | + .accessibilityLabel("Present visualizer full screen") | |
| 458 | + .help("Watch this visualizer full screen with the soundtrack. Escape returns to the editor.") | |
| 459 | + .disabled(exporter.isExporting) | |
| 460 | + } | |
| 461 | + } | |
| 462 | + } | |
| 463 | + | |
| 464 | + private var canvasFooter: some View { | |
| 465 | + VStack(spacing: 4) { | |
| 466 | + HStack { | |
| 467 | + Text(exporter.aspect.title).foregroundStyle(.secondary) | |
| 468 | + Spacer() | |
| 469 | + let dimensions = exporter.aspect.dimensions(resolution: exporter.resolution) | |
| 470 | + Text("\(dimensions.width) × \(dimensions.height) / \(exporter.fps) fps").monospacedDigit().foregroundStyle(.secondary) | |
| 471 | + }.font(.system(size: 11)) | |
| 472 | + if let error = render.errorMessage { Text(error).font(.caption).foregroundStyle(.red) } | |
| 473 | + } | |
| 474 | + } | |
| 475 | + | |
| 476 | + private var inspector: some View { | |
| 477 | + ScrollView { | |
| 478 | + VStack(alignment: .leading, spacing: 18) { | |
| 479 | + Group { | |
| 480 | + HStack { | |
| 481 | + Text("Visual style").font(.title3.weight(.semibold)) | |
| 482 | + Spacer() | |
| 483 | + Button("Reset") { studio.reset(render) } | |
| 484 | + .buttonStyle(StudioButtonStyle(compact: true)) | |
| 485 | + .help("Reset this visualizer to its default visual settings; all sections using it update") | |
| 486 | + .accessibilityLabel("Reset visualizer to defaults") | |
| 487 | + Button { studio.randomize(render) } label: { Image(systemName: "dice.fill").font(.system(size: 20, weight: .medium)).frame(width: 32, height: 32).contentShape(Rectangle()) } | |
| 488 | + .buttonStyle(StudioButtonStyle(compact: true)).help("Randomize visuals").accessibilityLabel("Randomize visuals") | |
| 489 | + } | |
| 490 | + if render.scene < RenderState.nativeSceneNames.count { | |
| 491 | + Text("Color palette").font(.system(size: 12, weight: .medium)) | |
| 492 | + VStack(spacing: 4) { | |
| 493 | + ForEach(VisualPalette.allCases, id: \.rawValue) { palette in | |
| 494 | + Button { render.palette = palette.rawValue; studio.save(render) } label: { | |
| 495 | + HStack(spacing: 10) { | |
| 496 | + HStack(spacing: 0) { | |
| 497 | + ForEach(0..<palette.stops.count, id: \.self) { index in | |
| 498 | + let rgb = palette.stops[index] | |
| 499 | + Rectangle().fill(Color(red: Double(rgb.x), green: Double(rgb.y), blue: Double(rgb.z))) | |
| 500 | + } | |
| 501 | + }.frame(width: 70, height: 18).clipShape(RoundedRectangle(cornerRadius: 4)) | |
| 502 | + Text(palette.title).font(.system(size: 12)) | |
| 503 | + Spacer() | |
| 504 | + if render.palette == palette.rawValue { Image(systemName: "checkmark").foregroundStyle(accent) } | |
| 505 | + }.padding(.horizontal, 10).frame(minHeight: 44) | |
| 506 | + .background(render.palette == palette.rawValue ? accent.opacity(0.12) : background.opacity(0.4), in: RoundedRectangle(cornerRadius: 6)) | |
| 507 | + .contentShape(Rectangle()) | |
| 508 | + }.buttonStyle(.plain).accessibilityLabel(palette.title).accessibilityAddTraits(render.palette == palette.rawValue ? .isSelected : []) | |
| 509 | + } | |
| 510 | + } | |
| 511 | + } else { | |
| 512 | + Text("This preset supplies its own colors, shapes, waves, and feedback. Adjust motion and audio response below.") | |
| 513 | + .font(.system(size: 12)).foregroundStyle(.secondary) | |
| 514 | + } | |
| 515 | + Divider() | |
| 516 | + Text("Motion & depth").font(.system(size: 12, weight: .medium)) | |
| 517 | + control("Motion speed", key: \.speed, range: 0.05...3) | |
| 518 | + control("Zoom speed", key: \.zoomSpeed, range: 0...3) | |
| 519 | + .help("Add continuous forward zoom. Zero keeps the framing flat while the visualization continues animating.") | |
| 520 | + control("Chaos", key: \.chaos, range: 0...1) | |
| 521 | + .help("Zero turns off music response while smooth visualization motion and zoom continue. Increase for beat-driven waves, local swelling, liquid deformation, and motion.") | |
| 522 | + control("Brightness", key: \.brightness, range: 0.1...3) | |
| 523 | + if let detail = NativeEffects.effect(render.scene)?.detailLabel { | |
| 524 | + control(LocalizedStringKey(detail), key: \.liquidDetail, range: 0...1) | |
| 525 | + .help(render.scene == 23 ? "Add flowing ripples, finer folds, and sharper liquid reflections." : "Add finer structure and surface detail.") | |
| 526 | + } | |
| 527 | + if render.scene == 28 { | |
| 528 | + VStack(alignment: .leading, spacing: 4) { | |
| 529 | + HStack { Text("Halo count"); Spacer(); Text("\(render.haloCount)").foregroundStyle(.secondary).monospacedDigit() } | |
| 530 | + Slider(value: Binding(get: { Float(render.haloCount) }, set: { render.haloCount = Int($0.rounded()); studio.save(render) }), in: 1...12, step: 1) | |
| 531 | + .accessibilityLabel("Halo count") | |
| 532 | + }.font(.system(size: 11)) | |
| 533 | + .help("Number of rings in each travelling group. Add more for a denser field of halos.") | |
| 534 | + } | |
| 535 | + if render.scene < RenderState.nativeSceneNames.count { | |
| 536 | + control(LocalizedStringKey(NativeEffects.effect(render.scene)?.sizeLabel ?? "Particle size"), key: \.particleSize, range: 0.3...6) | |
| 537 | + control("Depth / fog", key: \.fog, range: 0...1) | |
| 538 | + } | |
| 539 | + control("Camera zoom", key: \.zoom, range: 0.3...2) | |
| 540 | + control("Camera rotation", key: \.rotation, range: -3.14...3.14) | |
| 541 | + control("Blur", key: \.motionBlur, range: 0...0.9) | |
| 542 | + Toggle("Hi-hat strobe", isOn: Binding(get: { render.strobeEnabled }, set: { render.strobeEnabled = $0; studio.save(render) })).toggleStyle(StudioSwitchStyle()) | |
| 543 | + if render.strobeEnabled { | |
| 544 | + control("Strobe sensitivity", key: \.strobeSensitivity, range: 0.25...4) | |
| 545 | + control("Flash strength", key: \.strobeStrength, range: 0.1...1) | |
| 546 | + Text("White flashes follow rapid high-frequency attacks in the soundtrack.").font(.system(size: 10)).foregroundStyle(.secondary) | |
| 547 | + } | |
| 548 | + }.disabled(exporter.isExporting) | |
| 549 | + if let url = exporter.exportedURL { | |
| 550 | + Button { NSWorkspace.shared.activateFileViewerSelecting([url]) } label: { | |
| 551 | + Label("Show in Finder", systemImage: "folder").frame(maxWidth: .infinity) | |
| 552 | + }.buttonStyle(StudioButtonStyle(compact: true)) | |
| 553 | + } | |
| 554 | + }.padding(19) | |
| 555 | + }.background(panel) | |
| 556 | + } | |
| 557 | + | |
| 558 | + private var projectSettings: some View { | |
| 559 | + VStack(alignment: .leading, spacing: 22) { | |
| 560 | + Text("Project settings").font(.title2.weight(.semibold)) | |
| 561 | + Text("Canvas shape and export quality for this project.").font(.system(size: 13)).foregroundStyle(.secondary) | |
| 562 | + VStack(spacing: 18) { | |
| 563 | + Picker("Canvas", selection: $exporter.aspect) { | |
| 564 | + ForEach(SocialAspect.allCases) { aspect in Text(aspect.title).tag(aspect) } | |
| 565 | + } | |
| 566 | + Picker("Resolution", selection: $exporter.resolution) { Text("720p").tag(720); Text("1080p").tag(1080); Text("4K").tag(2160) } | |
| 567 | + Picker("Frame rate", selection: $exporter.fps) { | |
| 568 | + ForEach(SocialExportController.supportedFrameRates, id: \.self) { rate in | |
| 569 | + Text(rate == 120 ? "120 fps (Experimental)" : "\(rate) fps").tag(rate) | |
| 570 | + } | |
| 571 | + } | |
| 572 | + }.pickerStyle(.menu).controlSize(.large) | |
| 573 | + if exporter.fps == 120 { | |
| 574 | + HStack(alignment: .top, spacing: 10) { | |
| 575 | + Image(systemName: "flask").foregroundStyle(accent) | |
| 576 | + VStack(alignment: .leading, spacing: 6) { | |
| 577 | + Text("Experimental frame rate").font(.system(size: 13, weight: .semibold)) | |
| 578 | + Text("120 fps renders twice as many frames as 60 fps. Export times and playback support vary.") | |
| 579 | + .font(.system(size: 12)).foregroundStyle(.secondary) | |
| 580 | + #if !STORE_BUILD | |
| 581 | + Text("Some OpenGL presets may become darker or look different. Choose 60 fps if this happens.") | |
| 582 | + .font(.system(size: 12)).foregroundStyle(.secondary) | |
| 583 | + #endif | |
| 584 | + }.fixedSize(horizontal: false, vertical: true) | |
| 585 | + }.padding(14).frame(maxWidth: .infinity, alignment: .leading) | |
| 586 | + .background(accent.opacity(0.08), in: RoundedRectangle(cornerRadius: 12)) | |
| 587 | + } | |
| 588 | + Text("Resolution uses the shorter canvas edge. Export saves an MP4 with the soundtrack included.") | |
| 589 | + .font(.system(size: 12)).foregroundStyle(.secondary) | |
| 590 | + HStack { | |
| 591 | + Spacer() | |
| 592 | + Button("Done") { showProjectSettings = false }.buttonStyle(StudioButtonStyle(treatment: .primary)) | |
| 593 | + } | |
| 594 | + }.padding(30).frame(width: 460).tint(accent) | |
| 595 | + } | |
| 596 | + | |
| 597 | + private func control(_ name: LocalizedStringKey, key: ReferenceWritableKeyPath<RenderState, Float>, range: ClosedRange<Float>) -> some View { | |
| 598 | + VStack(spacing: 6) { | |
| 599 | + HStack { Text(name); Spacer(); Text(String(format: "%.2f", render[keyPath: key])).monospacedDigit().foregroundStyle(.secondary) }.font(.system(size: 11)) | |
| 600 | + Slider(value: Binding(get: { render[keyPath: key] }, set: { render[keyPath: key] = $0; studio.save(render) }), in: range) | |
| 601 | + .accessibilityLabel(name) | |
| 602 | + } | |
| 603 | + } | |
| 604 | + private func presentStudio() { | |
| 605 | + guard studio.isStudio, audio.selectedURL != nil, !studio.segments.isEmpty, !exporter.isExporting else { return } | |
| 606 | + studio.save(render) | |
| 607 | + if presentation.present(audio: audio) { audio.playFullSoundtrack() } | |
| 608 | + } | |
| 609 | + | |
| 610 | + private func presentVisualizer() { | |
| 611 | + guard !studio.isStudio, !exporter.isExporting else { return } | |
| 612 | + studio.save(render) | |
| 613 | + if presentation.present(audio: audio, mode: .visualizer) { audio.playFullSoundtrack() } | |
| 614 | + } | |
| 615 | + | |
| 616 | + private func choose(_ index: Int) { studio.selectScene(index, render: render); if index >= RenderState.nativeSceneNames.count { render.audioPCM = audio.visualizationPCM(at: audio.playbackSeconds) } } | |
| 617 | + private func useAtPlayhead() { | |
| 618 | + if studio.segments.isEmpty { detectSegments() } | |
| 619 | + if let index = studio.assignAtPlayhead(audio.playbackSeconds, render: render) { | |
| 620 | + message = String(localized: "\(RenderState.sceneNames[render.scene]) assigned to section \(index + 1) · \(format(studio.segments[index].start))") | |
| 621 | + } else { message = String(localized: "Add a soundtrack to create Studio sections") } | |
| 622 | + } | |
| 623 | + private func detectSegments() { | |
| 624 | + guard let plan = audio.segmentPlan(beatsPerSection: studio.beatsPerSection) else { return } | |
| 625 | + studio.makeTimeline(plan, render: render) | |
| 626 | + studio.follow(time: audio.playbackSeconds, render: render) | |
| 627 | + } | |
| 628 | + private func format(_ seconds: Double) -> String { guard seconds.isFinite else { return "0:00" }; return String(format: "%d:%02d", Int(max(0, seconds)) / 60, Int(max(0, seconds)) % 60) } | |
| 629 | + private func selectSoundtrack() { | |
| 630 | + let picker = NSOpenPanel(); picker.allowedContentTypes = [.audio]; picker.allowsMultipleSelection = false; picker.canChooseDirectories = false | |
| 631 | + picker.message = String(localized: "Choose the soundtrack for this video") | |
| 632 | + if picker.runModal() == .OK, let url = picker.url { | |
| 633 | + radio.leave() | |
| 634 | + if audio.load(url: url) { message = "" } | |
| 635 | + } | |
| 636 | + } | |
| 637 | + private func importLibrarySong(_ url: URL, title: String) async throws { | |
| 638 | + let directory = UserDataStorage.support.appendingPathComponent("StudioMusic", isDirectory: true) | |
| 639 | + let prepared = try await Task.detached(priority: .userInitiated) { | |
| 640 | + let copy = try StudioMusicStorage.copy(url, title: title, into: directory) | |
| 641 | + do { return try PreparedSoundtrack(url: copy) } | |
| 642 | + catch { try? FileManager.default.removeItem(at: copy.deletingLastPathComponent()); throw error } | |
| 643 | + }.value | |
| 644 | + do { try Task.checkCancellation() } | |
| 645 | + catch { try? FileManager.default.removeItem(at: prepared.url.deletingLastPathComponent()); throw error } | |
| 646 | + radio.leave(); studio.isStudio = true | |
| 647 | + guard audio.install(prepared, title: title) else { throw CocoaError(.fileReadCorruptFile) } | |
| 648 | + message = "" | |
| 649 | + } | |
| 650 | + private func startExport() { | |
| 651 | + guard !exporter.isExporting else { return } | |
| 652 | + let picker = NSSavePanel(); picker.allowedContentTypes = [.mpeg4Movie]; picker.nameFieldStringValue = "PulseCanvas-\(RenderState.sceneNames[render.scene].replacingOccurrences(of: "/", with: "-").replacingOccurrences(of: " ", with: "-").prefix(120)).mp4" | |
| 653 | + picker.title = String(localized: "Save video") | |
| 654 | + picker.prompt = String(localized: "Save video") | |
| 655 | + picker.canCreateDirectories = true | |
| 656 | + picker.message = String(localized: "Choose where to save your finished video") | |
| 657 | + guard picker.runModal() == .OK, let url = picker.url else { return } | |
| 658 | + radio.pause(); audio.pause() | |
| 659 | + studio.save(render) | |
| 660 | + let segments = studio.isStudio ? studio.segments : [] | |
| 661 | + let appearances = studio.presets | |
| 662 | + Task { await exporter.export(audioURL: audio.selectedURL, render: render, to: url, segments: segments, appearances: appearances) } | |
| 663 | + } | |
| 664 | + private func saveProject() { | |
| 665 | + let picker = NSSavePanel(); picker.nameFieldStringValue = "Untitled.pulsecanvas"; picker.allowedContentTypes = [UTType(filenameExtension: "pulsecanvas") ?? .json]; picker.canSelectHiddenExtension = true | |
| 666 | + guard picker.runModal() == .OK, let url = picker.url else { return } | |
| 667 | + studio.save(render) | |
| 668 | + if studio.cloudProjectID == nil { studio.cloudProjectID = UUID().uuidString } | |
| 669 | + do { | |
| 670 | + let data = try studio.document(audio: audio, render: render, exporter: exporter).encoded() | |
| 671 | + try data.write(to: url, options: .atomic) | |
| 672 | + try UserBackup.rememberProject(data, name: url.path) | |
| 673 | + message = String(localized: "Project saved") | |
| 674 | + } | |
| 675 | + catch { message = String(localized: "Cannot save project: \(error.localizedDescription)") } | |
| 676 | + } | |
| 677 | + private func openProject() { | |
| 678 | + let picker = NSOpenPanel(); picker.allowsMultipleSelection = false; picker.canChooseDirectories = false; picker.message = String(localized: "Choose a PulseCanvas project") | |
| 679 | + guard picker.runModal() == .OK, let url = picker.url else { return } | |
| 680 | + do { | |
| 681 | + let data = try Data(contentsOf: url) | |
| 682 | + if openProject(data) { try UserBackup.rememberProject(data, name: url.path) } | |
| 683 | + } catch { message = String(localized: "Cannot open project: \(error.localizedDescription)") } | |
| 684 | + } | |
| 685 | + @discardableResult | |
| 686 | + private func openProject(_ data: Data) -> Bool { | |
| 687 | + radio.leave() | |
| 688 | + do { | |
| 689 | + var project = try JSONDecoder().decode(CreatorProject.self, from: data) | |
| 690 | + project = try project.remapped(using: presetLibrary) | |
| 691 | + let aspect = try project.checkedAspect() | |
| 692 | + let soundtrack = try BundledSoundtrack.resolve(identifier: project.bundledSoundtrack, externalURL: project.soundtrack) | |
| 693 | + let previousSoundtrack = studio.timelineSoundtrack | |
| 694 | + studio.timelineSoundtrack = soundtrack | |
| 695 | + if let soundtrack { | |
| 696 | + if !audio.load(url: soundtrack, bookmark: project.soundtrackBookmark) { | |
| 697 | + let locate = NSOpenPanel() | |
| 698 | + locate.allowedContentTypes = [.audio] | |
| 699 | + locate.allowsMultipleSelection = false; locate.canChooseDirectories = false | |
| 700 | + locate.message = String(localized: "Locate this project’s soundtrack: \(soundtrack.lastPathComponent). Saved projects reference audio files; they do not include the audio.") | |
| 701 | + guard locate.runModal() == .OK, let replacement = locate.url, audio.load(url: replacement) else { | |
| 702 | + studio.timelineSoundtrack = previousSoundtrack; message = String(localized: "Project was not opened. Its soundtrack is unavailable."); return false | |
| 703 | + } | |
| 704 | + } | |
| 705 | + studio.timelineSoundtrack = audio.selectedURL | |
| 706 | + } else { audio.clear() } | |
| 707 | + guard (project.timeline?.last?.end ?? 0) <= audio.duration + 0.05 else { throw CocoaError(.fileReadCorruptFile) } | |
| 708 | + studio.applyDocument(project, aspect: aspect, audio: audio, render: render, exporter: exporter) | |
| 709 | + message = String(localized: "Project opened") | |
| 710 | + return true | |
| 711 | + } catch { | |
| 712 | + message = String(localized: "Cannot open project: \(error.localizedDescription)") | |
| 713 | + return false | |
| 714 | + } | |
| 715 | + } | |
| 716 | + } | |
| 717 | + | |
| 718 | + private struct SpectrumMeter: View { | |
| 719 | + let bands: [Float] | |
| 720 | + var body: some View { | |
| 721 | + GeometryReader { size in | |
| 722 | + let gap: CGFloat = 2 | |
| 723 | + HStack(alignment: .bottom, spacing: gap) { | |
| 724 | + ForEach(0..<16, id: \.self) { index in | |
| 725 | + let band = bands.indices.contains(index) && bands[index].isFinite ? CGFloat(bands[index]) : 0 | |
| 726 | + let height = max(2, size.size.height * min(1, max(0, band))) | |
| 727 | + RoundedRectangle(cornerRadius: 0.5) | |
| 728 | + .fill(Color(red: 0.95, green: 0.68, blue: 0.55).opacity(0.7)) | |
| 729 | + .frame(width: 3, height: height) | |
| 730 | + .animation(.linear(duration: 0.065), value: height) | |
| 731 | + } | |
| 732 | + }.frame(width: size.size.width, height: size.size.height, alignment: .bottomLeading) | |
| 733 | + } | |
| 734 | + } | |
| 735 | + } | |
| 736 | + | |
| 737 | + /// Keep frame-rate playback updates inside the small soundtrack panel. | |
| 738 | + @MainActor | |
| 739 | + private struct SoundtrackControls: View { | |
| 740 | + @ObservedObject var audio: AudioController | |
| 741 | + let exporting: Bool | |
| 742 | + let selectSoundtrack: () -> Void | |
| 743 | + let chooseMusic: () -> Void | |
| 744 | + var compactness: CGFloat = 0 | |
| 745 | + @State private var playbackRevision = 0 | |
| 746 | + private let accent = Color(red: 0.95, green: 0.68, blue: 0.55) | |
| 747 | + var body: some View { | |
| 748 | + let _ = playbackRevision | |
| 749 | + VStack(alignment: .leading, spacing: 14 - 6 * compactness) { | |
| 750 | + HStack(spacing: 12) { | |
| 751 | + Image(systemName: "waveform").font(.system(size: 18)).foregroundStyle(accent) | |
| 752 | + .frame(width: 44, height: 44).background(accent.opacity(0.1), in: RoundedRectangle(cornerRadius: 10)) | |
| 753 | + VStack(alignment: .leading, spacing: 4) { | |
| 754 | + Text(audio.title).font(.system(size: 14, weight: .semibold)).lineLimit(1) | |
| 755 | + Text(audio.selectedURL == nil ? "Add music to sync your visuals." : "\(format(audio.duration)) soundtrack") | |
| 756 | + .font(.system(size: 12)).foregroundStyle(.secondary) | |
| 757 | + } | |
| 758 | + Spacer() | |
| 759 | + Menu { | |
| 760 | + Button("Choose music", action: chooseMusic) | |
| 761 | + Button("Choose audio file…", action: selectSoundtrack) | |
| 762 | + } label: { | |
| 763 | + Label(audio.selectedURL == nil ? "Add soundtrack" : "Replace audio", systemImage: "waveform.badge.plus") | |
| 764 | + }.menuStyle(.borderlessButton).fixedSize() | |
| 765 | + if audio.selectedURL != nil { | |
| 766 | + Button { audio.clear() } label: { Image(systemName: "xmark").frame(width: 20) } | |
| 767 | + .buttonStyle(StudioButtonStyle(treatment: .quiet, compact: true)) | |
| 768 | + .help("Remove soundtrack").accessibilityLabel("Remove soundtrack") | |
| 769 | + } | |
| 770 | + }.buttonStyle(StudioButtonStyle()) | |
| 771 | + HStack(spacing: 14) { | |
| 772 | + Button { audio.playPause() } label: { | |
| 773 | + Image(systemName: audio.isPlaying ? "pause.fill" : "play.fill") | |
| 774 | + .font(.system(size: 17, weight: .semibold)).frame(width: 32, height: 4) | |
| 775 | + }.buttonStyle(StudioButtonStyle(treatment: .primary, compact: true)) | |
| 776 | + .accessibilityLabel(audio.isPlaying ? "Pause soundtrack" : "Play soundtrack") | |
| 777 | + .help("Play or pause soundtrack (Space)").disabled(audio.selectedURL == nil) | |
| 778 | + VStack(spacing: 4) { | |
| 779 | + HStack { | |
| 780 | + Text(format(audio.playbackSeconds)) | |
| 781 | + Spacer() | |
| 782 | + Text(format(audio.duration)).foregroundStyle(.secondary) | |
| 783 | + }.font(.system(size: 12, weight: .medium)).monospacedDigit() | |
| 784 | + Slider(value: Binding(get: { audio.progress }, set: { audio.seek(fraction: $0) }), in: 0...1) | |
| 785 | + .accessibilityLabel("Soundtrack position").disabled(audio.selectedURL == nil) | |
| 786 | + } | |
| 787 | + SpectrumMeter(bands: audio.spectrum).frame(width: 78, height: 28).accessibilityHidden(true) | |
| 788 | + Toggle("Loop", isOn: $audio.loopEnabled).toggleStyle(StudioSwitchStyle(icon: "repeat")) | |
| 789 | + .fixedSize(horizontal: true, vertical: false) | |
| 790 | + .help("Repeat the soundtrack when it ends").disabled(audio.selectedURL == nil) | |
| 791 | + HStack(spacing: 8) { | |
| 792 | + Image(systemName: "speaker.wave.2").font(.system(size: 13)).foregroundStyle(.secondary) | |
| 793 | + Slider(value: $audio.volume, in: 0...1).frame(width: 70).accessibilityLabel("Preview volume") | |
| 794 | + } | |
| 795 | + } | |
| 796 | + }.disabled(exporting) | |
| 797 | + .onReceive(audio.visualizationUpdated.throttle(for: .milliseconds(33), scheduler: RunLoop.main, latest: true)) { playbackRevision &+= 1 } | |
| 798 | + } | |
| 799 | + | |
| 800 | + private func format(_ seconds: Double) -> String { | |
| 801 | + let seconds = max(0, Int(seconds)); return "\(seconds / 60):\(String(format: "%02d", seconds % 60))" | |
| 802 | + } | |
| 803 | + } |
Sources/PulseCanvas/PulseCanvasMCP.swift added
| 1 | + #if os(macOS) && DIRECT_BUILD && !STORE_BUILD | |
| 2 | + import CoreFoundation | |
| 3 | + import Darwin | |
| 4 | + import Foundation | |
| 5 | + | |
| 6 | + struct PulseMCPError: LocalizedError { | |
| 7 | + let code: String | |
| 8 | + let message: String | |
| 9 | + init(_ code: String, _ message: String) { self.code = code; self.message = message } | |
| 10 | + var errorDescription: String? { message } | |
| 11 | + var payload: [String: Any] { ["code": code, "message": message] } | |
| 12 | + } | |
| 13 | + | |
| 14 | + enum PulseMCP { | |
| 15 | + typealias Object = [String: Any] | |
| 16 | + static let argument = "--mcp" | |
| 17 | + static let maxMessage = 2_000_000 | |
| 18 | + private static let versions = ["2025-11-25", "2025-06-18", "2025-03-26", "2024-11-05"] | |
| 19 | + | |
| 20 | + struct Tool { | |
| 21 | + let name: String | |
| 22 | + let description: String | |
| 23 | + let input: Object | |
| 24 | + let output: Object | |
| 25 | + let permission: String? | |
| 26 | + var schema: Object { | |
| 27 | + ["name": name, "description": description, "inputSchema": input, "outputSchema": output, | |
| 28 | + "annotations": ["readOnlyHint": permission == nil]] | |
| 29 | + } | |
| 30 | + } | |
| 31 | + | |
| 32 | + static func object(_ properties: Object, required: [String] = [], open: Bool = false) -> Object { | |
| 33 | + ["type": "object", "properties": properties, "required": required, "additionalProperties": open] | |
| 34 | + } | |
| 35 | + | |
| 36 | + static func text(_ values: [String]? = nil, limit: Int = 4096) -> Object { | |
| 37 | + var schema: Object = ["type": "string", "minLength": 1, "maxLength": limit] | |
| 38 | + if let values { schema["enum"] = values } | |
| 39 | + return schema | |
| 40 | + } | |
| 41 | + static func number(_ min: Double, _ max: Double, integer: Bool = false) -> Object { | |
| 42 | + ["type": integer ? "integer" : "number", "minimum": min, "maximum": max] | |
| 43 | + } | |
| 44 | + static func array(_ items: Object, max: Int = 10_000) -> Object { | |
| 45 | + ["type": "array", "items": items, "maxItems": max] | |
| 46 | + } | |
| 47 | + static let boolean = ["type": "boolean"] | |
| 48 | + static let resolutions = [720, 1080, 2160] | |
| 49 | + static let aspectNames = ["wide", "landscape", "portrait", "phone", "square"] | |
| 50 | + static var format: Object { | |
| 51 | + ["aspect": text(aspectNames), "resolution": ["type": "integer", "enum": resolutions], | |
| 52 | + "fps": ["type": "integer", "enum": [24, 30, 60]]] | |
| 53 | + } | |
| 54 | + static let id = text(limit: 256) | |
| 55 | + static let path = text() | |
| 56 | + static let revision = text(limit: 64) | |
| 57 | + static let requestKey = text(limit: 128) | |
| 58 | + static let seconds = number(0, 86_400) | |
| 59 | + static let bars = number(1, 128, integer: true) | |
| 60 | + static let timelineEntry = object( | |
| 61 | + ["visualizerId": id, "startSeconds": seconds, "endSeconds": seconds, "bars": bars], | |
| 62 | + required: ["visualizerId", "startSeconds", "endSeconds"]) | |
| 63 | + static let playback = object( | |
| 64 | + ["ready": boolean, "playing": boolean, "positionSeconds": seconds, "durationSeconds": seconds, | |
| 65 | + "volume": number(0, 1), "mode": text(["studio", "radio"]), "title": text(), "revision": revision], | |
| 66 | + required: ["ready", "playing", "positionSeconds", "durationSeconds", "volume", "mode", "title", "revision"]) | |
| 67 | + static let visualizer = object( | |
| 68 | + ["id": id, "name": text(), "category": text(), "engine": text(["metal", "projectM"]), | |
| 69 | + "available": boolean, "favorite": boolean, "settings": ["type": "object"], "controls": ["type": "object"]], | |
| 70 | + required: ["id", "name", "category", "engine", "available", "favorite"]) | |
| 71 | + static let project = object( | |
| 72 | + ["id": id, "revision": revision, "soundtrackPath": path, "durationSeconds": seconds, "seed": id, | |
| 73 | + "barsPerScene": bars, "visualizerId": id, "timeline": array(timelineEntry), | |
| 74 | + "exportSettings": object(format.merging(["fps": ["type": "integer", "enum": [24, 30, 60, 120]]]) { _, actual in actual }, required: ["aspect", "resolution", "fps"]), "studioEnabled": boolean], | |
| 75 | + required: ["revision", "durationSeconds", "visualizerId", "timeline", "exportSettings", "studioEnabled"]) | |
| 76 | + static let job = object( | |
| 77 | + ["id": id, "phase": text(["queued", "preparing", "rendering", "muxing", "validating", "completed", "failed", "cancelled"]), | |
| 78 | + "progress": number(0, 1), "framesRendered": ["type": "integer"], "totalFrames": ["type": "integer"], | |
| 79 | + "etaSeconds": ["type": "number"], "destination": path, "projectPath": path, "manifestPath": path, | |
| 80 | + "previewOnly": boolean, "error": object(["code": text(), "message": text()], required: ["code", "message"]), | |
| 81 | + "artifact": object(["path": path, "durationSeconds": seconds, "width": ["type": "integer"], | |
| 82 | + "height": ["type": "integer"], "fps": ["type": "number"], "expectedFrames": ["type": "integer"], | |
| 83 | + "videoCodec": text(), "audioCodec": text(), "bytes": ["type": "integer"]], | |
| 84 | + required: ["path", "durationSeconds", "width", "height", "fps", "expectedFrames", "videoCodec", "audioCodec", "bytes"])], | |
| 85 | + required: ["id", "phase", "progress", "framesRendered", "totalFrames", "destination", "previewOnly"]) | |
| 86 | + static let visualRanges: [String: ClosedRange<Double>] = [ | |
| 87 | + "speed": 0.05...3, "zoomSpeed": 0...3, "chaos": 0...1, "brightness": 0.1...3, | |
| 88 | + "liquidDetail": 0...1, "particleSize": 0.3...6, "fog": 0...1, "zoom": 0.3...2, | |
| 89 | + "rotation": -3.14...3.14, "motionBlur": 0...0.9, "strobeSensitivity": 0.25...4, | |
| 90 | + "strobeStrength": 0.1...1, "haloCount": 1...12, "palette": 0...4 | |
| 91 | + ] | |
| 92 | + static let controlProperties: Object = { | |
| 93 | + var properties: Object = visualRanges.mapValues { number($0.lowerBound, $0.upperBound) } | |
| 94 | + for key in ["haloCount", "palette"] { | |
| 95 | + let range = visualRanges[key]! | |
| 96 | + properties[key] = number(range.lowerBound, range.upperBound, integer: true) | |
| 97 | + } | |
| 98 | + properties["strobeEnabled"] = boolean | |
| 99 | + return properties | |
| 100 | + }() | |
| 101 | + | |
| 102 | + static let tools: [Tool] = { | |
| 103 | + func tool(_ name: String, _ description: String, _ input: Object = [:], _ required: [String] = [], | |
| 104 | + output: Object, permission: String? = nil) -> Tool { | |
| 105 | + Tool(name: name, description: description, input: object(input, required: required), output: output, permission: permission) | |
| 106 | + } | |
| 107 | + let jobResult = object(["job": job], required: ["job"]) | |
| 108 | + let kind = text(["visualizer", "radioSong"]) | |
| 109 | + let projectChange = ["expectedRevision": revision] | |
| 110 | + let start = format.merging(["path": path, "expectedRevision": revision, "requestKey": requestKey, | |
| 111 | + "overwrite": boolean, "previewSeconds": number(0.5, 30)]) { first, _ in first } | |
| 112 | + let generate = format.merging(["songPath": path, "projectPath": path, "outputPath": path, "barsPerScene": bars, | |
| 113 | + "expectedRevision": revision, "requestKey": requestKey, "seed": id, | |
| 114 | + "fallback": text(["metal", "available", "error"]), "visualizerIds": array(id, max: 500), | |
| 115 | + "strobeEnabled": boolean, "previewOnly": boolean, | |
| 116 | + "previewSeconds": number(0.5, 30)]) { first, _ in first } | |
| 117 | + return [ | |
| 118 | + tool("get_app_status", "Check whether the Mac app is running and agent access is enabled.", | |
| 119 | + output: object(["running": boolean, "enabled": boolean, "edition": text(), "version": text(), | |
| 120 | + "playback": boolean, "editing": boolean, "rendering": boolean, "pendingExports": ["type": "integer"]], | |
| 121 | + required: ["running", "enabled", "edition", "version", "playback", "editing", "rendering", "pendingExports"])), | |
| 122 | + tool("get_capabilities", "Read current permissions, supported export formats, and effect controls.", | |
| 123 | + output: object(["edition": text(), "resolutions": array(["type": "integer"]), "frameRates": array(["type": "integer"]), | |
| 124 | + "aspects": array(text()), "engines": array(text()), "inputFolder": path, "outputFolder": path, | |
| 125 | + "videoCodec": text(), "audioCodec": text(), "controls": ["type": "object"], "maxPendingExports": ["type": "integer"]], | |
| 126 | + required: ["edition", "resolutions", "frameRates", "aspects", "engines", "videoCodec", "audioCodec", "controls", "maxPendingExports"])), | |
| 127 | + tool("list_visualizers", "Find installed effects by stable ID, name, category, engine or favorite state.", | |
| 128 | + ["query": text(limit: 256), "engine": text(["metal", "projectM"]), "category": text(limit: 256), | |
| 129 | + "favoritesOnly": boolean, "offset": number(0, 100_000, integer: true), "limit": number(1, 200, integer: true)], | |
| 130 | + output: object(["visualizers": array(visualizer, max: 200), "total": ["type": "integer"], "nextOffset": ["type": "integer"]], | |
| 131 | + required: ["visualizers", "total"])), | |
| 132 | + tool("get_visualizer", "Read one installed visualizer and its saved appearance.", ["id": id], ["id"], output: visualizer), | |
| 133 | + tool("list_favorites", "List saved visualizers or radio songs by stable ID.", ["kind": kind], ["kind"], | |
| 134 | + output: object(["kind": kind, "favorites": array(["type": "object"])], required: ["kind", "favorites"])), | |
| 135 | + tool("list_radio_songs", "List tracks in the current or configured Radio catalog without starting playback.", | |
| 136 | + ["offset": number(0, 500, integer: true), "limit": number(1, 200, integer: true)], | |
| 137 | + output: object(["songs": array(["type": "object"], max: 200), "total": ["type": "integer"], "nextOffset": ["type": "integer"]], | |
| 138 | + required: ["songs", "total"])), | |
| 139 | + tool("set_favorite", "Set or remove a saved favorite explicitly. Repeating the same request preserves the current saved look.", | |
| 140 | + ["kind": kind, "id": id, "favorite": boolean], ["kind", "id", "favorite"], | |
| 141 | + output: object(["kind": kind, "id": id, "favorite": boolean], required: ["kind", "id", "favorite"]), permission: "editing"), | |
| 142 | + tool("load_song", "Prepare an existing local song and select it for Studio.", | |
| 143 | + ["path": path, "expectedRevision": revision], ["path", "expectedRevision"], output: playback, permission: "playback"), | |
| 144 | + tool("get_playback_state", "Read the current transport position in seconds, duration, volume, and project revision.", output: playback), | |
| 145 | + tool("set_playback_state", "Play, pause, or stop explicitly.", | |
| 146 | + ["state": text(["play", "pause", "stop"])], ["state"], output: playback, permission: "playback"), | |
| 147 | + tool("seek", "Seek Studio audio to a position in seconds.", ["seconds": seconds], ["seconds"], output: playback, permission: "playback"), | |
| 148 | + tool("set_volume", "Set transport volume from zero to one.", ["volume": number(0, 1)], ["volume"], output: playback, permission: "playback"), | |
| 149 | + tool("get_project", "Read the editable Studio project and concurrency revision.", output: project), | |
| 150 | + tool("create_project", "Start a new editable project using the loaded song and current visualizer.", | |
| 151 | + projectChange.merging(["barsPerScene": bars]) { first, _ in first }, ["expectedRevision"], output: project, permission: "editing"), | |
| 152 | + tool("open_project", "Open an existing PulseCanvas project and its authorized soundtrack.", | |
| 153 | + ["path": path, "expectedRevision": revision], ["path", "expectedRevision"], output: project, permission: "editing"), | |
| 154 | + tool("save_project", "Save the editable project to an authorized .pulsecanvas path.", | |
| 155 | + ["path": path, "overwrite": boolean, "expectedRevision": revision, "requestKey": requestKey], | |
| 156 | + ["path", "expectedRevision", "requestKey"], output: object(["path": path, "project": project], required: ["path", "project"]), | |
| 157 | + permission: "editing"), | |
| 158 | + tool("analyze_song", "Read detected BPM and beat or bar grid boundaries on the loaded song.", | |
| 159 | + ["beatsPerSection": number(1, 512, integer: true)], output: object( | |
| 160 | + ["bpm": ["type": "number"], "boundariesSeconds": array(seconds, max: 500_000)], | |
| 161 | + required: ["boundariesSeconds"])), | |
| 162 | + tool("set_timeline", "Replace the entire contiguous full-song timeline using stable visualizer IDs.", | |
| 163 | + ["segments": array(timelineEntry), "expectedRevision": revision], ["segments", "expectedRevision"], | |
| 164 | + output: project, permission: "editing"), | |
| 165 | + tool("set_visualizer", "Select a visualizer in the editor, or assign it to an existing timeline section.", | |
| 166 | + ["id": id, "expectedRevision": revision, "section": number(0, 9999, integer: true)], ["id", "expectedRevision"], | |
| 167 | + output: project, permission: "editing"), | |
| 168 | + tool("set_visualizer_settings", "Update applicable appearance controls for an installed visualizer.", | |
| 169 | + ["id": id, "settings": object(controlProperties), "expectedRevision": revision], ["id", "settings", "expectedRevision"], | |
| 170 | + output: project, permission: "editing"), | |
| 171 | + tool("start_export", "Queue a full-song MP4 using a snapshot of the current Studio project.", start, | |
| 172 | + ["path", "expectedRevision", "requestKey"], output: jobResult, permission: "rendering"), | |
| 173 | + tool("render_preview", "Queue a short MP4 using the same renderer and settings as the full export.", start, | |
| 174 | + ["path", "expectedRevision", "requestKey"], output: jobResult, permission: "rendering"), | |
| 175 | + tool("get_export_status", "Read an export's progress, failure, or validated media artifact.", ["id": id], ["id"], output: jobResult), | |
| 176 | + tool("list_exports", "Read current and recent retained export jobs.", ["limit": number(1, 100, integer: true)], | |
| 177 | + output: object(["jobs": array(job, max: 100)], required: ["jobs"])), | |
| 178 | + tool("cancel_export", "Cancel a queued or running export by its durable job ID.", ["id": id], ["id"], output: jobResult, permission: "rendering"), | |
| 179 | + tool("create_music_video", "Analyze an authorized song, save a beat-aligned project, and queue an export. Explicit fallback and strobe choices are required.", | |
| 180 | + generate, ["songPath", "projectPath", "outputPath", "fallback", "strobeEnabled", "expectedRevision", "requestKey"], | |
| 181 | + output: object(["projectPath": path, "project": project, "job": job, "usedFallback": boolean], | |
| 182 | + required: ["projectPath", "project", "job", "usedFallback"]), permission: "rendering") | |
| 183 | + ] | |
| 184 | + }() | |
| 185 | + | |
| 186 | + static func valid(_ value: Any, schema: Object) -> Bool { | |
| 187 | + switch schema["type"] as? String { | |
| 188 | + case "object": | |
| 189 | + guard let dictionary = value as? Object else { return false } | |
| 190 | + let fields = schema["properties"] as? [String: Object] ?? [:] | |
| 191 | + if let required = schema["required"] as? [String], !required.allSatisfy({ dictionary[$0] != nil }) { return false } | |
| 192 | + return dictionary.allSatisfy { key, value in | |
| 193 | + fields[key].map { valid(value, schema: $0) } ?? (schema["additionalProperties"] as? Bool != false) | |
| 194 | + } | |
| 195 | + case "array": | |
| 196 | + guard let array = value as? [Any], let items = schema["items"] as? Object, | |
| 197 | + array.count <= (schema["maxItems"] as? Int ?? Int.max) else { return false } | |
| 198 | + return array.allSatisfy { valid($0, schema: items) } | |
| 199 | + case "string": | |
| 200 | + guard let string = value as? String, string.count >= (schema["minLength"] as? Int ?? 0), | |
| 201 | + string.count <= (schema["maxLength"] as? Int ?? Int.max), | |
| 202 | + !string.utf8.contains(0) else { return false } | |
| 203 | + return (schema["enum"] as? [String])?.contains(string) ?? true | |
| 204 | + case "boolean": | |
| 205 | + return (value as? NSNumber).map { CFGetTypeID($0) == CFBooleanGetTypeID() } ?? false | |
| 206 | + case "number", "integer": | |
| 207 | + guard let number = value as? NSNumber, CFGetTypeID(number) != CFBooleanGetTypeID() else { return false } | |
| 208 | + let amount = number.doubleValue | |
| 209 | + guard amount.isFinite, amount >= (schema["minimum"] as? Double ?? -.infinity), | |
| 210 | + amount <= (schema["maximum"] as? Double ?? .infinity), | |
| 211 | + schema["type"] as? String != "integer" || amount.rounded() == amount else { return false } | |
| 212 | + return (schema["enum"] as? [Int])?.contains(number.intValue) ?? true | |
| 213 | + default: return false | |
| 214 | + } | |
| 215 | + } | |
| 216 | + | |
| 217 | + static func run() { | |
| 218 | + var initialized = false | |
| 219 | + while let line = readLine(strippingNewline: true) { | |
| 220 | + guard line.utf8.count <= maxMessage, | |
| 221 | + let message = (try? JSONSerialization.jsonObject(with: Data(line.utf8))) as? Object else { | |
| 222 | + send(["jsonrpc": "2.0", "id": NSNull(), "error": ["code": -32700, "message": "Invalid JSON-RPC message"]]) | |
| 223 | + continue | |
| 224 | + } | |
| 225 | + let id = message["id"] ?? NSNull() | |
| 226 | + func respond(_ result: Object) { send(["jsonrpc": "2.0", "id": id, "result": result]) } | |
| 227 | + func error(_ code: Int, _ reason: String) { send(["jsonrpc": "2.0", "id": id, "error": ["code": code, "message": reason]]) } | |
| 228 | + guard message["jsonrpc"] as? String == "2.0", let method = message["method"] as? String else { | |
| 229 | + error(-32600, "Invalid request"); continue | |
| 230 | + } | |
| 231 | + guard message["id"] != nil else { continue } | |
| 232 | + let params = message["params"] as? Object ?? [:] | |
| 233 | + switch method { | |
| 234 | + case "initialize": | |
| 235 | + guard !initialized, let version = params["protocolVersion"] as? String else { | |
| 236 | + error(-32602, "Expected one initialize request with a protocol version"); continue | |
| 237 | + } | |
| 238 | + initialized = true | |
| 239 | + respond(["protocolVersion": versions.contains(version) ? version : versions[0], | |
| 240 | + "capabilities": ["tools": ["listChanged": false]], | |
| 241 | + "serverInfo": ["name": "pulsecanvas", "title": "PulseCanvas Studio", | |
| 242 | + "version": Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "development"], | |
| 243 | + "instructions": "Open PulseCanvas Studio on this Mac and enable Settings → Agent access. Read get_app_status and get_capabilities before changing data."]) | |
| 244 | + case "ping": respond([:]) | |
| 245 | + case "tools/list" where initialized: respond(["tools": tools.map(\.schema)]) | |
| 246 | + case "tools/call" where initialized: | |
| 247 | + guard let name = params["name"] as? String, let tool = tools.first(where: { $0.name == name }) else { | |
| 248 | + error(-32602, "Unknown PulseCanvas tool"); continue | |
| 249 | + } | |
| 250 | + let arguments = params["arguments"] ?? Object() | |
| 251 | + guard let args = arguments as? Object, valid(args, schema: tool.input) else { | |
| 252 | + error(-32602, "Arguments do not match the tool input schema"); continue | |
| 253 | + } | |
| 254 | + let result = PulseMCPMailbox.call(name, args) | |
| 255 | + if let failure = result["error"] as? Object { | |
| 256 | + respond(["isError": true, "content": [["type": "text", "text": jsonText(failure)]]]) | |
| 257 | + } else if let value = result["value"] as? Object, valid(value, schema: tool.output) { | |
| 258 | + respond(["structuredContent": value, "content": [["type": "text", "text": jsonText(value)]]]) | |
| 259 | + } else { | |
| 260 | + respond(["isError": true, "content": [["type": "text", "text": "INVALID_RESPONSE: PulseCanvas returned unexpected data."]]]) | |
| 261 | + } | |
| 262 | + default: error(-32601, "Method not available") | |
| 263 | + } | |
| 264 | + } | |
| 265 | + } | |
| 266 | + | |
| 267 | + static func jsonText(_ object: Object) -> String { | |
| 268 | + guard let data = try? JSONSerialization.data(withJSONObject: object, options: [.sortedKeys, .withoutEscapingSlashes]) else { return "{}" } | |
| 269 | + return String(decoding: data, as: UTF8.self) | |
| 270 | + } | |
| 271 | + private static func send(_ object: Object) { | |
| 272 | + FileHandle.standardOutput.write(Data((jsonText(object) + "\n").utf8)) | |
| 273 | + } | |
| 274 | + } | |
| 275 | + | |
| 276 | + /// Both processes are the app's executable. A per-user directory lets the sandboxed | |
| 277 | + /// build use the same local transport without network server entitlements. | |
| 278 | + enum PulseMCPMailbox { | |
| 279 | + typealias Object = PulseMCP.Object | |
| 280 | + static var configuredRoot: URL { | |
| 281 | + UserDataStorage.defaultSupport.appendingPathComponent("AgentConnection", isDirectory: true) | |
| 282 | + } | |
| 283 | + private static let unavailable = PulseMCPError("APP_UNAVAILABLE", "Open PulseCanvas Studio on this Mac, then retry.") | |
| 284 | + private static let lifetime: TimeInterval = 180 | |
| 285 | + | |
| 286 | + static func root() throws -> URL { | |
| 287 | + let directory = configuredRoot | |
| 288 | + try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true, | |
| 289 | + attributes: [.posixPermissions: 0o700]) | |
| 290 | + var info = stat() | |
| 291 | + guard lstat(directory.path, &info) == 0, info.st_uid == geteuid(), | |
| 292 | + info.st_mode & S_IFMT == S_IFDIR, info.st_mode & 0o077 == 0 else { | |
| 293 | + throw PulseMCPError("CONNECTION_DIRECTORY", "PulseCanvas needs a private AgentConnection directory.") | |
| 294 | + } | |
| 295 | + return directory | |
| 296 | + } | |
| 297 | + | |
| 298 | + static func lock(_ root: URL) throws -> Int32 { | |
| 299 | + let fd = Darwin.open(root.appendingPathComponent("host.lock").path, O_RDWR | O_CREAT | O_NOFOLLOW | O_CLOEXEC, 0o600) | |
| 300 | + guard fd >= 0 else { throw unavailable } | |
| 301 | + return fd | |
| 302 | + } | |
| 303 | + | |
| 304 | + static func call(_ name: String, _ arguments: Object) -> Object { | |
| 305 | + do { | |
| 306 | + let root = try root() | |
| 307 | + let fd = try lock(root) | |
| 308 | + defer { close(fd) } | |
| 309 | + func hostIsRunning() -> Bool { | |
| 310 | + if flock(fd, LOCK_EX | LOCK_NB) == 0 { flock(fd, LOCK_UN); return false } | |
| 311 | + return errno == EWOULDBLOCK | |
| 312 | + } | |
| 313 | + guard hostIsRunning() else { | |
| 314 | + if name == "get_app_status" { return ["value": PulseMCPAccess.offlineStatus] } | |
| 315 | + throw unavailable | |
| 316 | + } | |
| 317 | + let id = UUID().uuidString | |
| 318 | + let request = root.appendingPathComponent(id + ".request") | |
| 319 | + let response = root.appendingPathComponent(id + ".response") | |
| 320 | + let deadline = Date().addingTimeInterval(lifetime) | |
| 321 | + let message: Object = ["name": name, "arguments": arguments, "deadline": deadline.timeIntervalSince1970] | |
| 322 | + let data = try JSONSerialization.data(withJSONObject: message) | |
| 323 | + guard data.count <= PulseMCP.maxMessage else { | |
| 324 | + throw PulseMCPError("INVALID_ARGUMENTS", "Tool arguments exceed the size limit.") | |
| 325 | + } | |
| 326 | + try data.write(to: request, options: .atomic) | |
| 327 | + defer { | |
| 328 | + try? FileManager.default.removeItem(at: request) | |
| 329 | + try? FileManager.default.removeItem(at: response) | |
| 330 | + } | |
| 331 | + while deadline.timeIntervalSinceNow > 0 { | |
| 332 | + if let data = try? Data(contentsOf: response), let result = try? JSONSerialization.jsonObject(with: data) as? Object { | |
| 333 | + return result | |
| 334 | + } | |
| 335 | + guard hostIsRunning() else { throw unavailable } | |
| 336 | + Thread.sleep(forTimeInterval: 0.05) | |
| 337 | + } | |
| 338 | + throw PulseMCPError("CONNECTION_TIMEOUT", "PulseCanvas did not reply. Reuse the same request key when retrying an operation that writes a file.") | |
| 339 | + } catch let error as PulseMCPError { return ["error": error.payload] } | |
| 340 | + catch { return ["error": unavailable.payload] } | |
| 341 | + } | |
| 342 | + | |
| 343 | + @MainActor | |
| 344 | + final class Host { | |
| 345 | + private var timer: Timer? | |
| 346 | + private var fd: Int32 = -1 | |
| 347 | + private var directory: URL? | |
| 348 | + private var inFlight = Set<UUID>() | |
| 349 | + private var lastSweep = Date.distantPast | |
| 350 | + | |
| 351 | + func start(handler: @escaping @MainActor (String, Object) async -> Object) { | |
| 352 | + guard timer == nil else { return } | |
| 353 | + do { | |
| 354 | + let directory = try root() | |
| 355 | + let fd = try lock(directory) | |
| 356 | + guard flock(fd, LOCK_EX | LOCK_NB) == 0 else { | |
| 357 | + close(fd) | |
| 358 | + return | |
| 359 | + } | |
| 360 | + self.fd = fd | |
| 361 | + self.directory = directory | |
| 362 | + let timer = Timer(timeInterval: 0.125, repeats: true) { [weak self] _ in | |
| 363 | + MainActor.assumeIsolated { self?.consume(handler) } | |
| 364 | + } | |
| 365 | + self.timer = timer | |
| 366 | + RunLoop.main.add(timer, forMode: .common) | |
| 367 | + } catch { | |
| 368 | + NSLog("PulseCanvas could not open its local agent connection.") | |
| 369 | + } | |
| 370 | + } | |
| 371 | + | |
| 372 | + var isRunning: Bool { fd >= 0 } | |
| 373 | + | |
| 374 | + private func consume(_ handler: @escaping @MainActor (String, Object) async -> Object) { | |
| 375 | + guard inFlight.count < 16, let directory, | |
| 376 | + let files = try? FileManager.default.contentsOfDirectory(at: directory, includingPropertiesForKeys: [.isRegularFileKey, .contentModificationDateKey, .fileSizeKey], options: [.skipsHiddenFiles]) | |
| 377 | + else { return } | |
| 378 | + let now = Date() | |
| 379 | + let sweep = now.timeIntervalSince(lastSweep) > 60 | |
| 380 | + if sweep { lastSweep = now } | |
| 381 | + for file in files { | |
| 382 | + guard let id = UUID(uuidString: file.deletingPathExtension().lastPathComponent), !inFlight.contains(id), | |
| 383 | + let properties = try? file.resourceValues(forKeys: [.isRegularFileKey, .isSymbolicLinkKey, .contentModificationDateKey, .fileSizeKey]), | |
| 384 | + properties.isRegularFile == true, properties.isSymbolicLink != true else { continue } | |
| 385 | + if sweep, let date = properties.contentModificationDate, now.timeIntervalSince(date) > lifetime + 10 { | |
| 386 | + if ["request", "response"].contains(file.pathExtension) { try? FileManager.default.removeItem(at: file) } | |
| 387 | + continue | |
| 388 | + } | |
| 389 | + guard file.pathExtension == "request", inFlight.count < 16, | |
| 390 | + (properties.fileSize ?? Int.max) <= PulseMCP.maxMessage, | |
| 391 | + let data = try? Data(contentsOf: file), let message = try? JSONSerialization.jsonObject(with: data) as? Object, | |
| 392 | + let name = message["name"] as? String, let args = message["arguments"] as? Object, | |
| 393 | + let deadline = message["deadline"] as? Double, | |
| 394 | + deadline > now.timeIntervalSince1970, deadline <= now.timeIntervalSince1970 + lifetime | |
| 395 | + else { continue } | |
| 396 | + inFlight.insert(id) | |
| 397 | + Task { | |
| 398 | + let result = await handler(name, args) | |
| 399 | + defer { inFlight.remove(id) } | |
| 400 | + guard Date().timeIntervalSince1970 < deadline, FileManager.default.fileExists(atPath: file.path), | |
| 401 | + let response = try? JSONSerialization.data(withJSONObject: result) else { return } | |
| 402 | + let target = file.deletingPathExtension().appendingPathExtension("response") | |
| 403 | + // The bridge owns its request until it has read the reply. Keep | |
| 404 | + // this ID claimed until the request is removed by that bridge. | |
| 405 | + try? response.write(to: target, options: .atomic) | |
| 406 | + try? FileManager.default.removeItem(at: file) | |
| 407 | + } | |
| 408 | + } | |
| 409 | + } | |
| 410 | + | |
| 411 | + deinit { timer?.invalidate(); if fd >= 0 { close(fd) } } | |
| 412 | + } | |
| 413 | + } | |
| 414 | + #endif |
Sources/PulseCanvas/PulseCanvasMCPJobs.swift added
| 1 | + #if os(macOS) && DIRECT_BUILD && !STORE_BUILD | |
| 2 | + @preconcurrency import AVFoundation | |
| 3 | + import Foundation | |
| 4 | + | |
| 5 | + @MainActor | |
| 6 | + final class PulseMCPJobs { | |
| 7 | + static let maxPending = 3 | |
| 8 | + private static let historyLimit = 200 | |
| 9 | + | |
| 10 | + struct Format: Codable { | |
| 11 | + let aspect: String | |
| 12 | + let resolution: Int | |
| 13 | + let fps: Int | |
| 14 | + } | |
| 15 | + | |
| 16 | + struct Job: Codable, Identifiable { | |
| 17 | + let id: String | |
| 18 | + let signature: String | |
| 19 | + let requestKey: String | |
| 20 | + let destination: String | |
| 21 | + let projectPath: String? | |
| 22 | + let sourcePath: String | |
| 23 | + let sourceBytes: Int | |
| 24 | + let sourceModified: Date | |
| 25 | + let settings: Format | |
| 26 | + let previewSeconds: Double? | |
| 27 | + let overwrite: Bool | |
| 28 | + let project: CreatorProject | |
| 29 | + let timeline: [PulseMCPScene] | |
| 30 | + let duration: Double | |
| 31 | + let usedFallback: Bool | |
| 32 | + var phase = "queued" | |
| 33 | + var artifact: Artifact? | |
| 34 | + var errorCode: String? | |
| 35 | + var errorMessage: String? | |
| 36 | + var manifestPath: String? | |
| 37 | + var pending: Bool { ["queued", "preparing", "rendering", "muxing", "validating"].contains(phase) } | |
| 38 | + } | |
| 39 | + | |
| 40 | + struct Artifact: Codable { | |
| 41 | + var path: String | |
| 42 | + let durationSeconds: Double | |
| 43 | + let width: Int | |
| 44 | + let height: Int | |
| 45 | + let fps: Double | |
| 46 | + let expectedFrames: Int | |
| 47 | + let videoCodec: String | |
| 48 | + let audioCodec: String | |
| 49 | + let bytes: Int | |
| 50 | + } | |
| 51 | + | |
| 52 | + struct SaveReceipt: Codable { | |
| 53 | + let key: String | |
| 54 | + let signature: String | |
| 55 | + let path: String | |
| 56 | + let project: CreatorProject | |
| 57 | + let duration: Double | |
| 58 | + } | |
| 59 | + | |
| 60 | + struct Ledger: Codable { | |
| 61 | + var jobs: [Job] = [] | |
| 62 | + var saves: [SaveReceipt] = [] | |
| 63 | + } | |
| 64 | + | |
| 65 | + private let access: PulseMCPAccess | |
| 66 | + private let exporter: SocialExportController | |
| 67 | + private let url: URL | |
| 68 | + private var ledger = Ledger() | |
| 69 | + private var loadError: Error? | |
| 70 | + private var worker: Task<Void, Never>? | |
| 71 | + private var active: String? | |
| 72 | + private(set) var pendingCount = 0 | |
| 73 | + | |
| 74 | + init(access: PulseMCPAccess, exporter: SocialExportController) { | |
| 75 | + self.access = access | |
| 76 | + self.exporter = exporter | |
| 77 | + url = PulseMCPMailbox.configuredRoot.appendingPathComponent("jobs.json") | |
| 78 | + do { | |
| 79 | + _ = try PulseMCPMailbox.root() | |
| 80 | + if FileManager.default.fileExists(atPath: url.path) { | |
| 81 | + ledger = try JSONDecoder().decode(Ledger.self, from: Data(contentsOf: url)) | |
| 82 | + var recovered = ledger | |
| 83 | + for index in recovered.jobs.indices where recovered.jobs[index].pending { | |
| 84 | + cleanupInterrupted(recovered.jobs[index]) | |
| 85 | + recovered.jobs[index].phase = "failed" | |
| 86 | + recovered.jobs[index].errorCode = "EXPORT_INTERRUPTED" | |
| 87 | + recovered.jobs[index].errorMessage = "PulseCanvas closed before this export completed. Start a new export with a new request key." | |
| 88 | + } | |
| 89 | + try write(recovered) | |
| 90 | + } | |
| 91 | + } catch { loadError = error } | |
| 92 | + } | |
| 93 | + | |
| 94 | + private func cleanupInterrupted(_ job: Job) { | |
| 95 | + guard UUID(uuidString: job.id) != nil, | |
| 96 | + let output = try? access.authorize(job.destination, in: [.output], writing: true) else { return } | |
| 97 | + defer { withExtendedLifetime(output.scope) {} } | |
| 98 | + let folder = workDirectory(destination: output.url, id: job.id) | |
| 99 | + let marker = folder.appendingPathComponent("owner") | |
| 100 | + guard let properties = try? folder.resourceValues(forKeys: [.isDirectoryKey, .isSymbolicLinkKey]), | |
| 101 | + properties.isDirectory == true, properties.isSymbolicLink != true, | |
| 102 | + (try? marker.resourceValues(forKeys: [.isRegularFileKey, .isSymbolicLinkKey, .fileSizeKey])).map({ | |
| 103 | + $0.isRegularFile == true && $0.isSymbolicLink != true && $0.fileSize == job.id.utf8.count | |
| 104 | + }) == true, | |
| 105 | + (try? Data(contentsOf: marker)) == Data(job.id.utf8) else { return } | |
| 106 | + try? FileManager.default.removeItem(at: folder) | |
| 107 | + } | |
| 108 | + | |
| 109 | + private func workDirectory(destination: URL, id: String) -> URL { | |
| 110 | + destination.deletingLastPathComponent().appendingPathComponent(".PulseCanvas-" + id, isDirectory: true) | |
| 111 | + } | |
| 112 | + | |
| 113 | + func requireStorage() throws { | |
| 114 | + if loadError != nil { | |
| 115 | + throw PulseMCPError("JOB_STORAGE_UNAVAILABLE", "PulseCanvas could not read or save its job history. Check the AgentConnection folder before retrying.") | |
| 116 | + } | |
| 117 | + } | |
| 118 | + | |
| 119 | + func job(_ id: String) throws -> Job { | |
| 120 | + try requireStorage() | |
| 121 | + guard let job = ledger.jobs.first(where: { $0.id == id }) else { | |
| 122 | + throw PulseMCPError("JOB_NOT_FOUND", "Read list_exports to find the retained ID.") | |
| 123 | + } | |
| 124 | + return job | |
| 125 | + } | |
| 126 | + | |
| 127 | + func recent(_ limit: Int) throws -> [Job] { | |
| 128 | + try requireStorage() | |
| 129 | + return Array(ledger.jobs.suffix(limit).reversed()) | |
| 130 | + } | |
| 131 | + | |
| 132 | + func repeatJob(key: String, signature: String) throws -> Job? { | |
| 133 | + try requireStorage() | |
| 134 | + if ledger.saves.contains(where: { $0.key == key }) { throw keyConflict() } | |
| 135 | + guard let previous = ledger.jobs.first(where: { $0.requestKey == key }) else { return nil } | |
| 136 | + guard previous.signature == signature else { throw keyConflict() } | |
| 137 | + return previous | |
| 138 | + } | |
| 139 | + | |
| 140 | + func repeatSave(key: String, signature: String) throws -> SaveReceipt? { | |
| 141 | + try requireStorage() | |
| 142 | + if ledger.jobs.contains(where: { $0.requestKey == key }) { throw keyConflict() } | |
| 143 | + guard let receipt = ledger.saves.first(where: { $0.key == key }) else { return nil } | |
| 144 | + guard receipt.signature == signature else { throw keyConflict() } | |
| 145 | + return receipt | |
| 146 | + } | |
| 147 | + | |
| 148 | + func rememberSave(_ receipt: SaveReceipt) throws { | |
| 149 | + var next = ledger | |
| 150 | + next.saves.append(receipt) | |
| 151 | + if next.saves.count > Self.historyLimit { next.saves.removeFirst() } | |
| 152 | + try write(next) | |
| 153 | + } | |
| 154 | + | |
| 155 | + private func keyConflict() -> PulseMCPError { | |
| 156 | + PulseMCPError("REQUEST_KEY_CONFLICT", "Use a new request key for a different operation or different arguments.") | |
| 157 | + } | |
| 158 | + | |
| 159 | + func checkCapacity(destination: URL) throws { | |
| 160 | + try requireStorage() | |
| 161 | + guard pendingCount < Self.maxPending, | |
| 162 | + !ledger.jobs.contains(where: { $0.pending && $0.destination == destination.path }) else { | |
| 163 | + throw PulseMCPError("EXPORT_BUSY", "Wait for a pending export or choose an unused destination.") | |
| 164 | + } | |
| 165 | + } | |
| 166 | + | |
| 167 | + func checkOutput(_ destination: URL, overwrite: Bool) throws { | |
| 168 | + let manifest = Self.manifestURL(destination) | |
| 169 | + try Self.checkDestination(destination, overwrite: overwrite) | |
| 170 | + try Self.checkDestination(manifest, overwrite: overwrite) | |
| 171 | + let fm = FileManager.default | |
| 172 | + guard overwrite && (fm.fileExists(atPath: destination.path) || fm.fileExists(atPath: manifest.path)) else { return } | |
| 173 | + let known = ledger.jobs.last { $0.phase == "completed" && $0.destination == destination.path } | |
| 174 | + guard let known, let artifact = known.artifact, known.manifestPath == manifest.path, | |
| 175 | + let size = try? destination.resourceValues(forKeys: [.fileSizeKey]).fileSize, size == artifact.bytes, | |
| 176 | + let manifestSize = try? manifest.resourceValues(forKeys: [.fileSizeKey]).fileSize, manifestSize <= 2_000_000, | |
| 177 | + let data = try? Data(contentsOf: manifest), | |
| 178 | + let metadata = try? JSONSerialization.jsonObject(with: data) as? PulseMCP.Object, | |
| 179 | + metadata["jobId"] as? String == known.id | |
| 180 | + else { | |
| 181 | + throw PulseMCPError("OUTPUT_EXISTS", "Use a new name. PulseCanvas can replace only an export it previously recorded at this path.") | |
| 182 | + } | |
| 183 | + } | |
| 184 | + | |
| 185 | + func submit(_ job: Job) throws { | |
| 186 | + var next = ledger | |
| 187 | + next.jobs.append(job) | |
| 188 | + if next.jobs.count > Self.historyLimit, let index = next.jobs.firstIndex(where: { !$0.pending }) { | |
| 189 | + next.jobs.remove(at: index) | |
| 190 | + } | |
| 191 | + try write(next) | |
| 192 | + kick() | |
| 193 | + } | |
| 194 | + | |
| 195 | + func failPreparation(_ queued: Job, error: Error) { | |
| 196 | + var job = queued | |
| 197 | + job.phase = "failed" | |
| 198 | + let failure = Self.error(error, defaultCode: "PROJECT_SAVE_FAILED") | |
| 199 | + job.errorCode = failure.code | |
| 200 | + job.errorMessage = failure.message | |
| 201 | + try? record(job) | |
| 202 | + } | |
| 203 | + | |
| 204 | + private func write(_ next: Ledger) throws { | |
| 205 | + let data = try JSONEncoder().encode(next) | |
| 206 | + try data.write(to: url, options: .atomic) | |
| 207 | + ledger = next | |
| 208 | + pendingCount = ledger.jobs.filter(\.pending).count | |
| 209 | + } | |
| 210 | + | |
| 211 | + private func record(_ job: Job) throws { | |
| 212 | + guard let index = ledger.jobs.firstIndex(where: { $0.id == job.id }) else { return } | |
| 213 | + var next = ledger | |
| 214 | + next.jobs[index] = job | |
| 215 | + do { try write(next) } | |
| 216 | + catch { | |
| 217 | + // Never report an unpersisted completion. Stop accepting further work | |
| 218 | + // until the storage problem is resolved and the app restarts. | |
| 219 | + loadError = error | |
| 220 | + throw error | |
| 221 | + } | |
| 222 | + } | |
| 223 | + | |
| 224 | + private func kick() { | |
| 225 | + guard worker == nil else { return } | |
| 226 | + worker = Task { [weak self] in await self?.drain() } | |
| 227 | + } | |
| 228 | + | |
| 229 | + private func drain() async { | |
| 230 | + defer { active = nil; worker = nil } | |
| 231 | + while let job = ledger.jobs.first(where: { $0.phase == "queued" }), loadError == nil, !Task.isCancelled { | |
| 232 | + if exporter.isExporting { | |
| 233 | + try? await Task.sleep(for: .milliseconds(150)) | |
| 234 | + continue | |
| 235 | + } | |
| 236 | + active = job.id | |
| 237 | + let task = Task { await run(job) } | |
| 238 | + activeTask = task | |
| 239 | + await task.value | |
| 240 | + activeTask = nil | |
| 241 | + active = nil | |
| 242 | + } | |
| 243 | + } | |
| 244 | + | |
| 245 | + private var activeTask: Task<Void, Never>? | |
| 246 | + | |
| 247 | + func cancel(_ id: String) throws -> Job { | |
| 248 | + var job = try self.job(id) | |
| 249 | + guard job.pending else { return job } | |
| 250 | + if id == active { | |
| 251 | + activeTask?.cancel() | |
| 252 | + exporter.cancel() | |
| 253 | + } else { | |
| 254 | + job.phase = "cancelled" | |
| 255 | + try record(job) | |
| 256 | + } | |
| 257 | + return job | |
| 258 | + } | |
| 259 | + | |
| 260 | + func details(_ job: Job) -> PulseMCP.Object { | |
| 261 | + let live = active == job.id && job.pending | |
| 262 | + var result: PulseMCP.Object = [ | |
| 263 | + "id": job.id, "phase": live && exporter.isExporting ? exporter.phase.rawValue : job.phase, | |
| 264 | + "progress": job.phase == "completed" ? 1.0 : live ? min(exporter.progress, 0.99) : 0.0, | |
| 265 | + "framesRendered": live ? exporter.renderedFrames : job.artifact?.expectedFrames ?? 0, | |
| 266 | + "totalFrames": live ? exporter.totalFrames : job.artifact?.expectedFrames ?? 0, | |
| 267 | + "destination": job.destination, "previewOnly": job.previewSeconds != nil | |
| 268 | + ] | |
| 269 | + result["projectPath"] = job.projectPath | |
| 270 | + result["manifestPath"] = job.manifestPath | |
| 271 | + if let eta = live ? exporter.estimatedSecondsRemaining : nil { result["etaSeconds"] = eta } | |
| 272 | + if let artifact = job.artifact, let data = try? JSONEncoder().encode(artifact) { | |
| 273 | + result["artifact"] = try? JSONSerialization.jsonObject(with: data) | |
| 274 | + } | |
| 275 | + if let code = job.errorCode, let message = job.errorMessage { | |
| 276 | + result["error"] = ["code": code, "message": message] | |
| 277 | + } | |
| 278 | + return result | |
| 279 | + } | |
| 280 | + | |
| 281 | + private func run(_ queued: Job) async { | |
| 282 | + var job = queued | |
| 283 | + do { | |
| 284 | + try Task.checkCancellation() | |
| 285 | + guard access.enabled, access.rendering else { throw revoked() } | |
| 286 | + let source = try access.authorize(job.sourcePath, in: [.input]) | |
| 287 | + let output = try access.authorize(job.destination, in: [.output], writing: true) | |
| 288 | + defer { withExtendedLifetime((source.scope, output.scope)) {} } | |
| 289 | + let identity = try Self.sourceIdentity(source.url) | |
| 290 | + guard identity.bytes == job.sourceBytes, identity.modified == job.sourceModified else { | |
| 291 | + throw PulseMCPError("AUDIO_CHANGED", "The source file changed since submission. Reload it and start a new export.") | |
| 292 | + } | |
| 293 | + let destination = output.url | |
| 294 | + let manifestPath = Self.manifestURL(destination) | |
| 295 | + try checkOutput(destination, overwrite: job.overwrite) | |
| 296 | + let work = workDirectory(destination: destination, id: job.id) | |
| 297 | + try FileManager.default.createDirectory(at: work, withIntermediateDirectories: false, attributes: [.posixPermissions: 0o700]) | |
| 298 | + defer { try? FileManager.default.removeItem(at: work) } | |
| 299 | + try Data(job.id.utf8).write(to: work.appendingPathComponent("owner"), options: .withoutOverwriting) | |
| 300 | + let staged = work.appendingPathComponent("video.mp4") | |
| 301 | + let manifest = work.appendingPathComponent("manifest.json") | |
| 302 | + let snapshot: CreatorProject | |
| 303 | + do { | |
| 304 | + snapshot = try job.project.remapped(using: .shared) | |
| 305 | + let allScenes = Set((snapshot.timeline ?? []).map(\.scene)).union([snapshot.scene]) | |
| 306 | + guard allScenes.isSubset(of: Set(ProjectMPresets.shared.availableScenes)), | |
| 307 | + job.project.effectIdentities?[job.project.scene] == ProjectMPresets.shared.identity(for: snapshot.scene), | |
| 308 | + job.timeline.count == (snapshot.timeline ?? []).count, | |
| 309 | + zip(job.timeline, snapshot.timeline ?? []).allSatisfy({ $0.visualizerId == ProjectMPresets.shared.identity(for: $1.scene) }) | |
| 310 | + else { throw CocoaError(.fileReadCorruptFile) } | |
| 311 | + } catch { throw PulseMCPError("UNSUPPORTED_EFFECT", "An effect used by the saved export is no longer installed. Restore it and submit another job.") } | |
| 312 | + guard let aspect = SocialAspect.allCases.first(where: { $0.agentName == job.settings.aspect }) else { | |
| 313 | + throw PulseMCPError("UNSUPPORTED_FORMAT", "Read the current export capabilities.") | |
| 314 | + } | |
| 315 | + job.phase = "preparing" | |
| 316 | + try record(job) | |
| 317 | + let state = RenderState() | |
| 318 | + state.scene = snapshot.scene | |
| 319 | + snapshot.appearance.apply(to: state) | |
| 320 | + await exporter.export(audioURL: source.url, render: state, to: staged, | |
| 321 | + segments: snapshot.studioEnabled == true ? (snapshot.timeline ?? []) : [], | |
| 322 | + appearances: snapshot.visualPresets ?? [:], | |
| 323 | + offline: .init(aspect: aspect, resolution: job.settings.resolution, fps: job.settings.fps, | |
| 324 | + scratchDirectory: work, previewSeconds: job.previewSeconds)) | |
| 325 | + try Task.checkCancellation() | |
| 326 | + if let error = exporter.error { throw error } | |
| 327 | + guard exporter.exportedURL == staged else { throw CancellationError() } | |
| 328 | + job.phase = "validating" | |
| 329 | + try record(job) | |
| 330 | + let duration = min(job.previewSeconds ?? job.duration, job.duration) | |
| 331 | + let dimensions = aspect.dimensions(resolution: job.settings.resolution) | |
| 332 | + var artifact = try await Self.validate(staged, dimensions: dimensions, fps: job.settings.fps, duration: duration) | |
| 333 | + try Task.checkCancellation() | |
| 334 | + guard access.enabled, access.rendering else { throw revoked() } | |
| 335 | + let liveGrant = try access.authorize(job.destination, in: [.output], writing: true) | |
| 336 | + let liveInput = try access.authorize(job.sourcePath, in: [.input]) | |
| 337 | + defer { withExtendedLifetime((liveGrant.scope, liveInput.scope)) {} } | |
| 338 | + let finalSource = try Self.sourceIdentity(liveInput.url) | |
| 339 | + guard finalSource.bytes == job.sourceBytes, finalSource.modified == job.sourceModified else { | |
| 340 | + throw PulseMCPError("AUDIO_CHANGED", "The source file changed during the render. Reload it and start a new export.") | |
| 341 | + } | |
| 342 | + artifact.path = destination.path | |
| 343 | + let details: PulseMCP.Object = ["jobId": job.id, "appVersion": PulseMCPAccess.version, | |
| 344 | + "appEdition": PulseMCPAccess.edition, "sourcePath": job.sourcePath, "sourceBytes": job.sourceBytes, | |
| 345 | + "sourceModified": ISO8601DateFormatter().string(from: job.sourceModified), "projectPath": job.projectPath as Any? ?? NSNull(), | |
| 346 | + "seed": job.project.generationSeed as Any? ?? NSNull(), "timeline": job.timeline.map(\.payload), | |
| 347 | + "settings": ["aspect": job.settings.aspect, "resolution": job.settings.resolution, "fps": job.settings.fps], | |
| 348 | + "artifact": try JSONSerialization.jsonObject(with: JSONEncoder().encode(artifact))] | |
| 349 | + try JSONSerialization.data(withJSONObject: details, options: [.prettyPrinted, .sortedKeys]).write(to: manifest) | |
| 350 | + try checkOutput(destination, overwrite: job.overwrite) | |
| 351 | + try Self.publish(staged, to: destination, overwrite: job.overwrite) | |
| 352 | + do { try Self.publish(manifest, to: manifestPath, overwrite: job.overwrite) } | |
| 353 | + catch { | |
| 354 | + if !job.overwrite { try? FileManager.default.removeItem(at: destination) } | |
| 355 | + throw error | |
| 356 | + } | |
| 357 | + job.phase = "completed" | |
| 358 | + job.artifact = artifact | |
| 359 | + job.manifestPath = manifestPath.path | |
| 360 | + try record(job) | |
| 361 | + } catch is CancellationError { | |
| 362 | + job.phase = "cancelled" | |
| 363 | + try? record(job) | |
| 364 | + } catch { | |
| 365 | + job.phase = "failed" | |
| 366 | + job.artifact = nil | |
| 367 | + job.manifestPath = nil | |
| 368 | + let failure = Self.error(error) | |
| 369 | + job.errorCode = failure.code | |
| 370 | + job.errorMessage = failure.message | |
| 371 | + try? record(job) | |
| 372 | + } | |
| 373 | + } | |
| 374 | + | |
| 375 | + private func revoked() -> PulseMCPError { | |
| 376 | + PulseMCPError("PERMISSION_REQUIRED", "Rendering access was disabled. Review Settings → Agent access before submitting another export.") | |
| 377 | + } | |
| 378 | + | |
| 379 | + static func error(_ error: Error, defaultCode: String = "EXPORT_FAILED") -> PulseMCPError { | |
| 380 | + if let error = error as? PulseMCPError { return error } | |
| 381 | + var underlying: NSError? = error as NSError | |
| 382 | + while let current = underlying { | |
| 383 | + if (current.domain == NSPOSIXErrorDomain && current.code == Int(ENOSPC)) || | |
| 384 | + (current.domain == NSCocoaErrorDomain && current.code == NSFileWriteOutOfSpaceError) { | |
| 385 | + return PulseMCPError("DISK_FULL", "Free space on the authorized output drive or choose another output folder.") | |
| 386 | + } | |
| 387 | + if (current.domain == NSPOSIXErrorDomain && current.code == Int(EEXIST)) || | |
| 388 | + (current.domain == NSCocoaErrorDomain && current.code == NSFileWriteFileExistsError) { | |
| 389 | + return PulseMCPError("OUTPUT_EXISTS", "Choose a new output path.") | |
| 390 | + } | |
| 391 | + underlying = current.userInfo[NSUnderlyingErrorKey] as? NSError | |
| 392 | + } | |
| 393 | + return PulseMCPError(defaultCode, "\(error.localizedDescription) Check the source, authorized folder and available storage before retrying.") | |
| 394 | + } | |
| 395 | + | |
| 396 | + static func sourceIdentity(_ url: URL) throws -> (bytes: Int, modified: Date) { | |
| 397 | + let values = try url.resourceValues(forKeys: [.fileSizeKey, .contentModificationDateKey]) | |
| 398 | + guard let bytes = values.fileSize, let modified = values.contentModificationDate else { | |
| 399 | + throw PulseMCPError("AUDIO_UNAVAILABLE", "Choose a readable audio file in the authorized input folder.") | |
| 400 | + } | |
| 401 | + return (bytes, modified) | |
| 402 | + } | |
| 403 | + | |
| 404 | + static func manifestURL(_ video: URL) -> URL { video.deletingPathExtension().appendingPathExtension("render.json") } | |
| 405 | + | |
| 406 | + static func checkDestination(_ url: URL, overwrite: Bool) throws { | |
| 407 | + var isDirectory: ObjCBool = false | |
| 408 | + let exists = FileManager.default.fileExists(atPath: url.path, isDirectory: &isDirectory) | |
| 409 | + let symbol = try? FileManager.default.destinationOfSymbolicLink(atPath: url.path) | |
| 410 | + guard symbol == nil, !isDirectory.boolValue, !exists || overwrite else { | |
| 411 | + throw PulseMCPError("OUTPUT_EXISTS", "Choose a new destination; directories and symbolic links are never overwritten.") | |
| 412 | + } | |
| 413 | + } | |
| 414 | + | |
| 415 | + static func publish(_ staged: URL, to destination: URL, overwrite: Bool) throws { | |
| 416 | + try checkDestination(destination, overwrite: overwrite) | |
| 417 | + if overwrite { | |
| 418 | + guard rename(staged.path, destination.path) == 0 else { throw NSError(domain: NSPOSIXErrorDomain, code: Int(errno)) } | |
| 419 | + } else { | |
| 420 | + guard renamex_np(staged.path, destination.path, UInt32(RENAME_EXCL)) == 0 else { | |
| 421 | + throw NSError(domain: NSPOSIXErrorDomain, code: Int(errno)) | |
| 422 | + } | |
| 423 | + } | |
| 424 | + } | |
| 425 | + | |
| 426 | + private static func validate(_ url: URL, dimensions: (width: Int, height: Int), fps: Int, duration: Double) async throws -> Artifact { | |
| 427 | + let asset = AVURLAsset(url: url) | |
| 428 | + let videoTracks = try await asset.loadTracks(withMediaType: .video) | |
| 429 | + let audioTracks = try await asset.loadTracks(withMediaType: .audio) | |
| 430 | + let failure = PulseMCPError("MEDIA_VALIDATION_FAILED", "The MP4 did not match the requested audio and video format.") | |
| 431 | + guard videoTracks.count == 1, audioTracks.count == 1, | |
| 432 | + let video = videoTracks.first, let audio = audioTracks.first else { throw failure } | |
| 433 | + let actual = try await asset.load(.duration).seconds | |
| 434 | + let size = try await video.load(.naturalSize) | |
| 435 | + let rate = try await video.load(.nominalFrameRate) | |
| 436 | + let videoRange = try await video.load(.timeRange) | |
| 437 | + let audioRange = try await audio.load(.timeRange) | |
| 438 | + let videoCodec = try await video.load(.formatDescriptions).first.map(CMFormatDescriptionGetMediaSubType) | |
| 439 | + let audioCodec = try await audio.load(.formatDescriptions).first.map(CMFormatDescriptionGetMediaSubType) | |
| 440 | + let tolerance = max(2 / Double(fps), 0.06) | |
| 441 | + let bytes = try url.resourceValues(forKeys: [.fileSizeKey]).fileSize ?? 0 | |
| 442 | + guard bytes > 0, abs(actual - duration) <= tolerance, Int(size.width) == dimensions.width, | |
| 443 | + Int(size.height) == dimensions.height, abs(Double(rate) - Double(fps)) < 0.5, | |
| 444 | + videoCodec == kCMVideoCodecType_H264, audioCodec == kAudioFormatMPEG4AAC, | |
| 445 | + abs(videoRange.start.seconds - audioRange.start.seconds) <= tolerance, | |
| 446 | + abs(videoRange.duration.seconds - audioRange.duration.seconds) <= tolerance else { throw failure } | |
| 447 | + let frames = Int(ceil(duration * Double(fps) - 0.00000001)) | |
| 448 | + let scan = Task.detached { | |
| 449 | + try await Self.checkVideoSamples(url, fps: fps, expected: frames) | |
| 450 | + } | |
| 451 | + try await withTaskCancellationHandler { try await scan.value } onCancel: { scan.cancel() } | |
| 452 | + return Artifact(path: url.path, durationSeconds: actual, width: dimensions.width, height: dimensions.height, | |
| 453 | + fps: Double(rate), expectedFrames: frames, videoCodec: "h264", audioCodec: "aac", bytes: bytes) | |
| 454 | + } | |
| 455 | + | |
| 456 | + nonisolated private static func checkVideoSamples(_ url: URL, fps: Int, expected: Int) async throws { | |
| 457 | + let asset = AVURLAsset(url: url) | |
| 458 | + guard let track = try await asset.loadTracks(withMediaType: .video).first else { | |
| 459 | + throw PulseMCPError("MEDIA_VALIDATION_FAILED", "The video track could not be opened for decoding.") | |
| 460 | + } | |
| 461 | + let reader = try AVAssetReader(asset: asset) | |
| 462 | + let output = AVAssetReaderTrackOutput(track: track, outputSettings: [ | |
| 463 | + kCVPixelBufferPixelFormatTypeKey as String: kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange | |
| 464 | + ]) | |
| 465 | + output.alwaysCopiesSampleData = false | |
| 466 | + guard reader.canAdd(output) else { | |
| 467 | + throw PulseMCPError("MEDIA_VALIDATION_FAILED", "The decoder rejected the encoded video track.") | |
| 468 | + } | |
| 469 | + reader.add(output) | |
| 470 | + guard reader.startReading() else { | |
| 471 | + throw reader.error ?? PulseMCPError("MEDIA_VALIDATION_FAILED", "The decoder could not start.") | |
| 472 | + } | |
| 473 | + var frames = 0 | |
| 474 | + var mediaStart: Double? | |
| 475 | + defer { if reader.status == .reading { reader.cancelReading() } } | |
| 476 | + while let sample = output.copyNextSampleBuffer() { | |
| 477 | + try Task.checkCancellation() | |
| 478 | + guard CMSampleBufferGetImageBuffer(sample) != nil else { continue } | |
| 479 | + let timestamp = CMSampleBufferGetPresentationTimeStamp(sample).seconds | |
| 480 | + if mediaStart == nil { mediaStart = timestamp } | |
| 481 | + let elapsed = timestamp - (mediaStart ?? timestamp) | |
| 482 | + guard timestamp.isFinite, abs(elapsed - Double(frames) / Double(fps)) < 0.001 else { | |
| 483 | + throw PulseMCPError("MEDIA_VALIDATION_FAILED", "Decoded frame \(frames + 1) does not match the requested frame cadence.") | |
| 484 | + } | |
| 485 | + frames += 1 | |
| 486 | + } | |
| 487 | + guard reader.status == .completed, frames == expected else { | |
| 488 | + throw reader.error ?? PulseMCPError("MEDIA_VALIDATION_FAILED", "The decoder found \(frames) frames. Expected \(expected).") | |
| 489 | + } | |
| 490 | + } | |
| 491 | + | |
| 492 | + } | |
| 493 | + | |
| 494 | + struct PulseMCPScene: Codable { | |
| 495 | + let visualizerId: String | |
| 496 | + let startSeconds: Double | |
| 497 | + let endSeconds: Double | |
| 498 | + let bars: Int? | |
| 499 | + var payload: PulseMCP.Object { | |
| 500 | + var object: PulseMCP.Object = ["visualizerId": visualizerId, "startSeconds": startSeconds, "endSeconds": endSeconds] | |
| 501 | + object["bars"] = bars.flatMap { (1...128).contains($0) ? $0 : nil } | |
| 502 | + return object | |
| 503 | + } | |
| 504 | + } | |
| 505 | + | |
| 506 | + extension SocialAspect { | |
| 507 | + var agentName: String { PulseMCP.aspectNames[Self.allCases.firstIndex(of: self)!] } | |
| 508 | + } | |
| 509 | + #endif |
Sources/PulseCanvas/PulseCanvasMCPService.swift added
| 1 | + #if os(macOS) && DIRECT_BUILD && !STORE_BUILD | |
| 2 | + import AVFoundation | |
| 3 | + import Combine | |
| 4 | + import Foundation | |
| 5 | + | |
| 6 | + @MainActor | |
| 7 | + final class PulseMCPService: ObservableObject { | |
| 8 | + typealias Object = PulseMCP.Object | |
| 9 | + private var access: PulseMCPAccess! | |
| 10 | + private var audio: AudioController! | |
| 11 | + private var studio: StudioStore! | |
| 12 | + private var radio: RadioController! | |
| 13 | + private var render: RenderState! | |
| 14 | + private var exporter: SocialExportController! | |
| 15 | + private var jobs: PulseMCPJobs! | |
| 16 | + private let library = ProjectMPresets.shared | |
| 17 | + private var preparing = false | |
| 18 | + private var radioCatalog: (source: URL, catalog: RadioCatalog, url: URL, stationID: String)? | |
| 19 | + | |
| 20 | + func attach(access: PulseMCPAccess, audio: AudioController, studio: StudioStore, radio: RadioController, | |
| 21 | + render: RenderState, exporter: SocialExportController) { | |
| 22 | + guard self.access == nil else { return } | |
| 23 | + self.access = access | |
| 24 | + self.audio = audio | |
| 25 | + self.studio = studio | |
| 26 | + self.radio = radio | |
| 27 | + self.render = render | |
| 28 | + self.exporter = exporter | |
| 29 | + jobs = PulseMCPJobs(access: access, exporter: exporter) | |
| 30 | + } | |
| 31 | + | |
| 32 | + func call(_ name: String, _ args: Object) async -> Object { | |
| 33 | + do { | |
| 34 | + guard let tool = PulseMCP.tools.first(where: { $0.name == name }), PulseMCP.valid(args, schema: tool.input) else { | |
| 35 | + throw PulseMCPError("INVALID_ARGUMENTS", "Use the published input schema.") | |
| 36 | + } | |
| 37 | + if name == "get_app_status" { | |
| 38 | + return ["value": ["running": true, "enabled": access.enabled, | |
| 39 | + "edition": PulseMCPAccess.edition, "version": PulseMCPAccess.version, | |
| 40 | + "editing": access.enabled && access.editing, "playback": access.enabled && access.playback, | |
| 41 | + "rendering": access.enabled && access.rendering, | |
| 42 | + "pendingExports": access.enabled ? jobs.pendingCount : 0]] | |
| 43 | + } | |
| 44 | + guard access.enabled else { | |
| 45 | + throw PulseMCPError("CONNECTION_DISABLED", "Enable local agent access in PulseCanvas Studio → Settings → Agent access.") | |
| 46 | + } | |
| 47 | + if let permission = tool.permission { try require(permission) } | |
| 48 | + return ["value": try await execute(name, args)] | |
| 49 | + } catch { | |
| 50 | + return ["error": PulseMCPJobs.error(error, defaultCode: "OPERATION_FAILED").payload] | |
| 51 | + } | |
| 52 | + } | |
| 53 | + | |
| 54 | + private func execute(_ name: String, _ args: Object) async throws -> Object { | |
| 55 | + switch name { | |
| 56 | + case "get_capabilities": return capabilities() | |
| 57 | + case "list_visualizers": return listVisualizers(args) | |
| 58 | + case "get_visualizer": return visualizer(try scene(args.string("id")), detailed: true) | |
| 59 | + case "list_favorites": | |
| 60 | + let kind = args.string("kind") | |
| 61 | + let items = kind == "visualizer" | |
| 62 | + ? library.availableScenes.filter(library.isFavorite).map { visualizer($0) } | |
| 63 | + : radio.favoriteSongs.map { song($0.track) } | |
| 64 | + return ["kind": kind, "favorites": items] | |
| 65 | + case "list_radio_songs": | |
| 66 | + let tracks: [RadioTrack] | |
| 67 | + if let current = radio.catalog, !radio.isPersonalMusic { tracks = current.tracks } | |
| 68 | + else { tracks = try await radioFavoritesCatalog().catalog.tracks } | |
| 69 | + return page(tracks.map { song($0) }, args: args, key: "songs") | |
| 70 | + case "set_favorite": return try await setFavorite(args) | |
| 71 | + case "get_playback_state": return try playback() | |
| 72 | + case "load_song": | |
| 73 | + try checkRevision(args) | |
| 74 | + let source = try authorizedAudio(args.string("path")) | |
| 75 | + let prepared = try await prepare(source, args: args, permission: "playback") | |
| 76 | + try install(prepared) | |
| 77 | + studio.segments = []; studio.detectedBPM = nil; studio.generationSeed = nil | |
| 78 | + return try playback() | |
| 79 | + case "set_playback_state": | |
| 80 | + try checkStudio() | |
| 81 | + guard audio.selectedURL != nil else { throw audioUnavailable() } | |
| 82 | + switch args.string("state") { | |
| 83 | + case "play": | |
| 84 | + if !audio.isPlaying { audio.playFullSoundtrack() } | |
| 85 | + guard audio.isPlaying else { throw PulseMCPError("PLAYBACK_FAILED", "PulseCanvas could not start the audio engine.") } | |
| 86 | + case "pause": audio.pause() | |
| 87 | + default: audio.stop() | |
| 88 | + } | |
| 89 | + return try playback() | |
| 90 | + case "seek": | |
| 91 | + try checkStudio() | |
| 92 | + guard audio.selectedURL != nil, audio.duration > 0 else { throw audioUnavailable() } | |
| 93 | + let position = args.double("seconds") | |
| 94 | + guard position <= audio.duration else { throw PulseMCPError("INVALID_POSITION", "Seek within the reported soundtrack duration.") } | |
| 95 | + audio.seek(fraction: position / audio.duration) | |
| 96 | + return try playback() | |
| 97 | + case "set_volume": | |
| 98 | + let volume = Float(args.double("volume")) | |
| 99 | + if radio.isActive { radio.volume = volume } else { audio.volume = volume } | |
| 100 | + return try playback() | |
| 101 | + case "get_project": | |
| 102 | + try checkStudio() | |
| 103 | + return try projectDetails(document(), duration: audio.duration) | |
| 104 | + case "create_project": | |
| 105 | + try checkStudio(); try checkRevision(args) | |
| 106 | + studio.cloudProjectID = UUID().uuidString | |
| 107 | + studio.generationSeed = nil; studio.isStudio = true | |
| 108 | + studio.barsPerSection = args["barsPerScene"] as? Int ?? 4 | |
| 109 | + studio.segments = []; studio.selectedSegment = 0 | |
| 110 | + studio.detectedBPM = audio.segmentPlan(beatsPerSection: studio.beatsPerSection)?.bpm | |
| 111 | + return try projectDetails(document(), duration: audio.duration) | |
| 112 | + case "open_project": return try await openProject(args) | |
| 113 | + case "save_project": return try saveProject(args) | |
| 114 | + case "analyze_song": | |
| 115 | + try checkStudio() | |
| 116 | + guard let grid = audio.segmentPlan(beatsPerSection: args["beatsPerSection"] as? Int ?? 1) else { throw audioUnavailable() } | |
| 117 | + var info: Object = ["boundariesSeconds": grid.boundaries] | |
| 118 | + info["bpm"] = grid.bpm | |
| 119 | + return info | |
| 120 | + case "set_timeline": | |
| 121 | + try checkStudio(); try checkRevision(args) | |
| 122 | + let entries = args["segments"] as? [Object] ?? [] | |
| 123 | + let segments = try entries.map { | |
| 124 | + StudioSegment(start: $0.double("startSeconds"), end: $0.double("endSeconds"), | |
| 125 | + scene: try scene($0.string("visualizerId")), bars: $0["bars"] as? Int) | |
| 126 | + } | |
| 127 | + try checkWholeSong(segments, duration: audio.duration) | |
| 128 | + var appearances = studio.presets | |
| 129 | + for index in Set(segments.map(\.scene)) where appearances[index] == nil { | |
| 130 | + appearances[index] = library.favoriteAppearance(for: index) ?? .defaults(for: index) | |
| 131 | + } | |
| 132 | + studio.presets = appearances | |
| 133 | + studio.isStudio = true; studio.segments = segments; studio.generationSeed = nil | |
| 134 | + studio.follow(time: audio.playbackSeconds, render: render) | |
| 135 | + return try projectDetails(document(), duration: audio.duration) | |
| 136 | + case "set_visualizer": | |
| 137 | + try checkStudio(); try checkRevision(args) | |
| 138 | + let index = try scene(args.string("id")) | |
| 139 | + if let section = args["section"] as? Int { | |
| 140 | + guard studio.segments.indices.contains(section) else { | |
| 141 | + throw PulseMCPError("INVALID_TIMELINE", "Read the project and choose an existing section index.") | |
| 142 | + } | |
| 143 | + studio.assignScene(index, at: section, render: render) | |
| 144 | + studio.generationSeed = nil | |
| 145 | + } else { | |
| 146 | + studio.selectScene(index, render: render) | |
| 147 | + } | |
| 148 | + return try projectDetails(document(), duration: audio.duration) | |
| 149 | + case "set_visualizer_settings": | |
| 150 | + try checkStudio(); try checkRevision(args) | |
| 151 | + let index = try scene(args.string("id")) | |
| 152 | + let changes = args["settings"] as? Object ?? [:] | |
| 153 | + let controls = controls(for: index) | |
| 154 | + guard changes.keys.allSatisfy({ controls[$0] != nil }) else { | |
| 155 | + throw PulseMCPError("UNSUPPORTED_SETTING", "Read get_visualizer for controls that apply to this effect.") | |
| 156 | + } | |
| 157 | + let updated = try appearance(for: index, changes: changes) | |
| 158 | + if studio.presets[index] != updated { studio.presets[index] = updated } | |
| 159 | + if index == render.scene { updated.apply(to: render) } | |
| 160 | + return try projectDetails(document(), duration: audio.duration) | |
| 161 | + case "start_export", "render_preview": return try startExport(name, args) | |
| 162 | + case "get_export_status": return ["job": jobs.details(try jobs.job(args.string("id")))] | |
| 163 | + case "list_exports": return ["jobs": try jobs.recent(args["limit"] as? Int ?? 25).map(jobs.details)] | |
| 164 | + case "cancel_export": return ["job": jobs.details(try jobs.cancel(args.string("id")))] | |
| 165 | + case "create_music_video": return try await createMusicVideo(args) | |
| 166 | + default: throw PulseMCPError("UNKNOWN_TOOL", "Use tools/list to discover the supported tools.") | |
| 167 | + } | |
| 168 | + } | |
| 169 | + | |
| 170 | + private func require(_ permission: String) throws { | |
| 171 | + guard access.enabled, access.permits(permission) else { | |
| 172 | + throw PulseMCPError("PERMISSION_REQUIRED", "Enable \(permission) access in PulseCanvas Studio → Settings → Agent access.") | |
| 173 | + } | |
| 174 | + } | |
| 175 | + | |
| 176 | + private func capabilities() -> Object { | |
| 177 | + var result: Object = [ | |
| 178 | + "edition": PulseMCPAccess.edition, "resolutions": SocialExportController.supportedResolutions, | |
| 179 | + "frameRates": SocialExportController.supportedFrameRates.filter { [24, 30, 60].contains($0) }, | |
| 180 | + "aspects": SocialAspect.allCases.map(\.agentName), | |
| 181 | + "engines": library.entries.isEmpty ? ["metal"] : ["metal", "projectM"], | |
| 182 | + "videoCodec": "h264", "audioCodec": "aac", "controls": PulseMCP.controlProperties, | |
| 183 | + "maxPendingExports": PulseMCPJobs.maxPending | |
| 184 | + ] | |
| 185 | + result["inputFolder"] = access.scope(.input)?.url.path | |
| 186 | + result["outputFolder"] = access.scope(.output)?.url.path | |
| 187 | + return result | |
| 188 | + } | |
| 189 | + | |
| 190 | + private func checkStudio() throws { | |
| 191 | + guard !radio.isActive else { | |
| 192 | + throw PulseMCPError("RADIO_ACTIVE", "Studio operations preserve the current Radio session. Load an authorized song to switch to Studio.") | |
| 193 | + } | |
| 194 | + } | |
| 195 | + | |
| 196 | + private func scene(_ id: String) throws -> Int { | |
| 197 | + let index = id.hasPrefix("native:") ? Int(id.dropFirst(7)) : library.scene(for: id) | |
| 198 | + guard let index, library.availableScenes.contains(index), library.identity(for: index) == id else { | |
| 199 | + throw PulseMCPError("UNSUPPORTED_EFFECT", "The visualizer ID is unknown or unavailable in this edition. Read list_visualizers.") | |
| 200 | + } | |
| 201 | + return index | |
| 202 | + } | |
| 203 | + | |
| 204 | + private func visualizer(_ index: Int, detailed: Bool = false) -> Object { | |
| 205 | + var item: Object = ["id": library.identity(for: index), "name": library.sceneNames[index], | |
| 206 | + "category": library.category(for: index), | |
| 207 | + "engine": library.preset(for: index) == nil ? "metal" : "projectM", | |
| 208 | + "available": true, "favorite": library.isFavorite(index)] | |
| 209 | + if detailed { | |
| 210 | + if let data = try? JSONEncoder().encode(look(index)) { | |
| 211 | + item["settings"] = try? JSONSerialization.jsonObject(with: data) | |
| 212 | + } | |
| 213 | + item["controls"] = controls(for: index) | |
| 214 | + } | |
| 215 | + return item | |
| 216 | + } | |
| 217 | + | |
| 218 | + private func listVisualizers(_ args: Object) -> Object { | |
| 219 | + let query = args["query"] as? String | |
| 220 | + let engine = args["engine"] as? String | |
| 221 | + let category = args["category"] as? String | |
| 222 | + let hits = library.availableScenes.lazy.map { self.visualizer($0) }.filter { | |
| 223 | + (engine == nil || $0.string("engine") == engine) && | |
| 224 | + (category == nil || $0.string("category").localizedCaseInsensitiveCompare(category!) == .orderedSame) && | |
| 225 | + (args["favoritesOnly"] as? Bool != true || $0["favorite"] as? Bool == true) && | |
| 226 | + (query == nil || $0.string("name").localizedCaseInsensitiveContains(query!) || | |
| 227 | + $0.string("id").localizedCaseInsensitiveContains(query!)) | |
| 228 | + } | |
| 229 | + return page(Array(hits), args: args, key: "visualizers") | |
| 230 | + } | |
| 231 | + | |
| 232 | + private func page(_ items: [Object], args: Object, key: String) -> Object { | |
| 233 | + let offset = min(args["offset"] as? Int ?? 0, items.count) | |
| 234 | + let end = min(offset + (args["limit"] as? Int ?? 50), items.count) | |
| 235 | + var response: Object = [key: Array(items[offset..<end]), "total": items.count] | |
| 236 | + if end < items.count { response["nextOffset"] = end } | |
| 237 | + return response | |
| 238 | + } | |
| 239 | + | |
| 240 | + private func song(_ track: RadioTrack) -> Object { | |
| 241 | + ["id": track.id, "title": track.title, "genre": track.genre, "durationSeconds": track.duration, | |
| 242 | + "favorite": radio.isFavoriteSong(track)] | |
| 243 | + } | |
| 244 | + | |
| 245 | + private func setFavorite(_ args: Object) async throws -> Object { | |
| 246 | + let id = args.string("id"), kind = args.string("kind"), desired = args["favorite"] as? Bool == true | |
| 247 | + if kind == "visualizer" { | |
| 248 | + let index = try scene(id) | |
| 249 | + if library.isFavorite(index) != desired { library.toggleFavorite(index, appearance: look(index)) } | |
| 250 | + } else { | |
| 251 | + if desired, !radio.favoriteSongs.contains(where: { $0.id == id }), | |
| 252 | + !radio.setFavoriteSong(id: id, favorite: true) { | |
| 253 | + let resolved = try await radioFavoritesCatalog() | |
| 254 | + guard let track = resolved.catalog.tracks.first(where: { $0.id == id }) else { | |
| 255 | + throw PulseMCPError("SONG_NOT_FOUND", "Read list_radio_songs to find an available Radio track ID.") | |
| 256 | + } | |
| 257 | + try require("editing") | |
| 258 | + let song = FavoriteRadioSong(track: track, sourceURL: resolved.source, catalogURL: resolved.url, | |
| 259 | + stationID: resolved.stationID, folderBookmark: radio.studioMusicFolderBookmark) | |
| 260 | + guard radio.setFavoriteSong(id: id, favorite: true, candidate: song) else { | |
| 261 | + throw PulseMCPError("FAVORITE_NOT_SAVED", "Verify the Radio catalog and the saved favorites limit.") | |
| 262 | + } | |
| 263 | + } else if !desired { | |
| 264 | + guard UUID(uuidString: id) != nil else { | |
| 265 | + throw PulseMCPError("SONG_NOT_FOUND", "Supply a Radio track ID from list_radio_songs or list_favorites.") | |
| 266 | + } | |
| 267 | + _ = radio.setFavoriteSong(id: id, favorite: false) | |
| 268 | + } | |
| 269 | + } | |
| 270 | + return ["kind": kind, "id": id, "favorite": desired] | |
| 271 | + } | |
| 272 | + | |
| 273 | + /// Resolve the app's configured Radio library without starting playback or | |
| 274 | + /// changing the active station. Local libraries still require an input grant. | |
| 275 | + private func radioFavoritesCatalog() async throws -> (source: URL, catalog: RadioCatalog, url: URL, stationID: String) { | |
| 276 | + let configured = radio.studioMusicSource | |
| 277 | + let authorized = configured.isFileURL ? try access.authorize(configured.path, in: [.input]) : nil | |
| 278 | + let source = authorized?.url ?? configured | |
| 279 | + defer { withExtendedLifetime(authorized?.scope) {} } | |
| 280 | + if let radioCatalog, radioCatalog.source == source { return radioCatalog } | |
| 281 | + do { | |
| 282 | + let resolved = try await radio.studioMusicLibrary.completeCatalog(at: source) | |
| 283 | + guard access.enabled, radio.studioMusicSource == configured else { | |
| 284 | + throw PulseMCPError("RADIO_CATALOG_CHANGED", "The Radio source or agent access changed. Read the current catalog and retry.") | |
| 285 | + } | |
| 286 | + if source.isFileURL { _ = try access.authorize(resolved.url.path, in: [.input]) } | |
| 287 | + let entry = (source: source, catalog: resolved.catalog, url: resolved.url, stationID: resolved.stationID) | |
| 288 | + radioCatalog = entry | |
| 289 | + return entry | |
| 290 | + } catch let failure as PulseMCPError { throw failure } | |
| 291 | + catch { | |
| 292 | + throw PulseMCPError("RADIO_CATALOG_UNAVAILABLE", "The configured Radio catalog could not be loaded. Check the Radio source or connection.") | |
| 293 | + } | |
| 294 | + } | |
| 295 | + | |
| 296 | + private func controls(for index: Int) -> Object { | |
| 297 | + var controls = PulseMCP.controlProperties | |
| 298 | + if library.preset(for: index) != nil { | |
| 299 | + // The preset supplies its own colors, particle sizes and depth. | |
| 300 | + for key in ["palette", "particleSize", "fog"] { controls.removeValue(forKey: key) } | |
| 301 | + } | |
| 302 | + if NativeEffects.effect(index)?.detailLabel == nil { controls.removeValue(forKey: "liquidDetail") } | |
| 303 | + if index != 28 { controls.removeValue(forKey: "haloCount") } | |
| 304 | + return controls | |
| 305 | + } | |
| 306 | + | |
| 307 | + private func look(_ index: Int) -> VisualPreset { | |
| 308 | + if index == render.scene { return studio.preset(render) } | |
| 309 | + return studio.presets[index] ?? library.favoriteAppearance(for: index) ?? .defaults(for: index) | |
| 310 | + } | |
| 311 | + | |
| 312 | + private func appearance(for index: Int, changes: Object) throws -> VisualPreset { | |
| 313 | + let data = try JSONEncoder().encode(look(index)) | |
| 314 | + let existing = try JSONSerialization.jsonObject(with: data) as? Object ?? [:] | |
| 315 | + let merged = existing.merging(changes) { _, new in new } | |
| 316 | + return try JSONDecoder().decode(VisualPreset.self, from: JSONSerialization.data(withJSONObject: merged)) | |
| 317 | + } | |
| 318 | + | |
| 319 | + private func audioUnavailable() -> PulseMCPError { | |
| 320 | + PulseMCPError("AUDIO_UNAVAILABLE", "Load an existing local audio file from the authorized input folder.") | |
| 321 | + } | |
| 322 | + | |
| 323 | + private func authorizedAudio(_ path: String) throws -> PulseMCPAccess.AuthorizedPath { | |
| 324 | + do { return try access.authorize(path, in: [.input]) } | |
| 325 | + catch let error as PulseMCPError where error.code == "FILE_UNAVAILABLE" { | |
| 326 | + throw PulseMCPError("AUDIO_UNAVAILABLE", error.message) | |
| 327 | + } | |
| 328 | + } | |
| 329 | + | |
| 330 | + private func prepare(_ source: PulseMCPAccess.AuthorizedPath, args: Object, permission: String) async throws -> PreparedSoundtrack { | |
| 331 | + guard !preparing else { throw PulseMCPError("PROJECT_BUSY", "Wait for the other song or project preparation to finish.") } | |
| 332 | + preparing = true | |
| 333 | + defer { preparing = false } | |
| 334 | + let original = try PulseMCPJobs.sourceIdentity(source.url) | |
| 335 | + defer { withExtendedLifetime(source.scope) {} } | |
| 336 | + let preparation = Task.detached(priority: .userInitiated) { try PreparedSoundtrack(url: source.url) } | |
| 337 | + let prepared: PreparedSoundtrack | |
| 338 | + do { | |
| 339 | + prepared = try await withTaskCancellationHandler { try await preparation.value } onCancel: { preparation.cancel() } | |
| 340 | + } catch { throw PulseMCPJobs.error(error, defaultCode: "AUDIO_UNAVAILABLE") } | |
| 341 | + let current = try PulseMCPJobs.sourceIdentity(source.url) | |
| 342 | + guard current.bytes == original.bytes, current.modified == original.modified else { | |
| 343 | + throw PulseMCPError("AUDIO_CHANGED", "The file changed during preparation. Retry with a stable local copy.") | |
| 344 | + } | |
| 345 | + try require(permission) | |
| 346 | + _ = try authorizedAudio(source.url.path) | |
| 347 | + try checkRevision(args) | |
| 348 | + guard prepared.analyzer.duration > 0, prepared.analyzer.duration <= 86_400 else { throw audioUnavailable() } | |
| 349 | + return prepared | |
| 350 | + } | |
| 351 | + | |
| 352 | + private func install(_ prepared: PreparedSoundtrack) throws { | |
| 353 | + radio.leave() | |
| 354 | + guard audio.install(prepared) else { throw audioUnavailable() } | |
| 355 | + studio.timelineSoundtrack = audio.selectedURL | |
| 356 | + } | |
| 357 | + | |
| 358 | + private func document() -> CreatorProject { | |
| 359 | + studio.document(audio: audio, render: render, exporter: exporter) | |
| 360 | + } | |
| 361 | + | |
| 362 | + private func revision(_ project: CreatorProject) throws -> String { | |
| 363 | + var stable = project | |
| 364 | + if let scene = stable.timeline?.first?.scene, stable.studioEnabled == true { | |
| 365 | + stable.scene = scene | |
| 366 | + stable.appearance = stable.visualPresets?[scene] ?? .defaults(for: scene) | |
| 367 | + } | |
| 368 | + return UserBackup.hash(try stable.encoded()) | |
| 369 | + } | |
| 370 | + | |
| 371 | + private func checkRevision(_ args: Object) throws { | |
| 372 | + guard try revision(document()) == args.string("expectedRevision") else { | |
| 373 | + throw PulseMCPError("PROJECT_CONFLICT", "The Studio project changed. Read the current revision and review the new project before retrying.") | |
| 374 | + } | |
| 375 | + } | |
| 376 | + | |
| 377 | + private func projectDetails(_ project: CreatorProject, duration: Double) throws -> Object { | |
| 378 | + let aspect = SocialAspect(rawValue: project.aspect) ?? .wide | |
| 379 | + var result: Object = ["revision": try revision(project), "durationSeconds": min(duration, 86_400), | |
| 380 | + "visualizerId": library.identity(for: project.scene), | |
| 381 | + "studioEnabled": project.studioEnabled ?? false, | |
| 382 | + "timeline": timeline(project).map(\.payload), | |
| 383 | + "exportSettings": ["aspect": aspect.agentName, "resolution": project.resolution, "fps": project.fps]] | |
| 384 | + result["id"] = project.cloudProjectID | |
| 385 | + result["seed"] = project.generationSeed | |
| 386 | + if let path = project.soundtrack?.path, (try? authorizedAudio(path)) != nil { | |
| 387 | + result["soundtrackPath"] = path | |
| 388 | + } | |
| 389 | + result["barsPerScene"] = project.barsPerSection.flatMap { (1...128).contains($0) ? $0 : nil } | |
| 390 | + return result | |
| 391 | + } | |
| 392 | + | |
| 393 | + private func timeline(_ project: CreatorProject) -> [PulseMCPScene] { | |
| 394 | + (project.timeline ?? []).map { | |
| 395 | + PulseMCPScene(visualizerId: project.effectIdentities?[$0.scene] ?? library.identity(for: $0.scene), | |
| 396 | + startSeconds: $0.start, endSeconds: $0.end, bars: $0.bars) | |
| 397 | + } | |
| 398 | + } | |
| 399 | + | |
| 400 | + private func playback() throws -> Object { | |
| 401 | + ["ready": audio.selectedURL != nil, "playing": audio.isPlaying, "positionSeconds": min(audio.playbackSeconds, 86_400), | |
| 402 | + "durationSeconds": min(audio.duration, 86_400), "volume": audio.volume, | |
| 403 | + "mode": radio.isActive ? "radio" : "studio", "title": audio.title, "revision": try revision(document())] | |
| 404 | + } | |
| 405 | + | |
| 406 | + private func checkWholeSong(_ segments: [StudioSegment], duration: Double) throws { | |
| 407 | + guard duration > 0, !segments.isEmpty, | |
| 408 | + StudioTimeline.valid(segments, sceneCount: library.sceneNames.count), | |
| 409 | + let end = segments.last?.end, abs(end - duration) <= 0.001 else { | |
| 410 | + throw PulseMCPError("INVALID_TIMELINE", "Supply contiguous sections from zero through the exact soundtrack duration.") | |
| 411 | + } | |
| 412 | + } | |
| 413 | + | |
| 414 | + private func outputPath(_ path: String, extension expected: String) throws -> PulseMCPAccess.AuthorizedPath { | |
| 415 | + let output = try access.authorize(path, in: [.output], writing: true) | |
| 416 | + guard output.url.pathExtension.lowercased() == expected else { | |
| 417 | + throw PulseMCPError("INVALID_PATH", "Use a .\(expected) filename in the authorized output folder.") | |
| 418 | + } | |
| 419 | + return output | |
| 420 | + } | |
| 421 | + | |
| 422 | + private func openProject(_ args: Object) async throws -> Object { | |
| 423 | + try checkRevision(args) | |
| 424 | + let input = try access.authorize(args.string("path"), in: [.input, .output]) | |
| 425 | + defer { withExtendedLifetime(input.scope) {} } | |
| 426 | + guard input.url.pathExtension.lowercased() == "pulsecanvas", | |
| 427 | + let size = try input.url.resourceValues(forKeys: [.fileSizeKey]).fileSize, size <= 8_000_000 else { | |
| 428 | + throw PulseMCPError("INVALID_PROJECT", "Choose a PulseCanvas project file under 8 MB.") | |
| 429 | + } | |
| 430 | + let data = try Data(contentsOf: input.url) | |
| 431 | + let saved = try JSONDecoder().decode(CreatorProject.self, from: data) | |
| 432 | + let referenced = Set((saved.timeline ?? []).map(\.scene)).union([saved.scene]) | |
| 433 | + for index in referenced { | |
| 434 | + if library.isRetiredScene(index, identities: saved.effectIdentities) { | |
| 435 | + throw PulseMCPError("UNSUPPORTED_EFFECT", "This project uses a retired effect. Open it in Studio if you want to choose a replacement.") | |
| 436 | + } | |
| 437 | + } | |
| 438 | + let project: CreatorProject | |
| 439 | + do { project = try saved.remapped(using: library) } | |
| 440 | + catch { throw PulseMCPError("UNSUPPORTED_EFFECT", error.localizedDescription) } | |
| 441 | + let aspect = try project.checkedAspect() | |
| 442 | + if let source = try BundledSoundtrack.resolve(identifier: project.bundledSoundtrack, externalURL: project.soundtrack) { | |
| 443 | + try require("playback") | |
| 444 | + let prepared = try await prepare(try authorizedAudio(source.path), args: args, permission: "editing") | |
| 445 | + try require("playback") | |
| 446 | + guard (project.timeline?.last?.end ?? 0) <= prepared.analyzer.duration + 0.05 else { | |
| 447 | + throw PulseMCPError("INVALID_TIMELINE", "The project's timeline extends beyond its authorized soundtrack.") | |
| 448 | + } | |
| 449 | + try install(prepared) | |
| 450 | + } else { | |
| 451 | + guard (project.timeline?.last?.end ?? 0) == 0 else { throw audioUnavailable() } | |
| 452 | + try require("playback") | |
| 453 | + radio.leave(); audio.clear(); studio.timelineSoundtrack = nil | |
| 454 | + } | |
| 455 | + studio.applyDocument(project, aspect: aspect, audio: audio, render: render, exporter: exporter) | |
| 456 | + try UserBackup.rememberProject(data, name: input.url.path) | |
| 457 | + return try projectDetails(document(), duration: audio.duration) | |
| 458 | + } | |
| 459 | + | |
| 460 | + private func signature(_ tool: String, _ args: Object) -> String { | |
| 461 | + UserBackup.hash(Data((tool + "\n" + PulseMCP.jsonText(args)).utf8)) | |
| 462 | + } | |
| 463 | + | |
| 464 | + private func writeProject(_ project: CreatorProject, to url: URL, overwrite: Bool) throws { | |
| 465 | + try PulseMCPJobs.checkDestination(url, overwrite: overwrite) | |
| 466 | + let staging = url.deletingLastPathComponent().appendingPathComponent(".PulseCanvas-project-" + UUID().uuidString) | |
| 467 | + let data = try project.encoded() | |
| 468 | + if overwrite && FileManager.default.fileExists(atPath: url.path) { | |
| 469 | + guard let current = project.cloudProjectID, | |
| 470 | + let size = try? url.resourceValues(forKeys: [.fileSizeKey]).fileSize, size <= 8_000_000, | |
| 471 | + let existing = try? JSONDecoder().decode(CreatorProject.self, from: Data(contentsOf: url)), | |
| 472 | + existing.cloudProjectID == current else { | |
| 473 | + throw PulseMCPError("OUTPUT_EXISTS", "Use a new name. PulseCanvas can replace only another save of this project.") | |
| 474 | + } | |
| 475 | + } | |
| 476 | + try data.write(to: staging, options: .withoutOverwriting) | |
| 477 | + defer { try? FileManager.default.removeItem(at: staging) } | |
| 478 | + try PulseMCPJobs.publish(staging, to: url, overwrite: overwrite) | |
| 479 | + try UserBackup.rememberProject(data, name: url.path) | |
| 480 | + } | |
| 481 | + | |
| 482 | + private func saveProject(_ args: Object) throws -> Object { | |
| 483 | + let key = args.string("requestKey"), signature = signature("save_project", args) | |
| 484 | + let target = try outputPath(args.string("path"), extension: "pulsecanvas") | |
| 485 | + defer { withExtendedLifetime(target.scope) {} } | |
| 486 | + if let receipt = try jobs.repeatSave(key: key, signature: signature) { | |
| 487 | + guard FileManager.default.fileExists(atPath: target.url.path) else { | |
| 488 | + throw PulseMCPError("PROJECT_NOT_FOUND", "The previously saved project is missing. Choose a destination and new request key.") | |
| 489 | + } | |
| 490 | + return ["path": receipt.path, "project": try projectDetails(receipt.project, duration: receipt.duration)] | |
| 491 | + } | |
| 492 | + try checkStudio(); try checkRevision(args) | |
| 493 | + var document = document() | |
| 494 | + if document.cloudProjectID == nil { document.cloudProjectID = UUID().uuidString } | |
| 495 | + try writeProject(document, to: target.url, overwrite: args["overwrite"] as? Bool == true) | |
| 496 | + try jobs.rememberSave(.init(key: key, signature: signature, path: target.url.path, project: document, duration: audio.duration)) | |
| 497 | + studio.cloudProjectID = document.cloudProjectID | |
| 498 | + return ["path": target.url.path, "project": try projectDetails(document, duration: audio.duration)] | |
| 499 | + } | |
| 500 | + | |
| 501 | + private func exportFormat(_ args: Object) throws -> PulseMCPJobs.Format { | |
| 502 | + let aspect = args["aspect"] as? String ?? exporter.aspect.agentName | |
| 503 | + let resolution = args["resolution"] as? Int ?? exporter.resolution | |
| 504 | + let fps = args["fps"] as? Int ?? exporter.fps | |
| 505 | + guard SocialExportController.supportedResolutions.contains(resolution), | |
| 506 | + SocialExportController.supportedFrameRates.contains(fps), [24, 30, 60].contains(fps) else { | |
| 507 | + throw PulseMCPError("UNSUPPORTED_FORMAT", "Choose a resolution and frame rate from get_capabilities.") | |
| 508 | + } | |
| 509 | + return .init(aspect: aspect, resolution: resolution, fps: fps) | |
| 510 | + } | |
| 511 | + | |
| 512 | + private func startExport(_ tool: String, _ args: Object) throws -> Object { | |
| 513 | + let key = args.string("requestKey"), signature = signature(tool, args) | |
| 514 | + if let previous = try jobs.repeatJob(key: key, signature: signature) { return ["job": jobs.details(previous)] } | |
| 515 | + try checkStudio(); try checkRevision(args) | |
| 516 | + guard let soundtrack = audio.selectedURL, audio.duration > 0 else { throw audioUnavailable() } | |
| 517 | + let source = try authorizedAudio(soundtrack.path) | |
| 518 | + let target = try outputPath(args.string("path"), extension: "mp4") | |
| 519 | + defer { withExtendedLifetime((source.scope, target.scope)) {} } | |
| 520 | + let preview = tool == "render_preview" ? (args["previewSeconds"] as? Double ?? 5) : nil | |
| 521 | + guard tool == "render_preview" || args["previewSeconds"] == nil else { | |
| 522 | + throw PulseMCPError("INVALID_ARGUMENTS", "Use render_preview for a short clip.") | |
| 523 | + } | |
| 524 | + let project = document() | |
| 525 | + if project.studioEnabled == true { try checkWholeSong(project.timeline ?? [], duration: audio.duration) } | |
| 526 | + let job = try makeJob(args: args, signature: signature, project: project, source: source.url, destination: target.url, | |
| 527 | + format: exportFormat(args), projectPath: nil, preview: preview, duration: audio.duration, fallback: false) | |
| 528 | + try jobs.submit(job) | |
| 529 | + return ["job": jobs.details(job)] | |
| 530 | + } | |
| 531 | + | |
| 532 | + private func makeJob(args: Object, signature: String, project: CreatorProject, source: URL, destination: URL, | |
| 533 | + format: PulseMCPJobs.Format, projectPath: String?, preview: Double?, duration: Double, | |
| 534 | + fallback: Bool) throws -> PulseMCPJobs.Job { | |
| 535 | + let overwrite = args["overwrite"] as? Bool == true | |
| 536 | + try jobs.checkCapacity(destination: destination) | |
| 537 | + try jobs.checkOutput(destination, overwrite: overwrite) | |
| 538 | + let identity = try PulseMCPJobs.sourceIdentity(source) | |
| 539 | + _ = try scene(library.identity(for: project.scene)) | |
| 540 | + for entry in timeline(project) { _ = try scene(entry.visualizerId) } | |
| 541 | + return .init(id: UUID().uuidString, signature: signature, requestKey: args.string("requestKey"), | |
| 542 | + destination: destination.path, projectPath: projectPath, sourcePath: source.path, | |
| 543 | + sourceBytes: identity.bytes, sourceModified: identity.modified, settings: format, | |
| 544 | + previewSeconds: preview, overwrite: overwrite, project: project, | |
| 545 | + timeline: timeline(project), duration: duration, usedFallback: fallback) | |
| 546 | + } | |
| 547 | + | |
| 548 | + private func creationResult(_ job: PulseMCPJobs.Job) throws -> Object { | |
| 549 | + guard let path = job.projectPath else { | |
| 550 | + throw PulseMCPError("PROJECT_NOT_FOUND", "The job does not have an editable project.") | |
| 551 | + } | |
| 552 | + let saved = try? access.authorize(path, in: [.output]) | |
| 553 | + defer { withExtendedLifetime(saved?.scope) {} } | |
| 554 | + guard saved != nil else { | |
| 555 | + throw PulseMCPError(job.errorCode ?? "PROJECT_NOT_FOUND", | |
| 556 | + job.errorMessage ?? "The editable project is unavailable in the authorized folder.") | |
| 557 | + } | |
| 558 | + return ["projectPath": path, "project": try projectDetails(job.project, duration: job.duration), | |
| 559 | + "job": jobs.details(job), "usedFallback": job.usedFallback] | |
| 560 | + } | |
| 561 | + | |
| 562 | + private func createMusicVideo(_ args: Object) async throws -> Object { | |
| 563 | + try require("editing"); try require("playback") | |
| 564 | + let key = args.string("requestKey"), signature = signature("create_music_video", args) | |
| 565 | + if let previous = try jobs.repeatJob(key: key, signature: signature) { return try creationResult(previous) } | |
| 566 | + try checkRevision(args) | |
| 567 | + let source = try authorizedAudio(args.string("songPath")) | |
| 568 | + let projectPath = try outputPath(args.string("projectPath"), extension: "pulsecanvas") | |
| 569 | + let output = try outputPath(args.string("outputPath"), extension: "mp4") | |
| 570 | + defer { withExtendedLifetime((source.scope, projectPath.scope, output.scope)) {} } | |
| 571 | + try jobs.checkCapacity(destination: output.url) | |
| 572 | + try PulseMCPJobs.checkDestination(output.url, overwrite: false) | |
| 573 | + try PulseMCPJobs.checkDestination(PulseMCPJobs.manifestURL(output.url), overwrite: false) | |
| 574 | + try PulseMCPJobs.checkDestination(projectPath.url, overwrite: false) | |
| 575 | + let format = try exportFormat(args) | |
| 576 | + let isPreview = args["previewOnly"] as? Bool == true | |
| 577 | + guard isPreview || args["previewSeconds"] == nil else { | |
| 578 | + throw PulseMCPError("INVALID_ARGUMENTS", "Set previewOnly to true to use previewSeconds.") | |
| 579 | + } | |
| 580 | + let prepared = try await prepare(source, args: args, permission: "editing") | |
| 581 | + try require("playback"); try require("rendering") | |
| 582 | + _ = try outputPath(projectPath.url.path, extension: "pulsecanvas") | |
| 583 | + _ = try outputPath(output.url.path, extension: "mp4") | |
| 584 | + let bars = args["barsPerScene"] as? Int ?? 4 | |
| 585 | + let seed = args["seed"] as? String ?? UUID().uuidString | |
| 586 | + var generator = PulseMCPSeed(seed) | |
| 587 | + let requested = try (args["visualizerIds"] as? [String] ?? []).map(scene) | |
| 588 | + var pool = requested.isEmpty ? library.availableScenes.filter(library.isFavorite) : requested | |
| 589 | + let fallback = pool.isEmpty | |
| 590 | + if fallback { | |
| 591 | + switch args.string("fallback") { | |
| 592 | + case "metal": pool = library.availableScenes.filter { library.preset(for: $0) == nil } | |
| 593 | + case "available": pool = library.availableScenes | |
| 594 | + default: throw PulseMCPError("EMPTY_STYLE_POOL", "Add a favorite, choose visualizer IDs, or request an explicit fallback.") | |
| 595 | + } | |
| 596 | + } | |
| 597 | + pool = Set(pool).sorted { library.identity(for: $0) < library.identity(for: $1) } | |
| 598 | + guard !pool.isEmpty else { throw PulseMCPError("EMPTY_STYLE_POOL", "Choose an installed visualizer.") } | |
| 599 | + pool.shuffle(using: &generator) | |
| 600 | + let grid = prepared.analyzer.segmentPlan(beatsPerSection: bars * 4) | |
| 601 | + let duration = prepared.analyzer.duration | |
| 602 | + let sections = StudioTimeline.sections(boundaries: grid.boundaries, bars: bars) { index, _ in pool[index % pool.count] } | |
| 603 | + try checkWholeSong(sections, duration: duration) | |
| 604 | + var appearances = studio.presets | |
| 605 | + for index in Set(sections.map(\.scene)) { | |
| 606 | + var settings = appearances[index] ?? library.favoriteAppearance(for: index) ?? .defaults(for: index) | |
| 607 | + settings.strobeEnabled = args["strobeEnabled"] as? Bool == true | |
| 608 | + appearances[index] = settings | |
| 609 | + } | |
| 610 | + let first = sections[0].scene | |
| 611 | + guard let aspect = SocialAspect.allCases.first(where: { $0.agentName == format.aspect }) else { | |
| 612 | + throw PulseMCPError("UNSUPPORTED_FORMAT", "Choose an aspect from get_capabilities.") | |
| 613 | + } | |
| 614 | + let bookmarked = try? prepared.access.readOnlyBookmark() | |
| 615 | + let project = CreatorProject(soundtrack: source.url, scene: first, appearance: appearances[first]!, | |
| 616 | + aspect: aspect.rawValue, resolution: format.resolution, fps: format.fps, timeline: sections, | |
| 617 | + studioEnabled: true, visualPresets: appearances, barsPerSection: bars, | |
| 618 | + effectIdentities: library.identities(for: Set(appearances.keys)), soundtrackBookmark: bookmarked, | |
| 619 | + loopPlayback: false, cloudProjectID: UUID().uuidString, generationSeed: seed) | |
| 620 | + let job = try makeJob(args: args, signature: signature, project: project, source: source.url, destination: output.url, | |
| 621 | + format: format, projectPath: projectPath.url.path, | |
| 622 | + preview: isPreview ? args["previewSeconds"] as? Double ?? 5 : nil, duration: duration, fallback: fallback) | |
| 623 | + try jobs.submit(job) | |
| 624 | + do { | |
| 625 | + try writeProject(project, to: projectPath.url, overwrite: false) | |
| 626 | + try install(prepared) | |
| 627 | + studio.applyDocument(project, aspect: aspect, audio: audio, render: render, exporter: exporter) | |
| 628 | + } catch { | |
| 629 | + jobs.failPreparation(job, error: error) | |
| 630 | + throw error | |
| 631 | + } | |
| 632 | + return try creationResult(job) | |
| 633 | + } | |
| 634 | + } | |
| 635 | + | |
| 636 | + private extension Dictionary where Key == String, Value == Any { | |
| 637 | + func string(_ key: String) -> String { self[key] as? String ?? "" } | |
| 638 | + func double(_ key: String) -> Double { self[key] as? Double ?? 0 } | |
| 639 | + } | |
| 640 | + #endif |
Sources/PulseCanvas/PulseCanvasOnboarding.swift added
| 1 | + import SwiftUI | |
| 2 | + import StoreKit | |
| 3 | + #if os(macOS) | |
| 4 | + import AppKit | |
| 5 | + #else | |
| 6 | + import UIKit | |
| 7 | + #endif | |
| 8 | + | |
| 9 | + extension Notification.Name { | |
| 10 | + static let pulseCanvasOnboarding = Notification.Name("PulseCanvas.showOnboarding") | |
| 11 | + } | |
| 12 | + | |
| 13 | + #if os(visionOS) | |
| 14 | + private struct PulseCanvasOnboardingActiveKey: EnvironmentKey { | |
| 15 | + static let defaultValue = false | |
| 16 | + } | |
| 17 | + | |
| 18 | + extension EnvironmentValues { | |
| 19 | + var pulseCanvasOnboardingActive: Bool { | |
| 20 | + get { self[PulseCanvasOnboardingActiveKey.self] } | |
| 21 | + set { self[PulseCanvasOnboardingActiveKey.self] = newValue } | |
| 22 | + } | |
| 23 | + } | |
| 24 | + #endif | |
| 25 | + | |
| 26 | + enum PulseCanvasOnboarding { | |
| 27 | + static let completedKey = "PulseCanvas.onboarding.completed.v1" | |
| 28 | + static var initialStep: Int { | |
| 29 | + #if DEBUG | |
| 30 | + let args = ProcessInfo.processInfo.arguments | |
| 31 | + if let index = args.firstIndex(of: "-PCOnboardingStep"), args.indices.contains(index + 1) { | |
| 32 | + return min(PulseCanvasOnboardingView.lastStep, max(0, Int(args[index + 1]) ?? 0)) | |
| 33 | + } | |
| 34 | + #endif | |
| 35 | + return 0 | |
| 36 | + } | |
| 37 | + static var forced: Bool { | |
| 38 | + #if DEBUG | |
| 39 | + return ProcessInfo.processInfo.arguments.contains("-PCOnboardingQA") | |
| 40 | + #else | |
| 41 | + return false | |
| 42 | + #endif | |
| 43 | + } | |
| 44 | + static var fixture: Bool { | |
| 45 | + #if DEBUG | |
| 46 | + let args = ProcessInfo.processInfo.arguments | |
| 47 | + return !forced && (args.contains("-PCMobileQA") || args.contains("-PCUITesting")) | |
| 48 | + #else | |
| 49 | + return false | |
| 50 | + #endif | |
| 51 | + } | |
| 52 | + } | |
| 53 | + | |
| 54 | + /// Owns the entire root surface; onboarding is never presented in a sheet or popover. | |
| 55 | + struct PulseCanvasOnboardingPresentation: ViewModifier { | |
| 56 | + var onReplay: () -> Void = {} | |
| 57 | + @AppStorage(PulseCanvasOnboarding.completedKey) private var completed = false | |
| 58 | + @State private var replay = false | |
| 59 | + @State private var presentationID = UUID() | |
| 60 | + @State private var force = PulseCanvasOnboarding.forced | |
| 61 | + private var showingOnboarding: Bool { | |
| 62 | + replay || force || (!completed && !PulseCanvasOnboarding.fixture) | |
| 63 | + } | |
| 64 | + func body(content: Content) -> some View { | |
| 65 | + Group { | |
| 66 | + #if os(visionOS) | |
| 67 | + // Keep the established spatial editor attached to its window during | |
| 68 | + // replay. Removing and reinserting it can leave its controls unhittable. | |
| 69 | + ZStack { | |
| 70 | + if (completed || PulseCanvasOnboarding.fixture) && !force { | |
| 71 | + content.opacity(showingOnboarding ? 0 : 1) | |
| 72 | + .environment(\.pulseCanvasOnboardingActive, showingOnboarding) | |
| 73 | + .allowsHitTesting(!showingOnboarding) | |
| 74 | + .accessibilityElement(children: showingOnboarding ? .ignore : .contain) | |
| 75 | + .accessibilityHidden(showingOnboarding) | |
| 76 | + } | |
| 77 | + if showingOnboarding { onboarding } | |
| 78 | + } | |
| 79 | + #else | |
| 80 | + if showingOnboarding { onboarding } else { content } | |
| 81 | + #endif | |
| 82 | + } | |
| 83 | + .onReceive(NotificationCenter.default.publisher(for: .pulseCanvasOnboarding)) { _ in | |
| 84 | + onReplay() | |
| 85 | + presentationID = UUID() | |
| 86 | + replay = true | |
| 87 | + } | |
| 88 | + } | |
| 89 | + private var onboarding: some View { | |
| 90 | + PulseCanvasOnboardingView(initialStep: replay ? 0 : PulseCanvasOnboarding.initialStep) { | |
| 91 | + completed = true | |
| 92 | + replay = false | |
| 93 | + force = false | |
| 94 | + }.id(presentationID) | |
| 95 | + } | |
| 96 | + } | |
| 97 | + | |
| 98 | + struct PulseCanvasOnboardingView: View { | |
| 99 | + let finish: () -> Void | |
| 100 | + @State private var step: Int | |
| 101 | + init(initialStep: Int = PulseCanvasOnboarding.initialStep, finish: @escaping () -> Void) { | |
| 102 | + self.finish = finish | |
| 103 | + _step = State(initialValue: min(Self.lastStep, max(0, initialStep))) | |
| 104 | + } | |
| 105 | + static let pageCount = 4 | |
| 106 | + static let lastStep = pageCount - 1 | |
| 107 | + @Environment(\.accessibilityReduceMotion) private var reduceMotion | |
| 108 | + @ScaledMetric(relativeTo: .largeTitle) private var titleSize = 42 | |
| 109 | + @ScaledMetric(relativeTo: .largeTitle) private var tabletTitleSize = 56 | |
| 110 | + @ScaledMetric(relativeTo: .body) private var tabletBodySize = 24 | |
| 111 | + @ScaledMetric(relativeTo: .headline) private var tabletLessonTitleSize = 23 | |
| 112 | + @ScaledMetric(relativeTo: .subheadline) private var tabletDetailSize = 20 | |
| 113 | + @ScaledMetric(relativeTo: .footnote) private var tabletNoteSize = 18 | |
| 114 | + private let accent = Color(red: 0.95, green: 0.68, blue: 0.55) | |
| 115 | + private let background = Color(red: 50.0 / 255, green: 44.0 / 255, blue: 55.0 / 255) | |
| 116 | + private let ink = Color.white | |
| 117 | + private var names: [String] { | |
| 118 | + [String(localized: "Welcome"), String(localized: "Visualizers"), String(localized: "Studio"), | |
| 119 | + String(localized: "Play & share")] | |
| 120 | + } | |
| 121 | + private let assets = ["welcome", "visuals", "studio", "share"] | |
| 122 | + #if os(iOS) | |
| 123 | + private let locksTextPositions = true | |
| 124 | + #else | |
| 125 | + private let locksTextPositions = false | |
| 126 | + #endif | |
| 127 | + private func title(for step: Int) -> String { | |
| 128 | + switch step { | |
| 129 | + case 0: return String(localized: "Your music.\nYour visual world.") | |
| 130 | + case 1: return String(localized: "Find a look.\nMake it yours.") | |
| 131 | + case 2: | |
| 132 | + return String(localized: "Give your song\na visual story.") | |
| 133 | + default: | |
| 134 | + #if os(visionOS) | |
| 135 | + return String(localized: "Make room\nfor your music.") | |
| 136 | + #else | |
| 137 | + return String(localized: "From your canvas\nto any screen.") | |
| 138 | + #endif | |
| 139 | + } | |
| 140 | + } | |
| 141 | + private func subtitle(for step: Int) -> String { | |
| 142 | + switch step { | |
| 143 | + case 0: return String(localized: "Turn sound into moving art with PulseCanvas Studio. A few basics, then the canvas is yours.") | |
| 144 | + case 1: return String(localized: "Explore the visualizer library, save your favorites, and shape the colors and motion to suit your music.") | |
| 145 | + case 2: | |
| 146 | + return String(localized: "Choose music or import a soundtrack. Studio finds the beat so your scenes can change with the song.") | |
| 147 | + default: | |
| 148 | + #if os(visionOS) | |
| 149 | + return String(localized: "Open the immersive screen to surround yourself with the visuals, or export your Studio project as an MP4.") | |
| 150 | + #else | |
| 151 | + return String(localized: "Enjoy your visuals full screen, or export an MP4 with your soundtrack, ready to save and share.") | |
| 152 | + #endif | |
| 153 | + } | |
| 154 | + } | |
| 155 | + private func lessons(for step: Int) -> [(String, String, String)] { | |
| 156 | + switch step { | |
| 157 | + case 0: return [("waveform", String(localized: "Start with a song"), String(localized: "Try the included music or discover a station in Radio.")), | |
| 158 | + ("sparkles", String(localized: "Watch the music move"), String(localized: "Visuals respond to the rhythm as you listen."))] | |
| 159 | + case 1: return [("square.grid.2x2", String(localized: "Explore the library"), String(localized: "Browse categories and heart the looks you love.")), | |
| 160 | + ("slider.horizontal.3", String(localized: "Shape your style"), String(localized: "Adjust palettes, motion, and Chaos for a different feel."))] | |
| 161 | + case 2: | |
| 162 | + return [("rectangle.stack", String(localized: "Build scenes in Studio"), String(localized: "Choose a visualizer and a bar length for each scene.")), | |
| 163 | + ("shuffle", String(localized: "Try a new sequence"), String(localized: "Randomize the timeline, then fine-tune your favorite moments."))] | |
| 164 | + default: | |
| 165 | + #if os(visionOS) | |
| 166 | + return [("vision.pro", String(localized: "Open the immersive screen"), String(localized: "Choose Hide room for full immersion before entering.")), | |
| 167 | + ("film", String(localized: "Save your creation"), String(localized: "Export MP4 renders the Studio timeline with your soundtrack."))] | |
| 168 | + #elseif os(macOS) | |
| 169 | + return [("arrow.up.left.and.arrow.down.right", String(localized: "Press Present"), String(localized: "Space pauses playback. Escape returns to the editor.")), | |
| 170 | + ("film", String(localized: "Save a video"), String(localized: "In Project settings, choose a canvas and quality. Then choose Save video."))] | |
| 171 | + #else | |
| 172 | + return [("arrow.up.left.and.arrow.down.right", String(localized: "Open full-screen viewing"), String(localized: "Tap to reveal the controls while you listen.")), | |
| 173 | + ("film", String(localized: "Export your video"), String(localized: "Open Project actions → Export MP4. Render, then Save video to Files."))] | |
| 174 | + #endif | |
| 175 | + } | |
| 176 | + } | |
| 177 | + var body: some View { | |
| 178 | + GeometryReader { geometry in | |
| 179 | + let wide = geometry.size.width >= 760 || geometry.size.width > geometry.size.height | |
| 180 | + let short = geometry.size.height < 500 && wide | |
| 181 | + #if os(iOS) | |
| 182 | + let largeTablet = UIDevice.current.userInterfaceIdiom == .pad && min(geometry.size.width, geometry.size.height) >= 900 | |
| 183 | + #else | |
| 184 | + let largeTablet = false | |
| 185 | + #endif | |
| 186 | + VStack(spacing: 0) { | |
| 187 | + header(wide: wide).zIndex(2) | |
| 188 | + GeometryReader { pageGeometry in | |
| 189 | + OnboardingFittedContent(alignment: locksTextPositions && !largeTablet ? .topLeading : .center) { | |
| 190 | + page(wide: wide, size: pageGeometry.size, compact: pageGeometry.size.height < 480, largeTablet: largeTablet) | |
| 191 | + } | |
| 192 | + .frame(maxWidth: .infinity, maxHeight: .infinity) | |
| 193 | + .contentShape(Rectangle()) | |
| 194 | + .clipped() | |
| 195 | + }.id(step) | |
| 196 | + footer(wide: wide, short: short).zIndex(2) | |
| 197 | + } | |
| 198 | + .padding(.horizontal, wide ? 48 : 24) | |
| 199 | + .padding(.top, 16) | |
| 200 | + .padding(.bottom, 18) | |
| 201 | + .frame(maxWidth: .infinity, maxHeight: .infinity) | |
| 202 | + .background(background.ignoresSafeArea()) | |
| 203 | + .contentShape(Rectangle()) | |
| 204 | + // A recognized drag takes precedence over button taps so swiping | |
| 205 | + // across Continue cannot also activate it. Ordinary taps still work. | |
| 206 | + .highPriorityGesture(DragGesture(minimumDistance: 20).onEnded { value in | |
| 207 | + let distance = value.translation | |
| 208 | + #if os(iOS) | |
| 209 | + // Accept a deliberate short flick as well as a longer drag. | |
| 210 | + // Require real horizontal travel before consulting momentum. | |
| 211 | + let projected = value.predictedEndTranslation | |
| 212 | + guard abs(distance.width) >= 24, | |
| 213 | + abs(distance.width) > abs(distance.height) * 1.25, | |
| 214 | + abs(distance.width) >= 44 || (distance.width * projected.width > 0 && abs(projected.width) >= 80) else { return } | |
| 215 | + #else | |
| 216 | + guard abs(distance.width) >= 44, | |
| 217 | + abs(distance.width) > abs(distance.height) * 1.25 else { return } | |
| 218 | + #endif | |
| 219 | + changeStep(step + (distance.width < 0 ? 1 : -1)) | |
| 220 | + }) | |
| 221 | + #if os(macOS) | |
| 222 | + .background(OnboardingTrackpadNavigation { direction in | |
| 223 | + changeStep(step + direction) | |
| 224 | + }) | |
| 225 | + #endif | |
| 226 | + } | |
| 227 | + .dynamicTypeSize(.xSmall ... .xxxLarge) | |
| 228 | + .foregroundStyle(ink).tint(accent).preferredColorScheme(.dark).environment(\.colorScheme, .dark) | |
| 229 | + #if DEBUG | |
| 230 | + .task(id: step) { | |
| 231 | + // A capture waits for the actual page to appear before taking its screenshot. | |
| 232 | + guard PulseCanvasOnboarding.forced else { return } | |
| 233 | + try? await Task.sleep(for: .seconds(1)) | |
| 234 | + guard !Task.isCancelled else { return } | |
| 235 | + let file = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0].appendingPathComponent("onboarding-capture-ready.txt") | |
| 236 | + try? FileManager.default.createDirectory(at: file.deletingLastPathComponent(), withIntermediateDirectories: true) | |
| 237 | + try? String(step).write(to: file, atomically: true, encoding: .utf8) | |
| 238 | + } | |
| 239 | + #endif | |
| 240 | + } | |
| 241 | + @ViewBuilder private func page(wide: Bool, size: CGSize, compact: Bool, largeTablet: Bool) -> some View { | |
| 242 | + if wide { | |
| 243 | + HStack(alignment: locksTextPositions && !largeTablet ? .top : .center, spacing: compact ? 28 : 54) { | |
| 244 | + illustration | |
| 245 | + .frame(width: min(size.width * 0.44, largeTablet ? 620 : 510), | |
| 246 | + height: min(size.height * (compact ? 0.75 : 0.94), largeTablet ? 620 : 510)) | |
| 247 | + copy(wide: true, compact: compact, largeTablet: largeTablet).frame(maxWidth: largeTablet ? 600 : 490) | |
| 248 | + }.frame(maxWidth: largeTablet ? 1280 : 1120) | |
| 249 | + .accessibilityElement(children: .contain) | |
| 250 | + .accessibilityIdentifier("onboardingContent") | |
| 251 | + } else { | |
| 252 | + VStack(alignment: .leading, spacing: compact ? 12 : 20) { | |
| 253 | + illustration.frame(height: min(compact ? 110 : 220, size.height * (compact ? 0.22 : 0.32))) | |
| 254 | + .frame(maxWidth: .infinity) | |
| 255 | + copy(wide: false, compact: compact, largeTablet: false) | |
| 256 | + }.frame(maxWidth: 500) | |
| 257 | + } | |
| 258 | + } | |
| 259 | + private var startTitle: String { | |
| 260 | + String(localized: "Start creating") | |
| 261 | + } | |
| 262 | + private func header(wide: Bool) -> some View { | |
| 263 | + HStack(spacing: 10) { | |
| 264 | + if let logo = onboardingImage(named: "logo") { | |
| 265 | + logo.resizable().interpolation(.high).scaledToFit() | |
| 266 | + .frame(width: 36, height: 36) | |
| 267 | + .clipShape(RoundedRectangle(cornerRadius: 8)).accessibilityHidden(true) | |
| 268 | + } | |
| 269 | + VStack(alignment: .leading, spacing: 1) { | |
| 270 | + Text("PulseCanvas").font(.system(size: 19, weight: .semibold, design: .rounded)).lineLimit(1).minimumScaleFactor(0.8) | |
| 271 | + Text("Studio").font(.caption).foregroundStyle(ink.opacity(0.92)) | |
| 272 | + } | |
| 273 | + Spacer() | |
| 274 | + Button("Skip onboarding", action: finish).lineLimit(1).minimumScaleFactor(0.8).buttonStyle(OnboardingButtonStyle(primary: false, compact: true)) | |
| 275 | + .accessibilityIdentifier("onboardingSkip") | |
| 276 | + }.frame(minHeight: 48) | |
| 277 | + } | |
| 278 | + private var illustration: some View { | |
| 279 | + Group { | |
| 280 | + if let image = onboardingImage(named: assets[step]) { | |
| 281 | + image.resizable().interpolation(.high).scaledToFit() | |
| 282 | + } | |
| 283 | + } | |
| 284 | + .accessibilityHidden(true) | |
| 285 | + } | |
| 286 | + private func onboardingImage(named name: String) -> Image? { | |
| 287 | + let directories = ["Resources/Onboarding", "Onboarding"] | |
| 288 | + guard let url = directories.compactMap({ Bundle.module.url(forResource: name, withExtension: "png", subdirectory: $0) }).first else { return nil } | |
| 289 | + #if os(macOS) | |
| 290 | + guard let image = NSImage(contentsOf: url) else { return nil } | |
| 291 | + return Image(nsImage: image) | |
| 292 | + #else | |
| 293 | + guard let image = UIImage(contentsOfFile: url.path) else { return nil } | |
| 294 | + return Image(uiImage: image) | |
| 295 | + #endif | |
| 296 | + } | |
| 297 | + private func copy(wide: Bool, compact: Bool, largeTablet: Bool) -> some View { | |
| 298 | + VStack(alignment: .leading, spacing: compact ? 12 : 20) { | |
| 299 | + copySection { index in | |
| 300 | + Text(title(for: index)).font(.system(size: largeTablet ? tabletTitleSize : min(titleSize, wide ? 52 : 38) * (compact ? 0.88 : 1), weight: .bold, design: .rounded)) | |
| 301 | + .tracking(-1.2).fixedSize(horizontal: false, vertical: true) | |
| 302 | + .accessibilityIdentifier("onboardingTitle").accessibilityAddTraits(.isHeader) | |
| 303 | + } | |
| 304 | + copySection { index in | |
| 305 | + Text(subtitle(for: index)).font(largeTablet ? .system(size: tabletBodySize) : (compact ? .callout : .body)).foregroundStyle(ink.opacity(0.92)) | |
| 306 | + .fixedSize(horizontal: false, vertical: true).lineSpacing(3) | |
| 307 | + .accessibilityIdentifier("onboardingSubtitle") | |
| 308 | + } | |
| 309 | + #if os(iOS) | |
| 310 | + VStack(alignment: .leading, spacing: compact ? 12 : 18) { | |
| 311 | + ForEach(0..<2) { row in | |
| 312 | + copySection { index in | |
| 313 | + lessonRow(lessons(for: index)[row], compact: compact, largeTablet: largeTablet) | |
| 314 | + }.accessibilityIdentifier("onboardingLesson\(row)") | |
| 315 | + } | |
| 316 | + } | |
| 317 | + #else | |
| 318 | + copySection { index in | |
| 319 | + details(for: index, compact: compact) | |
| 320 | + } | |
| 321 | + #endif | |
| 322 | + }.frame(maxWidth: locksTextPositions ? .infinity : nil, alignment: .topLeading) | |
| 323 | + } | |
| 324 | + @ViewBuilder private func copySection<Content: View>(@ViewBuilder content: @escaping (Int) -> Content) -> some View { | |
| 325 | + #if os(iOS) | |
| 326 | + // Reserve the largest section across all slides in this layout pass. | |
| 327 | + // Titles, descriptions and details therefore keep the same top/left | |
| 328 | + // origins, including after rotation and Dynamic Type changes. | |
| 329 | + ZStack(alignment: .topLeading) { | |
| 330 | + ZStack(alignment: .topLeading) { | |
| 331 | + ForEach(0..<Self.pageCount, id: \.self) { index in | |
| 332 | + content(index).hidden() | |
| 333 | + } | |
| 334 | + }.accessibilityElement(children: .ignore).accessibilityHidden(true) | |
| 335 | + content(step) | |
| 336 | + }.frame(maxWidth: .infinity, alignment: .topLeading) | |
| 337 | + #else | |
| 338 | + content(step) | |
| 339 | + #endif | |
| 340 | + } | |
| 341 | + @ViewBuilder private func details(for step: Int, compact: Bool) -> some View { | |
| 342 | + VStack(alignment: .leading, spacing: compact ? 12 : 18) { | |
| 343 | + ForEach(lessons(for: step), id: \.0) { lesson in | |
| 344 | + lessonRow(lesson, compact: compact) | |
| 345 | + } | |
| 346 | + } | |
| 347 | + } | |
| 348 | + private func lessonRow(_ lesson: (String, String, String), compact: Bool, largeTablet: Bool = false) -> some View { | |
| 349 | + HStack(alignment: .onboardingLessonTitle, spacing: 14) { | |
| 350 | + Image(systemName: lesson.0).font(.system(size: largeTablet ? 28 : 22)).foregroundStyle(accent) | |
| 351 | + .frame(width: largeTablet ? 40 : 28).accessibilityHidden(true) | |
| 352 | + VStack(alignment: .leading, spacing: 5) { | |
| 353 | + Text(lesson.1).font(largeTablet ? .system(size: tabletLessonTitleSize, weight: .semibold) : (compact ? .subheadline.weight(.semibold) : .headline)) | |
| 354 | + .alignmentGuide(.onboardingLessonTitle) { $0[VerticalAlignment.center] } | |
| 355 | + Text(lesson.2).font(largeTablet ? .system(size: tabletDetailSize) : (compact ? .caption : .subheadline)).foregroundStyle(ink.opacity(0.92)) | |
| 356 | + .fixedSize(horizontal: false, vertical: true) | |
| 357 | + } | |
| 358 | + }.accessibilityElement(children: .combine) | |
| 359 | + } | |
| 360 | + @ViewBuilder private func footer(wide: Bool, short: Bool) -> some View { | |
| 361 | + if short { | |
| 362 | + HStack(spacing: 24) { | |
| 363 | + progress(compact: true) | |
| 364 | + navigation.frame(maxWidth: 360) | |
| 365 | + }.frame(maxWidth: .infinity).padding(.top, 10) | |
| 366 | + } else { | |
| 367 | + VStack(spacing: 18) { | |
| 368 | + progress(compact: false) | |
| 369 | + navigation.frame(maxWidth: 420) | |
| 370 | + }.frame(maxWidth: .infinity).padding(.top, 14) | |
| 371 | + } | |
| 372 | + } | |
| 373 | + private func progress(compact: Bool) -> some View { | |
| 374 | + HStack(spacing: 7) { | |
| 375 | + if !compact { | |
| 376 | + ForEach(0..<Self.pageCount, id: \.self) { index in | |
| 377 | + Capsule().fill(index == step ? accent : ink.opacity(0.18)) | |
| 378 | + .frame(width: index == step ? 26 : 7, height: 6) | |
| 379 | + } | |
| 380 | + } | |
| 381 | + Text("\(step + 1) of \(Self.pageCount) · \(names[step])").font(.caption) | |
| 382 | + .foregroundStyle(ink.opacity(0.92)).padding(.leading, 7) | |
| 383 | + } | |
| 384 | + .accessibilityElement(children: .ignore) | |
| 385 | + .accessibilityLabel("Step \(step + 1) of \(Self.pageCount), \(names[step])") | |
| 386 | + .accessibilityIdentifier("onboardingProgress") | |
| 387 | + .accessibilityHint("Adjust to move between onboarding pages") | |
| 388 | + .accessibilityAdjustableAction { direction in | |
| 389 | + switch direction { | |
| 390 | + case .increment: changeStep(step + 1) | |
| 391 | + case .decrement: changeStep(step - 1) | |
| 392 | + @unknown default: break | |
| 393 | + } | |
| 394 | + } | |
| 395 | + } | |
| 396 | + private var navigation: some View { | |
| 397 | + HStack(spacing: 12) { | |
| 398 | + if step > 0 { | |
| 399 | + Button { changeStep(step - 1) } label: { Image(systemName: "chevron.left").frame(width: 20) } | |
| 400 | + .buttonStyle(OnboardingButtonStyle(primary: false)).accessibilityLabel("Back") | |
| 401 | + .accessibilityIdentifier("onboardingBack") | |
| 402 | + } | |
| 403 | + Button { | |
| 404 | + if step == Self.lastStep { finish() } else { changeStep(step + 1) } | |
| 405 | + } label: { | |
| 406 | + HStack(spacing: 12) { | |
| 407 | + Text(step == Self.lastStep ? startTitle : "Continue").lineLimit(1).minimumScaleFactor(0.7) | |
| 408 | + Image(systemName: "arrow.right") | |
| 409 | + }.frame(maxWidth: .infinity) | |
| 410 | + }.buttonStyle(OnboardingButtonStyle(primary: true)).accessibilityIdentifier("onboardingContinue") | |
| 411 | + } | |
| 412 | + } | |
| 413 | + private func changeStep(_ value: Int) { | |
| 414 | + let next = min(names.count - 1, max(0, value)) | |
| 415 | + guard next != step else { return } | |
| 416 | + withAnimation(reduceMotion ? nil : .easeInOut(duration: 0.18)) { step = next } | |
| 417 | + } | |
| 418 | + } | |
| 419 | + | |
| 420 | + private extension VerticalAlignment { | |
| 421 | + struct OnboardingLessonTitleAlignment: AlignmentID { | |
| 422 | + static func defaultValue(in dimensions: ViewDimensions) -> CGFloat { dimensions[VerticalAlignment.center] } | |
| 423 | + } | |
| 424 | + static let onboardingLessonTitle = VerticalAlignment(OnboardingLessonTitleAlignment.self) | |
| 425 | + } | |
| 426 | + | |
| 427 | + #if os(macOS) | |
| 428 | + /// SwiftUI's DragGesture covers click-and-drag. AppKit delivers two-finger | |
| 429 | + /// trackpad navigation as scroll events, so observe those only while this | |
| 430 | + /// onboarding surface is visible in its own window. | |
| 431 | + private struct OnboardingTrackpadNavigation: NSViewRepresentable { | |
| 432 | + var navigate: (Int) -> Void | |
| 433 | + | |
| 434 | + func makeNSView(context: Context) -> TrackpadView { | |
| 435 | + let view = TrackpadView() | |
| 436 | + view.navigate = navigate | |
| 437 | + return view | |
| 438 | + } | |
| 439 | + func updateNSView(_ view: TrackpadView, context: Context) { view.navigate = navigate } | |
| 440 | + static func dismantleNSView(_ view: TrackpadView, coordinator: ()) { view.stopObserving() } | |
| 441 | + | |
| 442 | + final class TrackpadView: NSView { | |
| 443 | + var navigate: (Int) -> Void = { _ in } | |
| 444 | + private var monitor: Any? | |
| 445 | + private var travel = CGSize.zero | |
| 446 | + | |
| 447 | + override func hitTest(_ point: NSPoint) -> NSView? { nil } | |
| 448 | + | |
| 449 | + override func viewDidMoveToWindow() { | |
| 450 | + super.viewDidMoveToWindow() | |
| 451 | + stopObserving() | |
| 452 | + guard window != nil else { return } | |
| 453 | + monitor = NSEvent.addLocalMonitorForEvents(matching: [.scrollWheel, .swipe]) { [weak self] event in | |
| 454 | + self?.handle(event) | |
| 455 | + return event | |
| 456 | + } | |
| 457 | + } | |
| 458 | + | |
| 459 | + func stopObserving() { | |
| 460 | + if let monitor { NSEvent.removeMonitor(monitor) } | |
| 461 | + monitor = nil | |
| 462 | + travel = .zero | |
| 463 | + } | |
| 464 | + | |
| 465 | + private func handle(_ event: NSEvent) { | |
| 466 | + guard let window, event.window === window, window.isKeyWindow, | |
| 467 | + !isHiddenOrHasHiddenAncestor, | |
| 468 | + bounds.contains(convert(event.locationInWindow, from: nil)) else { | |
| 469 | + travel = .zero | |
| 470 | + return | |
| 471 | + } | |
| 472 | + if event.type == .swipe { | |
| 473 | + // NSEvent uses +1 for a left swipe and -1 for a right swipe. | |
| 474 | + if abs(event.deltaX) > abs(event.deltaY) { navigate(event.deltaX > 0 ? 1 : -1) } | |
| 475 | + travel = .zero | |
| 476 | + return | |
| 477 | + } | |
| 478 | + guard event.hasPreciseScrollingDeltas, event.momentumPhase.isEmpty, | |
| 479 | + !event.phase.isEmpty else { return } | |
| 480 | + if event.phase.contains(.began) { travel = .zero } | |
| 481 | + if event.phase.contains(.cancelled) { travel = .zero; return } | |
| 482 | + travel.width += event.scrollingDeltaX | |
| 483 | + travel.height += event.scrollingDeltaY | |
| 484 | + if event.phase.contains(.ended) { | |
| 485 | + defer { travel = .zero } | |
| 486 | + guard abs(travel.width) >= 44, | |
| 487 | + abs(travel.width) > abs(travel.height) * 1.25 else { return } | |
| 488 | + navigate(travel.width < 0 ? 1 : -1) | |
| 489 | + } | |
| 490 | + } | |
| 491 | + } | |
| 492 | + } | |
| 493 | + #endif | |
| 494 | + | |
| 495 | + private struct OnboardingButtonStyle: ButtonStyle { | |
| 496 | + var primary: Bool | |
| 497 | + var compact = false | |
| 498 | + var fontSize: CGFloat? = nil | |
| 499 | + @Environment(\.isEnabled) private var enabled | |
| 500 | + func makeBody(configuration: Configuration) -> some View { | |
| 501 | + configuration.label | |
| 502 | + .font(fontSize.map { .system(size: $0, weight: .semibold) } ?? (compact ? .subheadline.weight(.medium) : .headline)) | |
| 503 | + .padding(.horizontal, compact ? 16 : 22).padding(.vertical, compact ? 12 : 17) | |
| 504 | + .foregroundStyle(primary ? Color(red: 0.16, green: 0.12, blue: 0.20) : .white) | |
| 505 | + .background(primary ? Color(red: 0.95, green: 0.68, blue: 0.55) : .white.opacity(configuration.isPressed ? 0.12 : 0.065), in: Capsule()) | |
| 506 | + .overlay(Capsule().strokeBorder(.white.opacity(primary ? 0 : 0.12), lineWidth: 1)) | |
| 507 | + .opacity(enabled ? (configuration.isPressed ? 0.8 : 1) : 0.4) | |
| 508 | + } | |
| 509 | + } | |
| 510 | + | |
| 511 | + /// Fit lesson artwork and copy to the available space without scrolling or | |
| 512 | + /// covering the header and navigation. Measure and transform in one layout pass. | |
| 513 | + private struct OnboardingFittedContent<Content: View>: View { | |
| 514 | + var alignment: Alignment | |
| 515 | + @ViewBuilder var content: () -> Content | |
| 516 | + var body: some View { | |
| 517 | + GeometryReader { available in | |
| 518 | + content() | |
| 519 | + .frame(width: available.size.width) | |
| 520 | + .fixedSize(horizontal: false, vertical: true) | |
| 521 | + .visualEffect { effect, measured in | |
| 522 | + effect.scaleEffect(min(1, available.size.height / max(1, measured.size.height)), anchor: alignment == .topLeading ? .topLeading : .center) | |
| 523 | + } | |
| 524 | + .frame(width: available.size.width, height: available.size.height, alignment: alignment) | |
| 525 | + .clipped() | |
| 526 | + } | |
| 527 | + } | |
| 528 | + } |
Sources/PulseCanvas/RadioController.swift added
| 1 | + import Combine | |
| 2 | + import Foundation | |
| 3 | + | |
| 4 | + @MainActor | |
| 5 | + final class RadioController: ObservableObject { | |
| 6 | + let visualizer = RenderState() | |
| 7 | + @Published private(set) var catalog: RadioCatalog? | |
| 8 | + @Published private(set) var stations: [RadioStation] = [] | |
| 9 | + @Published private(set) var stationID = "all-music" | |
| 10 | + @Published private(set) var currentIndex: Int? | |
| 11 | + @Published private(set) var isActive = false | |
| 12 | + @Published private(set) var isLoading = false | |
| 13 | + @Published private(set) var isCatalogLoading = false | |
| 14 | + @Published private(set) var catalogError: String? | |
| 15 | + @Published private(set) var status = String(localized: "Choose a radio library to begin") | |
| 16 | + var visualizerGroup: VisualizerRandomizerGroup { presets.randomizerGroup } | |
| 17 | + @Published private(set) var favoriteSongsOnly = false | |
| 18 | + @Published private(set) var visualizerChoices: [Int] = [] | |
| 19 | + var usesFavorites: Bool { visualizerGroup == .favorites && visualizerChoices.contains { presets.isFavorite($0) } } | |
| 20 | + var canRandomizeVisualizer: Bool { !isLoading && visualizerChoices.contains { $0 != visualizer.scene } } | |
| 21 | + var visualizerGroupMessage: String? { | |
| 22 | + if let message = presets.favoritesFallbackMessage { return message } | |
| 23 | + guard visualizerChoices.isEmpty else { return nil } | |
| 24 | + return visualizerGroup == .favorites | |
| 25 | + ? "No favorite visualizers in this pool. Add a heart or choose another group." | |
| 26 | + : "No visualizers in this group. Choose another group or change the visualizer pool." | |
| 27 | + } | |
| 28 | + var musicGroupID: String { isPersonalMusic ? "my-music" : favoriteSongsOnly ? "favorite-songs" : stationID } | |
| 29 | + var eligibleTrackIndices: [Int] { | |
| 30 | + guard let catalog else { return [] } | |
| 31 | + let favorites = Set(favoriteSongs.map(\.id)) | |
| 32 | + return catalog.tracks.indices.filter { !favoriteSongsOnly || favorites.contains(catalog.tracks[$0].id) } | |
| 33 | + } | |
| 34 | + @Published private(set) var sceneTitle = "" | |
| 35 | + @Published private(set) var favoriteSongs: [FavoriteRadioSong] = [] | |
| 36 | + @Published private(set) var favoritePlaybackError: String? | |
| 37 | + private let favoriteSongsKey = "PulseCanvas.radio.favoriteSongs.v1" | |
| 38 | + @Published var volume: Float = 0.7 { | |
| 39 | + didSet { | |
| 40 | + defaults.set(volume, forKey: "PulseCanvas.radio.volume") | |
| 41 | + if isActive { audio?.volume = volume } | |
| 42 | + } | |
| 43 | + } | |
| 44 | + @Published var barsPerVisualizer: Int = 4 { | |
| 45 | + didSet { | |
| 46 | + guard Self.barChoices.contains(barsPerVisualizer) else { barsPerVisualizer = 4; return } | |
| 47 | + defaults.set(barsPerVisualizer, forKey: "PulseCanvas.radio.bars") | |
| 48 | + if isActive && !isLoading { rebuildVisuals() } | |
| 49 | + } | |
| 50 | + } | |
| 51 | + static let barChoices = [1, 2, 4, 8, 16] | |
| 52 | + @Published var shuffle = true { didSet { queue.reset(); discardPrefetch() } } | |
| 53 | + @Published private(set) var sourceText: String | |
| 54 | + var studioMusicSource: URL { (isPersonalMusic ? nil : directoryURL) ?? URL(string: sourceText) ?? URL(string: "https://radio.pulsecanvas.si/stations.json")! } | |
| 55 | + var studioMusicFolderBookmark: Data? { defaults.data(forKey: "PulseCanvas.radio.folderBookmark") } | |
| 56 | + var studioMusicLibrary: RadioLibrary { library } | |
| 57 | + @Published private(set) var isPersonalMusic = false | |
| 58 | + @Published private(set) var folderImportNotice: String? | |
| 59 | + var hasPersonalMusic: Bool { defaults.url(forKey: PersonalRadioMusic.catalogKey) != nil } | |
| 60 | + private var personalImportTask: Task<Void, Never>? | |
| 61 | + var canFavoriteCurrentSong: Bool { !isPersonalMusic } | |
| 62 | + private(set) var segments: [StudioSegment] = [] | |
| 63 | + let soundtrackInstalled = PassthroughSubject<Void, Never>() | |
| 64 | + var currentTrack: RadioTrack? { currentIndex.flatMap { catalog?.tracks.indices.contains($0) == true ? catalog?.tracks[$0] : nil } } | |
| 65 | + var stationTitle: String { if isPersonalMusic { return catalog?.title ?? String(localized: "My music folder") }; return stations.first { $0.id == stationID }?.title ?? catalog?.title ?? String(localized: "All Music") } | |
| 66 | + var canStart: Bool { !eligibleTrackIndices.isEmpty && !visualizerChoices.isEmpty && !isCatalogLoading } | |
| 67 | + var canSeek: Bool { isActive && hasRadioAudio && !isLoading } | |
| 68 | + private let library: RadioLibrary | |
| 69 | + private let defaults: UserDefaults | |
| 70 | + private let presets: ProjectMPresets | |
| 71 | + private var directoryURL: URL? | |
| 72 | + private var catalogURL: URL? | |
| 73 | + private var catalogAccess: SecurityScopedAccess? | |
| 74 | + private var queue = RadioQueue() | |
| 75 | + private var task: Task<Void, Never>? | |
| 76 | + private var prefetch: Task<Void, Never>? | |
| 77 | + private var upcomingIndex: Int? | |
| 78 | + private var preparedNext: (index: Int, audio: PreparedSoundtrack)? | |
| 79 | + private var revision = UUID() | |
| 80 | + private var wantsPlayback = true | |
| 81 | + private var requestedIndex: Int? | |
| 82 | + private var hasRadioAudio = false | |
| 83 | + private var refreshingFavorites = false | |
| 84 | + private var visualFavoritesObserver: AnyCancellable? | |
| 85 | + private var visualPoolObserver: AnyCancellable? | |
| 86 | + private var visualCatalogObserver: AnyCancellable? | |
| 87 | + private var playedVisualizers = Set<Int>() | |
| 88 | + private weak var audio: AudioController? | |
| 89 | + private var snapshot: Snapshot? | |
| 90 | + private struct Snapshot { | |
| 91 | + let prepared: PreparedSoundtrack? | |
| 92 | + let url: URL? | |
| 93 | + let bookmark: Data? | |
| 94 | + let progress: Double | |
| 95 | + let title: String | |
| 96 | + let loop: Bool | |
| 97 | + let volume: Float | |
| 98 | + } | |
| 99 | + | |
| 100 | + init(library: RadioLibrary = RadioLibrary(), defaults: UserDefaults = .standard, presets: ProjectMPresets? = nil) { | |
| 101 | + self.library = library; self.defaults = defaults; self.presets = presets ?? .shared | |
| 102 | + sourceText = defaults.string(forKey: "PulseCanvas.radio.catalogURL") | |
| 103 | + ?? Bundle.main.object(forInfoDictionaryKey: "PulseCanvasRadioCatalogURL") as? String | |
| 104 | + ?? "https://radio.pulsecanvas.si/stations.json" | |
| 105 | + if let data = defaults.data(forKey: favoriteSongsKey), data.count <= 8_000_000, | |
| 106 | + let saved = try? JSONDecoder().decode([FavoriteRadioSong].self, from: data), saved.count <= 2_000 { | |
| 107 | + var seen = Set<String>() | |
| 108 | + favoriteSongs = saved.filter { $0.isValid && seen.insert($0.id).inserted } | |
| 109 | + } | |
| 110 | + visualizerChoices = self.presets.eligibleScenes | |
| 111 | + favoriteSongsOnly = defaults.bool(forKey: "PulseCanvas.radio.favoriteSongsOnly.v1") | |
| 112 | + let bars = defaults.integer(forKey: "PulseCanvas.radio.bars") | |
| 113 | + barsPerVisualizer = Self.barChoices.contains(bars) ? bars : 4 | |
| 114 | + if let savedVolume = defaults.object(forKey: "PulseCanvas.radio.volume") as? NSNumber { | |
| 115 | + let value = savedVolume.floatValue | |
| 116 | + volume = value.isFinite ? min(1, max(0, value)) : 0.7 | |
| 117 | + } | |
| 118 | + visualFavoritesObserver = self.presets.$favoriteIDs.dropFirst().sink { [weak self] _ in | |
| 119 | + // @Published sends before storing the new set; read it on the next turn. | |
| 120 | + Task { @MainActor [weak self] in | |
| 121 | + guard let self, self.presets.pool.enabled, self.presets.pool.favoritesOnly else { return } | |
| 122 | + self.refreshVisualizerGroup() | |
| 123 | + } | |
| 124 | + } | |
| 125 | + visualPoolObserver = self.presets.$pool.dropFirst().sink { [weak self] _ in | |
| 126 | + Task { @MainActor [weak self] in | |
| 127 | + guard let self else { return } | |
| 128 | + self.refreshVisualizerGroup() | |
| 129 | + } | |
| 130 | + } | |
| 131 | + visualCatalogObserver = self.presets.$entries.dropFirst().sink { [weak self] _ in | |
| 132 | + Task { @MainActor [weak self] in self?.refreshVisualizerGroup() } | |
| 133 | + } | |
| 134 | + } | |
| 135 | + | |
| 136 | + func selectVisualizerGroup(_ group: VisualizerRandomizerGroup) { | |
| 137 | + presets.setRandomizerGroup(group) | |
| 138 | + refreshVisualizerGroup() | |
| 139 | + } | |
| 140 | + | |
| 141 | + /// Keep transport and bar boundaries intact; replace an out-of-group current look immediately. | |
| 142 | + private func refreshVisualizerGroup() { | |
| 143 | + visualizerChoices = presets.eligibleScenes | |
| 144 | + guard isActive, !isLoading, let audio else { return } | |
| 145 | + let available = visualizerChoices | |
| 146 | + if !available.isEmpty, !available.contains(visualizer.scene), | |
| 147 | + let index = StudioTimeline.index(at: audio.playbackSeconds, in: segments), | |
| 148 | + let scene = available.randomElement() { | |
| 149 | + segments[index].scene = scene | |
| 150 | + sceneTitle = "" | |
| 151 | + follow(time: audio.playbackSeconds) | |
| 152 | + } | |
| 153 | + rebuildVisuals(keepingCurrent: true) | |
| 154 | + } | |
| 155 | + | |
| 156 | + func selectMusicGroup(_ id: String, startPlayback: Bool = false) { | |
| 157 | + if id == "my-music" { usePersonalMusic(startPlayback: startPlayback); return } | |
| 158 | + if isPersonalMusic { | |
| 159 | + favoriteSongsOnly = id == "favorite-songs" | |
| 160 | + defaults.set(favoriteSongsOnly, forKey: "PulseCanvas.radio.favoriteSongsOnly.v1") | |
| 161 | + let station = favoriteSongsOnly ? "all-music" : id | |
| 162 | + loadCatalog(at: studioMusicSource, preferredStationID: station, startPlayback: isActive || startPlayback) | |
| 163 | + return | |
| 164 | + } | |
| 165 | + let favorites = id == "favorite-songs" | |
| 166 | + favoriteSongsOnly = favorites | |
| 167 | + defaults.set(favorites, forKey: "PulseCanvas.radio.favoriteSongsOnly.v1") | |
| 168 | + queue.reset(); discardPrefetch() | |
| 169 | + let station = favorites ? "all-music" : id | |
| 170 | + defaults.set(station, forKey: "PulseCanvas.radio.station") | |
| 171 | + selectStation(station, startPlayback: startPlayback) | |
| 172 | + if startPlayback, !isCatalogLoading { start() } | |
| 173 | + if isActive, !isCatalogLoading, let currentIndex, let catalog, let catalogURL { | |
| 174 | + prepareNextTrack(after: currentIndex, catalog: catalog, catalogURL: catalogURL) | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + func playFavoriteStation() { selectMusicGroup("favorite-songs", startPlayback: true) } | |
| 179 | + | |
| 180 | + var canSkipStation: Bool { !isCatalogLoading && stations.contains { $0.id != musicGroupID } } | |
| 181 | + | |
| 182 | + func nextStation() { | |
| 183 | + guard canSkipStation else { return } | |
| 184 | + let index = stations.firstIndex { $0.id == musicGroupID } | |
| 185 | + let next = stations[((index ?? -1) + 1) % stations.count] | |
| 186 | + selectMusicGroup(next.id, startPlayback: true) | |
| 187 | + } | |
| 188 | + | |
| 189 | + func attach(audio: AudioController) { self.audio = audio } | |
| 190 | + /// Preserve the requested transport state through a temporary download/decode pause. | |
| 191 | + var isPlaybackRequested: Bool { isLoading ? wantsPlayback : audio?.isPlaying == true } | |
| 192 | + | |
| 193 | + func isFavoriteSong(_ track: RadioTrack) -> Bool { favoriteSongs.contains { $0.id == track.id } } | |
| 194 | + | |
| 195 | + func toggleFavoriteSong(_ track: RadioTrack) { | |
| 196 | + _ = setFavoriteSong(id: track.id, favorite: !isFavoriteSong(track)) | |
| 197 | + } | |
| 198 | + | |
| 199 | + @discardableResult | |
| 200 | + func setFavoriteSong(id: String, favorite: Bool, candidate: FavoriteRadioSong? = nil) -> Bool { | |
| 201 | + let index = favoriteSongs.firstIndex { $0.id == id } | |
| 202 | + guard (index != nil) != favorite else { return true } | |
| 203 | + if let index { | |
| 204 | + favoriteSongs.remove(at: index) | |
| 205 | + } else { | |
| 206 | + let song: FavoriteRadioSong | |
| 207 | + if let candidate, candidate.id == id { | |
| 208 | + song = candidate | |
| 209 | + } else { | |
| 210 | + guard !isPersonalMusic, let catalogURL, let directoryURL, | |
| 211 | + let track = catalog?.tracks.first(where: { $0.id == id }) else { return false } | |
| 212 | + song = FavoriteRadioSong(track: track, sourceURL: directoryURL, catalogURL: catalogURL, | |
| 213 | + stationID: stationID, folderBookmark: try? catalogAccess?.readOnlyBookmark()) | |
| 214 | + } | |
| 215 | + guard favoriteSongs.count < 2_000, song.isValid else { return false } | |
| 216 | + favoriteSongs.append(song) | |
| 217 | + } | |
| 218 | + persistFavoriteSongs() | |
| 219 | + return true | |
| 220 | + } | |
| 221 | + | |
| 222 | + private func persistFavoriteSongs() { | |
| 223 | + if let data = try? JSONEncoder().encode(favoriteSongs) { defaults.set(data, forKey: favoriteSongsKey) } | |
| 224 | + NotificationCenter.default.post(name: .pulseCanvasUserDataChanged, object: nil) | |
| 225 | + queue.reset(); discardPrefetch() | |
| 226 | + if isActive, !isLoading, let currentIndex, let catalog, let catalogURL { | |
| 227 | + prepareNextTrack(after: currentIndex, catalog: catalog, catalogURL: catalogURL) | |
| 228 | + } | |
| 229 | + } | |
| 230 | + | |
| 231 | + func reloadCloudFavorites() { | |
| 232 | + guard let data = defaults.data(forKey: favoriteSongsKey), | |
| 233 | + let songs = try? JSONDecoder().decode([FavoriteRadioSong].self, from: data), songs.count <= 2_000, | |
| 234 | + songs.allSatisfy(\.isValid) else { return } | |
| 235 | + favoriteSongs = songs; queue.reset(); discardPrefetch() | |
| 236 | + } | |
| 237 | + | |
| 238 | + func refreshFavoriteSongs() async { | |
| 239 | + guard !refreshingFavorites else { return } | |
| 240 | + refreshingFavorites = true | |
| 241 | + defer { refreshingFavorites = false } | |
| 242 | + var checked = Set<URL>() | |
| 243 | + for song in favoriteSongs where checked.insert(song.sourceURL).inserted { | |
| 244 | + let folder = SecurityScopedAccess.resolve(bookmark: song.folderBookmark, fallback: song.sourceURL.deletingLastPathComponent()) | |
| 245 | + let source = song.sourceURL.isFileURL ? folder.appendingPathComponent(song.sourceURL.lastPathComponent) : song.sourceURL | |
| 246 | + let access = source.isFileURL ? SecurityScopedAccess(url: folder) : nil | |
| 247 | + defer { withExtendedLifetime(access) {} } | |
| 248 | + guard let complete = try? await library.completeCatalog(at: source), !Task.isCancelled else { continue } | |
| 249 | + reconcileFavoriteSongs(complete.catalog, source: song.sourceURL, catalogURL: complete.url, station: complete.stationID) | |
| 250 | + } | |
| 251 | + } | |
| 252 | + | |
| 253 | + private func reconcileFavoriteSongs(_ complete: RadioCatalog, source: URL, catalogURL: URL, station: String) { | |
| 254 | + let tracks = Dictionary(uniqueKeysWithValues: complete.tracks.map { ($0.id, $0) }) | |
| 255 | + let retained = favoriteSongs.compactMap { song -> FavoriteRadioSong? in | |
| 256 | + guard song.sourceURL == source else { return song } | |
| 257 | + guard let track = tracks[song.id] else { return nil } | |
| 258 | + return FavoriteRadioSong(track: track, sourceURL: source, catalogURL: catalogURL, | |
| 259 | + stationID: station, folderBookmark: song.folderBookmark) | |
| 260 | + } | |
| 261 | + guard retained != favoriteSongs else { return } | |
| 262 | + favoriteSongs = retained | |
| 263 | + persistFavoriteSongs() | |
| 264 | + } | |
| 265 | + | |
| 266 | + func playFavoriteSong(_ song: FavoriteRadioSong) { | |
| 267 | + guard song.isValid else { return } | |
| 268 | + favoritePlaybackError = nil | |
| 269 | + let folder = SecurityScopedAccess.resolve(bookmark: song.folderBookmark, fallback: song.sourceURL.deletingLastPathComponent()) | |
| 270 | + let source = song.sourceURL.isFileURL ? folder.appendingPathComponent(song.sourceURL.lastPathComponent) : song.sourceURL | |
| 271 | + loadCatalog(at: source, access: source.isFileURL ? SecurityScopedAccess(url: folder) : nil, | |
| 272 | + preferredStationID: song.stationID, playTrackID: song.id) | |
| 273 | + } | |
| 274 | + | |
| 275 | + func importMusicFolder(_ folder: URL, into root: URL = PersonalRadioMusic.directory) { | |
| 276 | + guard !isCatalogLoading else { return } | |
| 277 | + isCatalogLoading = true; catalogError = nil; folderImportNotice = nil; status = String(localized: "Copying music folder…") | |
| 278 | + let previous = defaults.url(forKey: PersonalRadioMusic.catalogKey) | |
| 279 | + personalImportTask = Task { [weak self, library] in | |
| 280 | + do { | |
| 281 | + let result = try await library.importMusicFolder(folder, into: root) | |
| 282 | + guard let self, !Task.isCancelled else { | |
| 283 | + await library.removePersonalCopy(at: result.url, within: root); return | |
| 284 | + } | |
| 285 | + self.folderImportNotice = result.skipped > 0 ? String(localized: "\(result.skipped) unsupported files were skipped.") : nil | |
| 286 | + self.defaults.set(result.url, forKey: PersonalRadioMusic.catalogKey) | |
| 287 | + self.isCatalogLoading = false; self.personalImportTask = nil | |
| 288 | + self.loadCatalog(at: result.url, personal: true, startPlayback: true, skipped: result.skipped) | |
| 289 | + await library.removePersonalCopy(at: previous, within: root) | |
| 290 | + } catch { | |
| 291 | + guard let self, !Task.isCancelled else { return } | |
| 292 | + self.isCatalogLoading = false; self.catalogError = error.localizedDescription; self.status = error.localizedDescription | |
| 293 | + } | |
| 294 | + } | |
| 295 | + } | |
| 296 | + | |
| 297 | + func usePersonalMusic(startPlayback: Bool = true) { | |
| 298 | + guard let url = defaults.url(forKey: PersonalRadioMusic.catalogKey) else { return } | |
| 299 | + loadCatalog(at: url, personal: true, startPlayback: startPlayback) | |
| 300 | + } | |
| 301 | + | |
| 302 | + func loadSavedCatalogIfNeeded(refresh: Bool = false) { | |
| 303 | + if defaults.bool(forKey: PersonalRadioMusic.activeKey), hasPersonalMusic { | |
| 304 | + if (catalog == nil || refresh) && !isCatalogLoading { usePersonalMusic(startPlayback: false) } | |
| 305 | + return | |
| 306 | + } | |
| 307 | + guard (catalog == nil || refresh), !isCatalogLoading, !sourceText.isEmpty, let url = URL(string: sourceText) else { return } | |
| 308 | + let bookmark = url.isFileURL ? defaults.data(forKey: "PulseCanvas.radio.folderBookmark") : nil | |
| 309 | + let directory = SecurityScopedAccess.resolve(bookmark: bookmark, fallback: url.deletingLastPathComponent()) | |
| 310 | + loadCatalog(at: url.isFileURL ? directory.appendingPathComponent(url.lastPathComponent) : url, | |
| 311 | + access: url.isFileURL ? SecurityScopedAccess(url: directory) : nil) | |
| 312 | + } | |
| 313 | + | |
| 314 | + /// A stations directory is the public entry point. A direct catalog also works for local testing. | |
| 315 | + func loadCatalog(at url: URL, access: SecurityScopedAccess? = nil, preferredStationID: String? = nil, playTrackID: String? = nil, personal: Bool = false, startPlayback: Bool = false, skipped: Int = 0) { | |
| 316 | + leave() | |
| 317 | + task?.cancel(); revision = UUID(); let token = revision | |
| 318 | + catalogError = nil; isCatalogLoading = true; status = String(localized: "Loading radio library…") | |
| 319 | + task = Task { [weak self, library] in | |
| 320 | + let lease = access | |
| 321 | + do { | |
| 322 | + let stationList: [RadioStation] | |
| 323 | + let stationURL: URL | |
| 324 | + if url.lastPathComponent == "stations.json" { | |
| 325 | + let directory = try await library.stations(at: url) | |
| 326 | + stationList = directory.stations | |
| 327 | + let savedID = preferredStationID ?? (self?.favoriteSongsOnly == true ? "all-music" : self?.defaults.string(forKey: "PulseCanvas.radio.station")) | |
| 328 | + let selected = stationList.first { $0.id == savedID } ?? stationList[0] | |
| 329 | + stationURL = try selected.resolvedURL(relativeTo: url) | |
| 330 | + } else { | |
| 331 | + stationList = [RadioStation(id: "all-music", title: "All Music", description: "Every genre, one station", catalog: url.absoluteString)] | |
| 332 | + stationURL = url | |
| 333 | + } | |
| 334 | + let loaded = try await library.catalog(at: stationURL) | |
| 335 | + try Task.checkCancellation() | |
| 336 | + guard let self, self.revision == token else { return } | |
| 337 | + self.catalog = loaded; self.catalogURL = stationURL; self.catalogAccess = lease | |
| 338 | + self.stations = stationList; self.directoryURL = url | |
| 339 | + self.stationID = try stationList.first { try $0.resolvedURL(relativeTo: url) == stationURL }?.id ?? stationList[0].id | |
| 340 | + self.isPersonalMusic = personal | |
| 341 | + self.defaults.set(personal, forKey: PersonalRadioMusic.activeKey) | |
| 342 | + if personal { self.favoriteSongsOnly = false } | |
| 343 | + self.currentIndex = nil; self.queue.reset() | |
| 344 | + if !personal { | |
| 345 | + self.sourceText = url.absoluteString | |
| 346 | + self.defaults.set(url.absoluteString, forKey: "PulseCanvas.radio.catalogURL") | |
| 347 | + self.defaults.set(try? lease?.readOnlyBookmark(), forKey: "PulseCanvas.radio.folderBookmark") | |
| 348 | + } | |
| 349 | + if !personal && (stationList.count == 1 || self.stationID == "all-music") { | |
| 350 | + self.reconcileFavoriteSongs(loaded, source: url, catalogURL: stationURL, station: self.stationID) | |
| 351 | + } | |
| 352 | + self.isCatalogLoading = false; self.status = String(localized: "\(loaded.tracks.count) songs · Ready to play") + (skipped > 0 ? String(localized: " · \(skipped) unsupported files skipped") : "") | |
| 353 | + Task { [weak self] in await self?.refreshFavoriteSongs() } | |
| 354 | + if startPlayback { self.start() } | |
| 355 | + if let playTrackID { | |
| 356 | + if let index = loaded.tracks.firstIndex(where: { $0.id == playTrackID }) { self.start(at: index) } | |
| 357 | + else { | |
| 358 | + self.status = String(localized: "This favorite is no longer available in its radio library.") | |
| 359 | + self.favoritePlaybackError = self.status | |
| 360 | + } | |
| 361 | + } | |
| 362 | + } catch { | |
| 363 | + guard let self, self.revision == token else { return } | |
| 364 | + self.isCatalogLoading = false; self.status = error.localizedDescription; self.catalogError = self.status | |
| 365 | + if playTrackID != nil { self.favoritePlaybackError = self.status } | |
| 366 | + } | |
| 367 | + } | |
| 368 | + } | |
| 369 | + | |
| 370 | + func selectStation(_ id: String, startPlayback: Bool = false) { | |
| 371 | + guard id != stationID, let station = stations.first(where: { $0.id == id }), let directoryURL, | |
| 372 | + let url = try? station.resolvedURL(relativeTo: directoryURL) else { return } | |
| 373 | + let resume = isActive || startPlayback | |
| 374 | + leave(); revision = UUID(); let token = revision | |
| 375 | + catalogError = nil; isCatalogLoading = true; status = String(localized: "Loading \(station.title)…") | |
| 376 | + task = Task { [weak self, library] in | |
| 377 | + do { | |
| 378 | + let loaded = try await library.catalog(at: url) | |
| 379 | + try Task.checkCancellation() | |
| 380 | + guard let self, self.revision == token else { return } | |
| 381 | + self.catalog = loaded; self.catalogURL = url; self.stationID = id | |
| 382 | + self.defaults.set(id, forKey: "PulseCanvas.radio.station") | |
| 383 | + self.currentIndex = nil; self.queue.reset(); self.isCatalogLoading = false | |
| 384 | + self.status = String(localized: "\(loaded.tracks.count) songs · Ready to play") | |
| 385 | + if resume { self.start() } | |
| 386 | + } catch { | |
| 387 | + guard let self, self.revision == token else { return } | |
| 388 | + self.isCatalogLoading = false; self.status = error.localizedDescription; self.catalogError = self.status | |
| 389 | + } | |
| 390 | + } | |
| 391 | + } | |
| 392 | + | |
| 393 | + func start(at index: Int? = nil) { | |
| 394 | + guard canStart, let audio else { return } | |
| 395 | + if !isActive { | |
| 396 | + hasRadioAudio = false | |
| 397 | + snapshot = Snapshot(prepared: audio.retainedSoundtrack(), url: audio.selectedURL, bookmark: audio.soundtrackBookmark, progress: audio.progress, | |
| 398 | + title: audio.title, loop: audio.loopEnabled, volume: audio.volume) | |
| 399 | + isActive = true | |
| 400 | + audio.volume = volume | |
| 401 | + } | |
| 402 | + wantsPlayback = true | |
| 403 | + audio.onSoundtrackFinished = { [weak self] in self?.next() } | |
| 404 | + guard let selected = index.flatMap({ eligibleTrackIndices.contains($0) ? $0 : nil }) | |
| 405 | + ?? queuedTrack(after: currentIndex) else { return } | |
| 406 | + loadTrack(at: selected) | |
| 407 | + } | |
| 408 | + | |
| 409 | + func next() { | |
| 410 | + guard isActive, let index = upcomingIndex ?? queuedTrack(after: requestedIndex ?? currentIndex) else { return } | |
| 411 | + loadTrack(at: index) | |
| 412 | + } | |
| 413 | + | |
| 414 | + private func queuedTrack(after current: Int?) -> Int? { | |
| 415 | + let choices = eligibleTrackIndices | |
| 416 | + guard let next = queue.next(count: choices.count, current: current.flatMap { choices.firstIndex(of: $0) }, shuffle: shuffle) else { return nil } | |
| 417 | + return choices[next] | |
| 418 | + } | |
| 419 | + | |
| 420 | + func togglePlayback() { | |
| 421 | + guard isActive, let audio else { return } | |
| 422 | + if !isLoading && !hasRadioAudio { start(at: currentIndex); return } | |
| 423 | + if isLoading { wantsPlayback.toggle(); status = wantsPlayback ? String(localized: "Preparing next song…") : String(localized: "Next song will start paused") } | |
| 424 | + else { if audio.isPlaying { audio.pause() } else { audio.playFullSoundtrack() }; wantsPlayback = audio.isPlaying } | |
| 425 | + } | |
| 426 | + | |
| 427 | + func seek(fraction: Double) { | |
| 428 | + guard canSeek, fraction.isFinite, let audio else { return } | |
| 429 | + audio.seek(fraction: fraction) | |
| 430 | + follow(time: audio.playbackSeconds) | |
| 431 | + } | |
| 432 | + | |
| 433 | + /// Reroll only within the selected group, without restarting the music. | |
| 434 | + func randomizeCurrentVisualizer() { | |
| 435 | + guard isActive, !isLoading, let audio, | |
| 436 | + let index = StudioTimeline.index(at: audio.playbackSeconds, in: segments) else { return } | |
| 437 | + let alternatives = visualizerChoices.filter { $0 != visualizer.scene } | |
| 438 | + let unheard = alternatives.filter { !playedVisualizers.contains($0) } | |
| 439 | + guard let scene = (unheard.isEmpty ? alternatives : unheard).randomElement() else { return } | |
| 440 | + segments[index].scene = scene | |
| 441 | + follow(time: audio.playbackSeconds) | |
| 442 | + rebuildVisuals(keepingCurrent: true) | |
| 443 | + } | |
| 444 | + | |
| 445 | + func pause() { | |
| 446 | + wantsPlayback = false; audio?.pause() | |
| 447 | + if isLoading { task?.cancel(); revision = UUID(); isLoading = false; requestedIndex = nil; status = String(localized: "Radio paused") } | |
| 448 | + } | |
| 449 | + | |
| 450 | + func leave() { | |
| 451 | + personalImportTask?.cancel(); personalImportTask = nil | |
| 452 | + task?.cancel(); discardPrefetch(); revision = UUID() | |
| 453 | + isCatalogLoading = false; isLoading = false; requestedIndex = nil | |
| 454 | + guard isActive, let audio else { return } | |
| 455 | + audio.onSoundtrackFinished = nil; audio.pause(); isActive = false | |
| 456 | + if let saved = snapshot { | |
| 457 | + if let prepared = saved.prepared { | |
| 458 | + if audio.install(prepared, title: saved.title) { audio.seek(fraction: saved.progress) } | |
| 459 | + } else if let url = saved.url { | |
| 460 | + if audio.load(url: url, bookmark: saved.bookmark) { audio.seek(fraction: saved.progress) } | |
| 461 | + } else { audio.clear() } | |
| 462 | + audio.loopEnabled = saved.loop | |
| 463 | + audio.volume = saved.volume | |
| 464 | + soundtrackInstalled.send() | |
| 465 | + } | |
| 466 | + snapshot = nil; segments = []; hasRadioAudio = false; status = String(localized: "Radio stopped · Your soundtrack restored") | |
| 467 | + } | |
| 468 | + | |
| 469 | + /// App shutdown cancels downloads and completions without reloading the editor song. | |
| 470 | + func shutdown() { | |
| 471 | + personalImportTask?.cancel() | |
| 472 | + task?.cancel(); discardPrefetch(); revision = UUID() | |
| 473 | + audio?.onSoundtrackFinished = nil; audio?.stop() | |
| 474 | + isActive = false; isLoading = false; isCatalogLoading = false | |
| 475 | + requestedIndex = nil; snapshot = nil; segments = []; hasRadioAudio = false | |
| 476 | + } | |
| 477 | + | |
| 478 | + func follow(time: Double) { | |
| 479 | + guard isActive, let index = StudioTimeline.index(at: time, in: segments) else { return } | |
| 480 | + let scene = segments[index].scene | |
| 481 | + playedVisualizers.insert(scene) | |
| 482 | + guard visualizer.scene != scene || sceneTitle.isEmpty else { return } | |
| 483 | + visualizer.scene = scene | |
| 484 | + presets.appearanceForSelection(scene).apply(to: visualizer) | |
| 485 | + sceneTitle = RenderState.sceneNames[scene] | |
| 486 | + } | |
| 487 | + | |
| 488 | + private func rebuildVisuals(keepingCurrent: Bool = false, previousScene: Int? = nil) { | |
| 489 | + guard let audio, let plan = audio.segmentPlan(beatsPerSection: barsPerVisualizer * 4) else { return } | |
| 490 | + visualizerChoices = presets.eligibleScenes | |
| 491 | + let available = visualizerChoices | |
| 492 | + if !sceneTitle.isEmpty, let index = StudioTimeline.index(at: audio.playbackSeconds, in: segments) { | |
| 493 | + var retained = Array(segments.prefix(index + 1)) | |
| 494 | + let last = retained.removeLast() | |
| 495 | + let end = keepingCurrent ? last.end : plan.boundaries.first(where: { $0 > audio.playbackSeconds }) ?? audio.duration | |
| 496 | + retained.append(StudioSegment(start: last.start, end: end, scene: visualizer.scene, bars: barsPerVisualizer)) | |
| 497 | + let remaining = SongSegmentation(boundaries: [end] + plan.boundaries.filter { $0 > end }, bpm: plan.bpm) | |
| 498 | + let future = RadioVisualSchedule.make(plan: remaining, pool: available, bars: barsPerVisualizer, | |
| 499 | + previous: visualizer.scene) | |
| 500 | + if future.isEmpty, end < audio.duration { | |
| 501 | + let held = retained.removeLast() | |
| 502 | + retained.append(StudioSegment(start: held.start, end: audio.duration, scene: held.scene, bars: held.bars)) | |
| 503 | + } | |
| 504 | + segments = retained + future | |
| 505 | + } else { | |
| 506 | + segments = RadioVisualSchedule.make(plan: plan, pool: available, bars: barsPerVisualizer, | |
| 507 | + previous: previousScene) | |
| 508 | + } | |
| 509 | + follow(time: audio.playbackSeconds) | |
| 510 | + } | |
| 511 | + | |
| 512 | + private func discardPrefetch() { | |
| 513 | + prefetch?.cancel(); prefetch = nil; upcomingIndex = nil; preparedNext = nil | |
| 514 | + } | |
| 515 | + | |
| 516 | + private func loadTrack(at first: Int) { | |
| 517 | + guard let audio, let catalog, let catalogURL, eligibleTrackIndices.contains(first) else { return } | |
| 518 | + let choices = eligibleTrackIndices | |
| 519 | + let ready = preparedNext?.index == first ? preparedNext?.audio : nil | |
| 520 | + task?.cancel(); discardPrefetch(); revision = UUID(); let token = revision | |
| 521 | + requestedIndex = first | |
| 522 | + audio.pause(); isLoading = true; status = String(localized: "Preparing \(catalog.tracks[first].title)…") | |
| 523 | + task = Task { [weak self, library] in | |
| 524 | + var index = first | |
| 525 | + var attempted = Set<Int>() | |
| 526 | + while attempted.insert(index).inserted { | |
| 527 | + do { | |
| 528 | + let track = catalog.tracks[index] | |
| 529 | + let prepared: PreparedSoundtrack | |
| 530 | + if index == first, let ready { prepared = ready } | |
| 531 | + else { | |
| 532 | + let url = try await library.localAudio(for: track, catalogURL: catalogURL) | |
| 533 | + prepared = try await Task.detached(priority: .userInitiated) { try PreparedSoundtrack(url: url) }.value | |
| 534 | + } | |
| 535 | + try Task.checkCancellation() | |
| 536 | + guard let self, self.revision == token, self.isActive else { return } | |
| 537 | + let previousScene = self.hasRadioAudio ? self.visualizer.scene : nil | |
| 538 | + guard audio.install(prepared, title: track.title) else { throw RadioError.download } | |
| 539 | + self.hasRadioAudio = true | |
| 540 | + self.currentIndex = index; self.requestedIndex = nil; self.isLoading = false | |
| 541 | + self.segments = []; self.playedVisualizers = []; self.sceneTitle = "" | |
| 542 | + self.rebuildVisuals(previousScene: previousScene); self.soundtrackInstalled.send() | |
| 543 | + self.status = "\(track.title) · \(track.genre)" | |
| 544 | + if self.wantsPlayback { audio.playFullSoundtrack() } | |
| 545 | + // Download AND analyze the next song while this song plays. | |
| 546 | + self.prepareNextTrack(after: index, catalog: catalog, catalogURL: catalogURL) | |
| 547 | + return | |
| 548 | + } catch { | |
| 549 | + guard let self, self.revision == token, !Task.isCancelled else { return } | |
| 550 | + self.status = String(localized: "Skipping \(catalog.tracks[index].title): \(error.localizedDescription)") | |
| 551 | + guard let position = choices.firstIndex(of: index) else { break } | |
| 552 | + index = choices[(position + 1) % choices.count] | |
| 553 | + } | |
| 554 | + } | |
| 555 | + guard let self, self.revision == token else { return } | |
| 556 | + self.isLoading = false; self.requestedIndex = nil; self.wantsPlayback = false | |
| 557 | + self.status = RadioError.allUnavailable.localizedDescription | |
| 558 | + } | |
| 559 | + } | |
| 560 | + | |
| 561 | + private func prepareNextTrack(after index: Int, catalog: RadioCatalog, catalogURL: URL) { | |
| 562 | + guard let nextIndex = queuedTrack(after: index) else { return } | |
| 563 | + upcomingIndex = nextIndex | |
| 564 | + let next = catalog.tracks[nextIndex], token = revision | |
| 565 | + prefetch = Task { [weak self, library] in | |
| 566 | + do { | |
| 567 | + let url = try await library.localAudio(for: next, catalogURL: catalogURL) | |
| 568 | + let prepared = try await Task.detached(priority: .utility) { try PreparedSoundtrack(url: url) }.value | |
| 569 | + try Task.checkCancellation() | |
| 570 | + guard let self, self.revision == token else { return } | |
| 571 | + self.preparedNext = (nextIndex, prepared) | |
| 572 | + } catch { /* The transition retries and reports failures if needed. */ } | |
| 573 | + } | |
| 574 | + } | |
| 575 | + } |
Sources/PulseCanvas/RadioLibrary.swift added
| 1 | + import AVFoundation | |
| 2 | + import CryptoKit | |
| 3 | + import Foundation | |
| 4 | + import Combine | |
| 5 | + | |
| 6 | + struct RadioStation: Codable, Identifiable, Sendable { | |
| 7 | + let id: String | |
| 8 | + let title: String | |
| 9 | + let description: String | |
| 10 | + let catalog: String | |
| 11 | + | |
| 12 | + func resolvedURL(relativeTo directoryURL: URL) throws -> URL { | |
| 13 | + guard let url = URL(string: catalog, relativeTo: directoryURL)?.absoluteURL else { throw RadioError.invalidCatalog } | |
| 14 | + if directoryURL.isFileURL { | |
| 15 | + guard url.isFileURL, url.resolvingSymlinksInPath().path.hasPrefix(directoryURL.deletingLastPathComponent().resolvingSymlinksInPath().path + "/") else { throw RadioError.invalidCatalog } | |
| 16 | + } else { | |
| 17 | + guard url.scheme == "https", url.host != nil, url.user == nil, url.password == nil else { throw RadioError.invalidCatalog } | |
| 18 | + } | |
| 19 | + return url | |
| 20 | + } | |
| 21 | + } | |
| 22 | + | |
| 23 | + struct RadioStationDirectory: Codable, Sendable { | |
| 24 | + let version: Int | |
| 25 | + let stations: [RadioStation] | |
| 26 | + | |
| 27 | + static func decode(_ data: Data, from url: URL) throws -> Self { | |
| 28 | + guard data.count <= 2_000_000 else { throw RadioError.invalidCatalog } | |
| 29 | + let directory = try JSONDecoder().decode(Self.self, from: data) | |
| 30 | + guard directory.version == 1, (1...100).contains(directory.stations.count), | |
| 31 | + Set(directory.stations.map(\.id)).count == directory.stations.count else { throw RadioError.invalidCatalog } | |
| 32 | + for station in directory.stations { | |
| 33 | + guard !station.id.isEmpty, station.id.count <= 80, !station.title.isEmpty else { throw RadioError.invalidCatalog } | |
| 34 | + _ = try station.resolvedURL(relativeTo: url) | |
| 35 | + } | |
| 36 | + return directory | |
| 37 | + } | |
| 38 | + } | |
| 39 | + | |
| 40 | + struct RadioTrack: Codable, Identifiable, Sendable, Equatable { | |
| 41 | + let id: String | |
| 42 | + let title: String | |
| 43 | + let genre: String | |
| 44 | + let duration: Double | |
| 45 | + let audio: String | |
| 46 | + let sha256: String | |
| 47 | + let byteCount: Int | |
| 48 | + | |
| 49 | + func resolvedURL(relativeTo catalogURL: URL) throws -> URL { | |
| 50 | + guard let url = URL(string: audio, relativeTo: catalogURL)?.absoluteURL else { throw RadioError.invalidCatalog } | |
| 51 | + if catalogURL.isFileURL { | |
| 52 | + let directory = catalogURL.deletingLastPathComponent().resolvingSymlinksInPath().path + "/" | |
| 53 | + guard url.isFileURL, url.resolvingSymlinksInPath().path.hasPrefix(directory) else { throw RadioError.invalidCatalog } | |
| 54 | + } else { | |
| 55 | + guard url.scheme == "https", url.host != nil, url.user == nil, url.password == nil else { throw RadioError.invalidCatalog } | |
| 56 | + } | |
| 57 | + return url | |
| 58 | + } | |
| 59 | + } | |
| 60 | + | |
| 61 | + struct RadioCatalog: Codable, Sendable { | |
| 62 | + let version: Int | |
| 63 | + let title: String | |
| 64 | + let tracks: [RadioTrack] | |
| 65 | + | |
| 66 | + static func decode(_ data: Data, from url: URL) throws -> RadioCatalog { | |
| 67 | + guard data.count <= 2_000_000 else { throw RadioError.invalidCatalog } | |
| 68 | + let catalog = try JSONDecoder().decode(Self.self, from: data) | |
| 69 | + guard catalog.version == 1, !catalog.title.isEmpty, | |
| 70 | + catalog.tracks.count <= 500, Set(catalog.tracks.map(\.id)).count == catalog.tracks.count else { throw RadioError.invalidCatalog } | |
| 71 | + for track in catalog.tracks { | |
| 72 | + guard UUID(uuidString: track.id) != nil, !track.title.isEmpty, | |
| 73 | + track.duration.isFinite, track.duration > 0, track.duration <= 7200, | |
| 74 | + (1...100_000_000).contains(track.byteCount), track.sha256.count == 64, | |
| 75 | + track.sha256.allSatisfy({ $0.isHexDigit && $0.isASCII }) else { throw RadioError.invalidCatalog } | |
| 76 | + _ = try track.resolvedURL(relativeTo: url) | |
| 77 | + } | |
| 78 | + return catalog | |
| 79 | + } | |
| 80 | + } | |
| 81 | + | |
| 82 | + /// Keep enough source information to replay a favorite after changing stations | |
| 83 | + /// or relaunching. Song identities are independent of visualizer favorites. | |
| 84 | + struct FavoriteRadioSong: Codable, Identifiable, Sendable, Equatable { | |
| 85 | + let track: RadioTrack | |
| 86 | + let sourceURL: URL | |
| 87 | + let catalogURL: URL | |
| 88 | + let stationID: String | |
| 89 | + let folderBookmark: Data? | |
| 90 | + var id: String { track.id } | |
| 91 | + | |
| 92 | + var isValid: Bool { | |
| 93 | + guard sourceURL.isFileURL || (sourceURL.scheme == "https" && sourceURL.host != nil && sourceURL.user == nil && sourceURL.password == nil), | |
| 94 | + sourceURL.isFileURL == catalogURL.isFileURL, | |
| 95 | + let data = try? JSONEncoder().encode(RadioCatalog(version: 1, title: "Favorite", tracks: [track])) else { return false } | |
| 96 | + return (try? RadioCatalog.decode(data, from: catalogURL)) != nil | |
| 97 | + } | |
| 98 | + } | |
| 99 | + | |
| 100 | + enum RadioError: LocalizedError { | |
| 101 | + case invalidCatalog, download, integrity, allUnavailable | |
| 102 | + var errorDescription: String? { | |
| 103 | + switch self { | |
| 104 | + case .invalidCatalog: return String(localized: "This radio catalog is invalid. Choose a version 1 catalog with HTTPS audio URLs.") | |
| 105 | + case .download: return String(localized: "The radio library could not be downloaded. Check your connection and catalog URL.") | |
| 106 | + case .integrity: return String(localized: "A radio track did not match the catalog. Refresh the library and try again.") | |
| 107 | + case .allUnavailable: return String(localized: "None of the radio tracks could be played. Check the library and try again.") | |
| 108 | + } | |
| 109 | + } | |
| 110 | + } | |
| 111 | + | |
| 112 | + /// Content-addressed files remain available offline and never contain R2 credentials. | |
| 113 | + actor RadioLibrary { | |
| 114 | + private let directory: URL | |
| 115 | + init(directory: URL = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask)[0] | |
| 116 | + .appendingPathComponent("PulseCanvas/Radio/Audio", isDirectory: true)) { self.directory = directory } | |
| 117 | + | |
| 118 | + /// A private Radio-only copy: no server catalog changes, cloud uploads, or Studio imports. | |
| 119 | + func importMusicFolder(_ folder: URL, into root: URL = PersonalRadioMusic.directory) async throws -> (url: URL, skipped: Int) { | |
| 120 | + let lease = SecurityScopedAccess(url: folder) | |
| 121 | + defer { withExtendedLifetime(lease) {} } | |
| 122 | + let fm = FileManager.default | |
| 123 | + let destination = root.appendingPathComponent(UUID().uuidString, isDirectory: true) | |
| 124 | + try fm.createDirectory(at: destination, withIntermediateDirectories: true) | |
| 125 | + var committed = false | |
| 126 | + defer { if !committed { try? fm.removeItem(at: destination) } } | |
| 127 | + guard let enumerator = fm.enumerator(at: folder, includingPropertiesForKeys: [.isRegularFileKey, .isSymbolicLinkKey, .fileSizeKey], | |
| 128 | + options: [.skipsHiddenFiles, .skipsPackageDescendants]) else { | |
| 129 | + throw PersonalRadioMusic.FolderError.unreadable | |
| 130 | + } | |
| 131 | + var candidates: [URL] = [] | |
| 132 | + let extensions: Set<String> = ["mp3", "m4a", "aac", "wav", "aif", "aiff", "caf", "flac", "mp4", "alac"] | |
| 133 | + for case let file as URL in enumerator { | |
| 134 | + try Task.checkCancellation() | |
| 135 | + let values = try file.resourceValues(forKeys: [.isRegularFileKey, .isSymbolicLinkKey]) | |
| 136 | + if values.isSymbolicLink == true { enumerator.skipDescendants(); continue } | |
| 137 | + guard values.isRegularFile == true, extensions.contains(file.pathExtension.lowercased()) else { continue } | |
| 138 | + candidates.append(file) | |
| 139 | + guard candidates.count <= 500 else { throw PersonalRadioMusic.FolderError.tooMany } | |
| 140 | + } | |
| 141 | + var tracks: [RadioTrack] = [] | |
| 142 | + var skipped = 0 | |
| 143 | + for file in candidates.sorted(by: { $0.path.localizedStandardCompare($1.path) == .orderedAscending }) { | |
| 144 | + try Task.checkCancellation() | |
| 145 | + let id = UUID().uuidString | |
| 146 | + let copy = destination.appendingPathComponent(id + "." + file.pathExtension.lowercased()) | |
| 147 | + do { | |
| 148 | + let size = try file.resourceValues(forKeys: [.fileSizeKey]).fileSize ?? 0 | |
| 149 | + guard (1...100_000_000).contains(size) else { skipped += 1; continue } | |
| 150 | + try fm.copyItem(at: file, to: copy) | |
| 151 | + let asset = AVURLAsset(url: copy) | |
| 152 | + let duration = try await asset.load(.duration).seconds | |
| 153 | + guard duration.isFinite, duration > 0, duration <= 7200, | |
| 154 | + !(try await asset.loadTracks(withMediaType: .audio)).isEmpty else { | |
| 155 | + try? fm.removeItem(at: copy); skipped += 1; continue | |
| 156 | + } | |
| 157 | + let data = try Data(contentsOf: copy, options: .mappedIfSafe) | |
| 158 | + tracks.append(RadioTrack(id: id, title: file.deletingPathExtension().lastPathComponent, | |
| 159 | + genre: "My music", duration: duration, audio: copy.lastPathComponent, | |
| 160 | + sha256: SHA256.hash(data: data).map { String(format: "%02x", $0) }.joined(), byteCount: data.count)) | |
| 161 | + } catch is CancellationError { throw CancellationError() } | |
| 162 | + catch { try? fm.removeItem(at: copy); skipped += 1 } | |
| 163 | + } | |
| 164 | + try Task.checkCancellation() | |
| 165 | + guard !tracks.isEmpty else { throw PersonalRadioMusic.FolderError.empty } | |
| 166 | + let url = destination.appendingPathComponent("catalog.json") | |
| 167 | + let data = try JSONEncoder().encode(RadioCatalog(version: 1, title: folder.lastPathComponent, tracks: tracks)) | |
| 168 | + _ = try RadioCatalog.decode(data, from: url) | |
| 169 | + try data.write(to: url, options: .atomic) | |
| 170 | + committed = true | |
| 171 | + return (url, skipped) | |
| 172 | + } | |
| 173 | + | |
| 174 | + func removePersonalCopy(at url: URL?, within root: URL = PersonalRadioMusic.directory) { | |
| 175 | + guard let url, url.lastPathComponent == "catalog.json", | |
| 176 | + UUID(uuidString: url.deletingLastPathComponent().lastPathComponent) != nil, | |
| 177 | + url.deletingLastPathComponent().deletingLastPathComponent().standardizedFileURL.path == root.standardizedFileURL.path else { return } | |
| 178 | + try? FileManager.default.removeItem(at: url.deletingLastPathComponent()) | |
| 179 | + } | |
| 180 | + | |
| 181 | + func catalog(at url: URL) async throws -> RadioCatalog { | |
| 182 | + try RadioCatalog.decode(await document(at: url), from: url) | |
| 183 | + } | |
| 184 | + | |
| 185 | + func stations(at url: URL) async throws -> RadioStationDirectory { | |
| 186 | + try RadioStationDirectory.decode(await document(at: url), from: url) | |
| 187 | + } | |
| 188 | + | |
| 189 | + /// Only a complete library can prove a song was removed. Genre subsets and | |
| 190 | + /// failed requests must never delete favorites from other stations. | |
| 191 | + func completeCatalog(at source: URL) async throws -> (catalog: RadioCatalog, url: URL, stationID: String) { | |
| 192 | + if source.lastPathComponent == "stations.json" { | |
| 193 | + let directory = try await stations(at: source) | |
| 194 | + guard let all = directory.stations.first(where: { $0.id == "all-music" }) | |
| 195 | + ?? (directory.stations.count == 1 ? directory.stations.first : nil) else { throw RadioError.invalidCatalog } | |
| 196 | + let url = try all.resolvedURL(relativeTo: source) | |
| 197 | + return (try await catalog(at: url), url, all.id) | |
| 198 | + } | |
| 199 | + return (try await catalog(at: source), source, "all-music") | |
| 200 | + } | |
| 201 | + | |
| 202 | + private func document(at url: URL) async throws -> Data { | |
| 203 | + let data: Data | |
| 204 | + if url.isFileURL { data = try Data(contentsOf: url) } | |
| 205 | + else { | |
| 206 | + guard url.scheme == "https", url.host != nil, url.user == nil, url.password == nil else { throw RadioError.invalidCatalog } | |
| 207 | + let request = URLRequest(url: url, cachePolicy: .reloadRevalidatingCacheData, timeoutInterval: 30) | |
| 208 | + let (body, response) = try await URLSession.shared.data(for: request) | |
| 209 | + guard let response = response as? HTTPURLResponse, response.statusCode == 200, | |
| 210 | + response.url?.scheme == "https" else { throw RadioError.download } | |
| 211 | + data = body | |
| 212 | + } | |
| 213 | + try Task.checkCancellation() | |
| 214 | + guard data.count <= 2_000_000 else { throw RadioError.invalidCatalog } | |
| 215 | + return data | |
| 216 | + } | |
| 217 | + | |
| 218 | + func localAudio(for track: RadioTrack, catalogURL: URL) async throws -> URL { | |
| 219 | + let source = try track.resolvedURL(relativeTo: catalogURL) | |
| 220 | + try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) | |
| 221 | + let destination = directory.appendingPathComponent(track.sha256.lowercased() + ".m4a") | |
| 222 | + if let data = try? Data(contentsOf: destination), valid(data, track: track) { return destination } | |
| 223 | + let temporary: URL | |
| 224 | + if source.isFileURL { temporary = source } | |
| 225 | + else { | |
| 226 | + let request = URLRequest(url: source, timeoutInterval: 90) | |
| 227 | + let (downloaded, response) = try await URLSession.shared.download(for: request) | |
| 228 | + guard let response = response as? HTTPURLResponse, response.statusCode == 200, | |
| 229 | + response.url?.scheme == "https" else { | |
| 230 | + try? FileManager.default.removeItem(at: downloaded) | |
| 231 | + throw RadioError.download | |
| 232 | + } | |
| 233 | + temporary = downloaded | |
| 234 | + } | |
| 235 | + defer { if !source.isFileURL { try? FileManager.default.removeItem(at: temporary) } } | |
| 236 | + try Task.checkCancellation() | |
| 237 | + guard try temporary.resourceValues(forKeys: [.fileSizeKey]).fileSize == track.byteCount else { throw RadioError.integrity } | |
| 238 | + let data = try Data(contentsOf: temporary, options: .mappedIfSafe) | |
| 239 | + guard valid(data, track: track) else { throw RadioError.integrity } | |
| 240 | + try data.write(to: destination, options: .atomic) | |
| 241 | + return destination | |
| 242 | + } | |
| 243 | + | |
| 244 | + private func valid(_ data: Data, track: RadioTrack) -> Bool { | |
| 245 | + data.count == track.byteCount && SHA256.hash(data: data).map { String(format: "%02x", $0) }.joined() == track.sha256.lowercased() | |
| 246 | + } | |
| 247 | + } | |
| 248 | + | |
| 249 | + /// Browsing Studio music never switches Radio's station or starts its player. | |
| 250 | + @MainActor final class StudioMusicCatalog: ObservableObject { | |
| 251 | + @Published private(set) var tracks: [RadioTrack] = [] | |
| 252 | + @Published private(set) var loading = false | |
| 253 | + @Published private(set) var error: String? | |
| 254 | + private let library: RadioLibrary | |
| 255 | + private let source: URL | |
| 256 | + private var catalogURL: URL? | |
| 257 | + private let access: SecurityScopedAccess? | |
| 258 | + | |
| 259 | + init(source: URL, folderBookmark: Data? = nil, library: RadioLibrary = RadioLibrary()) { | |
| 260 | + self.library = library | |
| 261 | + let folder = SecurityScopedAccess.resolve(bookmark: folderBookmark, fallback: source.deletingLastPathComponent()) | |
| 262 | + self.source = source.isFileURL ? folder.appendingPathComponent(source.lastPathComponent) : source | |
| 263 | + access = source.isFileURL ? SecurityScopedAccess(url: folder) : nil | |
| 264 | + } | |
| 265 | + | |
| 266 | + func load() async { | |
| 267 | + guard !loading else { return } | |
| 268 | + loading = true; error = nil | |
| 269 | + defer { loading = false } | |
| 270 | + do { | |
| 271 | + let complete = try await library.completeCatalog(at: source) | |
| 272 | + try Task.checkCancellation() | |
| 273 | + tracks = complete.catalog.tracks.sorted { $0.title.localizedStandardCompare($1.title) == .orderedAscending } | |
| 274 | + catalogURL = complete.url | |
| 275 | + } catch is CancellationError { } | |
| 276 | + catch { self.error = error.localizedDescription } | |
| 277 | + } | |
| 278 | + | |
| 279 | + func matching(search: String, favoritesOnly: Bool, favoriteIDs: Set<String>) -> [RadioTrack] { | |
| 280 | + let query = search.trimmingCharacters(in: .whitespacesAndNewlines) | |
| 281 | + return tracks.filter { track in | |
| 282 | + (!favoritesOnly || favoriteIDs.contains(track.id)) && | |
| 283 | + (query.isEmpty || track.title.localizedStandardContains(query) || track.genre.localizedStandardContains(query)) | |
| 284 | + } | |
| 285 | + } | |
| 286 | + | |
| 287 | + func audio(for track: RadioTrack) async throws -> URL { | |
| 288 | + guard tracks.contains(track), let catalogURL else { throw RadioError.invalidCatalog } | |
| 289 | + return try await library.localAudio(for: track, catalogURL: catalogURL) | |
| 290 | + } | |
| 291 | + } | |
| 292 | + | |
| 293 | + /// A Studio project owns its soundtrack copy, independent of Radio cache cleanup. | |
| 294 | + enum StudioMusicStorage { | |
| 295 | + static func copy(_ source: URL, title: String, into directory: URL) throws -> URL { | |
| 296 | + let allowed = CharacterSet.alphanumerics.union(CharacterSet(charactersIn: " -_()")) | |
| 297 | + let name = String(title.components(separatedBy: allowed.inverted).joined(separator: " ").prefix(100)) | |
| 298 | + .trimmingCharacters(in: .whitespacesAndNewlines) | |
| 299 | + let folder = directory.appendingPathComponent(UUID().uuidString, isDirectory: true) | |
| 300 | + let destination = folder.appendingPathComponent(name.isEmpty ? "Soundtrack" : name).appendingPathExtension(source.pathExtension) | |
| 301 | + do { | |
| 302 | + try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) | |
| 303 | + try FileManager.default.copyItem(at: source, to: destination) | |
| 304 | + return destination | |
| 305 | + } catch { try? FileManager.default.removeItem(at: folder); throw error } | |
| 306 | + } | |
| 307 | + } | |
| 308 | + | |
| 309 | + /// Shuffle deals every track once before starting another round. | |
| 310 | + struct RadioQueue { | |
| 311 | + private var remaining: [Int] = [] | |
| 312 | + mutating func reset() { remaining = [] } | |
| 313 | + mutating func next(count: Int, current: Int?, shuffle: Bool, prioritized: Set<Int> = []) -> Int? { | |
| 314 | + guard count > 0 else { return nil } | |
| 315 | + if !shuffle { return current.map { ($0 + 1) % count } ?? 0 } | |
| 316 | + // A manually selected song can still be in the bag. Count it as heard. | |
| 317 | + if remaining.count == 1, remaining.last == current, count > 1 { remaining = [] } | |
| 318 | + if remaining.isEmpty { | |
| 319 | + let favorites = (0..<count).filter { prioritized.contains($0) }.shuffled() | |
| 320 | + let others = (0..<count).filter { !prioritized.contains($0) }.shuffled() | |
| 321 | + remaining = others + favorites | |
| 322 | + } | |
| 323 | + if count > 1, remaining.last == current, | |
| 324 | + let alternate = remaining.indices.reversed().first(where: { remaining[$0] != current && prioritized.contains(remaining[$0]) == prioritized.contains(current ?? -1) }) | |
| 325 | + ?? remaining.indices.reversed().first(where: { remaining[$0] != current }) { | |
| 326 | + remaining.swapAt(alternate, remaining.count - 1) | |
| 327 | + } | |
| 328 | + return remaining.popLast() | |
| 329 | + } | |
| 330 | + } | |
| 331 | + | |
| 332 | + /// Deal favorites once per song, then fill with non-favorites. Studio is independent. | |
| 333 | + enum RadioVisualSchedule { | |
| 334 | + static func make(plan: SongSegmentation, pool: [Int], bars: Int, | |
| 335 | + favorites: Set<Int> = [], played: Set<Int> = [], previous: Int? = nil, repeatFavorites: Bool = false) -> [StudioSegment] { | |
| 336 | + guard !pool.isEmpty else { return [] } | |
| 337 | + let available = Array(Set(pool)).sorted() | |
| 338 | + var preferred = available.filter { favorites.contains($0) && !played.contains($0) }.shuffled() | |
| 339 | + let fillers = repeatFavorites ? available : available.filter { !favorites.contains($0) } | |
| 340 | + var bag: [Int] = [], previous = previous, result: [StudioSegment] = [] | |
| 341 | + for (start, end) in zip(plan.boundaries, plan.boundaries.dropFirst()) { | |
| 342 | + let scene: Int | |
| 343 | + if preferred.last == previous, | |
| 344 | + let alternate = preferred.firstIndex(where: { $0 != previous }) { | |
| 345 | + preferred.swapAt(alternate, preferred.count - 1) | |
| 346 | + } | |
| 347 | + // A lone favorite can be the outgoing song's last visual. Open with | |
| 348 | + // a different design, then deal that favorite later in the song. | |
| 349 | + if let favorite = preferred.last, favorite != previous || available.count == 1 { | |
| 350 | + scene = preferred.removeLast() | |
| 351 | + } | |
| 352 | + else { | |
| 353 | + // If the entire gallery is favorited, hold the last design once | |
| 354 | + // its unique choices run out rather than repeating favorites. | |
| 355 | + guard !fillers.isEmpty else { | |
| 356 | + if let last = result.popLast() { result.append(StudioSegment(start: last.start, end: end, scene: last.scene, bars: last.bars)) } | |
| 357 | + continue | |
| 358 | + } | |
| 359 | + if bag.isEmpty { | |
| 360 | + bag = fillers.shuffled() | |
| 361 | + if bag.count > 1, bag.last == previous { bag.swapAt(0, bag.count - 1) } | |
| 362 | + } | |
| 363 | + scene = bag.removeLast() | |
| 364 | + } | |
| 365 | + result.append(StudioSegment(start: start, end: end, scene: scene, bars: bars)) | |
| 366 | + previous = scene | |
| 367 | + } | |
| 368 | + return result | |
| 369 | + } | |
| 370 | + } | |
| 371 | + | |
| 372 | + /// Separate storage and preferences keep personal playlists out of Studio's catalog picker. | |
| 373 | + enum PersonalRadioMusic { | |
| 374 | + static var directory: URL { | |
| 375 | + UserDataStorage.support.appendingPathComponent("PersonalRadio", isDirectory: true) | |
| 376 | + } | |
| 377 | + static let catalogKey = "PulseCanvas.radio.personalCatalog.v1" | |
| 378 | + static let activeKey = "PulseCanvas.radio.personalActive.v1" | |
| 379 | + enum FolderError: LocalizedError { | |
| 380 | + case unreadable, empty, tooMany | |
| 381 | + var errorDescription: String? { | |
| 382 | + switch self { | |
| 383 | + case .unreadable: return String(localized: "This folder couldn't be opened. Choose a downloaded music folder and try again.") | |
| 384 | + case .empty: return String(localized: "No playable songs found. Use MP3, M4A, WAV, AIFF, AAC, CAF or FLAC files up to 100 MB and two hours each.") | |
| 385 | + case .tooMany: return String(localized: "Choose a folder with up to 500 songs, including its subfolders.") | |
| 386 | + } | |
| 387 | + } | |
| 388 | + } | |
| 389 | + } |
Sources/PulseCanvas/RadioView.swift added
| 1 | + import AppKit | |
| 2 | + import Combine | |
| 3 | + import SwiftUI | |
| 4 | + | |
| 5 | + @MainActor | |
| 6 | + struct RadioLibraryView: View { | |
| 7 | + @ObservedObject var radio: RadioController | |
| 8 | + let dismiss: () -> Void | |
| 9 | + @State private var source = "" | |
| 10 | + @State private var opening = true | |
| 11 | + | |
| 12 | + var body: some View { | |
| 13 | + VStack(alignment: .leading, spacing: 14) { | |
| 14 | + HStack { | |
| 15 | + Label("PulseCanvas Radio", systemImage: "dot.radiowaves.left.and.right").font(.title2) | |
| 16 | + Spacer() | |
| 17 | + Button("Done", action: dismiss) | |
| 18 | + } | |
| 19 | + Text("Music and visuals on shuffle. Choose all, favorites, or a station.") | |
| 20 | + .foregroundStyle(.secondary) | |
| 21 | + if Bundle.main.object(forInfoDictionaryKey: "PulseCanvasRadioDeveloperMode") as? Bool == true { | |
| 22 | + DisclosureGroup("Library source") { | |
| 23 | + HStack { | |
| 24 | + TextField("HTTPS catalog URL", text: $source).textFieldStyle(.roundedBorder) | |
| 25 | + .accessibilityLabel("Radio catalog URL") | |
| 26 | + Button("Load library") { | |
| 27 | + if let url = URL(string: source.trimmingCharacters(in: .whitespacesAndNewlines)), url.scheme == "https" { | |
| 28 | + radio.loadCatalog(at: url) | |
| 29 | + } | |
| 30 | + }.disabled(URL(string: source)?.scheme != "https" || radio.isCatalogLoading) | |
| 31 | + } | |
| 32 | + } | |
| 33 | + HStack { | |
| 34 | + Button("Open local library…", action: openLocalLibrary) | |
| 35 | + Text("Choose a folder containing catalog.json and its audio files.").font(.caption).foregroundStyle(.secondary) | |
| 36 | + } | |
| 37 | + } | |
| 38 | + Divider() | |
| 39 | + if opening || radio.isCatalogLoading { | |
| 40 | + VStack(spacing: 16) { | |
| 41 | + ProgressView().controlSize(.large).tint(Color(red: 0.95, green: 0.68, blue: 0.55)) | |
| 42 | + Text("Loading Radio…").font(.headline) | |
| 43 | + Text("Getting stations and songs ready.").font(.callout).foregroundStyle(.secondary) | |
| 44 | + }.frame(maxWidth: .infinity, maxHeight: .infinity) | |
| 45 | + .accessibilityElement(children: .combine) | |
| 46 | + } else { | |
| 47 | + HStack { | |
| 48 | + Text(radio.favoriteSongsOnly ? "Favorite songs" : radio.stationTitle).font(.headline) | |
| 49 | + Spacer() | |
| 50 | + Button { | |
| 51 | + if radio.isActive { radio.next() } else { radio.start() } | |
| 52 | + dismiss() | |
| 53 | + } label: { | |
| 54 | + Label(radio.isActive ? "Next song" : "Play radio", | |
| 55 | + systemImage: radio.isActive ? "forward.end.fill" : "play.fill") | |
| 56 | + .frame(minWidth: 104) | |
| 57 | + } | |
| 58 | + .buttonStyle(StudioButtonStyle(treatment: .primary)) | |
| 59 | + .disabled(!radio.canStart) | |
| 60 | + } | |
| 61 | + RadioMusicGroupPicker(radio: radio) | |
| 62 | + if let message = radio.visualizerGroupMessage { | |
| 63 | + HStack { | |
| 64 | + Text(message).font(.caption).foregroundStyle(.secondary) | |
| 65 | + Spacer() | |
| 66 | + VisualizerRandomizerPicker(compact: true) | |
| 67 | + } | |
| 68 | + } | |
| 69 | + if let station = radio.stations.first(where: { $0.id == radio.stationID }), !radio.favoriteSongsOnly && !radio.isPersonalMusic { | |
| 70 | + Text(station.description).font(.caption).foregroundStyle(.secondary) | |
| 71 | + } | |
| 72 | + if radio.favoriteSongsOnly { | |
| 73 | + FavoriteSongsView(radio: radio) { song in | |
| 74 | + radio.playFavoriteSong(song) | |
| 75 | + if radio.isActive { dismiss() } | |
| 76 | + } | |
| 77 | + } else if let catalog = radio.catalog { | |
| 78 | + List(Array(catalog.tracks.enumerated()), id: \.element.id) { index, track in | |
| 79 | + HStack(spacing: 8) { | |
| 80 | + Button { | |
| 81 | + radio.start(at: index); dismiss() | |
| 82 | + } label: { | |
| 83 | + HStack { | |
| 84 | + Image(systemName: radio.isActive && radio.currentIndex == index ? "speaker.wave.2.fill" : "play.circle") | |
| 85 | + VStack(alignment: .leading, spacing: 3) { | |
| 86 | + Text(track.title) | |
| 87 | + Text(track.genre).font(.caption).foregroundStyle(.secondary) | |
| 88 | + } | |
| 89 | + Spacer() | |
| 90 | + Text(String(format: "%d:%02d", Int(track.duration) / 60, Int(track.duration) % 60)) | |
| 91 | + .monospacedDigit().foregroundStyle(.secondary) | |
| 92 | + }.padding(.vertical, 4).contentShape(Rectangle()) | |
| 93 | + }.buttonStyle(.plain) | |
| 94 | + if radio.canFavoriteCurrentSong { | |
| 95 | + Button { radio.toggleFavoriteSong(track) } label: { | |
| 96 | + Image(systemName: radio.isFavoriteSong(track) ? "heart.fill" : "heart") | |
| 97 | + .frame(width: 44, height: 44).contentShape(Rectangle()) | |
| 98 | + }.buttonStyle(.plain) | |
| 99 | + .accessibilityLabel("\(radio.isFavoriteSong(track) ? "Unfavorite" : "Favorite") song \(track.title)") | |
| 100 | + } | |
| 101 | + } | |
| 102 | + }.frame(minHeight: 160, maxHeight: .infinity).disabled(radio.isCatalogLoading) | |
| 103 | + } else { | |
| 104 | + ContentUnavailableView("Choose a radio library", systemImage: "music.note.list", | |
| 105 | + description: Text("Your radio library will appear here when it finishes loading.")) | |
| 106 | + .frame(height: 220) | |
| 107 | + } | |
| 108 | + } | |
| 109 | + HStack { | |
| 110 | + if radio.isLoading { ProgressView().controlSize(.small) } | |
| 111 | + Text(radio.isCatalogLoading ? "" : radio.status).font(.callout).foregroundStyle(.secondary).lineLimit(2) | |
| 112 | + Spacer() | |
| 113 | + if radio.isActive { Button("Leave radio") { radio.leave(); dismiss() } } | |
| 114 | + } | |
| 115 | + if radio.isPersonalMusic, let notice = radio.folderImportNotice { | |
| 116 | + Text(notice).font(.caption).foregroundStyle(.secondary) | |
| 117 | + } | |
| 118 | + Text(radio.isPersonalMusic ? "Folder songs are copied to this Mac and loop continuously in Radio. They stay out of Studio." : "Radio downloads music to this Mac for playback and analysis. Your own soundtracks stay on your Mac.") | |
| 119 | + .font(.caption).foregroundStyle(.secondary) | |
| 120 | + }.padding(24).frame(width: 670, height: 650) | |
| 121 | + .onAppear { source = radio.sourceText; radio.loadSavedCatalogIfNeeded(refresh: !radio.isActive); opening = false } | |
| 122 | + .onChange(of: radio.isActive) { _, active in if active && radio.favoriteSongsOnly { dismiss() } } | |
| 123 | + } | |
| 124 | + | |
| 125 | + private func openLocalLibrary() { | |
| 126 | + let picker = NSOpenPanel() | |
| 127 | + picker.canChooseFiles = false; picker.canChooseDirectories = true; picker.allowsMultipleSelection = false | |
| 128 | + picker.message = "Choose the radio library folder containing catalog.json and the audio folder" | |
| 129 | + guard picker.runModal() == .OK, let folder = picker.url else { return } | |
| 130 | + let index = FileManager.default.fileExists(atPath: folder.appendingPathComponent("stations.json").path) ? "stations.json" : "catalog.json" | |
| 131 | + radio.loadCatalog(at: folder.appendingPathComponent(index), access: SecurityScopedAccess(url: folder)) | |
| 132 | + } | |
| 133 | + } | |
| 134 | + | |
| 135 | + @MainActor | |
| 136 | + struct FavoriteSongsView: View { | |
| 137 | + @ObservedObject var radio: RadioController | |
| 138 | + let play: (FavoriteRadioSong) -> Void | |
| 139 | + | |
| 140 | + var body: some View { | |
| 141 | + VStack(alignment: .leading, spacing: 12) { | |
| 142 | + HStack { | |
| 143 | + Text("Favorite songs").font(.headline) | |
| 144 | + Spacer() | |
| 145 | + Text("\(radio.favoriteSongs.count) songs") | |
| 146 | + .font(.caption).foregroundStyle(.secondary) | |
| 147 | + } | |
| 148 | + Button { | |
| 149 | + radio.playFavoriteStation() | |
| 150 | + } label: { | |
| 151 | + Label("Play favorite songs", systemImage: "shuffle") | |
| 152 | + }.buttonStyle(StudioButtonStyle(treatment: .primary)) | |
| 153 | + .disabled(radio.favoriteSongs.isEmpty || radio.isCatalogLoading || radio.isLoading) | |
| 154 | + Text("Choose a song to open Radio and start listening.").font(.callout).foregroundStyle(.secondary) | |
| 155 | + if radio.favoriteSongs.isEmpty { | |
| 156 | + ContentUnavailableView("No favorite songs yet", systemImage: "heart", | |
| 157 | + description: Text("Tap a song’s heart in Radio to save it here.")) | |
| 158 | + .frame(maxWidth: .infinity, maxHeight: .infinity) | |
| 159 | + } else { | |
| 160 | + ScrollView { | |
| 161 | + LazyVStack(spacing: 6) { | |
| 162 | + ForEach(radio.favoriteSongs.sorted { $0.track.title.localizedStandardCompare($1.track.title) == .orderedAscending }) { song in | |
| 163 | + HStack(spacing: 0) { | |
| 164 | + Button { play(song) } label: { | |
| 165 | + HStack(spacing: 12) { | |
| 166 | + Image(systemName: "play.circle.fill").font(.title2).foregroundStyle(.orange) | |
| 167 | + VStack(alignment: .leading, spacing: 4) { | |
| 168 | + Text(song.track.title).font(.system(size: 13, weight: .medium)).lineLimit(1) | |
| 169 | + Text(song.track.genre).font(.caption).foregroundStyle(.secondary).lineLimit(1) | |
| 170 | + } | |
| 171 | + Spacer(minLength: 8) | |
| 172 | + }.padding(12).frame(maxWidth: .infinity, minHeight: 56).contentShape(Rectangle()) | |
| 173 | + }.buttonStyle(.plain).accessibilityLabel("Play \(song.track.title) in Radio") | |
| 174 | + Button { radio.toggleFavoriteSong(song.track) } label: { | |
| 175 | + Image(systemName: "heart.fill").foregroundStyle(.orange) | |
| 176 | + .frame(width: 44, height: 56).contentShape(Rectangle()) | |
| 177 | + }.buttonStyle(.plain).accessibilityLabel("Unfavorite song \(song.track.title)") | |
| 178 | + }.background(.white.opacity(0.04), in: RoundedRectangle(cornerRadius: 10)) | |
| 179 | + } | |
| 180 | + } | |
| 181 | + } | |
| 182 | + } | |
| 183 | + if radio.isCatalogLoading || radio.isLoading { | |
| 184 | + HStack { ProgressView().controlSize(.small); Text(radio.status).font(.caption) } | |
| 185 | + } else if let error = radio.favoritePlaybackError { | |
| 186 | + Text(error).font(.caption).foregroundStyle(.secondary) | |
| 187 | + } | |
| 188 | + }.frame(minHeight: 220) | |
| 189 | + .task { await radio.refreshFavoriteSongs() } | |
| 190 | + } | |
| 191 | + } | |
| 192 | + | |
| 193 | + /// The editor's Library keeps visualizer browsing and saved songs in separate tabs. | |
| 194 | + @MainActor | |
| 195 | + struct PulseCanvasLibraryView: View { | |
| 196 | + @ObservedObject var radio: RadioController | |
| 197 | + let selected: Int | |
| 198 | + var appearance: ((Int) -> VisualPreset)? = nil | |
| 199 | + let choose: (Int) -> Void | |
| 200 | + let dismiss: () -> Void | |
| 201 | + @State private var favoriteSongsSelected = false | |
| 202 | + | |
| 203 | + var body: some View { | |
| 204 | + VStack(spacing: 0) { | |
| 205 | + HStack(spacing: 8) { | |
| 206 | + Button { favoriteSongsSelected = false } label: { Label("Visualizers", systemImage: "square.grid.2x2") } | |
| 207 | + .buttonStyle(StudioButtonStyle(treatment: favoriteSongsSelected ? .secondary : .accent, compact: true)) | |
| 208 | + Button { favoriteSongsSelected = true } label: { Label("Favorite songs", systemImage: "heart") } | |
| 209 | + .buttonStyle(StudioButtonStyle(treatment: favoriteSongsSelected ? .accent : .secondary, compact: true)) | |
| 210 | + Spacer() | |
| 211 | + }.padding(.horizontal, 18).padding(.top, 18) | |
| 212 | + if favoriteSongsSelected { | |
| 213 | + FavoriteSongsView(radio: radio) { song in | |
| 214 | + radio.playFavoriteSong(song) | |
| 215 | + if radio.isActive { dismiss() } | |
| 216 | + }.padding(18).frame(height: 560) | |
| 217 | + } else { | |
| 218 | + VisualizerBrowser(selected: selected, heading: "Visualizers", appearance: appearance, choose: choose) | |
| 219 | + } | |
| 220 | + HStack { Spacer(); Button("Done", action: dismiss).buttonStyle(StudioButtonStyle(compact: true)) }.padding(18) | |
| 221 | + }.frame(width: 680) | |
| 222 | + .onChange(of: radio.isActive) { _, active in if active && favoriteSongsSelected { dismiss() } } | |
| 223 | + } | |
| 224 | + } | |
| 225 | + | |
| 226 | + /// An independent listening surface: there are no Studio cards or appearance editors. | |
| 227 | + @MainActor | |
| 228 | + struct RadioPlayerView: View { | |
| 229 | + @ObservedObject var radio: RadioController | |
| 230 | + @ObservedObject var audio: AudioController | |
| 231 | + @ObservedObject var render: RenderState | |
| 232 | + @ObservedObject private var presets = ProjectMPresets.shared | |
| 233 | + @State private var playbackRevision = 0 | |
| 234 | + @StateObject private var presentation = RadioPresentationController() | |
| 235 | + @State private var controlsVisible = true | |
| 236 | + @State private var hideControls: Task<Void, Never>? | |
| 237 | + @State private var showLibrary = false | |
| 238 | + @State private var trackingMenus = 0 | |
| 239 | + | |
| 240 | + var body: some View { | |
| 241 | + ZStack(alignment: .bottom) { | |
| 242 | + Color.black.ignoresSafeArea() | |
| 243 | + VisualizerView(state: render).ignoresSafeArea() | |
| 244 | + .modifier(VisualizerFavoriteGesture { | |
| 245 | + presets.favorite(render.scene, appearance: VisualPreset(render: render)) | |
| 246 | + }) | |
| 247 | + if controlsVisible || !radio.isPlaybackRequested || radio.isLoading { | |
| 248 | + controls.padding(20) | |
| 249 | + .transition(.opacity) | |
| 250 | + } | |
| 251 | + }.background(Color.black) | |
| 252 | + .background(StudioWindowReader(attach: presentation.attach).frame(width: 0, height: 0)) | |
| 253 | + .background(RadioPointerActivity(activity: revealControls).frame(width: 0, height: 0)) | |
| 254 | + .contentShape(Rectangle()) | |
| 255 | + .onAppear { revealControls() } | |
| 256 | + .onChange(of: presentation.isFullScreen) { _, _ in revealControls() } | |
| 257 | + .onChange(of: audio.isPlaying) { _, _ in revealControls() } | |
| 258 | + .onChange(of: showLibrary) { _, _ in revealControls() } | |
| 259 | + .onReceive(NotificationCenter.default.publisher(for: NSMenu.didBeginTrackingNotification)) { _ in | |
| 260 | + trackingMenus += 1; hideControls?.cancel() | |
| 261 | + } | |
| 262 | + .onReceive(NotificationCenter.default.publisher(for: NSMenu.didEndTrackingNotification)) { _ in | |
| 263 | + trackingMenus = max(0, trackingMenus - 1) | |
| 264 | + if trackingMenus == 0 { revealControls() } | |
| 265 | + } | |
| 266 | + .onDisappear { hideControls?.cancel(); presentation.restore() } | |
| 267 | + .sheet(isPresented: $showLibrary) { | |
| 268 | + RadioLibraryView(radio: radio) { showLibrary = false } | |
| 269 | + .dismissOnOutsideClick { showLibrary = false } | |
| 270 | + } | |
| 271 | + } | |
| 272 | + | |
| 273 | + private var visualizerRow: some View { | |
| 274 | + VStack(alignment: .leading, spacing: 12) { | |
| 275 | + ViewThatFits(in: .horizontal) { | |
| 276 | + HStack(spacing: 16) { | |
| 277 | + Label("Radio", systemImage: "dot.radiowaves.left.and.right").font(.headline) | |
| 278 | + currentVisualizer | |
| 279 | + visualizerControls | |
| 280 | + Spacer(minLength: 8) | |
| 281 | + presentationControls | |
| 282 | + } | |
| 283 | + VStack(alignment: .leading, spacing: 12) { | |
| 284 | + HStack(spacing: 16) { | |
| 285 | + Label("Radio", systemImage: "dot.radiowaves.left.and.right").font(.headline) | |
| 286 | + currentVisualizer | |
| 287 | + Spacer(minLength: 8) | |
| 288 | + presentationControls | |
| 289 | + } | |
| 290 | + HStack { visualizerControls; Spacer(minLength: 0) } | |
| 291 | + } | |
| 292 | + } | |
| 293 | + if let message = radio.visualizerGroupMessage { | |
| 294 | + Text(message).font(.caption).foregroundStyle(.secondary) | |
| 295 | + } | |
| 296 | + } | |
| 297 | + } | |
| 298 | + | |
| 299 | + @ViewBuilder private var currentVisualizer: some View { | |
| 300 | + if !radio.sceneTitle.isEmpty { | |
| 301 | + HStack(spacing: 8) { | |
| 302 | + Button { | |
| 303 | + presets.toggleFavorite(render.scene, appearance: VisualPreset(render: render)) | |
| 304 | + revealControls() | |
| 305 | + } label: { | |
| 306 | + Image(systemName: presets.isFavorite(render.scene) ? "heart.fill" : "heart") | |
| 307 | + } | |
| 308 | + .buttonStyle(StudioButtonStyle(compact: true, circular: true)) | |
| 309 | + .accessibilityLabel(presets.isFavorite(render.scene) ? "Unfavorite visualizer" : "Favorite visualizer") | |
| 310 | + .help(presets.isFavorite(render.scene) ? "Remove \(radio.sceneTitle) from Favorites" : "Add \(radio.sceneTitle) to Favorites") | |
| 311 | + VStack(alignment: .leading, spacing: 2) { | |
| 312 | + Text("Visualizer").font(.caption2).foregroundStyle(.secondary) | |
| 313 | + Text(radio.sceneTitle).font(.callout.weight(.medium)) | |
| 314 | + .lineLimit(1).truncationMode(.tail) | |
| 315 | + } | |
| 316 | + .help(radio.sceneTitle) | |
| 317 | + .accessibilityElement(children: .combine) | |
| 318 | + | |
| 319 | + } | |
| 320 | + .frame(maxWidth: 320, alignment: .leading) | |
| 321 | + } | |
| 322 | + } | |
| 323 | + | |
| 324 | + | |
| 325 | + private var visualizerControls: some View { | |
| 326 | + HStack(spacing: 12) { | |
| 327 | + Button { radio.randomizeCurrentVisualizer(); revealControls() } label: { | |
| 328 | + Label("Randomize", systemImage: "shuffle") | |
| 329 | + }.buttonStyle(StudioButtonStyle(compact: true)) | |
| 330 | + .help("Choose another visualizer from the selected group without restarting the song") | |
| 331 | + .disabled(!radio.canRandomizeVisualizer) | |
| 332 | + VisualizerRandomizerPicker(compact: true) | |
| 333 | + .onChange(of: radio.visualizerGroup) { _, _ in revealControls() } | |
| 334 | + Picker("Bars per visualizer", selection: $radio.barsPerVisualizer) { | |
| 335 | + ForEach(RadioController.barChoices, id: \.self) { Text("\($0) bars").tag($0) } | |
| 336 | + }.labelsHidden().frame(width: 96).controlSize(.large) | |
| 337 | + .help("How many bars each Radio visualizer plays") | |
| 338 | + }.fixedSize(horizontal: true, vertical: false) | |
| 339 | + } | |
| 340 | + | |
| 341 | + private var presentationControls: some View { | |
| 342 | + HStack(spacing: 12) { | |
| 343 | + Button { | |
| 344 | + presentation.toggle(); revealControls() | |
| 345 | + } label: { | |
| 346 | + Label(presentation.isFullScreen ? "Exit full screen" : "Present", | |
| 347 | + systemImage: presentation.isFullScreen ? "arrow.down.right.and.arrow.up.left" : "arrow.up.left.and.arrow.down.right") | |
| 348 | + }.buttonStyle(StudioButtonStyle(compact: true)) | |
| 349 | + Button("Back to editor") { radio.leave() }.buttonStyle(StudioButtonStyle(compact: true)) | |
| 350 | + }.fixedSize(horizontal: true, vertical: false) | |
| 351 | + } | |
| 352 | + | |
| 353 | + private var controls: some View { | |
| 354 | + let _ = playbackRevision | |
| 355 | + return VStack(alignment: .leading, spacing: 12) { | |
| 356 | + visualizerRow | |
| 357 | + Divider().overlay(.white.opacity(0.12)) | |
| 358 | + HStack(spacing: 16) { | |
| 359 | + VStack(alignment: .leading, spacing: 4) { | |
| 360 | + HStack(spacing: 8) { | |
| 361 | + if let track = radio.currentTrack, radio.canFavoriteCurrentSong { | |
| 362 | + Button { radio.toggleFavoriteSong(track); revealControls() } label: { | |
| 363 | + Image(systemName: radio.isFavoriteSong(track) ? "heart.fill" : "heart") | |
| 364 | + }.buttonStyle(StudioButtonStyle(compact: true, circular: true)) | |
| 365 | + .disabled(radio.isLoading) | |
| 366 | + .accessibilityLabel(radio.isFavoriteSong(track) ? "Unfavorite song" : "Favorite song") | |
| 367 | + .help("Save or remove this song in Library → Favorite songs") | |
| 368 | + } | |
| 369 | + Text(radio.isLoading ? String(localized: "Preparing next song…") : radio.currentTrack?.title ?? String(localized: "Radio")) | |
| 370 | + .font(.title3.weight(.semibold)).lineLimit(1) | |
| 371 | + | |
| 372 | + }.frame(minHeight: 44) | |
| 373 | + Text(radio.isLoading || !audio.isPlaying ? radio.status : radio.currentTrack?.genre ?? "") | |
| 374 | + .font(.callout).foregroundStyle(.secondary).lineLimit(1).frame(height: 17) | |
| 375 | + } | |
| 376 | + Spacer() | |
| 377 | + RadioMusicGroupPicker(radio: radio).frame(width: 240) | |
| 378 | + .onChange(of: radio.musicGroupID) { _, _ in revealControls() } | |
| 379 | + Button { showLibrary = true; revealControls() } label: { | |
| 380 | + Label("Library", systemImage: "music.note.list") | |
| 381 | + }.buttonStyle(StudioButtonStyle(compact: true)) | |
| 382 | + } | |
| 383 | + HStack(spacing: 18) { | |
| 384 | + Button { radio.togglePlayback() } label: { | |
| 385 | + Label(radio.isPlaybackRequested ? "Pause" : "Play", systemImage: radio.isPlaybackRequested ? "pause.fill" : "play.fill") | |
| 386 | + .frame(width: 68) | |
| 387 | + }.buttonStyle(StudioButtonStyle(treatment: .primary, compact: true)) | |
| 388 | + Button { radio.next() } label: { Label("Skip", systemImage: "forward.end.fill") } | |
| 389 | + .buttonStyle(StudioButtonStyle(compact: true)).disabled(!radio.canStart) | |
| 390 | + Slider(value: Binding(get: { radio.canSeek ? audio.progress : 0 }, set: { radio.seek(fraction: $0) }), in: 0...1) | |
| 391 | + .disabled(!radio.canSeek).accessibilityLabel("Radio song position") | |
| 392 | + Text("\(format(audio.playbackSeconds)) / \(format(audio.duration))").monospacedDigit().font(.caption) | |
| 393 | + .frame(width: 112, alignment: .trailing) | |
| 394 | + Image(systemName: "speaker.wave.2") | |
| 395 | + Slider(value: $radio.volume, in: 0...1).frame(width: 80).accessibilityLabel("Radio volume") | |
| 396 | + } | |
| 397 | + }.padding(20).background(.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 16)) | |
| 398 | + .onReceive(audio.visualizationUpdated.throttle(for: .milliseconds(100), scheduler: RunLoop.main, latest: true)) { playbackRevision &+= 1 } | |
| 399 | + } | |
| 400 | + | |
| 401 | + private func format(_ value: Double) -> String { | |
| 402 | + let seconds = max(0, Int(value)); return String(format: "%d:%02d", seconds / 60, seconds % 60) | |
| 403 | + } | |
| 404 | + | |
| 405 | + private func revealControls() { | |
| 406 | + hideControls?.cancel() | |
| 407 | + withAnimation(.easeOut(duration: 0.2)) { controlsVisible = true } | |
| 408 | + hideControls = Task { @MainActor in | |
| 409 | + do { try await Task.sleep(for: .seconds(3)) } catch { return } | |
| 410 | + guard audio.isPlaying, !radio.isLoading, !showLibrary, trackingMenus == 0 else { return } | |
| 411 | + withAnimation(.easeOut(duration: 0.3)) { controlsVisible = false } | |
| 412 | + } | |
| 413 | + } | |
| 414 | + } | |
| 415 | + | |
| 416 | + @MainActor | |
| 417 | + private struct RadioMusicGroupPicker: View { | |
| 418 | + @ObservedObject var radio: RadioController | |
| 419 | + var body: some View { | |
| 420 | + Menu { | |
| 421 | + Button("All music") { radio.selectMusicGroup("all-music") } | |
| 422 | + ForEach(radio.isPersonalMusic ? [] : radio.stations.filter { $0.id != "all-music" }) { station in | |
| 423 | + Button(station.title) { radio.selectMusicGroup(station.id) } | |
| 424 | + } | |
| 425 | + Button("Favorite songs") { radio.selectMusicGroup("favorite-songs") } | |
| 426 | + Divider() | |
| 427 | + if radio.hasPersonalMusic { Button("My music folder") { radio.usePersonalMusic() } } | |
| 428 | + Button("Choose music folder…") { | |
| 429 | + let picker = NSOpenPanel() | |
| 430 | + picker.canChooseFiles = false; picker.canChooseDirectories = true | |
| 431 | + picker.allowsMultipleSelection = false | |
| 432 | + picker.message = "Copy an album or music folder for continuous Radio playback. Up to 500 songs; subfolders are included. These songs stay out of Studio." | |
| 433 | + if picker.runModal() == .OK, let folder = picker.url { radio.importMusicFolder(folder) } | |
| 434 | + } | |
| 435 | + Toggle("Shuffle songs", isOn: $radio.shuffle) | |
| 436 | + } label: { | |
| 437 | + Label(radio.isPersonalMusic ? radio.stationTitle : radio.favoriteSongsOnly ? "Favorite songs" : radio.stationTitle, | |
| 438 | + systemImage: radio.isPersonalMusic ? "folder.badge.music.note" : "antenna.radiowaves.left.and.right") | |
| 439 | + }.controlSize(.large).disabled(radio.isCatalogLoading) | |
| 440 | + .accessibilityLabel("Radio music source") | |
| 441 | + } | |
| 442 | + } | |
| 443 | + | |
| 444 | + /// Native renderer surfaces can consume SwiftUI hover tracking. Observe actual | |
| 445 | + /// pointer events in this Radio window without consuming clicks or monitoring other apps. | |
| 446 | + private struct RadioPointerActivity: NSViewRepresentable { | |
| 447 | + let activity: () -> Void | |
| 448 | + func makeNSView(context: Context) -> RadioPointerView { | |
| 449 | + let view = RadioPointerView() | |
| 450 | + view.activity = activity | |
| 451 | + return view | |
| 452 | + } | |
| 453 | + func updateNSView(_ view: RadioPointerView, context: Context) { view.activity = activity } | |
| 454 | + static func dismantleNSView(_ view: RadioPointerView, coordinator: ()) { view.stop() } | |
| 455 | + } | |
| 456 | + | |
| 457 | + private final class RadioPointerView: NSView { | |
| 458 | + var activity: () -> Void = {} | |
| 459 | + private var monitor: Any? | |
| 460 | + private weak var monitoredWindow: NSWindow? | |
| 461 | + private var previousMouseMovedEvents = false | |
| 462 | + private var lastActivity = -Double.infinity | |
| 463 | + | |
| 464 | + override func viewDidMoveToWindow() { | |
| 465 | + super.viewDidMoveToWindow() | |
| 466 | + stop() | |
| 467 | + guard let window else { return } | |
| 468 | + monitoredWindow = window | |
| 469 | + previousMouseMovedEvents = window.acceptsMouseMovedEvents | |
| 470 | + window.acceptsMouseMovedEvents = true | |
| 471 | + monitor = NSEvent.addLocalMonitorForEvents(matching: [.mouseMoved, .leftMouseDown, .rightMouseDown, .scrollWheel]) { [weak self] event in | |
| 472 | + MainActor.assumeIsolated { | |
| 473 | + guard let self, event.window === self.monitoredWindow else { return } | |
| 474 | + let now = ProcessInfo.processInfo.systemUptime | |
| 475 | + guard now - self.lastActivity >= 0.1 else { return } | |
| 476 | + self.lastActivity = now | |
| 477 | + self.activity() | |
| 478 | + } | |
| 479 | + return event | |
| 480 | + } | |
| 481 | + } | |
| 482 | + | |
| 483 | + func stop() { | |
| 484 | + if let monitor { NSEvent.removeMonitor(monitor); self.monitor = nil } | |
| 485 | + monitoredWindow?.acceptsMouseMovedEvents = previousMouseMovedEvents | |
| 486 | + monitoredWindow = nil | |
| 487 | + } | |
| 488 | + } | |
| 489 | + | |
| 490 | + /// Radio always fills the window. Its full-screen state never reads export aspect settings. | |
| 491 | + @MainActor | |
| 492 | + final class RadioPresentationController: NSObject, ObservableObject { | |
| 493 | + @Published private(set) var isFullScreen = false | |
| 494 | + private weak var window: NSWindow? | |
| 495 | + private var startedFullScreen: Bool? | |
| 496 | + private var keyboardMonitor: Any? | |
| 497 | + | |
| 498 | + override init() { | |
| 499 | + super.init() | |
| 500 | + NotificationCenter.default.addObserver(self, selector: #selector(changed(_:)), name: NSWindow.didEnterFullScreenNotification, object: nil) | |
| 501 | + NotificationCenter.default.addObserver(self, selector: #selector(changed(_:)), name: NSWindow.didExitFullScreenNotification, object: nil) | |
| 502 | + } | |
| 503 | + | |
| 504 | + func attach(_ window: NSWindow?) { | |
| 505 | + self.window = window | |
| 506 | + guard let window else { return } | |
| 507 | + let full = window.styleMask.contains(.fullScreen) | |
| 508 | + if startedFullScreen == nil { startedFullScreen = full } | |
| 509 | + if isFullScreen != full { isFullScreen = full } | |
| 510 | + if keyboardMonitor == nil { | |
| 511 | + keyboardMonitor = NSEvent.addLocalMonitorForEvents(matching: .keyDown) { [weak self] event in | |
| 512 | + guard let self, self.isFullScreen, event.keyCode == 53, | |
| 513 | + event.modifierFlags.intersection([.command, .control, .option, .shift]).isEmpty else { return event } | |
| 514 | + if !event.isARepeat { self.toggle() } | |
| 515 | + return nil | |
| 516 | + } | |
| 517 | + } | |
| 518 | + } | |
| 519 | + | |
| 520 | + func toggle() { window?.toggleFullScreen(nil) } | |
| 521 | + | |
| 522 | + func restore() { | |
| 523 | + if let keyboardMonitor { NSEvent.removeMonitor(keyboardMonitor); self.keyboardMonitor = nil } | |
| 524 | + if startedFullScreen == false, window?.styleMask.contains(.fullScreen) == true { window?.toggleFullScreen(nil) } | |
| 525 | + } | |
| 526 | + | |
| 527 | + @objc private func changed(_ notification: Notification) { | |
| 528 | + guard let source = notification.object as? NSWindow, source === window else { return } | |
| 529 | + isFullScreen = source.styleMask.contains(.fullScreen) | |
| 530 | + } | |
| 531 | + } |
Sources/PulseCanvas/Resources/NativeDance.metal added
| 1 | + // PulseCanvas native designs: dancing and club visuals (scenes 167-183). Original | |
| 2 | + // procedural code; see NativeCommon.metal. Every design is a pure function of its | |
| 3 | + // uniforms. Choreography runs on procedural time (c.t) at zero Chaos; above zero the | |
| 4 | + // music clock (c.m) adds tempo, bands enlarge specific moves and lights, and attacks | |
| 5 | + // trigger local accents (a jump, a flick, a ripple) that ease out with the envelope. | |
| 6 | + | |
| 7 | + // ---------------------------------------------------------------- shared helpers | |
| 8 | + float dnBeat(Ctx c, float rate, float music) { return c.t * rate + c.m * music; } | |
| 9 | + // Attack envelope normalised by Chaos (0...1); only used through dnAccent. | |
| 10 | + float dnHit(Ctx c, constant NativeFrame &f) { return saturate(c.hit / max(f.camera.y, .05f)); } | |
| 11 | + // Smooth accent for moving geometry: zero at the attack onset and at rest, peaking as | |
| 12 | + // the envelope decays, so attacks never make shapes jump. Scales with Chaos. | |
| 13 | + float dnAccent(Ctx c, constant NativeFrame &f) { float h = dnHit(c, f); return 4 * h * (1 - h) * saturate(f.camera.y * 1.7f); } | |
| 14 | + | |
| 15 | + float2 dnMul(float2 a, float2 b) { return float2(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); } | |
| 16 | + float2 dnPolar(float a) { return float2(cos(a), sin(a)); } | |
| 17 | + float dnSq(float x) { return x * x; } | |
| 18 | + // Camera (focal length 2) pitched down over a ground plane so the horizon sits at | |
| 19 | + // screen height `horizon` (keep it above the canvas). Returns world x, forward z and | |
| 20 | + // the ray parameter t (world units per uv unit across the screen). | |
| 21 | + constant float DN_FOCAL = 2; | |
| 22 | + | |
| 23 | + // Projects a point (x, height, z) given relative to the dnFloor camera position. Returns | |
| 24 | + // screen xy and a depth z such that a world length L appears L / z long on screen. | |
| 25 | + | |
| 26 | + // Soft cone of light from src along dir. | |
| 27 | + | |
| 28 | + | |
| 29 | + // ---------------------------------------------------------------- 167 Groove Tiles | |
| 30 | + // An illuminated glass dance floor seen at an angle. Tiles glow from beneath in moving | |
| 31 | + // patterns (checker, diagonals, ripples, spirals) that crossfade over time; band groups | |
| 32 | + // light blocks of tiles; a ring of tiles ripples out from a wandering spot on the music | |
| 33 | + // clock and attacks light it up with a spark at its origin, while mirror-ball specks | |
| 34 | + // and soft pools of shadow sweep across the glass. Zoom speed slides the floor. | |
| 35 | + | |
| 36 | + | |
| 37 | + // ---------------------------------------------------------------- 168 Mirror Ball | |
| 38 | + // A big faceted mirror ball turns high in a hazy room. Each square facet reflects the | |
| 39 | + // coloured spotlights aimed at it and twinkles; hundreds of reflected specks sweep the | |
| 40 | + // walls. Bass brightens the beams, highs make facets sparkle, attacks bring out extra | |
| 41 | + // specks and light a ring of specks flung outward on the music clock. Zoom speed pans | |
| 42 | + // the room and turns the ball. | |
| 43 | + | |
| 44 | + | |
| 45 | + // ---------------------------------------------------------------- 169 Drone Ballet | |
| 46 | + // Two hundred and fifty-six light drones perform above dark water, flowing between | |
| 47 | + // formations (sphere, helix bundle, rippling sheet, nested rings, torus knot). Groups | |
| 48 | + // of drones morph on staggered schedules and arc out of each other's way, each drone a | |
| 49 | + // glowing point with a soft halo and a short trail, mirrored as shimmering streaks on | |
| 50 | + // the water above a faint far skyline. Bands brighten drone rows and sweep colour | |
| 51 | + // across the swarm, attacks light a ripple of brightness and displacement through it, | |
| 52 | + // the music clock speeds the morphs and Zoom speed orbits and dollies the camera. | |
| 53 | + constant int DRONE_U = 32, DRONE_V = 8, DRONE_PU = 4, DRONE_PV = 2; | |
| 54 | + | |
| 55 | + struct DroneSwarm { int from, to; float morph, t, rippleR, accent, bass, beat; float2 spin; }; | |
| 56 | + // A patch of drones morphs together: its blend and the arc it lifts along while | |
| 57 | + // changing formation are shared, so each patch travels its own path. | |
| 58 | + struct DronePatch { float blend; float3 lift; }; | |
| 59 | + | |
| 60 | + // World position (relative to the swarm centre, already spun) of the drone or patch | |
| 61 | + // centre at grid coordinate (u, v). | |
| 62 | + | |
| 63 | + | |
| 64 | + // ---------------------------------------------------------------- 170 Ribbon Gymnast | |
| 65 | + // Rhythmic-gymnastics ribbons loop, spiral and snake through the air over a dark stage. | |
| 66 | + // Each ribbon is the recent path of its stick tip (a sum of rotating phasors whose | |
| 67 | + // shape morphs between circles, figure eights and loops), drawn as a twisting band | |
| 68 | + // with a bright front and a darker back. Bass widens the loops; attacks whip the | |
| 69 | + // tail into a coil. Zoom speed drifts the camera. | |
| 70 | + | |
| 71 | + | |
| 72 | + // ---------------------------------------------------------------- 171 Laser Haze | |
| 73 | + // A club laser show: rows of emitters below and above fan thin beams through drifting | |
| 74 | + // haze, sweeping, fanning and converging into cones, with hot spots where beams strike | |
| 75 | + // the ceiling, above a dark stage edge with a soft footlight glow. Bands widen each | |
| 76 | + // emitter's fan, attacks flick fans to a new angle and Zoom speed pans along the rig. | |
| 77 | + | |
| 78 | + | |
| 79 | + // ---------------------------------------------------------------- 172 Moving Heads | |
| 80 | + // A concert rig: moving-head fixtures hang from a truss and swing their cones across | |
| 81 | + // the stage in choreographed sweeps, projecting rotating gobo patterns onto the floor | |
| 82 | + // through haze, with a chasing row of stage-edge lights. Bass widens the cones, highs | |
| 83 | + // twinkle the gobos and attacks sweep every head toward centre stage in unison. | |
| 84 | + | |
| 85 | + | |
| 86 | + // ---------------------------------------------------------------- 173 Conga Orbs | |
| 87 | + // A conga line of glossy orbs hops along a snaking, looping path across a polished | |
| 88 | + // dance floor, each orb squashing on landing and stretching as it springs, with a | |
| 89 | + // shadow, a mirror reflection and a glowing track joining the line. Bass raises the | |
| 90 | + // hops, highs sparkle the highlights, spinning flips ripple down the line with the | |
| 91 | + // music clock and attacks add a hop and light the track. Zoom speed dollies the camera. | |
| 92 | + | |
| 93 | + | |
| 94 | + // ---------------------------------------------------------------- 174 Headspin | |
| 95 | + // Breaking moves as pure light painting: four lights carried by an unseen dancer trace | |
| 96 | + // two-tone trails that cycle through spin figures every few seconds (stacked head-spin | |
| 97 | + // rings with epicycloid loops, windmill circles, figure-eight sweeps, low floor sweeps), | |
| 98 | + // crossfading between figures while trails build up and decay. Every so often the spin | |
| 99 | + // slows to a freeze and the lights flare. Sparks skid off the floor. Bass brightens the | |
| 100 | + // trails and attacks flare the lights and light a ring on the floor. | |
| 101 | + struct SpinLimbs { float3 p[4]; }; | |
| 102 | + // One figure for a foot or hand light, split into the part that flips sign for the | |
| 103 | + // opposite light (odd in the spin phasor) and the part both share (even). xy are screen | |
| 104 | + // offsets from the spin centre, z is nearness to the camera. | |
| 105 | + struct SpinPart { float3 odd, even; }; | |
| 106 | + | |
| 107 | + | |
| 108 | + // Feet (0, 1) sit opposite each other on the spin, hands (2, 3) a quarter turn away. | |
| 109 | + | |
| 110 | + // The spin slows to a near freeze every 24 seconds: rate = TAU * (1.25 - .95 * freeze). | |
| 111 | + constant float SPIN_FREEZE = TAU / 24; | |
| 112 | + | |
| 113 | + | |
| 114 | + // ---------------------------------------------------------------- 175 Waltz Pairs | |
| 115 | + // A ballroom seen from above: pairs of glowing partners turn around each other with | |
| 116 | + // soft trails while the couples travel counter-clockwise around a polished parquet | |
| 117 | + // floor that mirrors the chandeliers. The turn accelerates on beat one of each bar of | |
| 118 | + // three; bass widens the turns and attacks spin a couple out. Zoom speed slowly turns | |
| 119 | + // and dollies the overhead camera. | |
| 120 | + | |
| 121 | + | |
| 122 | + // ---------------------------------------------------------------- 176 Pigment Burst | |
| 123 | + // Slow-motion bursts of coloured powder bloom against a dark backdrop, like high-speed | |
| 124 | + // photographs of thrown pigment. Six plumes launch on a staggered schedule from points | |
| 125 | + // along the lower frame, each billowing outward (self-similar noise that expands with | |
| 126 | + // the cloud), curling, lit from one side with a glowing rim, and fading while newer | |
| 127 | + // plumes take over, so the frame is always full; overlapping plumes mix their colours. | |
| 128 | + // Bass swells and speeds the youngest plume, attacks push it outward, highs add | |
| 129 | + // glittering grains and Zoom speed drifts the camera through the clouds. | |
| 130 | + float3 pigmentBurst(Ctx c, constant NativeFrame &f) { | |
| 131 | + float zoom = 1 + .08 * sin(c.travel * .08); | |
| 132 | + float2 uv = c.uv / zoom + float2(sin(c.travel * .05) * .35, sin(c.travel * .037) * .15); | |
| 133 | + float3 color = deep(.4 + uv.y * .05, f) * .035 + paint(.5, f) * .05 * exp(-length(uv * float2(.6, 1)) * 1.2); | |
| 134 | + // Fine pigment dust hangs everywhere from earlier bursts. | |
| 135 | + float dust = fbm2(uv * .9 + float2(c.t * .02, -c.t * .015), 3); | |
| 136 | + color += paint(dust * 1.2 + .1, f) * (.035 + .05 * dust); | |
| 137 | + const int plumes = 6; | |
| 138 | + const float life = 7.5; | |
| 139 | + float clock = (c.t + c.m * 1.6) / life; | |
| 140 | + float accent = dnAccent(c, f); | |
| 141 | + float2 light = normalize(float2(-.6, .8)); | |
| 142 | + float density = 0; | |
| 143 | + // Oldest plume first so younger plumes billow in front. | |
| 144 | + int oldest = (plumes - 1 - int(floor(fract(clock) * plumes))) % plumes; | |
| 145 | + for (int m = 0; m < plumes; ++m) { | |
| 146 | + int k = (oldest - m + plumes) % plumes; | |
| 147 | + float phase = clock + float(k) / plumes; | |
| 148 | + float age = fract(phase); | |
| 149 | + float generation = floor(phase); | |
| 150 | + float3 seed = hash33(float3(generation, float(k), 7.1)); | |
| 151 | + float young = exp(-age * 5); | |
| 152 | + float grow = 1 - exp(-age * (3.2 + 2.5 * c.b.x * young)); | |
| 153 | + float2 launch = float2(((float(k) + seed.x) / plumes * 2 - 1) * .9 * c.extent.x, c.extent.y * (seed.y * 1.1 - .85)); | |
| 154 | + float2 dir = normalize(float2(-launch.x * .3 + (seed.z - .5) * .9, .8 - launch.y * .4)); | |
| 155 | + float2 center = launch + dir * grow * (.45 + .35 * seed.y) * c.extent.y; | |
| 156 | + float R = (.2 + .8 * grow) * c.size * (1 + .45 * c.b.x * young + .35 * accent * young) * 1.1; | |
| 157 | + float2 q = rot(uv - center, (seed.z - .5) * 1.6 * age + seed.x * 6) / R; | |
| 158 | + float r = length(q); | |
| 159 | + if (r > 1.7) continue; | |
| 160 | + float fade = smoothstep(0.f, .06f, age) * pow(1 - age, 1.3f); | |
| 161 | + // Billows: noise that expands with the plume and drifts outward as it grows. | |
| 162 | + float2 nq = q * 1.7 * (1 - .35 * age) + seed.xy * 20; | |
| 163 | + float billow = fbm2(nq, 5); | |
| 164 | + float bump = (billow - fbm2(nq + light * .07, 5)) * 5; | |
| 165 | + float edge = r + (billow - .5) * 1.25 + (noise2(nq * 3.3) - .5) * .3; | |
| 166 | + float body = smoothstep(1.f, .72f, edge); | |
| 167 | + float thick = smoothstep(1.f, .2f, edge); | |
| 168 | + float2 lq = q + light * .16; | |
| 169 | + float lit = fbm2(lq * 1.7 * (1 - .35 * age) + seed.xy * 20, 3); | |
| 170 | + float toward = smoothstep(1.f, .2f, length(lq) + (lit - .5) * 1.25); | |
| 171 | + float shade = saturate(.5 + (thick - toward) * 2.2 + dot(q, light) * .25 + bump); | |
| 172 | + float rim = smoothstep(.6f, 1.f, edge) * body; | |
| 173 | + float plumeBand = c.b[k % 4]; | |
| 174 | + float hue = seed.x * .9 + float(k) * .17 + plumeBand * .2; | |
| 175 | + float3 tint = paint(hue, f) * (1 + plumeBand * .6); | |
| 176 | + float3 plume = mix(deep(hue, f) * .45, tint, shade) + mix(tint, paint(.95, f), .3) * rim * .4; | |
| 177 | + plume *= (.75 + .45 * billow) * (.7 + .4 * thick); | |
| 178 | + color += tint * smoothstep(1.7f, .6f, r) * fade * .05; | |
| 179 | + float alpha = body * fade * .95; | |
| 180 | + color = mix(color, plume, alpha); | |
| 181 | + density = max(density, alpha); | |
| 182 | + } | |
| 183 | + // Glittering grains caught in the clouds. | |
| 184 | + float2 g = uv * 95; | |
| 185 | + float2 gid = floor(g); | |
| 186 | + float gh = hash21(gid); | |
| 187 | + float grain = step(.93f, gh) * pow(.5 + .5 * sin(c.t * (5 + gh * 7) + gh * 60), 10.f); | |
| 188 | + float dotMask = smoothstep(.35f, .1f, length(fract(g) - .5)); | |
| 189 | + color += paint(.9 + gh * .1, f) * grain * dotMask * density * (.35 + c.b.w * 3 + c.hit * 2.5); | |
| 190 | + return color; | |
| 191 | + } | |
| 192 | + | |
| 193 | + // ---------------------------------------------------------------- 177 Pirouette Bloom | |
| 194 | + // Spinning tulle skirts seen from above, abstracted into flowers: layered frills turn | |
| 195 | + // and their pleats flare wider the faster each bloom spins, sequins glint on the hems | |
| 196 | + // and a rosette of sequins glows at each heart, every bloom in its own spotlight pool. | |
| 197 | + // Bass flares the pleats, attacks pop the sequins and Zoom speed drifts the camera. | |
| 198 | + | |
| 199 | + | |
| 200 | + // ---------------------------------------------------------------- 178 Stretch Membrane | |
| 201 | + // One taut, glossy stretch-fabric sheet fills the frame. Unseen performers press into | |
| 202 | + // it from behind: seven knee-, shoulder- and palm-sized pushes glide and twist in slow | |
| 203 | + // phrases as low, flat-topped swells, with soft broad wrinkles pulled between | |
| 204 | + // neighbouring pushes. Everything is shaded from the sheet's own normals: a fine weave | |
| 205 | + // everywhere, a warm grazing light from one side and a cool one from the other, long | |
| 206 | + // anisotropic stretch highlights along the tension around each push and a coloured | |
| 207 | + // rim where the fabric bends at its base. Bass deepens the pushes, attacks raise a | |
| 208 | + // small sharp push, highs ripple the sheen and Zoom speed slides the pushes and lights. | |
| 209 | + float3 stretchMembrane(Ctx c, constant NativeFrame &f) { | |
| 210 | + float2 p = c.uv; | |
| 211 | + float slide = c.travel * .07; | |
| 212 | + float phrase = dnBeat(c, .3, .8); | |
| 213 | + float depthBoost = 1 + c.b.x * .6; | |
| 214 | + const int pushes = 7; | |
| 215 | + float2 centers[pushes]; | |
| 216 | + float amps[pushes]; | |
| 217 | + float2 grad = 0.f; | |
| 218 | + float height = 0, rim = 0; | |
| 219 | + float3 tension = 0.f; // structure tensor (xx, yy, xy) of the stretch directions | |
| 220 | + for (int k = 0; k < pushes; ++k) { | |
| 221 | + float fk = float(k); | |
| 222 | + float3 seed = hash33(float3(fk, 3.1, 7.7)); | |
| 223 | + float2 center = float2(sin(phrase * (.8 + seed.x * .6) + fk * 2.3 + slide) * .82 * c.extent.x, | |
| 224 | + sin(phrase * (.65 + seed.y * .5) + fk * 1.7 + slide * .6) * .78 * c.extent.y); | |
| 225 | + float press = .35 + .65 * smoothstep(.1f, .8f, .5 + .5 * sin(phrase * 1.2 + fk * 1.9)); | |
| 226 | + float size = (.2 + .22 * seed.z) * c.size; | |
| 227 | + float2 axes = float2(size * (1 + .6 * seed.x), size); | |
| 228 | + float twist = c.t * (seed.y - .5) * .8 + fk * 1.3; | |
| 229 | + float A = press * (.7 + .3 * seed.y) * depthBoost * (1 + c.b[k % 4] * 1.2) * size * .62; | |
| 230 | + // A low swell with a flat top that eases out slowly into the sheet. | |
| 231 | + float2 q = rot(p - center, -twist) / axes; | |
| 232 | + float q2 = dot(q, q); | |
| 233 | + float g = 1 / (1 + q2 * q2); | |
| 234 | + height += A * g; | |
| 235 | + float2 slope = rot(-4 * A * g * g * q2 * q / axes, twist); | |
| 236 | + grad += slope; | |
| 237 | + float w = dot(slope, slope); | |
| 238 | + float2 dir = slope * rsqrt(max(w, 1e-8f)); | |
| 239 | + tension += float3(dir.x * dir.x, dir.y * dir.y, dir.x * dir.y) * w; | |
| 240 | + rim += exp(-dnSq((sqrt(q2) - 1.15) / .45)) * press; | |
| 241 | + centers[k] = center; | |
| 242 | + amps[k] = A / size; | |
| 243 | + } | |
| 244 | + // Soft, broad wrinkles pulled taut between neighbouring pushes. | |
| 245 | + for (int k = 0; k < pushes; ++k) { | |
| 246 | + int j = (k + 1) % pushes; | |
| 247 | + float2 a = centers[k], b = centers[j]; | |
| 248 | + float2 ab = b - a; | |
| 249 | + float len = length(ab); | |
| 250 | + float strength = smoothstep(1.7f, .5f, len) * min(amps[k], amps[j]); | |
| 251 | + if (strength < 1e-4) continue; | |
| 252 | + float h = saturate(dot(p - a, ab) / max(len * len, 1e-4f)); | |
| 253 | + float2 along = ab / max(len, 1e-4f), across = float2(-along.y, along.x); | |
| 254 | + float side = dot(p - a - ab * h, across); | |
| 255 | + float width = .16 + .1 * len; | |
| 256 | + float env = sin(PI * h) * exp(-side * side / (width * width)) * strength; | |
| 257 | + float wave = side * 55 + h * 3; | |
| 258 | + float wrinkle = .006 * (1 + c.b.y * 1.6); | |
| 259 | + height += wrinkle * cos(wave) * env; | |
| 260 | + grad += across * (-wrinkle * 55 * sin(wave) * env); | |
| 261 | + tension += float3(along.x * along.x, along.y * along.y, along.x * along.y) * env * env * .2; | |
| 262 | + } | |
| 263 | + // A small sharp push springs up where the music clock points when an attack lands. | |
| 264 | + float2 hitAt = float2(sin(c.m * .9 + 1) * .6 * c.extent.x, cos(c.m * .7) * .5 * c.extent.y); | |
| 265 | + float2 hq = (p - hitAt) / (.1 * c.size); | |
| 266 | + float hinv = 1 / (1 + dot(hq, hq)); | |
| 267 | + float hA = dnAccent(c, f) * .1 * c.size * .5; | |
| 268 | + height += hA * hinv * hinv; | |
| 269 | + grad += -4 * hA * hinv * hinv * hinv * hq / (.1 * c.size); | |
| 270 | + // The woven surface: a rib and a fine weave tilt the normals everywhere. | |
| 271 | + float2 warp = normalize(float2(1, .35)), weft = float2(-warp.y, warp.x); | |
| 272 | + float shimmer = 1 + c.b.w * .8 * sin(dot(p, float2(23, 9)) - c.t * 7); | |
| 273 | + float fineWeave = saturate(1.6f - c.px * 420 * .9f); | |
| 274 | + float ribFade = saturate(1.6f - c.px * 150 * .9f); | |
| 275 | + float2 weave = (warp * cos(dot(p, warp) * 420) + weft * cos(dot(p, weft) * 420)) * .05 * fineWeave | |
| 276 | + + warp * cos(dot(p, warp) * 150 + sin(dot(p, weft) * 3) * 2) * .03 * ribFade; | |
| 277 | + float3 n = normalize(float3(-(grad + weave * shimmer), 1)); | |
| 278 | + // Stretch direction: the dominant eigenvector of the tension tensor. Fibres run across | |
| 279 | + // it, so highlights streak along the stretch. | |
| 280 | + float stretchAngle = .5 * atan2(2 * tension.z, tension.x - tension.y); | |
| 281 | + float2 stretchDir = float2(cos(stretchAngle), sin(stretchAngle)); | |
| 282 | + float stretchAmount = saturate(sqrt(dnSq(tension.x - tension.y) + 4 * tension.z * tension.z) * 5) * smoothstep(.04f, .22f, length(grad)); | |
| 283 | + float3 fibre = float3(-stretchDir.y, stretchDir.x, 0); | |
| 284 | + fibre = normalize(fibre - n * dot(fibre, n)); | |
| 285 | + float3 view = float3(0, 0, 1); | |
| 286 | + float swing = sin(c.travel * .05) * .25 + sin(c.t * .07) * .15; | |
| 287 | + float3 warmL = normalize(float3(-cos(swing) * .93, .2 + sin(swing) * .3, .36)); | |
| 288 | + float3 coolL = normalize(float3(cos(swing) * .93, -.15 + sin(swing) * .2, .36)); | |
| 289 | + float3 warmT = paint(.75 + c.b.x * .2, f), coolT = paint(.12 + c.b.z * .25, f) * 1.5; | |
| 290 | + float across = saturate(.5 - .5 * p.x / c.extent.x + .15 * sin(swing * 2)); | |
| 291 | + float3 lights[2] = {warmL, coolL}; | |
| 292 | + float3 tints[2] = {warmT, coolT}; | |
| 293 | + float reach[2] = {.2 + .8 * across, .2 + .8 * (1 - across)}; | |
| 294 | + float3 color = deep(.5, f) * .04; | |
| 295 | + for (int i = 0; i < 2; ++i) { | |
| 296 | + float3 L = lights[i]; | |
| 297 | + float3 hv = normalize(L + view); | |
| 298 | + float diffuse = max(dot(n, L), 0.f); | |
| 299 | + float sheen = pow(max(dot(n, hv), 0.f), 5.f); | |
| 300 | + float spec = pow(max(dot(n, hv), 0.f), 45.f); | |
| 301 | + float th = dot(fibre, hv); | |
| 302 | + float aniso = pow(sqrt(max(1 - th * th, 0.f)), 140.f) * stretchAmount; | |
| 303 | + color += tints[i] * (diffuse * diffuse * .55 + sheen * .12 + spec * .2 + aniso * 1.5) * reach[i]; | |
| 304 | + } | |
| 305 | + // A coloured rim where the fabric bends at the base of each push, and a faint glow | |
| 306 | + // where it is stretched thinnest. | |
| 307 | + color += mix(coolT, warmT, across) * rim * .07 * (1 + .5 * stretchAmount); | |
| 308 | + color += paint(.9, f) * dnSq(saturate(height * 9)) * .12; | |
| 309 | + color += paint(.9, f) * hinv * hinv * c.hit * .45; | |
| 310 | + return color; | |
| 311 | + } | |
| 312 | + | |
| 313 | + // ---------------------------------------------------------------- 179 Kinetic Mirrors | |
| 314 | + // A large kinetic wall of small square mirrors on pivots, seen at a slight angle. The | |
| 315 | + // tiles tilt in travelling waves (diagonals, rings, spirals), so each reflects a | |
| 316 | + // different part of a colourful stage behind the viewer (drifting colour spots, sweeping | |
| 317 | + // beams, pin lights) and shimmering waves of colour roll across the wall between thin | |
| 318 | + // dark gaps and bevelled edges. Bands drive the different wave patterns, attacks send a | |
| 319 | + // ripple of tilts out from a point, highs add glints and Zoom speed pans along the wall. | |
| 320 | + float3 mirrorStage(float3 d, Ctx c, constant NativeFrame &f) { | |
| 321 | + float3 color = deep(.4 + d.y * .2, f) * .07 + paint(.3, f) * .025 * (1 + d.y); | |
| 322 | + for (int k = 0; k < 5; ++k) { | |
| 323 | + float fk = float(k); | |
| 324 | + float3 spot = normalize(float3(sin(c.t * (.17 + fk * .03) + fk * 1.3) * .9, sin(c.t * (.13 + fk * .02) + fk * 2.1) * .45 + .05, -1)); | |
| 325 | + float a = max(dot(d, spot), 0.f); | |
| 326 | + color += paint(fk * .21 + .05, f) * (pow(a, 34.f) * .75 + pow(a, 400.f) * 2.5); | |
| 327 | + } | |
| 328 | + float az = atan2(d.x, -d.z); | |
| 329 | + float beams = pow(.5 + .5 * cos(az * 7 - c.t * 1.1 + d.y * 2), 24.f) * smoothstep(-.3f, .5f, d.y); | |
| 330 | + color += paint(.55 + .2 * sin(az * 2 + c.t * .2), f) * beams * .45; | |
| 331 | + float2 pin = float2(az * 9, d.y * 9); | |
| 332 | + float2 pid = floor(pin); | |
| 333 | + float ph = hash21(pid); | |
| 334 | + float twinkle = pow(.5 + .5 * sin(c.t * (2 + ph * 4) + ph * 30), 6.f); | |
| 335 | + color += paint(.9, f) * exp(-dot(fract(pin) - .5, fract(pin) - .5) * 60) * step(.7f, ph) * twinkle * (.6 + c.b.w * 3); | |
| 336 | + return color; | |
| 337 | + } | |
| 338 | + float3 kineticMirrors(Ctx c, constant NativeFrame &f) { | |
| 339 | + float yaw = .3 + .05 * sin(c.t * .07); | |
| 340 | + float3 rd = normalize(float3(c.uv, 2.2)); | |
| 341 | + float3 N0 = float3(-sin(yaw), 0, -cos(yaw)); | |
| 342 | + float3 T = float3(cos(yaw), 0, -sin(yaw)); | |
| 343 | + const float D = 3; | |
| 344 | + float t = dot(float3(0, 0, D), N0) / dot(rd, N0); | |
| 345 | + float3 hit = rd * t; | |
| 346 | + float2 w = float2(dot(hit - float3(0, 0, D), T), hit.y) + float2(c.travel * .15, 0); | |
| 347 | + float tile = .16 * c.size; | |
| 348 | + float2 cell = w / tile; | |
| 349 | + float2 id = floor(cell), lq = fract(cell) - .5; | |
| 350 | + float2 wc = (id + .5) * tile; | |
| 351 | + // Travelling tilt waves; each band drives its own pattern. | |
| 352 | + float2 ringC = float2(sin(c.t * .13) * 1.5 + c.travel * .15, cos(c.t * .11) * .6); | |
| 353 | + float2 rv = wc - ringC; | |
| 354 | + float rr = length(rv); | |
| 355 | + float diag = sin(dot(wc, float2(1.4, .9)) * 2.2 - c.t * 1.7 - c.m * 2.2); | |
| 356 | + float ringW = sin(rr * 4.5 - c.t * 2.3 - c.m * 2.8); | |
| 357 | + float spiral = sin(atan2(rv.y, rv.x) * 3 + rr * 3.2 - c.t * 1.5 - c.m * 1.8); | |
| 358 | + float mixA = .5 + .5 * sin(c.t * .09), mixB = .5 + .5 * sin(c.t * .07 + 2); | |
| 359 | + float wDiag = .45 * mixA + c.b.x * .6, wRing = .45 * (1 - mixA) + c.b.y * .6, wSpiral = .35 * mixB + c.b.z * .6; | |
| 360 | + float2 tilt = float2(diag * wDiag + ringW * wRing * rv.x / max(rr, .2f) + spiral * wSpiral * .7, | |
| 361 | + diag * wDiag * .6 + ringW * wRing * rv.y / max(rr, .2f) + spiral * wSpiral * .7 * cos(rr * 2)) * .3; | |
| 362 | + // Attack ripple from a point on the wall, riding the music clock. | |
| 363 | + float2 hitC = float2(sin(c.m * .8) * 1.2 + c.travel * .15, cos(c.m * .6) * .5); | |
| 364 | + float2 hv = wc - hitC; | |
| 365 | + float hr = length(hv); | |
| 366 | + float front = fract(c.m * .45) * 3; | |
| 367 | + float ripple = exp(-dnSq((hr - front) / .25)) * (1 - front / 3); | |
| 368 | + tilt += hv / max(hr, .05f) * ripple * dnAccent(c, f) * .45; | |
| 369 | + // Bevelled tile edges and dark gaps. | |
| 370 | + float edge = max(abs(lq.x), abs(lq.y)); | |
| 371 | + float bevel = smoothstep(.36f, .46f, edge); | |
| 372 | + float2 lean = tilt + sign(lq) * step(abs(lq.yx), abs(lq)) * bevel * .5; | |
| 373 | + float3 n = normalize(N0 + T * lean.x + float3(0, 1, 0) * lean.y); | |
| 374 | + float3 r = reflect(rd, n); | |
| 375 | + float3 color = mirrorStage(r, c, f); | |
| 376 | + color *= .75 + .25 * smoothstep(.5f, .2f, edge); | |
| 377 | + color += paint(.9, f) * c.hit * ripple * 1.2; | |
| 378 | + float px = c.px * t * 1.2 / tile; | |
| 379 | + float gap = smoothstep(.47f - px, .47f + px, edge); | |
| 380 | + color = mix(color, deep(.3, f) * .02, gap * .9); | |
| 381 | + return color * (1 - .35 * smoothstep(3.f, 8.f, t) * c.fog * 2); | |
| 382 | + } | |
| 383 | + | |
| 384 | + // ---------------------------------------------------------------- 180 Fire Dance | |
| 385 | + // Fire poi on a night beach, the performers implied only by the light: flaming heads | |
| 386 | + // trace circles, flowers and figure eights with flickering fire trails, shedding sparks | |
| 387 | + // while embers rise and the sand glows. Bass enlarges the flames, attacks flare the poi heads and light bursts | |
| 388 | + // of sparks around them, and highs make the embers flicker. Zoom speed pans the beach. | |
| 389 | + float3 fireDance(Ctx c, constant NativeFrame &f) { | |
| 390 | + float2 uv = c.uv; | |
| 391 | + float pan = c.travel * .1; | |
| 392 | + float seaY = .1 * c.extent.y, shoreY = -.22 * c.extent.y; | |
| 393 | + float2 moon = float2(.6 * c.extent.x - sin(pan * .3) * .1, .65 * c.extent.y); | |
| 394 | + float3 color; | |
| 395 | + if (uv.y > seaY) { | |
| 396 | + color = deep(.15 + uv.y * .05, f) * .05 + paint(.3, f) * .07 * exp(-(uv.y - seaY) * 3); | |
| 397 | + float2 star = uv * 90; | |
| 398 | + color += paint(.9, f) * pow(hash21(floor(star)), 90.f) * smoothstep(.3f, .1f, length(fract(star) - .5)) * 1.5; | |
| 399 | + color += paint(.95, f) * (fill(length(uv - moon) - .07, c.px) * .6 + exp(-length(uv - moon) * 6) * .12); | |
| 400 | + } else if (uv.y > shoreY) { | |
| 401 | + float depth = seaY - uv.y; | |
| 402 | + float glint = pow(noise2(float2(uv.x * 4 + pan, depth * 60 / (depth + .1) - c.t * .6)), 6.f); | |
| 403 | + color = deep(.2, f) * .05 + paint(.6, f) * glint * .35 * exp(-depth * 3); | |
| 404 | + color += paint(.9, f) * glint * exp(-abs(uv.x - moon.x) * 4) * (.5 + c.b.z * 1.5); | |
| 405 | + color += paint(.7, f) * .1 * exp(-dnSq((uv.y - shoreY) / .012)) * (.6 + .4 * sin(uv.x * 9 + c.t * .7)); | |
| 406 | + } else { | |
| 407 | + float grain = noise2(uv * 140) * .5 + noise2(uv * 9 + 3) * .5; | |
| 408 | + color = deep(.55, f) * (.045 + .03 * grain) + paint(.35, f) * .025; | |
| 409 | + } | |
| 410 | + const float H = .95; | |
| 411 | + float feetY = shoreY - .42 * min(c.extent.y, 1.4f); | |
| 412 | + const float sp = 1.45; | |
| 413 | + float slot = floor((uv.x + pan) / sp + .5); | |
| 414 | + float flameScale = c.size * (1 + c.b.x * .55); | |
| 415 | + float3 fire = 0.f, sparks = 0.f; | |
| 416 | + const int N = 18; | |
| 417 | + const float span = .36; | |
| 418 | + float fades[N + 1]; | |
| 419 | + for (int i = 0; i <= N; ++i) fades[i] = 1.2 * log(max(1 - float(i) / float(N), 1e-3f)); | |
| 420 | + for (int k = -1; k <= 1; ++k) { | |
| 421 | + float id = slot + float(k); | |
| 422 | + float seed = hash11(id * 2.9 + 1); | |
| 423 | + float2 feet = float2(id * sp - pan, feetY); | |
| 424 | + if (abs(uv.x - feet.x) > 1.05) continue; | |
| 425 | + float omega = TAU * (1 + .2 * seed) * (seed > .5 ? 1.f : -1.f); | |
| 426 | + float mode = .5 + .5 * sin(c.t * .15 + seed * 6); | |
| 427 | + float extension = mix(1.f, .35f, mode), flower = mode * .55; | |
| 428 | + float tauNow = c.t + c.m * 3 / TAU; | |
| 429 | + for (int side = 0; side < 2; ++side) { | |
| 430 | + float sgn = side == 0 ? -1.f : 1.f; | |
| 431 | + float2 hc = feet + float2(.3 * sgn, .64) * H; | |
| 432 | + float poiBand = c.b[(side + int(seed * 3.99)) % 4]; | |
| 433 | + float poiScale = flameScale * (1 + poiBand * .8); | |
| 434 | + // The poi head is a hand circle plus a tether made of two rotating phasors. | |
| 435 | + float2 A = dnPolar(omega * tauNow * sgn), B = float2(A.x, -A.y); | |
| 436 | + B = dnMul(dnMul(B, B), B); | |
| 437 | + float2 A0 = A, B0 = B; | |
| 438 | + const float2 lead = float2(.8775826, .4794255); | |
| 439 | + float2 prev = hc + .12 * A + .36 * (extension * dnMul(A, lead) + flower * B); | |
| 440 | + float2 head = prev; | |
| 441 | + fire += paint(.97, f) * exp(-length(uv - head) / (.016 * poiScale)) * 1.4; | |
| 442 | + fire += paint(.6, f) * exp(-length(uv - head) / (.12 * poiScale)) * (.16 + c.hit * .5); | |
| 443 | + if (length(uv - hc) > 1.1) continue; | |
| 444 | + // Flame trail: the recent path of the poi head. | |
| 445 | + float2 rA = dnPolar(-omega * span / float(N) * sgn), rB = float2(rA.x, -rA.y); | |
| 446 | + rB = dnMul(dnMul(rB, rB), rB); | |
| 447 | + float score = -1e4, sAt = 1, dAt = 9, dMin = 1e3, sMin = 1; | |
| 448 | + float prevW = .018 * poiScale; | |
| 449 | + for (int i = 1; i <= N; ++i) { | |
| 450 | + float s = float(i) / float(N); | |
| 451 | + A = dnMul(A, rA); B = dnMul(B, rB); | |
| 452 | + float2 pt = hc + .12 * A + .36 * (extension * dnMul(A, lead) + flower * B) + float2(0, s * s * .07); | |
| 453 | + float2 pa = uv - prev, ba = pt - prev; | |
| 454 | + float hh = saturate(dot(pa, ba) / max(dot(ba, ba), 1e-7f)); | |
| 455 | + float d = length(pa - ba * hh); | |
| 456 | + float curW = (.018 + .04 * s) * poiScale; | |
| 457 | + float dw = d / mix(prevW, curW, hh); | |
| 458 | + float sc = -dw * dw * 1.3 + mix(fades[i - 1], fades[i], hh); | |
| 459 | + if (sc > score) { score = sc; sAt = (float(i - 1) + hh) / float(N); dAt = dw; } | |
| 460 | + if (d < dMin) { dMin = d; sMin = (float(i - 1) + hh) / float(N); } | |
| 461 | + prev = pt; | |
| 462 | + prevW = curW; | |
| 463 | + } | |
| 464 | + float glowBest = exp(-dAt * dAt * 1.3) * pow(1 - sAt, 1.2f); | |
| 465 | + float flick = noise2(float2(sAt * 9 - c.t * 7 + id * 3 + sgn, dAt * 2 + c.t * 3)); | |
| 466 | + float tongues = noise2(uv * float2(16, 9) + float2(id * 5 + sgn * 3, -c.t * 6)); | |
| 467 | + float heat = glowBest * (.55 + .9 * flick); | |
| 468 | + fire += paint(mix(.98f, .25f, saturate(sAt * 1.1 + dAt * .3)), f) * heat * (1.5 + poiBand * 1.2); | |
| 469 | + float aura = exp(-dMin / (.055 * poiScale)) * dnSq(1 - sMin) * smoothstep(.35f, .8f, tongues); | |
| 470 | + fire += paint(.3 + .3 * (1 - sMin), f) * aura * .55; | |
| 471 | + // Sparks shed from the poi path, and a burst from the head on attacks. | |
| 472 | + for (int k2 = 0; k2 < 4; ++k2) { | |
| 473 | + float hk = hash11(id * 13 + float(k2) * 3.7 + sgn); | |
| 474 | + float age = fract(c.t * 1.2 + hk); | |
| 475 | + float2 back = dnPolar(-omega * age * .6 * sgn), backB = float2(back.x, -back.y); | |
| 476 | + float2 Aa = dnMul(A0, back), Ba = dnMul(B0, dnMul(dnMul(backB, backB), backB)); | |
| 477 | + float2 origin = hc + .12 * Aa + .36 * (extension * dnMul(Aa, lead) + flower * Ba); | |
| 478 | + float2 vel = (float2(hk, hash11(hk * 9)) - .5) * .5 + float2(0, .25); | |
| 479 | + float2 a = origin + vel * age - float2(0, .7 * age * age); | |
| 480 | + float2 b = a - (vel - float2(0, 1.4 * age)) * .03; | |
| 481 | + sparks += paint(.85, f) * exp(-sdSegment(uv, a, b) / .003) * dnSq(1 - age) * .9; | |
| 482 | + } | |
| 483 | + for (int k2 = 0; k2 < 5; ++k2) { | |
| 484 | + float hk = hash11(id * 7 + float(k2) * 5.1 + sgn * 3); | |
| 485 | + float2 dir = dnPolar(hk * TAU + float(k2)); | |
| 486 | + float age = fract(c.m * .8 + hk); | |
| 487 | + float2 a = head + dir * age * (.35 + .25 * hk) - float2(0, .3 * age * age); | |
| 488 | + sparks += paint(.9, f) * exp(-sdSegment(uv, a, a - dir * .04) / .004) * c.hit * 2.2 * (1 - age * .6) * smoothstep(0.f, .15f, age) * (1 - smoothstep(.75f, 1.f, age)); | |
| 489 | + } | |
| 490 | + } | |
| 491 | + color += paint(.6, f) * exp(-length((uv - feet) * float2(1, 3.5)) * 2.2) * .35 * (uv.y < shoreY ? 1.f : .4f) * (1 + c.b.x * 2.5); | |
| 492 | + } | |
| 493 | + // Embers rising over the whole beach. | |
| 494 | + float2 eq = (uv + float2(pan * .5, -c.t * .12)) * 11; | |
| 495 | + float2 eid = floor(eq); | |
| 496 | + float2 eh = hash22(eid + 5); | |
| 497 | + float2 ep = fract(eq) - .5 - (eh - .5) * .6 + .15 * float2(sin(c.t * 2 + eh.x * 9), 0); | |
| 498 | + float flickE = .55 + .45 * sin(c.t * (6 + eh.y * 8) + eh.x * 20) * (1 + c.b.w * 2.5); | |
| 499 | + float ember = exp(-dot(ep, ep) * 260 / (1 + c.b.w * 1.5)) * step(.6f - c.b.w * .2f, eh.x) * flickE * smoothstep(.9f, -.4f, uv.y / c.extent.y); | |
| 500 | + return color + fire + sparks + paint(.7 + eh.y * .25, f) * ember * .9; | |
| 501 | + } | |
| 502 | + | |
| 503 | + // ---------------------------------------------------------------- 181 Chiffon Swirl | |
| 504 | + // A long-exposure photograph of a twirling chiffon skirt without the dancer: four sheer | |
| 505 | + // layers flare around an invisible vertical axis in spiral folds, translucent where they | |
| 506 | + // overlap, rim-lit, with fine fabric grain and luminous hems, under a single spotlight | |
| 507 | + // in stage haze. The spin speeds up and slows in phrases and the skirt flares with it; | |
| 508 | + // bass flares the swirl wider, attacks flick a hem outward, highs make the hems glitter | |
| 509 | + // and Zoom speed slowly dollies around the swirl. | |
| 510 | + struct ChiffonLayer { float3 color; float alpha; }; | |
| 511 | + | |
| 512 | + | |
| 513 | + // ---------------------------------------------------------------- 182 Fountain Show | |
| 514 | + // A musical fountain at night: a row of jets throws columns and arcs of streaky water | |
| 515 | + // lit from below in shifting palette colours, with mist, splashes and reflections in | |
| 516 | + // the pool in front of a city skyline. Jets choreograph procedurally; bands drive the | |
| 517 | + // heights of their jet groups and attacks shoot the central jets high. Zoom speed pans. | |
| 518 | + float3 fountainJets(float2 p, float waterY, float pan, Ctx c, constant NativeFrame &f) { | |
| 519 | + float3 light = 0.f; | |
| 520 | + const float sp = .34; | |
| 521 | + float slot = floor((p.x + pan) / sp + .5); | |
| 522 | + float arcs = smoothstep(.25f, .75f, .5 + .5 * sin(c.t * .13)); | |
| 523 | + float modeA = .5 + .5 * sin(c.t * .07), modeB = .5 + .5 * sin(c.t * .11 + 2); | |
| 524 | + float tall = .8 + .55 * saturate(c.extent.y - 1); | |
| 525 | + float y = p.y - waterY; | |
| 526 | + for (int k = -3; k <= 3; ++k) { | |
| 527 | + float j = slot + float(k); | |
| 528 | + float xj = j * sp - pan; | |
| 529 | + float dx = p.x - xj; | |
| 530 | + int group = int(j - floor(j / 4) * 4); | |
| 531 | + float wave = .5 + .35 * sin(c.t * 1.5 + c.m * 2.4 - j * .6); | |
| 532 | + float alternate = .45 + .35 * sin(c.t * 2.1 + c.m * 3) * (fmod(abs(j), 2.f) < 1 ? 1.f : -1.f); | |
| 533 | + float pulse = .55 + .3 * sin(c.t * 1.1 + c.m * 1.8); | |
| 534 | + float H = mix(mix(wave, alternate, modeA), pulse, modeB * .5); | |
| 535 | + float central = exp(-dnSq(xj / .5)); | |
| 536 | + H = (H + c.b[group] * .5 + dnAccent(c, f) * .9 * central) * tall; | |
| 537 | + float3 tint = paint(j * .13 + c.t * .05, f) * (1 + c.hit * central); | |
| 538 | + if (abs(dx) < .2 && y > -.03 && y < H + .25) { | |
| 539 | + float frac = saturate(y / max(H, .05f)); | |
| 540 | + float w = (.012 + .03 * frac * frac) * c.size; | |
| 541 | + float core = exp(-dnSq(dx / w)); | |
| 542 | + float streak = noise2(float2(dx / w * 1.3 + j * 7, y * 10 - c.t * 7)); | |
| 543 | + float column = core * (.45 + .8 * streak) * smoothstep(H + .12f, H * .75f, y); | |
| 544 | + float crown = exp(-dnSq((y - H) / (.06 + .08 * frac)) - dnSq(dx / (w * 3))) * .5; | |
| 545 | + light += tint * (column + crown) * (1.5 - .7 * frac) * (1 - arcs * .5); | |
| 546 | + light += paint(.95, f) * core * core * .35 * (1 - frac) * (1 - arcs * .5); | |
| 547 | + } | |
| 548 | + for (int side = 0; side < 2; ++side) { | |
| 549 | + float dir = side == 0 ? -1.f : 1.f; | |
| 550 | + float reach = (.42 + .2 * sin(c.t * .4 + j)) * (.7 + .3 * H); | |
| 551 | + float u = dx * dir / reach; | |
| 552 | + if (u < 0 || u > 1.08) continue; | |
| 553 | + float apex = H * .75; | |
| 554 | + float yc = 4 * apex * u * (1 - u); | |
| 555 | + float slope = 4 * apex * (1 - 2 * u) / reach; | |
| 556 | + float dist = (y - yc) / sqrt(1 + slope * slope); | |
| 557 | + float w = (.006 + .018 * u) * c.size; | |
| 558 | + float drops = noise2(float2(u * 26 - c.t * 6 + j * 3, dist * 70)); | |
| 559 | + float stream = exp(-dnSq(dist / w)) * (.35 + .9 * drops) * smoothstep(1.08f, .95f, u); | |
| 560 | + light += tint * stream * arcs * 1.3; | |
| 561 | + float2 splash = float2(dx - dir * reach, y); | |
| 562 | + light += tint * exp(-dot(splash, splash) / .002) * arcs * .5; | |
| 563 | + } | |
| 564 | + light += tint * exp(-dnSq(dx / .14) - y * y / .003) * .35; | |
| 565 | + } | |
| 566 | + return light; | |
| 567 | + } | |
| 568 | + float3 fountainShow(Ctx c, constant NativeFrame &f) { | |
| 569 | + float2 uv = c.uv; | |
| 570 | + float pan = c.travel * .06; | |
| 571 | + float waterY = -.32 * c.extent.y; | |
| 572 | + float3 color; | |
| 573 | + if (uv.y > waterY) { | |
| 574 | + color = mix(paint(.15, f) * .1, deep(.1, f) * .05, smoothstep(waterY, c.extent.y, uv.y)); | |
| 575 | + float clouds = fbm2(float2(uv.x * .9 + pan * .1 + c.t * .01, uv.y * 2.2), 4); | |
| 576 | + color += paint(.35, f) * smoothstep(.45f, .8f, clouds) * .1 * smoothstep(waterY, waterY + .6f, uv.y); | |
| 577 | + float2 star = uv * 80; | |
| 578 | + color += paint(.9, f) * pow(hash21(floor(star)), 60.f) * smoothstep(.35f, .1f, length(fract(star) - .5)) * smoothstep(waterY + .4f, waterY + 1.f, uv.y); | |
| 579 | + float x = uv.x + pan * .3; | |
| 580 | + float bw = .16; | |
| 581 | + float bid = floor(x / bw); | |
| 582 | + float hb = hash11(bid * 1.7 + 3); | |
| 583 | + float top = waterY + .05 + (.12 + .55 * hb * hb) * min(c.extent.y, 1.4f); | |
| 584 | + if (uv.y < top) { | |
| 585 | + float2 win = float2(fract(x / .026), fract((uv.y - waterY) / .036)); | |
| 586 | + float2 wid = float2(floor(x / .026), floor((uv.y - waterY) / .036)); | |
| 587 | + float on = step(.62f, hash21(wid + bid)) * step(.25f, win.x) * step(win.x, .75f) * step(.3f, win.y) * step(win.y, .7f); | |
| 588 | + color = deep(.3, f) * .035 + paint(.75 + hash21(wid) * .25, f) * on * .3; | |
| 589 | + } | |
| 590 | + float bokeh = pow(noise2(float2(x * 14, 3)), 4.f) * exp(-(uv.y - waterY) * 30); | |
| 591 | + color += paint(.8, f) * bokeh * .4; | |
| 592 | + color += fountainJets(uv, waterY, pan, c, f); | |
| 593 | + color += paint(.4, f) * exp(-(uv.y - waterY) / .06) * .08; | |
| 594 | + } else { | |
| 595 | + float depth = waterY - uv.y; | |
| 596 | + float ripple = sin(depth * 70 / (depth + .15) + c.t * 2 + uv.x * 3) * .012 * min(depth * 6, 1.f); | |
| 597 | + float2 mirror = float2(uv.x + ripple, waterY + depth * .9); | |
| 598 | + color = deep(.25, f) * .04 + fountainJets(mirror, waterY, pan, c, f) * .45 * exp(-depth * 1.5); | |
| 599 | + color += paint(.3, f) * .04 * (.5 + .5 * sin(depth * 40 - c.t + uv.x * 5)); | |
| 600 | + float rimY = -c.extent.y + .07; | |
| 601 | + color = mix(color, deep(.4, f) * .08 + paint(.5, f) * .06, smoothstep(rimY + .01f, rimY - .01f, uv.y)); | |
| 602 | + } | |
| 603 | + return color; | |
| 604 | + } | |
| 605 | + | |
| 606 | + // ---------------------------------------------------------------- 183 Glowstick Rave | |
| 607 | + // A dark rave: dozens of glowsticks wave in circles and figure eights, held by a crowd | |
| 608 | + // you never see, leaving short light trails in drifting smoke. Each stick's motion is | |
| 609 | + // procedural; bands energize their stick groups and attacks throw some sticks spinning | |
| 610 | + // up into the air. Zoom speed drifts the view through the crowd. | |
| 611 | + float3 glowstickRave(Ctx c, constant NativeFrame &f) { | |
| 612 | + float2 uv = c.uv; | |
| 613 | + float pan = c.travel * .08; | |
| 614 | + float smoke = fbm2(uv * 1.2 + float2(c.t * .04 + pan * .3, c.t * .02), 3); | |
| 615 | + float3 color = deep(.4 + uv.y * .05, f) * (.03 + .05 * smoke); | |
| 616 | + float throwArc = dnAccent(c, f); | |
| 617 | + float3 sticks = 0.f; | |
| 618 | + for (int layer = 0; layer < 2; ++layer) { | |
| 619 | + float fl = float(layer); | |
| 620 | + float cell = layer == 0 ? .26 : .42; | |
| 621 | + float2 q = (uv + float2(pan * (.6 + fl * .7), 0)) / cell + fl * float2(.37, .51); | |
| 622 | + float2 base = floor(q); | |
| 623 | + float w = (layer == 0 ? .04 : .05) * c.size; | |
| 624 | + for (int j = -2; j <= 1; ++j) for (int i = -1; i <= 1; ++i) { | |
| 625 | + float2 id = base + float2(i, j); | |
| 626 | + float2 h = hash22(id + fl * 17); | |
| 627 | + float h3 = hash21(id * 1.7 + fl * 5 + 3); | |
| 628 | + if (h.x < (layer == 0 ? .5 : .3)) continue; | |
| 629 | + float band = c.b[int(h3 * 3.99)]; | |
| 630 | + float dirSpin = h3 > .5 ? 1.f : -1.f; | |
| 631 | + float omega = (2.6 + 2 * h.y) * dirSpin; | |
| 632 | + float theta = omega * c.t + c.m * 2.2 * dirSpin + h.x * TAU; | |
| 633 | + float A = .28 * (1 + band * .7); | |
| 634 | + float eight = smoothstep(.3f, .7f, h.y); | |
| 635 | + bool thrown = hash21(id + fl * 3 + 11) > .78; | |
| 636 | + float lift = thrown ? throwArc * 1.7 : 0.f; | |
| 637 | + float spinUp = thrown ? TAU * 1.5 * throwArc : 0.f; | |
| 638 | + float2 hand = id + .5 + (h - .5) * .35 + float2(0, lift); | |
| 639 | + bool twirl = h.y > .8; | |
| 640 | + float3 tint = paint(h3 * 1.1 + fl * .2, f); | |
| 641 | + float energy = (1 + band * 1.6 + (thrown ? c.hit * 2 : 0.f)) * (layer == 0 ? .3f : .6f); | |
| 642 | + float dHand = length(q - hand); | |
| 643 | + sticks += tint * exp(-dHand / .45) * .05 * (.5 + smoke) * energy; | |
| 644 | + if (dHand > A + .7) continue; | |
| 645 | + float2 e = dnPolar(theta), step = dnPolar(-.1 * dirSpin); | |
| 646 | + float stickLen = layer == 0 ? .3f : .36f; | |
| 647 | + for (int g = 0; g < 4; ++g) { | |
| 648 | + float2 pos = hand + A * mix(e, float2(e.y, e.x * e.y), eight); | |
| 649 | + float ang = PI * .5 + .7 * e.y + spinUp; | |
| 650 | + float2 dir = dnPolar(ang) * stickLen; | |
| 651 | + if (twirl) dir = dnMul(dir, dnMul(e, e)); | |
| 652 | + float d = sdSegment(q, pos - dir, pos + dir); | |
| 653 | + float ghost = g == 0 ? 1.f : dnSq(1 - float(g) / 4) * .55; | |
| 654 | + float core = 1 - smoothstep(w * .45f, w, d); | |
| 655 | + float halo = exp(-d / (w * 2.2)) * .3; | |
| 656 | + sticks += (tint * (halo + core * .8) + paint(.95, f) * core * .6) * ghost * energy; | |
| 657 | + e = dnMul(e, step); | |
| 658 | + } | |
| 659 | + } | |
| 660 | + } | |
| 661 | + return color + sticks; | |
| 662 | + } | |
| 663 | + | |
| 664 | + #define DANCE_EFFECTS(X) X(pigmentBurst) X(stretchMembrane) X(kineticMirrors) X(fireDance) X(fountainShow) X(glowstickRave) | |
| 665 | + DANCE_EFFECTS(NATIVE_EFFECT) |
Sources/PulseCanvas/Resources/NativeExpansionAtmospheric.metal added
| 1 | + #include <metal_stdlib> | |
| 2 | + using namespace metal; | |
| 3 | + | |
| 4 | + struct StudyFrame { | |
| 5 | + float phase; | |
| 6 | + float beat; | |
| 7 | + float travel; | |
| 8 | + float scale; | |
| 9 | + float fog; | |
| 10 | + }; | |
| 11 | + | |
| 12 | + constant float studyTurn = 6.28318530718f; | |
| 13 | + | |
| 14 | + constant float flightLength = 16.0f; | |
| 15 | + | |
| 16 | + static float repeatDepth(float depth, float period) { | |
| 17 | + return depth - floor(depth / period) * period; | |
| 18 | + } | |
| 19 | + | |
| 20 | + static float lattice(float3 cell) { | |
| 21 | + cell = fract(cell * 0.1031f); | |
| 22 | + cell += dot(cell, cell.yzx + 33.33f); | |
| 23 | + return fract((cell.x + cell.y) * cell.z); | |
| 24 | + } | |
| 25 | + | |
| 26 | + static float noise3D(float3 position, float depthCells) { | |
| 27 | + float3 cell = floor(position); | |
| 28 | + float3 blend = fract(position); | |
| 29 | + blend = blend * blend * (3.0f - 2.0f * blend); | |
| 30 | + | |
| 31 | + cell.z = repeatDepth(cell.z, depthCells); | |
| 32 | + float3 farCell = float3(cell.xy, repeatDepth(cell.z + 1.0f, depthCells)); | |
| 33 | + float nearLayer = mix( | |
| 34 | + mix(lattice(cell), lattice(cell + float3(1, 0, 0)), blend.x), | |
| 35 | + mix(lattice(cell + float3(0, 1, 0)), lattice(cell + float3(1, 1, 0)), blend.x), | |
| 36 | + blend.y | |
| 37 | + ); | |
| 38 | + float farLayer = mix( | |
| 39 | + mix(lattice(farCell), lattice(farCell + float3(1, 0, 0)), blend.x), | |
| 40 | + mix(lattice(farCell + float3(0, 1, 0)), lattice(farCell + float3(1, 1, 0)), blend.x), | |
| 41 | + blend.y | |
| 42 | + ); | |
| 43 | + return mix(nearLayer, farLayer, blend.z); | |
| 44 | + } | |
| 45 | + | |
| 46 | + // Overlapping randomized spheres form round lobes before finer noise erodes | |
| 47 | + // them. Radii plus center jitter stay below one cell, so eight nodes suffice. | |
| 48 | + static float billowField(float3 position, float depthCells) { | |
| 49 | + float3 cell = floor(position); | |
| 50 | + float3 local = fract(position); | |
| 51 | + float surface = -0.13f; | |
| 52 | + for (uint corner = 0; corner < 8; ++corner) { | |
| 53 | + float3 offset = float3(corner & 1, (corner >> 1) & 1, corner >> 2); | |
| 54 | + float3 node = cell + offset; | |
| 55 | + node.z = repeatDepth(node.z, depthCells); | |
| 56 | + float3 random = float3(lattice(node), lattice(node + 13.1f), lattice(node - 17.4f)); | |
| 57 | + float3 displacement = local - offset - (random - 0.5f) * 0.26f; | |
| 58 | + float radius = 0.58f + 0.19f * random.z; | |
| 59 | + float lobe = radius * radius - dot(displacement, displacement); | |
| 60 | + float join = max(0.09f - abs(lobe - surface), 0.0f); | |
| 61 | + float blend = smoothstep(-0.10f, -0.04f, min(lobe, surface)); | |
| 62 | + surface = max(surface, lobe) + join * join * 2.78f * blend; | |
| 63 | + } | |
| 64 | + return surface; | |
| 65 | + } | |
| 66 | + | |
| 67 | + static float seam(float depth) { | |
| 68 | + float turn = depth * (studyTurn / flightLength); | |
| 69 | + return 0.24f * sin(turn) + 0.13f * sin(turn * 2.0f - 0.7f); | |
| 70 | + } | |
| 71 | + | |
| 72 | + // The camera passes the same world-space filaments as it passes the billows. | |
| 73 | + static float emberSeam(float3 point, float arcDepth, float phase, float beat) { | |
| 74 | + float height = point.y; | |
| 75 | + float depth = 0.30f * sin(height * 1.9f); | |
| 76 | + float center = seam(point.z) + height * 0.54f - 0.43f | |
| 77 | + + (noise3D(float3(height * 4.0f, 2.0f, 1.0f), 16.0f) - 0.5f) * 0.44f | |
| 78 | + + (noise3D(float3(height * 13.0f, 7.0f, 4.0f), 16.0f) - 0.5f) * 0.14f; | |
| 79 | + float2 offset = float2((point.x - center) * 31.0f, (arcDepth - depth) * 6.0f); | |
| 80 | + float mask = smoothstep(-1.65f, -1.18f, height) * (1.0f - smoothstep(0.52f, 1.26f, height)); | |
| 81 | + float sweep = 0.23f + 0.77f * pow(0.5f + 0.5f * cos(height * 3.8f - phase * 5.0f), 3.0f); | |
| 82 | + return exp(-dot(offset, offset)) * mask * sweep * (0.25f + 1.4f * beat); | |
| 83 | + } | |
| 84 | + | |
| 85 | + // Each octave spans an integer number of cells along the flight. Sampling | |
| 86 | + // one flight length later therefore returns the same world-space density. | |
| 87 | + static float smokeDensity(float3 point, bool fine) { | |
| 88 | + float turn = point.z * (studyTurn / flightLength); | |
| 89 | + float across = dot(point.xy, float2(0.86f, -0.51f)) - seam(point.z); | |
| 90 | + float along = dot(point.xy, float2(0.51f, 0.86f)); | |
| 91 | + float width = 1.07f + 0.16f * sin(turn * 3.0f + 0.3f); | |
| 92 | + float shoulder = length(float2(across, along * 0.46f)) - width; | |
| 93 | + float billows = billowField(point * 1.3125f + float3(2.0f, 4.1f, 7.3f), 21.0f); | |
| 94 | + float body = noise3D(point * 0.9375f, 15.0f) - 0.48f; | |
| 95 | + float volume = clamp(shoulder, -1.8f, 0.75f) * 0.76f | |
| 96 | + + billows * 1.42f + body * 0.64f - 0.39f; | |
| 97 | + if (volume > -0.30f) { | |
| 98 | + float curls = noise3D(point * 4.125f + 2.7f, 66.0f); | |
| 99 | + float folds = noise3D(point * 9.1875f - 4.3f, 147.0f); | |
| 100 | + volume += (curls - 0.51f) * 0.40f + (folds - 0.53f) * 0.22f; | |
| 101 | + if (fine) { | |
| 102 | + volume += (noise3D(point * 18.0f + 8.2f, 288.0f) - 0.53f) * 0.12f; | |
| 103 | + } | |
| 104 | + } | |
| 105 | + return smoothstep(-0.06f, 0.29f, volume) * 6.2f; | |
| 106 | + } | |
| 107 | + | |
| 108 | + static float4 backlitRiftColor(float2 viewport, uint2 pixel, StudyFrame frame) { | |
| 109 | + viewport /= frame.scale; | |
| 110 | + float phase = frame.phase; | |
| 111 | + float3 eye = float3(0.0f, 0.0f, 1.75f + frame.travel * (flightLength / studyTurn)); | |
| 112 | + float3 ray = normalize(float3(viewport * 0.46f + float2(0.0f, -0.05f), 1.0f)); | |
| 113 | + float3 lamp = float3(-0.55f, 0.96f, 7.1f); | |
| 114 | + float3 shadow = float3(0.005f, 0.020f, 0.030f); | |
| 115 | + float3 mint = float3(0.13f, 0.81f, 0.53f); | |
| 116 | + float3 copper = float3(1.0f, 0.54f, 0.15f); | |
| 117 | + float transmission = 1.0f; | |
| 118 | + float3 color = float3(0.0f); | |
| 119 | + const int steps = 144; | |
| 120 | + float depthStep = 11.8f / float(steps); | |
| 121 | + float jitter = mix(0.14f, 0.86f, lattice(float3(float2(pixel), 21.0f))); | |
| 122 | + float distanceStep = depthStep / ray.z; | |
| 123 | + | |
| 124 | + for (int step = 0; step < steps && transmission > 0.012f; ++step) { | |
| 125 | + float depth = (float(step) + jitter) * depthStep; | |
| 126 | + float3 fromEye = ray * (depth / ray.z); | |
| 127 | + float3 point = eye + fromEye; | |
| 128 | + // Feather a billow as it passes the lens and as it enters visibility far ahead. | |
| 129 | + float fade = smoothstep(0.32f, 1.45f, depth) * (1.0f - smoothstep(10.0f, 11.8f, depth)); | |
| 130 | + float density = smokeDensity(point, true) * fade * (0.65f + 0.70f * frame.fog); | |
| 131 | + float3 toLamp = lamp - fromEye; | |
| 132 | + float distanceSquared = dot(toLamp, toLamp); | |
| 133 | + | |
| 134 | + float channel = point.x - 0.64f * point.y - seam(point.z); | |
| 135 | + float haze = exp(-abs(channel) * 1.26f) * exp(-distanceSquared * 0.40f); | |
| 136 | + float core = exp(-distanceSquared * 1.25f); | |
| 137 | + color += transmission * haze * distanceStep | |
| 138 | + * (float3(0.09f, 0.43f, 0.39f) + float3(1.18f, 1.29f, 1.02f) * core); | |
| 139 | + float arcDepth = repeatDepth(point.z - 1.5f, flightLength * 0.5f) - flightLength * 0.25f; | |
| 140 | + if (abs(arcDepth) < 0.85f && point.y > -1.65f && point.y < 1.26f) { | |
| 141 | + float arcFade = smoothstep(1.0f, 2.75f, depth) * fade; | |
| 142 | + color += transmission * distanceStep * copper * arcFade * emberSeam(point, arcDepth, phase, frame.beat); | |
| 143 | + } | |
| 144 | + | |
| 145 | + if (density < 0.008f) { | |
| 146 | + continue; | |
| 147 | + } | |
| 148 | + float3 lightDirection = toLamp * rsqrt(max(distanceSquared, 0.002f)); | |
| 149 | + float nearDensity = smokeDensity(point + lightDirection * 0.13f, false); | |
| 150 | + float middleDensity = smokeDensity(point + lightDirection * 0.39f, false); | |
| 151 | + float farDensity = smokeDensity(point + lightDirection * 0.85f, false); | |
| 152 | + float opticalDepth = density * 0.09f + nearDensity * 0.18f | |
| 153 | + + middleDensity * 0.34f + farDensity * 0.55f; | |
| 154 | + float light = exp(-opticalDepth); | |
| 155 | + float scatter = 0.28f + 0.72f * exp(-distanceSquared * 0.052f); | |
| 156 | + float forward = pow(max(dot(ray, lightDirection), 0.0f), 5.0f); | |
| 157 | + | |
| 158 | + float rim = saturate((density - nearDensity) * 0.52f); | |
| 159 | + float3 fill = float3(0.015f, 0.14f, 0.17f) * exp(-density * 0.37f); | |
| 160 | + float3 radiance = shadow + fill + mint * light * scatter * (0.61f + 0.80f * forward + 1.1f * rim); | |
| 161 | + float glint = exp(-distanceSquared * 0.12f) * light * (0.28f + 1.53f * rim); | |
| 162 | + float3 beatOffset = -toLamp + float3(0.40f, 0.10f, 1.0f); | |
| 163 | + float localBeat = frame.beat * exp(-dot(beatOffset, beatOffset) * 1.5f); | |
| 164 | + radiance += copper * glint * (1.24f + 1.0f * localBeat); | |
| 165 | + | |
| 166 | + float opacity = 1.0f - exp(-density * distanceStep); | |
| 167 | + color += transmission * opacity * radiance; | |
| 168 | + transmission *= 1.0f - opacity; | |
| 169 | + } | |
| 170 | + | |
| 171 | + float2 skyOffset = viewport - float2(-0.07f, 0.26f); | |
| 172 | + float sky = exp(-dot(skyOffset, skyOffset) * 2.1f); | |
| 173 | + color += transmission * mix(shadow, float3(0.034f, 0.14f, 0.14f), sky); | |
| 174 | + color *= mix(1.0f, 0.70f, smoothstep(0.55f, 1.9f, length(viewport))); | |
| 175 | + color = 1.0f - exp(-color * 1.66f); | |
| 176 | + color = pow(saturate(color), float3(0.73f)); | |
| 177 | + return float4(color, 1.0f); | |
| 178 | + } | |
| 179 | + | |
| 180 | + static float hash3(float3 p) { | |
| 181 | + p = fract(p * float3(0.1031f, 0.1030f, 0.0973f)); | |
| 182 | + p += dot(p, p.yxz + 33.33f); | |
| 183 | + return fract((p.x + p.y) * p.z); | |
| 184 | + } | |
| 185 | + | |
| 186 | + static float studyNoise3(float3 p, float repeatZ = 0.0f) { | |
| 187 | + float3 cell = floor(p); | |
| 188 | + float3 f = fract(p); | |
| 189 | + f = f * f * (3.0f - 2.0f * f); | |
| 190 | + float3 farCell = cell + float3(0, 0, 1); | |
| 191 | + if (repeatZ > 0.0f) { | |
| 192 | + cell.z -= floor(cell.z / repeatZ) * repeatZ; | |
| 193 | + farCell.z -= floor(farCell.z / repeatZ) * repeatZ; | |
| 194 | + } | |
| 195 | + float a = mix( | |
| 196 | + mix(hash3(cell), hash3(cell + float3(1, 0, 0)), f.x), | |
| 197 | + mix(hash3(cell + float3(0, 1, 0)), hash3(cell + float3(1, 1, 0)), f.x), f.y | |
| 198 | + ); | |
| 199 | + float b = mix( | |
| 200 | + mix(hash3(farCell), hash3(farCell + float3(1, 0, 0)), f.x), | |
| 201 | + mix(hash3(farCell + float3(0, 1, 0)), hash3(farCell + float3(1, 1, 0)), f.x), f.y | |
| 202 | + ); | |
| 203 | + return mix(a, b, f.z); | |
| 204 | + } | |
| 205 | + | |
| 206 | + | |
| 207 | + static float4 displayColor(float3 color, uint2 pixel) { | |
| 208 | + float grain = (hash3(float3(float2(pixel), 19.0f)) - 0.5f) / 255.0f; | |
| 209 | + float3 mapped = pow(saturate(1.0f - exp(-max(color, 0.0f))), float3(0.62f)); | |
| 210 | + return float4(mapped + grain, 1.0f); | |
| 211 | + } | |
| 212 | + | |
| 213 | + // Undersurface. A camera below a moving height field sees transmitted light | |
| 214 | + // within Snell's window, with internal reflection at more grazing angles. | |
| 215 | + static float waterLevel(float2 p, float t) { | |
| 216 | + return 0.13f * sin(dot(p, float2(1.7f, 2.2f)) - t) | |
| 217 | + + 0.085f * sin(dot(p, float2(-2.5f, 1.3f)) + t) | |
| 218 | + + 0.048f * sin(dot(p, float2(4.9f, -2.8f)) + 2.0f * t) | |
| 219 | + + 0.023f * sin(dot(p, float2(8.0f, 5.2f)) - 3.0f * t) | |
| 220 | + + 0.009f * sin(dot(p, float2(-13.0f, 8.1f)) + 4.0f * t); | |
| 221 | + } | |
| 222 | + | |
| 223 | + static float3 waterNormal(float2 p, float t) { | |
| 224 | + const float e = 0.016f; | |
| 225 | + float height = waterLevel(p, t); | |
| 226 | + float2 slope = float2(waterLevel(p + float2(e, 0), t), waterLevel(p + float2(0, e), t)) - height; | |
| 227 | + return normalize(float3(-slope.x, e, -slope.y)); | |
| 228 | + } | |
| 229 | + | |
| 230 | + static float surfaceDistance(float3 eye, float3 ray, float phase) { | |
| 231 | + float lo = 0.0f; | |
| 232 | + float hi = min((-eye.y + 0.31f) / max(ray.y, 0.001f), 30.0f); | |
| 233 | + if (eye.y + ray.y * hi < -0.30f) { | |
| 234 | + return 30.0f; | |
| 235 | + } | |
| 236 | + // Find the first interface even where a shallow ray crosses several waves. | |
| 237 | + const uint steps = 40; | |
| 238 | + float stepSize = hi / float(steps); | |
| 239 | + for (uint i = 1; i <= steps; ++i) { | |
| 240 | + float distance = float(i) * stepSize; | |
| 241 | + float3 point = eye + ray * distance; | |
| 242 | + if (point.y >= waterLevel(point.xz, phase)) { | |
| 243 | + hi = distance; | |
| 244 | + for (uint refine = 0; refine < 5; ++refine) { | |
| 245 | + float middle = 0.5f * (lo + hi); | |
| 246 | + float3 samplePoint = eye + ray * middle; | |
| 247 | + if (samplePoint.y > waterLevel(samplePoint.xz, phase)) { | |
| 248 | + hi = middle; | |
| 249 | + } else { | |
| 250 | + lo = middle; | |
| 251 | + } | |
| 252 | + } | |
| 253 | + return hi; | |
| 254 | + } | |
| 255 | + lo = distance; | |
| 256 | + } | |
| 257 | + return 30.0f; | |
| 258 | + } | |
| 259 | + | |
| 260 | + static float underwaterSilt(float3 eye, float3 ray, float distance, float phase) { | |
| 261 | + float particles = 0.0f; | |
| 262 | + for (int layer = 1; layer <= 11; ++layer) { | |
| 263 | + float depth = 0.65f + float(layer) * 0.68f; | |
| 264 | + if (depth > distance) { | |
| 265 | + break; | |
| 266 | + } | |
| 267 | + float3 point = eye + depth * ray; | |
| 268 | + float2 grid = point.xy * 4.0f + float2(0.22f * sin(phase), -0.21f * cos(phase + float(layer))); | |
| 269 | + float2 cell = floor(grid); | |
| 270 | + float3 seed = float3(cell, float(layer)); | |
| 271 | + float2 center = 0.18f + 0.64f * float2(hash3(seed), hash3(seed + 11.3f)); | |
| 272 | + float2 delta = fract(grid) - center; | |
| 273 | + float size = 0.027f + 0.036f * hash3(seed + 17.0f); | |
| 274 | + float brightness = pow(hash3(seed + 25.4f), 2.0f); | |
| 275 | + particles += exp(-dot(delta, delta) / (size * size)) * exp(-0.16f * depth) * brightness; | |
| 276 | + } | |
| 277 | + return particles; | |
| 278 | + } | |
| 279 | + | |
| 280 | + static float4 undersurfaceColor(float2 uv, uint2 pixel, StudyFrame frame) { | |
| 281 | + float phase = frame.phase; | |
| 282 | + float3 eye = float3(0.29f * sin(phase), (-1.36f + 0.10f * cos(phase)) * frame.scale, 0.23f * cos(phase)); | |
| 283 | + float3 ray = normalize(float3(uv.x * 0.68f, 0.72f + uv.y * 0.91f, 1.0f)); | |
| 284 | + float3 sun = normalize(float3(-0.55f, 0.45f, 0.78f)); | |
| 285 | + float distance = surfaceDistance(eye, ray, phase); | |
| 286 | + float3 color = float3(0.005f, 0.015f, 0.060f) + float3(0.01f, 0.065f, 0.19f) * smoothstep(-0.2f, 0.9f, ray.y); | |
| 287 | + if (distance < 29.9f) { | |
| 288 | + float3 hit = eye + ray * distance; | |
| 289 | + float3 normal = waterNormal(hit.xz, phase); | |
| 290 | + float3 airRay = refract(ray, -normal, 1.333f); | |
| 291 | + float transmission = smoothstep(0.0f, 0.45f, airRay.y); | |
| 292 | + float sunlight = pow(max(dot(airRay, sun), 0.0f), 9.0f); | |
| 293 | + float glint = pow(max(dot(airRay, sun), 0.0f), 90.0f); | |
| 294 | + float3 waterTint = exp(-distance * float3(0.39f, 0.23f, 0.12f)); | |
| 295 | + float3 sky = float3(0.055f, 0.18f, 0.43f) + float3(3.3f, 2.4f, 1.30f) * sunlight | |
| 296 | + + float3(4.6f, 3.9f, 2.7f) * glint; | |
| 297 | + float2 bent = hit.xz * float2(3.3f, 4.2f) + normal.xz * 5.5f; | |
| 298 | + float laceA = abs(sin(bent.x + 1.1f * sin(bent.y + phase))); | |
| 299 | + float laceB = abs(sin(bent.y + 1.4f * sin(bent.x - phase))); | |
| 300 | + float shimmer = exp(-min(laceA, laceB) * 7.0f) * exp(-distance * 0.47f); | |
| 301 | + float2 pool = hit.xz - float2(-0.57f, 1.18f); | |
| 302 | + float poolLight = exp(-dot(pool, pool) * 0.88f); | |
| 303 | + float reflectedSun = pow(max(dot(reflect(ray, -normal), float3(-0.55f, -0.42f, 0.72f)), 0.0f), 28.0f); | |
| 304 | + float3 reflection = float3(0.014f, 0.075f, 0.25f) + reflectedSun * float3(0.32f, 0.42f, 0.63f); | |
| 305 | + color += waterTint * mix(reflection, sky, transmission) | |
| 306 | + + shimmer * float3(0.61f, 0.78f, 1.12f) * (0.055f + 0.75f * poolLight); | |
| 307 | + } | |
| 308 | + float fan = 0.0f; | |
| 309 | + float reach = min(distance, 8.0f); | |
| 310 | + for (uint step = 0; step < 18; ++step) { | |
| 311 | + float3 point = eye + ray * (float(step) + 0.5f) * (reach / 18.0f); | |
| 312 | + float2 cast = point.xz - sun.xz * (point.y / sun.y); | |
| 313 | + float angle = 5.3f * cast.x + 1.4f * cast.y + 2.1f * sin(cast.y * 1.6f + phase); | |
| 314 | + float light = pow(0.5f + 0.5f * cos(angle), 7.0f + 3.0f * frame.beat); | |
| 315 | + float2 pool = cast - float2(-0.57f, 1.18f); | |
| 316 | + float spread = exp(-dot(pool, pool) * 0.26f); | |
| 317 | + fan += light * spread * exp(point.y * 0.44f); | |
| 318 | + } | |
| 319 | + color += fan * (reach / 18.0f) * float3(0.10f, 0.17f, 0.28f) * (0.65f + 0.70f * frame.fog); | |
| 320 | + color += underwaterSilt(eye, ray, distance, phase) * float3(0.038f, 0.081f, 0.13f); | |
| 321 | + return displayColor(color, pixel); | |
| 322 | + } | |
| 323 | + | |
| 324 | + // Mercury Fold. A narrow twisted band collects into larger bulbs, with | |
| 325 | + // separate beads shaped by the same lighting as the main mass. | |
| 326 | + static float softUnion(float a, float b, float width) { | |
| 327 | + float h = max(width - abs(a - b), 0.0f) / width; | |
| 328 | + return min(a, b) - h * h * width * 0.25f; | |
| 329 | + } | |
| 330 | + | |
| 331 | + static float mercuryShape(float3 p, float phase) { | |
| 332 | + float y = clamp(p.y, -1.0f, 1.0f); | |
| 333 | + float center = 0.37f * sin(y * 2.25f - 0.4f) | |
| 334 | + + 0.12f * sin(phase + y * 3.1f); | |
| 335 | + float depth = 0.22f * sin(y * 3.0f + phase); | |
| 336 | + float2 q = float2(p.x - center, p.z - depth); | |
| 337 | + float angle = 1.52f * y + 0.44f * sin(phase - y); | |
| 338 | + float2 band = float2(dot(q, float2(cos(angle), sin(angle))), dot(q, float2(-sin(angle), cos(angle)))); | |
| 339 | + float width = 0.35f + 0.16f * cos(3.5f * y - phase); | |
| 340 | + width *= 1.0f - 0.53f * pow(abs(y), 4.0f); | |
| 341 | + float2 edge = abs(band) - float2(width, 0.039f + 0.024f * cos(4.0f * y + phase)); | |
| 342 | + float ribbon = length(max(edge, 0.0f)) + min(max(edge.x, edge.y), 0.0f) - 0.084f; | |
| 343 | + float2 ends = float2(ribbon + 0.055f, abs(p.y) - 0.95f); | |
| 344 | + ribbon = length(max(ends, 0.0f)) + min(max(ends.x, ends.y), 0.0f) - 0.055f; | |
| 345 | + float3 bulb = float3(0.27f + 0.15f * cos(phase), 0.34f + 0.16f * sin(phase), 0.13f); | |
| 346 | + float shape = softUnion(ribbon, length((p - bulb) * float3(0.90f, 1.2f, 1.0f)) - 0.29f, 0.26f); | |
| 347 | + float3 lower = float3(-0.37f, -0.72f, -0.13f + 0.14f * sin(phase)); | |
| 348 | + shape = softUnion(shape, length(p - lower) - 0.21f, 0.19f); | |
| 349 | + for (uint i = 0; i < 6; ++i) { | |
| 350 | + float turn = phase + 1.83f * float(i); | |
| 351 | + float side = i % 2 == 0 ? -1.0f : 1.0f; | |
| 352 | + float3 drop = float3(side * (0.67f + float(i) * 0.061f) + 0.08f * cos(turn), | |
| 353 | + -0.82f + float(i) * 0.31f + 0.11f * sin(turn), | |
| 354 | + 0.27f * cos(turn)); | |
| 355 | + shape = min(shape, length(p - drop) - (0.045f + 0.027f * (0.5f + 0.5f * sin(turn)))); | |
| 356 | + } | |
| 357 | + float ripples = sin(p.y * 23.0f - phase * 2.0f + 3.6f * p.x) * sin(p.x * 13.0f + p.z * 8.0f); | |
| 358 | + return shape + ripples * 0.012f; | |
| 359 | + } | |
| 360 | + | |
| 361 | + static float3 studioReflection(float3 ray) { | |
| 362 | + float whiteStrip = exp(-pow((ray.x + 0.53f) * 7.5f, 2.0f)) * smoothstep(-0.55f, 0.22f, ray.y); | |
| 363 | + float softBox = pow(max(dot(ray, normalize(float3(0.29f, 0.85f, -0.43f))), 0.0f), 13.0f); | |
| 364 | + float amber = exp(-pow((ray.y + 0.38f + 0.18f * ray.x) * 7.5f, 2.0f)) * smoothstep(-0.2f, 0.77f, ray.x); | |
| 365 | + float blue = pow(max(dot(ray, normalize(float3(0.84f, 0.25f, 0.23f))), 0.0f), 14.0f); | |
| 366 | + return float3(0.008f, 0.012f, 0.025f) + whiteStrip * float3(1.6f, 1.85f, 2.0f) | |
| 367 | + + softBox * float3(1.35f, 1.2f, 1.04f) + amber * float3(2.25f, 0.76f, 0.25f) | |
| 368 | + + blue * float3(0.12f, 0.23f, 0.46f); | |
| 369 | + } | |
| 370 | + | |
| 371 | + static float4 mercuryFoldColor(float2 uv, uint2 pixel, StudyFrame frame) { | |
| 372 | + float phase = frame.phase; | |
| 373 | + float azimuth = 0.21f * sin(phase); | |
| 374 | + float3 eye = float3(3.6f * sin(azimuth), 0.15f + 0.19f * cos(phase), -3.6f * cos(azimuth)); | |
| 375 | + float3 forward = normalize(-eye); | |
| 376 | + float3 right = normalize(cross(float3(0, 1, 0), forward)); | |
| 377 | + float3 up = cross(forward, right); | |
| 378 | + float3 ray = normalize(forward + (0.34f / frame.scale) * (right * (uv.x + 0.13f) + up * uv.y)); | |
| 379 | + float tilt = -0.32f; | |
| 380 | + float2 axisX = float2(cos(tilt), sin(tilt)); | |
| 381 | + float2 axisY = float2(-sin(tilt), cos(tilt)); | |
| 382 | + float3 eyeLocal = float3(dot(eye.xy, axisX), dot(eye.xy, axisY), eye.z); | |
| 383 | + float3 rayLocal = float3(dot(ray.xy, axisX), dot(ray.xy, axisY), ray.z); | |
| 384 | + float at = 2.05f; | |
| 385 | + float3 point; | |
| 386 | + float distance = 2.0f; | |
| 387 | + for (uint step = 0; step < 100 && at < 5.7f; ++step) { | |
| 388 | + point = eyeLocal + rayLocal * at; | |
| 389 | + distance = mercuryShape(point, phase); | |
| 390 | + if (distance < 0.0018f) { | |
| 391 | + break; | |
| 392 | + } | |
| 393 | + at += max(distance * 0.46f, 0.003f); | |
| 394 | + } | |
| 395 | + float halo = exp(-dot(uv * float2(0.8f, 1.2f), uv * float2(0.8f, 1.2f)) * 1.5f); | |
| 396 | + float3 color = float3(0.003f, 0.003f, 0.007f) + halo * float3(0.019f, 0.012f, 0.011f); | |
| 397 | + if (distance < 0.0018f) { | |
| 398 | + const float e = 0.003f; | |
| 399 | + float3 normal = normalize(float3( | |
| 400 | + mercuryShape(point + float3(e, 0, 0), phase) - mercuryShape(point - float3(e, 0, 0), phase), | |
| 401 | + mercuryShape(point + float3(0, e, 0), phase) - mercuryShape(point - float3(0, e, 0), phase), | |
| 402 | + mercuryShape(point + float3(0, 0, e), phase) - mercuryShape(point - float3(0, 0, e), phase) | |
| 403 | + )); | |
| 404 | + float3 reflected = reflect(rayLocal, normal); | |
| 405 | + float rim = pow(1.0f - saturate(dot(-rayLocal, normal)), 3.0f); | |
| 406 | + float sheen = 0.72f + 0.24f * sin(point.y * 5.4f - phase + normal.x * 2.6f); | |
| 407 | + color = studioReflection(reflected) * sheen + float3(0.20f, 0.08f, 0.035f) * rim | |
| 408 | + * (0.54f + 0.24f * frame.beat); | |
| 409 | + } | |
| 410 | + return displayColor(color, pixel); | |
| 411 | + } | |
| 412 | + | |
| 413 | + // Ember Front. Particles live on periodic depth layers. The camera advances | |
| 414 | + // through the layers and the nearest grains stretch with their screen velocity. | |
| 415 | + static float4 emberFrontColor(float2 uv, uint2 pixel, StudyFrame frame) { | |
| 416 | + float phase = frame.phase; | |
| 417 | + float travel = 24.0f * frame.travel / studyTurn; | |
| 418 | + float3 ray = normalize(float3(uv * 0.57f, 1.0f)); | |
| 419 | + float ridge = 0.40f + uv.y * 0.29f + 0.11f * sin(uv.y * 3.1f + phase); | |
| 420 | + float cloud = exp(-abs(uv.x - ridge) * 2.1f); | |
| 421 | + float smoke = studyNoise3(float3(uv * 1.75f + float2(cos(phase), sin(phase)) * 0.46f, 7.6f)); | |
| 422 | + float3 color = float3(0.006f, 0.004f, 0.009f) + | |
| 423 | + cloud * (0.26f + 0.74f * smoke) * float3(0.15f, 0.031f, 0.012f); | |
| 424 | + const float layerSpacing = 0.67f; | |
| 425 | + | |
| 426 | + for (int i = 0; i < 28; ++i) { | |
| 427 | + float layer = floor(travel) + float(i); | |
| 428 | + float z = (layer - travel) * layerSpacing; | |
| 429 | + if (z < 0.45f) { | |
| 430 | + continue; | |
| 431 | + } | |
| 432 | + float seed = layer - floor(layer / 24.0f) * 24.0f; | |
| 433 | + float2 position = ray.xy * (z / ray.z); | |
| 434 | + float curl = sin(seed * (studyTurn / 24.0f) + position.y * 0.66f); | |
| 435 | + float shift = 1.07f * curl + 0.25f * sin(2.0f * phase + position.y * 1.1f); | |
| 436 | + float2 currentPoint = float2(position.x - shift - 0.30f * position.y, position.y); | |
| 437 | + // Rotate each layer's lattice in its own plane so rows of particles in | |
| 438 | + // different depth layers cannot line up into horizontal seams. | |
| 439 | + float rotation = studyTurn * hash3(float3(seed, 14.9f, 8.7f)); | |
| 440 | + float2 axisX = float2(cos(rotation), sin(rotation)); | |
| 441 | + float2 axisY = float2(-axisX.y, axisX.x); | |
| 442 | + float2 grid = float2(dot(currentPoint, axisX), dot(currentPoint, axisY)) * 4.8f; | |
| 443 | + float2 base = floor(grid); | |
| 444 | + float3 sampleSeed = float3(base, seed); | |
| 445 | + float2 center = 0.29f + 0.42f * float2(hash3(sampleSeed), hash3(sampleSeed + 19.27f)); | |
| 446 | + float2 delta = fract(grid) - center; | |
| 447 | + float random = hash3(sampleSeed + 7.36f); | |
| 448 | + float2 cellPoint = (axisX * (base.x + center.x) + axisY * (base.y + center.y)) / 4.8f; | |
| 449 | + float front = 0.26f + 0.42f * sin(seed * (studyTurn / 12.0f)); | |
| 450 | + float current = cellPoint.x - front; | |
| 451 | + float veil = smoothstep(-0.60f, 0.63f, current) * (1.0f - 0.55f * smoothstep(1.5f, 3.5f, current)); | |
| 452 | + float pockets = studyNoise3(float3(cellPoint, seed * 0.25f), 6.0f); | |
| 453 | + float occupancy = 0.032f + 0.64f * veil * smoothstep(0.20f, 0.75f, pockets); | |
| 454 | + if (random > occupancy) { | |
| 455 | + continue; | |
| 456 | + } | |
| 457 | + float brightness = hash3(sampleSeed + 37.0f); | |
| 458 | + float2 radial = position + float2(0.002f, -0.002f); | |
| 459 | + float2 outward = normalize(float2(dot(radial, axisX), dot(radial, axisY))); | |
| 460 | + float2 stroke = float2(dot(delta, outward), dot(delta, float2(-outward.y, outward.x))); | |
| 461 | + float width = frame.scale * (0.028f + 0.044f * brightness) * (1.0f + 0.020f * z); | |
| 462 | + float length = width * (1.0f + 1.82f * saturate(3.5f / z)); | |
| 463 | + float footprint = dot(stroke / float2(length, width), stroke / float2(length, width)); | |
| 464 | + float blast = smoothstep(0.5f, 1.55f, z) * (1.0f - smoothstep(9.0f, 17.5f, z)); | |
| 465 | + float core = exp(-footprint * 1.25f); | |
| 466 | + float glow = exp(-footprint * 0.25f) * 0.21f; | |
| 467 | + float3 copper = mix(float3(0.72f, 0.11f, 0.04f), float3(2.4f, 0.86f, 0.19f), brightness * brightness); | |
| 468 | + float3 grain = mix(copper, float3(0.18f, 0.27f, 0.63f), smoothstep(0.72f, 0.92f, hash3(sampleSeed + 43.9f))); | |
| 469 | + float pulse = 1.0f + 0.6f * frame.beat * smoothstep(0.6f, 1.0f, brightness); | |
| 470 | + float falloff = 1.0f - smoothstep(0.17f, 0.29f, max(abs(delta.x), abs(delta.y))); | |
| 471 | + color += grain * (core + glow) * blast * pulse * falloff * (0.11f + 0.74f * brightness); | |
| 472 | + } | |
| 473 | + return displayColor(color, pixel); | |
| 474 | + } | |
| 475 | + | |
| 476 | + // Anvil Flyover. A repeating terrain-like cloud deck, seen from above. | |
| 477 | + // Sampling X in the periodic dimension makes a continuous lateral flight. | |
| 478 | + static float anvilDensity(float3 p, bool detail) { | |
| 479 | + float3 q = p.zyx; | |
| 480 | + float large = studyNoise3(q * 0.25f + float3(21.0f, 4.0f, 1.0f), 4.0f); | |
| 481 | + float banks = studyNoise3(q * 0.625f + float3(0.0f, 3.0f, 11.1f), 10.0f); | |
| 482 | + float tower = smoothstep(0.51f, 0.82f, large); | |
| 483 | + float crowns = studyNoise3(q * 0.875f + float3(3.4f, 9.3f, 5.2f), 14.0f); | |
| 484 | + float ceiling = -0.48f + banks * 1.33f + tower * (1.69f + 1.30f * crowns); | |
| 485 | + const float base = -2.0f; | |
| 486 | + float volume = min(ceiling - p.y, p.y - base); | |
| 487 | + if (volume > -0.85f && detail) { | |
| 488 | + float fleece = studyNoise3(q * 1.5f + 6.0f, 24.0f); | |
| 489 | + float grain = studyNoise3(q * 3.75f - 4.4f, 60.0f); | |
| 490 | + float billows = studyNoise3(q * 8.0f + 11.3f, 128.0f); | |
| 491 | + volume += (fleece - 0.50f) * 1.40f + (grain - 0.53f) * 0.47f + (billows - 0.52f) * 0.19f; | |
| 492 | + } | |
| 493 | + return smoothstep(-0.23f, 0.28f, volume) * 2.55f; | |
| 494 | + } | |
| 495 | + | |
| 496 | + static float4 anvilFlyoverColor(float2 uv, uint2 pixel, StudyFrame frame) { | |
| 497 | + float phase = frame.phase; | |
| 498 | + float3 eye = float3(2.9f + 16.0f * (frame.travel / studyTurn), 2.62f + 0.31f * sin(phase) + (frame.scale - 1.0f) * 0.58f, 1.8f); | |
| 499 | + float3 ray = normalize(float3(0.43f * uv.x + 0.11f, 0.46f * uv.y - 0.21f, 1.0f)); | |
| 500 | + float3 sun = normalize(float3(0.56f, 0.28f, 0.91f)); | |
| 501 | + float towardSun = max(dot(ray, sun), 0.0f); | |
| 502 | + float horizon = exp(-abs(ray.y + 0.055f) * 5.5f); | |
| 503 | + float3 sky = mix(float3(0.041f, 0.039f, 0.15f), float3(0.45f, 0.22f, 0.31f), horizon); | |
| 504 | + sky += float3(0.50f, 0.27f, 0.31f) * pow(towardSun, 26.0f); | |
| 505 | + sky += float3(0.76f, 0.49f, 0.33f) * pow(towardSun, 260.0f); | |
| 506 | + float3 color = float3(0.0f); | |
| 507 | + float transmittance = 1.0f; | |
| 508 | + const uint steps = 116; | |
| 509 | + const float stride = 0.19f; | |
| 510 | + float offset = mix(0.12f, 0.88f, hash3(float3(float2(pixel), 3.1f))); | |
| 511 | + for (uint step = 0; step < steps && transmittance > 0.015f; ++step) { | |
| 512 | + float distance = 0.43f + (float(step) + offset) * stride; | |
| 513 | + float3 point = eye + ray * distance; | |
| 514 | + if (point.y < -2.45f) { | |
| 515 | + break; | |
| 516 | + } | |
| 517 | + float visibility = smoothstep(0.43f, 1.85f, distance) * (1.0f - smoothstep(17.0f, 22.0f, distance)); | |
| 518 | + float density = anvilDensity(point, true) * visibility * (0.65f + 0.70f * frame.fog); | |
| 519 | + if (density < 0.005f) { | |
| 520 | + continue; | |
| 521 | + } | |
| 522 | + | |
| 523 | + float nearDensity = anvilDensity(point + sun * 0.24f, true); | |
| 524 | + float occlusion = density * 0.18f | |
| 525 | + + nearDensity * 0.26f | |
| 526 | + + anvilDensity(point + sun * 0.65f, true) * 0.53f | |
| 527 | + + anvilDensity(point + sun * 1.6f, false) * 0.71f; | |
| 528 | + float light = exp(-occlusion); | |
| 529 | + float lavender = 0.60f + 0.40f * smoothstep(-0.9f, 1.4f, point.y); | |
| 530 | + float fillDensity = anvilDensity(point + float3(-0.29f, 0.23f, -0.37f), true); | |
| 531 | + float fill = exp(-fillDensity * 0.94f - density * 0.27f); | |
| 532 | + float3 shade = (float3(0.028f, 0.024f, 0.063f) + fill * float3(0.11f, 0.13f, 0.22f)) * lavender; | |
| 533 | + float rim = saturate((density - nearDensity) * 1.1f); | |
| 534 | + float3 radiance = shade + light * float3(0.98f, 0.85f, 1.06f) * (0.78f + 0.39f * towardSun) | |
| 535 | + + rim * light * pow(towardSun, 3.0f) * float3(0.69f, 0.26f, 0.14f); | |
| 536 | + float pocket = studyNoise3(point.zyx * 0.5f + 5.1f, 8.0f); | |
| 537 | + float discharge = smoothstep(0.68f, 0.83f, pocket) * frame.beat * frame.beat; | |
| 538 | + radiance += float3(0.11f, 0.061f, 0.15f) * discharge * (1.0f - light); | |
| 539 | + radiance = mix(radiance, sky * 0.87f, smoothstep(12.0f, 26.0f, distance) * 0.66f); | |
| 540 | + float opacity = 1.0f - exp(-density * stride); | |
| 541 | + color += transmittance * opacity * radiance; | |
| 542 | + transmittance *= 1.0f - opacity; | |
| 543 | + } | |
| 544 | + color += transmittance * sky; | |
| 545 | + return displayColor(color, pixel); | |
| 546 | + } | |
| 547 | + | |
| 548 | + // Pigment Strata. Inverse advection of horizontal pigment interfaces through | |
| 549 | + // rotating cells. Heterogeneous angular speeds stretch the edges into filaments. | |
| 550 | + static float2 pigmentVortex(float2 p, float2 center, float radius, float turn) { | |
| 551 | + float2 offset = p - center; | |
| 552 | + float weight = (1.0f - smoothstep(0.1f, 1.0f, length(offset) / radius)); | |
| 553 | + float angle = turn * weight * weight; | |
| 554 | + float2 rotated = float2( | |
| 555 | + dot(offset, float2(cos(angle), -sin(angle))), | |
| 556 | + dot(offset, float2(sin(angle), cos(angle))) | |
| 557 | + ); | |
| 558 | + return center + rotated; | |
| 559 | + } | |
| 560 | + | |
| 561 | + static float2 pigmentRow(float2 p, float height, float spacing, float phase, float offset) { | |
| 562 | + float tile = floor(p.x / spacing + offset) - offset; | |
| 563 | + float2 center = float2((tile + 0.5f) * spacing, height); | |
| 564 | + float spin = 2.9f + 0.73f * sin(phase + offset * 4.1f) | |
| 565 | + + 0.75f * sin(tile * 1.83f + offset); | |
| 566 | + return pigmentVortex(p, center, spacing * 0.49f, spin); | |
| 567 | + } | |
| 568 | + | |
| 569 | + static float4 pigmentStrataColor(float2 uv, uint2 pixel, StudyFrame frame) { | |
| 570 | + float phase = frame.phase; | |
| 571 | + float2 p = uv * float2(1.04f, 1.0f) / frame.scale; | |
| 572 | + p.x += 0.25f * sin(phase + p.y * 2.6f); | |
| 573 | + p.y += 0.12f * sin(1.7f * p.x + phase) + 0.065f * sin(4.4f * p.x - phase); | |
| 574 | + p = pigmentRow(p, 0.47f, 1.10f, phase, 0.23f); | |
| 575 | + p = pigmentRow(p, 0.10f, 1.65f, -phase, 0.66f); | |
| 576 | + p = pigmentRow(p, -0.51f, 0.84f, phase, 0.81f); | |
| 577 | + p = pigmentVortex(p, float2(0.17f, -0.23f), 0.83f, 7.8f + 2.3f * cos(phase)); | |
| 578 | + float wash = studyNoise3(float3(p * float2(3.3f, 22.0f) + float2(cos(phase), sin(phase)) * 0.37f, 4.3f)); | |
| 579 | + float grain = studyNoise3(float3(p * float2(18.0f, 78.0f), 12.1f)); | |
| 580 | + float boundary = p.y + (wash - 0.50f) * 0.075f + (grain - 0.50f) * 0.021f; | |
| 581 | + float3 color = float3(0.06f, 0.077f, 0.18f); | |
| 582 | + color = mix(color, float3(0.31f, 0.05f, 0.087f), smoothstep(-0.95f, -0.80f, boundary)); | |
| 583 | + color = mix(color, float3(0.78f, 0.28f, 0.10f), smoothstep(-0.62f, -0.49f, boundary)); | |
| 584 | + color = mix(color, float3(0.14f, 0.033f, 0.085f), smoothstep(-0.25f, -0.13f, boundary)); | |
| 585 | + color = mix(color, float3(1.20f, 0.72f, 0.35f), smoothstep(0.06f, 0.16f, boundary)); | |
| 586 | + color = mix(color, float3(0.25f, 0.141f, 0.235f), smoothstep(0.40f, 0.52f, boundary)); | |
| 587 | + color = mix(color, float3(0.024f, 0.045f, 0.11f), smoothstep(0.73f, 0.85f, boundary)); | |
| 588 | + float fibers = pow(0.5f + 0.5f * sin(boundary * 112.0f + wash * 5.0f), 10.0f); | |
| 589 | + float granulation = studyNoise3(float3(p * float2(57.0f, 131.0f), 9.2f)); | |
| 590 | + float mineral = 0.69f + 0.34f * wash + 0.24f * grain + 0.16f * granulation; | |
| 591 | + float luster = exp(-abs(boundary + 0.15f) * 20.0f) + exp(-abs(boundary - 0.15f) * 20.0f); | |
| 592 | + float2 glintOffset = (uv - float2(-0.30f, 0.38f)) * float2(0.5f, 1.65f); | |
| 593 | + float glint = exp(-dot(glintOffset, glintOffset) * 1.8f) * (0.2f + 0.8f * wash); | |
| 594 | + color = color * mineral + (0.065f + 0.05f * frame.beat + glint * 0.12f) | |
| 595 | + * luster * fibers * float3(1.0f, 0.72f, 0.32f); | |
| 596 | + float falloff = 1.0f - 0.23f * smoothstep(0.25f, 1.85f, length(uv)); | |
| 597 | + return displayColor(color * falloff, pixel); | |
| 598 | + } | |
| 599 | + | |
| 600 | + #if defined(PULSECANVAS_STUDY) | |
| 601 | + struct PreviewFrame { float phase; float beat; }; | |
| 602 | + static float2 screenPoint(uint2 pixel, uint2 size) { | |
| 603 | + float2 p = (float2(pixel) + 0.5f - 0.5f * float2(size)) * (2.0f / float(min(size.x, size.y))); | |
| 604 | + return float2(p.x, -p.y); | |
| 605 | + } | |
| 606 | + | |
| 607 | + #define STUDY_ENTRY(entry, color) \ | |
| 608 | + kernel void entry(texture2d<float, access::write> output [[texture(0)]], \ | |
| 609 | + constant PreviewFrame& preview [[buffer(0)]], uint2 pixel [[thread_position_in_grid]]) { \ | |
| 610 | + uint2 size = uint2(output.get_width(), output.get_height()); \ | |
| 611 | + if (any(pixel >= size)) { return; } \ | |
| 612 | + StudyFrame frame = {preview.phase, preview.beat, preview.phase, 1.0f, 0.5f}; \ | |
| 613 | + output.write(color(screenPoint(pixel, size), pixel, frame), pixel); \ | |
| 614 | + } | |
| 615 | + #else | |
| 616 | + static float4 styleAtmosphere(float4 color, constant NativeFrame& f) { | |
| 617 | + float3 rgb = color.rgb; | |
| 618 | + // The catalog default uses the authored grade. Alternate palettes tint | |
| 619 | + // the same lights and shadows using the standard five app color stops. | |
| 620 | + if (f.colors[0].w > 0.5f) { | |
| 621 | + float value = dot(rgb, float3(0.2126f, 0.7152f, 0.0722f)); | |
| 622 | + float3 tint = paint(value, f); | |
| 623 | + rgb = mix(rgb, tint * value / max(max(tint.r, tint.g), max(tint.b, 0.01f)), 0.68f); | |
| 624 | + } | |
| 625 | + return float4(saturate(rgb * f.style.x), color.a); | |
| 626 | + } | |
| 627 | + | |
| 628 | + #define STUDY_ENTRY(entry, color) \ | |
| 629 | + fragment float4 entry##Fragment(float4 position [[position]], constant NativeFrame& f [[buffer(0)]]) { \ | |
| 630 | + Ctx c = makeContext(position.xy, f); \ | |
| 631 | + float phase = fract(c.t / 8.0f) * studyTurn; \ | |
| 632 | + float travel = fract(c.travel / 8.0f) * studyTurn; \ | |
| 633 | + float beat = saturate(c.hit * 0.4f + f.rhythm.z * 0.6f); \ | |
| 634 | + StudyFrame frame = {phase, beat, travel, c.size, c.fog}; \ | |
| 635 | + return styleAtmosphere(color(c.uv, uint2(position.xy), frame), f); \ | |
| 636 | + } | |
| 637 | + #endif | |
| 638 | + | |
| 639 | + STUDY_ENTRY(smokeFrame, backlitRiftColor) | |
| 640 | + STUDY_ENTRY(undersurface, undersurfaceColor) | |
| 641 | + STUDY_ENTRY(mercuryFold, mercuryFoldColor) | |
| 642 | + STUDY_ENTRY(emberFront, emberFrontColor) | |
| 643 | + STUDY_ENTRY(anvilFlyover, anvilFlyoverColor) | |
| 644 | + STUDY_ENTRY(pigmentStrata, pigmentStrataColor) | |
| 645 | + #undef STUDY_ENTRY |
Sources/PulseCanvas/Resources/NativeExpansionBore.metal added
| 1 | + // Original PulseCanvas designs 300–309: tunnels with new structures. None of these is a | |
| 2 | + // centred polar tunnel with a pattern on its wall; each has its own geometry (a bending path, | |
| 3 | + // an off-axis camera, two bores, a coil, pleats, open sky, a vertical shaft, veils, pipes | |
| 4 | + // seen from outside, a twisting ribbon). Original procedural code; see the prelude. | |
| 5 | + | |
| 6 | + // ---------------------------------------------------------------- shared helpers | |
| 7 | + float boreAttack(Ctx c) { return smoothstep(.04f, .7f, c.hit); } | |
| 8 | + float boreBand(Ctx c, float id) { return c.b[min(3, int(id - 4 * floor(id / 4)))]; } | |
| 9 | + float boreWrap(float x, float period) { return x - period * floor(x / period); } | |
| 10 | + float boreSq(float x) { return x * x; } | |
| 11 | + float boreTwinkle(float seed, float t) { return pow(.5f + .5f * sin(t * (4 + 5 * seed) + seed * 37), 6.f); } | |
| 12 | + // Exit distance from inside a cylinder of radius r around the z axis (o = origin in the cross-section). | |
| 13 | + float boreCylinder(float2 o, float3 rd, float r) { | |
| 14 | + float a = max(dot(rd.xy, rd.xy), 1e-6f), b = dot(o, rd.xy), k = dot(o, o) - r * r; | |
| 15 | + return (-b + sqrt(max(b * b - a * k, 0.f))) / a; | |
| 16 | + } | |
| 17 | + | |
| 18 | + // ---------------------------------------------------------------- 300 Serpent Bore | |
| 19 | + // A scaled tube whose centreline winds through space. The camera rides the bends, so the | |
| 20 | + // far end swings around the frame while the walls sweep past. Overlapping glowing plates | |
| 21 | + // line the wall: bass lifts rows of plates, low-mids sweep a spiral sheen, high-mids light | |
| 22 | + // four dorsal stripes, highs glint the rims and attacks roll a lit wave toward the viewer. | |
| 23 | + float2 boreSerpentPath(float z) { | |
| 24 | + return float2(1.9 * sin(z * .23) + .9 * sin(z * .41 + 1.3), 1.4 * sin(z * .19 + 2.1) + .8 * sin(z * .37 + .4)); | |
| 25 | + } | |
| 26 | + | |
| 27 | + float3 serpentBore(Ctx c, constant NativeFrame &f) { | |
| 28 | + float camZ = c.travel * .85; | |
| 29 | + // The view follows the path's recent heading, so the bends ahead swing the far end around the frame. | |
| 30 | + float3 eye = float3(boreSerpentPath(camZ), camZ); | |
| 31 | + float3 heading = float3(boreSerpentPath(camZ + .4) - boreSerpentPath(camZ - 1.6), 2); | |
| 32 | + float roll = .4 * sin(c.t * .06); | |
| 33 | + float3 rd = cameraRay(c.uv, heading, float3(sin(roll), cos(roll), 0), 1.2); | |
| 34 | + float t = .02; | |
| 35 | + for (int i = 0; i < 56; ++i) { | |
| 36 | + float3 p = eye + rd * t; | |
| 37 | + float d = 1 - length(p.xy - boreSerpentPath(p.z)); | |
| 38 | + if (d < .001 + t * .002 || t > 42) break; | |
| 39 | + t += d * .65; | |
| 40 | + } | |
| 41 | + float3 p = eye + rd * t; | |
| 42 | + float2 q = p.xy - boreSerpentPath(p.z); | |
| 43 | + const float columns = 22; | |
| 44 | + float density = 2.7 / c.size; | |
| 45 | + float2 g = float2(atan2(q.y, q.x) * columns / TAU, p.z * density); | |
| 46 | + // Staggered plates; the row further away lies on top, so every visible rim faces the viewer. | |
| 47 | + float base = floor(g.y), cover = 9, lift = 0; | |
| 48 | + float4 s = 0; | |
| 49 | + for (int k = 1; k >= -1; --k) { | |
| 50 | + float row = base + float(k), shift = .5 * boreWrap(row, 2); | |
| 51 | + float col = floor(g.x - shift + .5); | |
| 52 | + float rowLift = c.b.x * boreSq(boreSq(.5 + .5 * sin(row * .55 - c.t * 1.6))); | |
| 53 | + float2 local = g - float2(col + shift, row); | |
| 54 | + float d = length(local * float2(1, 1.08)) - (.72 + .1 * rowLift); | |
| 55 | + s = float4(d, local.y, col, row); lift = rowLift; | |
| 56 | + if (d < 0) break; | |
| 57 | + cover = min(cover, d); | |
| 58 | + } | |
| 59 | + float colId = boreWrap(s.z, columns), row = s.w; | |
| 60 | + float seed = hash21(float2(colId, row)); | |
| 61 | + float foot = t * c.px * density * 1.4 + .01; | |
| 62 | + float inner = clamp(-s.x / .72, 0.f, 1.f); | |
| 63 | + float rim = 1 - smoothstep(0.f, .08f + foot, -s.x); | |
| 64 | + float shade = 1 - .7 * exp(-max(cover, 0.f) * 8); | |
| 65 | + float sheen = .3 + .7 * boreSq(1 - inner); | |
| 66 | + float hue = row * .031 + .22 * sin(colId * TAU / columns) + seed * .08; | |
| 67 | + float spiral = c.b.y * pow(.5f + .5f * sin(colId * TAU / columns * 2 + row * .21 - c.t * .8), 6.f); | |
| 68 | + float stripe = c.b.z * step(boreWrap(colId, 4), .5f); | |
| 69 | + float wave = c.hit * exp(-boreSq((row / density - camZ - 1.2 - 9 * boreAttack(c)) / .8)); | |
| 70 | + float3 plate = paint(hue, f) * (.12 + .88 * sheen * sheen) * shade * (.62 + lift * 1.6 + spiral * 2 + stripe * 1.3 + wave * 2.2); | |
| 71 | + plate += paint(hue + .3, f) * rim * shade * (.5 + lift * 1.2 + wave * 1.8); | |
| 72 | + plate += paint(.92, f) * rim * c.b.w * boreTwinkle(seed, c.t) * 2.5; | |
| 73 | + float3 haze = paint(.8 + .1 * sin(c.t * .1), f) * .4; | |
| 74 | + return mix(haze, plate / (1 + t * .08), exp(-t * (.05 + c.fog * .04))); | |
| 75 | + } | |
| 76 | + NATIVE_EFFECT(serpentBore) | |
| 77 | + | |
| 78 | + // ---------------------------------------------------------------- 301 Ringworld Drift | |
| 79 | + // Inside a vast cylinder habitat, standing just above its floor and looking down its axis. | |
| 80 | + // Terraced bands ring the habitat: each one hugs the floor below, curves up both sides and | |
| 81 | + // closes overhead, so they nest as eccentric arches around a vanishing point near the floor. | |
| 82 | + // The axial sun line hangs overhead. Each terrace's lamps pulse with its band, and attacks | |
| 83 | + // send light climbing up both sides of the nearer terraces to meet overhead. | |
| 84 | + float3 ringworldDrift(Ctx c, constant NativeFrame &f) { | |
| 85 | + float stand = -PI * .5 + .45 * sin(c.t * .045) + .15 * sin(c.t * .11); | |
| 86 | + float2 radial = float2(cos(stand), sin(stand)), side = float2(-radial.y, radial.x); | |
| 87 | + float2 eye = radial * .84; | |
| 88 | + float3 rd = cameraRay(c.uv, float3(-radial * .62 + side * .1 * sin(c.t * .07), 1), float3(-radial, 0), 1.05); | |
| 89 | + float t = min(boreCylinder(eye, rd, 1), 90.f); | |
| 90 | + float2 q = eye + rd.xy * t; | |
| 91 | + float camZ = c.travel * 1.8, z = t * rd.z + camZ; | |
| 92 | + float angle = atan2(q.y, q.x); | |
| 93 | + float foot = t * c.px / 1.05; | |
| 94 | + float graze = max(abs(dot(rd.xy, q)), .03f); | |
| 95 | + // Terraces along the axis: a lit face rising to a bright lip, then a shadowed step. | |
| 96 | + float span = 1.7 * c.size, u = z / span, terrace = floor(u), fr = u - terrace; | |
| 97 | + float footU = foot / graze / span; | |
| 98 | + float seed = hash11(terrace + 11), band = boreBand(c, terrace); | |
| 99 | + float face = smoothstep(0.f, .08f + footU, fr) * (1 - smoothstep(.86f - footU, .9f, fr)); | |
| 100 | + float lip = glow(fr - .9, .018 + footU); | |
| 101 | + // Each terrace is divided into fields around the habitat; some glow as panels of light. | |
| 102 | + const float sectors = 18; | |
| 103 | + float sector = angle * sectors / TAU, sectorId = boreWrap(floor(sector), sectors); | |
| 104 | + float seam = glow(abs(fract(sector) - .5) - .5, .02 + foot * sectors / TAU / max(graze, .15f)); | |
| 105 | + float panelSeed = hash21(float2(terrace, sectorId)); | |
| 106 | + float panel = smoothstep(.3f, .65f, panelSeed) * (.6 + band * 2.2 * boreSq(.5 + .5 * sin(sectorId * 2.1 + terrace - c.t * 1.4))); | |
| 107 | + float hue = .32 + .26 * sin(terrace * .7) + panelSeed * .25; | |
| 108 | + float3 col = mix(deep(hue + .35, f), paint(hue, f), .3 + .7 * fr) * face * (.12 + (.3 + .7 * fr * fr) * panel) * (1 - seam * .75) + deep(.5, f) * .06; | |
| 109 | + // Lamps around each lip, pulsing with the terrace's band. | |
| 110 | + const float lamps = 56; | |
| 111 | + float around = angle * lamps / TAU, lampId = floor(around + .5); | |
| 112 | + float arc = (around - lampId) * TAU / lamps, gapZ = (fr - .9) * span; | |
| 113 | + float w = .035 + foot; | |
| 114 | + float lampGlow = exp(-(arc * arc + gapZ * gapZ) / (w * w)) * boreSq(.035 / w); | |
| 115 | + float pulse = boreSq(.5 + .5 * sin(boreWrap(lampId, lamps) * .9 + terrace * 1.7 - c.t * 1.8)); | |
| 116 | + float nearFade = smoothstep(.3f, 1.8f, t); // lips fade before they sweep past the camera | |
| 117 | + col += (paint(.7 + seed * .2, f) * lip * (.45 + band * 1.6) + paint(.92, f) * lampGlow * (.8 + band * 6 * pulse)) * nearFade; | |
| 118 | + // Attack: light climbs both sides of the nearer terraces from the floor to meet overhead. | |
| 119 | + float h = boreAttack(c); | |
| 120 | + float fromFloor = abs(atan2(sin(angle - stand), cos(angle - stand))); | |
| 121 | + float climb = c.hit * exp(-boreSq((fromFloor - (1 - h) * PI) / .35)) * smoothstep(14.f, 3.f, z - camZ); | |
| 122 | + col += paint(.9, f) * climb * (lip * 3 + face * .7); | |
| 123 | + col = mix(paint(.6, f) * .5, col, exp(-t * (.03 + c.fog * .03))); | |
| 124 | + // The axial sun line, with low-mid surges running along it. | |
| 125 | + float s0 = -dot(eye, rd.xy) / max(dot(rd.xy, rd.xy), 1e-6f); | |
| 126 | + float axis = length(eye + rd.xy * s0), sunZ = s0 * rd.z + camZ; | |
| 127 | + float sun = glow(axis, .025 + s0 * c.px * .6) * step(0.f, s0); | |
| 128 | + float surge = .5 + .3 * sin(sunZ * .25 - c.t * .3) + c.b.y * 3 * pow(.5f + .5f * sin(sunZ * .6 - c.t * 2.4), 6.f); | |
| 129 | + return col + paint(.95, f) * sun * surge * exp(-s0 * .02); | |
| 130 | + } | |
| 131 | + NATIVE_EFFECT(ringworldDrift) | |
| 132 | + | |
| 133 | + // ---------------------------------------------------------------- 302 Twin Bore | |
| 134 | + // Two bores side by side, each with its own vanishing point and ring cadence, separated by a | |
| 135 | + // glowing translucent membrane. Bass and low-mids drive the left bore's rings and ribs, the | |
| 136 | + // high-mids and highs drive the right bore's slats and sparks, and attacks ripple the membrane. | |
| 137 | + float3 twinBore(Ctx c, constant NativeFrame &f) { | |
| 138 | + float spread = clamp(.36f * c.extent.x, .34f, .62f); | |
| 139 | + float2 drift = .06 * float2(sin(c.t * .13), cos(c.t * .11)); | |
| 140 | + float2 vl = float2(-spread, .05 * sin(c.t * .09)) + drift, vr = float2(spread, -.05 * sin(c.t * .09)) + drift; | |
| 141 | + float2 mid = (vl + vr) * .5, across = normalize(vr - vl); | |
| 142 | + float2 dl = c.uv - vl, dr = c.uv - vr; | |
| 143 | + float rl = max(length(dl), .015f), rr = max(length(dr), .015f); | |
| 144 | + // Left bore: thick filled rings on a slow cadence, ribs along the bore. | |
| 145 | + float zl = .8 / rl, al = atan2(dl.y, dl.x); | |
| 146 | + float ringL = (zl + c.travel * 1.3) * 1.3 / c.size, idL = floor(ringL + .5); | |
| 147 | + float swell = c.b.x * boreSq(.5 + .5 * sin(idL * 1.1 - c.t * 1.8)); | |
| 148 | + float eL = abs(fract(ringL + .5) - .5), aaL = fwidth(ringL); | |
| 149 | + float bandL = 1 - smoothstep(.1f + .16f * swell, .14f + .16f * swell + aaL, eL); | |
| 150 | + float ribs = glow(sin(al * 5 + zl * .15), .08) * (.15 + c.b.y * 2); | |
| 151 | + float3 left = paint(.55 + .12 * sin(al) + ringL * .045, f) * (.1 + bandL * (.55 + swell * 1.8) + exp(-eL * eL * 30) * .25) | |
| 152 | + + paint(.8, f) * ribs; | |
| 153 | + left = mix(paint(.85, f) * .8, left, exp(-zl * .07)); | |
| 154 | + // Right bore: dense segmented rings of slats with sparks at the joints. | |
| 155 | + float zr = .8 / rr, ar = atan2(dr.y, dr.x); | |
| 156 | + float ringR = (zr + c.travel * 1.3) * 2.4 / c.size, idR = floor(ringR + .5); | |
| 157 | + float eR = abs(fract(ringR + .5) - .5), aaR = fwidth(ringR); | |
| 158 | + float slot = ar * 14 / TAU + idR * .5, slotId = boreWrap(floor(slot + .5), 14); | |
| 159 | + float slat = smoothstep(.12f, .3f, abs(fract(slot) - .5)) * (1 - smoothstep(.12f, .2f + aaR, eR)); | |
| 160 | + float lift = c.b.z * boreSq(.5 + .5 * sin(idR * .7 + slotId * .9 - c.t * 2.2)); | |
| 161 | + float spark = exp(-(boreSq(fract(slot + .5) - .5) + eR * eR) * 60) * c.b.w * boreTwinkle(hash21(float2(slotId, idR)), c.t) * 4; | |
| 162 | + float3 right = paint(.22 + .1 * sin(ar * 2) + ringR * .03, f) * (.09 + slat * (.5 + lift * 2.5)) + paint(.95, f) * spark; | |
| 163 | + right = mix(paint(.4, f) * .8, right, exp(-zr * .07)); | |
| 164 | + // The membrane: the bisecting sheet, rippled by attacks as a wave running toward the viewer. | |
| 165 | + float zs = .8 / max(length(float2(spread, dot(c.uv - mid, float2(-across.y, across.x)))), .02f); | |
| 166 | + float front = .8 + 7 * boreAttack(c); | |
| 167 | + float rippleEnvelope = c.hit * exp(-boreSq((zs - front) / 1.6)); | |
| 168 | + float bend = .14 * rippleEnvelope * sin(zs * 3 - c.t * 3) + .03 * sin(c.uv.y * 4 + c.t * .5); | |
| 169 | + float mx = dot(c.uv - mid, across) - bend * min(1 / zs, 1.5f); | |
| 170 | + float wm = .012 + .05 / zs; | |
| 171 | + float sheet = exp(-abs(mx) / (wm * 3)); | |
| 172 | + float3 col = mix(left, right, smoothstep(-c.px * 1.5f, c.px * 1.5f, mx)); | |
| 173 | + col = mix(col, (left + right) * .5, sheet * .4); | |
| 174 | + col += filmColor(zs * .15 + c.uv.y * .4 + c.t * .04, f) * (glow(mx, wm) * .9 + sheet * .25) * (1 + rippleEnvelope * 3); | |
| 175 | + return col; | |
| 176 | + } | |
| 177 | + NATIVE_EFFECT(twinBore) | |
| 178 | + | |
| 179 | + // ---------------------------------------------------------------- 303 Coil Run | |
| 180 | + // Flying off-axis inside a giant helical coil of flat light ribbon. Gaps between the turns | |
| 181 | + // open onto a deep nebula on a wider cylinder, which drifts past with its own parallax. Bass | |
| 182 | + // breathes the coil pitch in travelling waves, low-mids light the centre lane, high-mids the | |
| 183 | + // edge dashes, highs sparkle the nebula, and attacks chase a bright pulse along the ribbon. | |
| 184 | + float3 coilRun(Ctx c, constant NativeFrame &f) { | |
| 185 | + float orbit = c.t * .04; | |
| 186 | + float2 eye = .55 * float2(cos(orbit), sin(orbit)); | |
| 187 | + float roll = .3 * sin(c.t * .05); | |
| 188 | + float3 rd = cameraRay(c.uv, float3(-eye * .35, 1), float3(-sin(roll), cos(roll), 0), 1.15); | |
| 189 | + float camZ = c.travel * 1.6; | |
| 190 | + float t = boreCylinder(eye, rd, 1); | |
| 191 | + float2 q = eye + rd.xy * t; | |
| 192 | + float zw = t * rd.z + camZ; | |
| 193 | + float pitch = 1.5 * c.size, duty = .6; | |
| 194 | + float breath = c.b.x * .3 * sin(zw * .55 - c.t * 1.4); | |
| 195 | + float phase = zw / pitch + breath - atan2(q.y, q.x) / TAU; | |
| 196 | + float u = fract(phase); | |
| 197 | + float foot = t * c.px / 1.15; | |
| 198 | + float aa = foot / max(abs(dot(rd.xy, q)), .03f) / pitch + foot / TAU + .004; | |
| 199 | + float mask = smoothstep(0.f, aa, u) * (1 - smoothstep(duty - aa, duty, u)); | |
| 200 | + mask = mix(mask, duty, smoothstep(.15f, .5f, aa)); | |
| 201 | + float across = u / duty, along = zw / pitch + breath - u; | |
| 202 | + float edge = glow(min(u, duty - u), .012 + aa); | |
| 203 | + float lane = glow(across - .5, .03 + aa) * (.2 + c.b.y * 2.2); | |
| 204 | + float dash = pow(.5f + .5f * cos(along * TAU * 6 - c.t * 3), 8.f) * edge * (.3 + c.b.z * 3); | |
| 205 | + float h = boreAttack(c); | |
| 206 | + float chase = c.hit * exp(-boreSq((along - camZ / pitch - .3 - (1 - h) * 7) / .16)); | |
| 207 | + float hue = along * .19 + across * .12; | |
| 208 | + float rails = glow(abs(across - .5) - .32, .02 + aa) * .5; | |
| 209 | + float3 ribbon = mix(deep(hue + .3, f), paint(hue, f), .4 + .6 * sin(across * PI)) * (.2 + .22 * sin(across * PI)) + paint(hue + .35, f) * (edge * .6 + rails) | |
| 210 | + + paint(.9, f) * (lane + dash + chase * 3); | |
| 211 | + // Nebula on an outer cylinder seen through the gaps. | |
| 212 | + float t2 = boreCylinder(eye, rd, 4); | |
| 213 | + float2 q2 = eye + rd.xy * t2; | |
| 214 | + float z2 = t2 * rd.z + camZ; | |
| 215 | + float n = fbm3(float3(q2 * .45, z2 * .12 + c.t * .02), 3); | |
| 216 | + float3 nebula = paint(n * 1.4 + .25, f) * (.05 + .9 * n * n) + deep(.3 + n, f) * .12; | |
| 217 | + float2 starCell = float2(floor((atan2(q2.y, q2.x) + PI) / TAU * 90), floor(z2 * 3)); | |
| 218 | + float starSeed = hash21(starCell); | |
| 219 | + float star = step(.86f, starSeed) * (.25 + c.b.w * 4 * boreTwinkle(starSeed, c.t)); | |
| 220 | + nebula += paint(.85, f) * star * exp(-boreSq(length(fract(float2((atan2(q2.y, q2.x) + PI) / TAU * 90, z2 * 3)) - .5) * 4)); | |
| 221 | + float3 col = mix(nebula, ribbon, mask * exp(-t * .03)); | |
| 222 | + return col; | |
| 223 | + } | |
| 224 | + NATIVE_EFFECT(coilRun) | |
| 225 | + | |
| 226 | + // ---------------------------------------------------------------- 304 Bellows Passage | |
| 227 | + // A pleated rectangular bellows. Each pleat is real geometry: the wall folds in to a lit ridge | |
| 228 | + // and out to a shadowed valley, and the faces that turn away hide behind the ridges. Bass | |
| 229 | + // squeezes the pleats in waves rolling toward the viewer, low-mids smoulder in the valleys, | |
| 230 | + // high-mids light the corner creases, highs spark along the ridges and attacks flash a band | |
| 231 | + // of ridges. | |
| 232 | + float boreBellowsMetric(float2 d) { | |
| 233 | + float2 a = abs(d) * float2(.82, 1.18); | |
| 234 | + a *= a; a *= a; | |
| 235 | + return sqrt(sqrt(a.x + a.y)); | |
| 236 | + } | |
| 237 | + | |
| 238 | + float3 bellowsPassage(Ctx c, constant NativeFrame &f) { | |
| 239 | + float2 sway = .1 * float2(sin(c.t * .13), cos(c.t * .11)); | |
| 240 | + float2 dir = (c.uv - sway) / 1.1; | |
| 241 | + float s = max(boreBellowsMetric(dir), 1e-4f); | |
| 242 | + float camZ = c.travel * 1.1; | |
| 243 | + float pitch = .42 * c.size, depthA = .24; | |
| 244 | + float slope = depthA * 2 * (1 / pitch + .2) + s; | |
| 245 | + // March to the first wall crossing; the Lipschitz step never skips a fold. | |
| 246 | + float z = 1 / s; | |
| 247 | + for (int i = 0; i < 32; ++i) { | |
| 248 | + if (z > 34) break; | |
| 249 | + float zw = z + camZ; | |
| 250 | + float u = zw / pitch + c.b.x * .4 * sin(zw * .45 + c.t * 1.8); | |
| 251 | + float wall = 1 + depthA * (1 - abs(2 * fract(u) - 1)); | |
| 252 | + z += max(wall - z * s, 0.f) / slope; | |
| 253 | + } | |
| 254 | + float zw = z + camZ; | |
| 255 | + float u = zw / pitch + c.b.x * .4 * sin(zw * .45 + c.t * 1.8), fu = fract(u), ridgeId = floor(u + .5); | |
| 256 | + float dw = depthA * (fu < .5 ? 2.f : -2.f) / pitch; | |
| 257 | + float lambert = clamp((s - dw) / sqrt((1 + dw * dw) * (1 + s * s)), 0.f, 1.f); | |
| 258 | + float aa = fwidth(u); | |
| 259 | + float ramp = clamp(fu * 2 - 1, 0.f, 1.f), facing = smoothstep(.46f, .54f, fu); | |
| 260 | + float ridge = 1 - smoothstep(0.f, .04f + aa * 1.5f, abs(fu - round(fu))); | |
| 261 | + float valley = exp(-boreSq((fu - .5) / .07)); | |
| 262 | + float2 e = abs(dir) * float2(.82, 1.18) / s; | |
| 263 | + float crease = glow(e.x - e.y, .025 + aa * .2) * (.15 + c.b.z * 2.5) * facing; | |
| 264 | + float around = atan2(dir.y * 1.18, dir.x * .82); | |
| 265 | + float sparks = pow(.5f + .5f * cos(around * 24 + ridgeId * 1.7 - c.t * 2), 12.f) * ridge * c.b.w * 3; | |
| 266 | + float h = boreAttack(c); | |
| 267 | + float flash = c.hit * exp(-boreSq((zw - camZ - 1.5 - h * 10) / 1.3)); | |
| 268 | + float hue = .12 + .1 * sin(ridgeId * .45) + .06 * sin(around * 2); | |
| 269 | + float3 face = mix(deep(hue + .1, f), paint(hue, f), ramp) * (.1 + .6 * ramp) * (.35 + .65 * lambert); | |
| 270 | + float3 col = mix(deep(hue + .1, f) * .3, face, facing); | |
| 271 | + float valleyId = floor(u); | |
| 272 | + col += paint(.3, f) * valley * c.b.y * 2.5 * (.4 + .6 * boreSq(sin(valleyId * .9 - c.t * 1.5))); | |
| 273 | + col += paint(.8, f) * ridge * (.45 + flash * 4) + paint(.7, f) * crease + paint(.95, f) * sparks; | |
| 274 | + return mix(paint(.6, f) * .45, col, exp(-z * (.06 + c.fog * .04))); | |
| 275 | + } | |
| 276 | + NATIVE_EFFECT(bellowsPassage) | |
| 277 | + | |
| 278 | + // ---------------------------------------------------------------- 305 Branching Bore | |
| 279 | + // A bore that forks every few lengths. The camera follows one branch, swinging left and | |
| 280 | + // right at alternate forks; the branch not taken glows hot as it peels away to the side. | |
| 281 | + // Junction rims light with their band, ribs and grooves take bass and low-mids, and attacks | |
| 282 | + // send a ring racing down the branch ahead. | |
| 283 | + float2 boreBranchMain(float z) { | |
| 284 | + float k = floor(z / 6), u = z / 6 - k, s = u * u * (3 - 2 * u); | |
| 285 | + return float2(1.4 * (boreWrap(k, 2) < .5 ? s : 1 - s), .5 * sin(z * .17)); | |
| 286 | + } | |
| 287 | + float2 boreBranchSide(float z, float k) { | |
| 288 | + float u = max(z / 6 - k, 0.f), grow = u < 1 ? u * u : 2 * u - 1; | |
| 289 | + float away = boreWrap(k, 2) < .5 ? -1 : 1; | |
| 290 | + return float2(1.4 * (away < 0 ? 0 : 1) + away * 1.5 * grow, .5 * sin(z * .17) + .45 * grow * (hash11(k) - .5)); | |
| 291 | + } | |
| 292 | + // x = interior field of the union, y = taken branch, z = branch not taken, w = its fork id. | |
| 293 | + float4 boreBranchField(float3 p) { | |
| 294 | + float k = floor(p.z / 6); | |
| 295 | + float main = 1 - length(p.xy - boreBranchMain(p.z)); | |
| 296 | + float sideA = 1 - length(p.xy - boreBranchSide(p.z, k)); | |
| 297 | + float sideB = 1 - length(p.xy - boreBranchSide(p.z, k - 1)) - max(0.f, (k - 1) * 6 - p.z) * 3; | |
| 298 | + float side = max(sideA, sideB), fork = sideA > sideB ? k : k - 1; | |
| 299 | + return float4(smax(main, side, .25), main, side, fork); | |
| 300 | + } | |
| 301 | + | |
| 302 | + float3 branchingBore(Ctx c, constant NativeFrame &f) { | |
| 303 | + float camZ = c.travel * 1.6; | |
| 304 | + float3 eye = float3(boreBranchMain(camZ), camZ), ahead = float3(boreBranchMain(camZ + 2.5), camZ + 2.5); | |
| 305 | + float roll = .25 * sin(c.t * .06); | |
| 306 | + float3 rd = cameraRay(c.uv, ahead - eye, float3(sin(roll), cos(roll), 0), 1.15); | |
| 307 | + float t = .02; | |
| 308 | + float4 g = 0; | |
| 309 | + for (int i = 0; i < 60; ++i) { | |
| 310 | + g = boreBranchField(eye + rd * t); | |
| 311 | + if (g.x < .001 + t * .0015 || t > 40) break; | |
| 312 | + t += g.x * .75; | |
| 313 | + } | |
| 314 | + float3 p = eye + rd * t; | |
| 315 | + float takenSide = smoothstep(-.03f, .03f, g.y - g.z); | |
| 316 | + float fork = g.w, uSide = p.z / 6 - fork; | |
| 317 | + float2 q = p.xy - (takenSide > .5 ? boreBranchMain(p.z) : boreBranchSide(p.z, fork)); | |
| 318 | + float around = atan2(q.y, q.x); | |
| 319 | + float rib = p.z * 1.7 / c.size, ribId = floor(rib + .5), eRib = abs(fract(rib + .5) - .5); | |
| 320 | + float foot = t * c.px * 1.7 / c.size + .01; | |
| 321 | + float ribs = (1 - smoothstep(.06f, .1f + foot, eRib)) * (.4 + c.b.x * 2.5 * boreSq(.5 + .5 * sin(ribId * .8 - c.t * 1.7))); | |
| 322 | + float veins = glow(sin(around * 4 + 1.3 * sin(p.z * .7 + around * 2) + p.z * .3), .12) * (.16 + c.b.y * 1.8); | |
| 323 | + float h = boreAttack(c); | |
| 324 | + float ring = c.hit * exp(-boreSq((p.z - camZ - 3.2 - (1 - h) * 18) / .5)) * takenSide; | |
| 325 | + // The branch not taken burns hotter the deeper it runs. | |
| 326 | + float heat = (1 - takenSide) * smoothstep(-.1f, 1.4f, uSide); | |
| 327 | + float3 wall = paint(.08 + .07 * sin(around * 3 + p.z * .4), f) * (.26 + .12 * cos(around - 1)); | |
| 328 | + wall += paint(.35 + heat * .3, f) * ribs * (.5 + heat) + paint(.55, f) * veins + paint(.92, f) * ring * 3; | |
| 329 | + wall += paint(.4 + .15 * sin(p.z * .6), f) * heat * (.4 + c.b.w * 1.2 * boreTwinkle(hash11(fork + 7), c.t)); | |
| 330 | + float split = length(boreBranchMain(p.z) - boreBranchSide(p.z, fork)); | |
| 331 | + float rim = glow(g.y - g.z, .04) * smoothstep(.35f, 1.f, split) * smoothstep(2.2f, 1.f, uSide); | |
| 332 | + wall += paint(.65 + .2 * sin(fork * 1.7), f) * rim * (.5 + boreBand(c, fork) * 4); | |
| 333 | + return mix(paint(.45, f) * .4, wall / (1 + t * .04), exp(-t * (.045 + c.fog * .04))); | |
| 334 | + } | |
| 335 | + NATIVE_EFFECT(branchingBore) | |
| 336 | + | |
| 337 | + // ---------------------------------------------------------------- 306 Skyward Shaft | |
| 338 | + // Looking up a square shaft while rising through it. Four walls of lit apertures converge on | |
| 339 | + // a bright square of sky. Each wall's windows pulse with their own band, floor slabs mark the | |
| 340 | + // storeys, and attacks drop rings of light down the shaft toward the viewer. | |
| 341 | + float3 skywardShaft(Ctx c, constant NativeFrame &f) { | |
| 342 | + float roll = c.t * .035; | |
| 343 | + float2 eye = float2(.38 * sin(c.t * .07), .3 * cos(c.t * .09)); | |
| 344 | + float3 rd = cameraRay(c.uv, float3(-eye * .25 + .06 * float2(sin(c.t * .11), cos(c.t * .13)), 1), float3(-sin(roll), cos(roll), 0), 1); | |
| 345 | + float2 safe = float2(abs(rd.x) < 1e-5 ? 1e-5 : rd.x, abs(rd.y) < 1e-5 ? 1e-5 : rd.y); | |
| 346 | + float2 lim = (sign(safe) - eye) / safe; | |
| 347 | + bool xWall = lim.x < lim.y; | |
| 348 | + float t = min(lim.x, lim.y); | |
| 349 | + float2 hit = eye + rd.xy * t; | |
| 350 | + float height = t * rd.z, top = 12; | |
| 351 | + float wallId = xWall ? (rd.x > 0 ? 0 : 1) : (rd.y > 0 ? 2 : 3); | |
| 352 | + float acrossW = xWall ? hit.y : hit.x; | |
| 353 | + float zw = height + c.travel * 1.5; | |
| 354 | + float foot = t * c.px; | |
| 355 | + float2 cellSize = float2(.5, .62) * c.size; | |
| 356 | + float2 g = float2(acrossW + 1, zw) / cellSize, cell = floor(g), local = (fract(g) - .5) * cellSize; | |
| 357 | + float seed = hash31(float3(cell, wallId)); | |
| 358 | + float box = sdBox2(local, cellSize * float2(.3, .3)); | |
| 359 | + float window = 1 - smoothstep(-foot, foot, box); | |
| 360 | + float frame = glow(box, .008 + foot); | |
| 361 | + float band = c.b[int(wallId)]; | |
| 362 | + float lit = step(.4f, seed) * (.25 + .75 * boreSq(.5 + .5 * sin(c.t * .6 + seed * 9))); | |
| 363 | + float pulse = band * boreSq(.5 + .5 * sin(cell.y * .7 - c.t * 2 + seed * 3)); | |
| 364 | + float slab = 1 - smoothstep(.03f, .05f + foot / cellSize.y, abs(fract(g.y / 5 + .1) - .1)); | |
| 365 | + float h = boreAttack(c); | |
| 366 | + float ring = c.hit * exp(-boreSq((height - 1.2 - h * (top - 3)) / .6)); | |
| 367 | + float spill = exp(-(top - height) * .18); | |
| 368 | + float3 wall = deep(.35 + wallId * .08, f) * (.1 + .6 * spill) + paint(.45, f) * frame * .35 + deep(.6, f) * window * .12; | |
| 369 | + wall += paint(.6 + seed * .35, f) * window * (lit * (.6 + pulse * 3.5) + ring * 2); | |
| 370 | + wall += paint(.8, f) * slab * (.4 + spill) + paint(.92, f) * ring * 1.5; | |
| 371 | + float rimLine = glow(top - height, .05 + foot); | |
| 372 | + // Sky beyond the opening. | |
| 373 | + float2 skyPoint = eye + rd.xy * (top + 8) / max(rd.z, .05f); | |
| 374 | + float cloud = fbm2(skyPoint * .35 + float2(c.t * .02, 0), 3); | |
| 375 | + float3 sky = paint(.9, f) * 1.3 + paint(.6 + cloud * .3, f) * cloud * .9; | |
| 376 | + float3 col = height > top ? sky : wall * exp(-height * c.fog * .03) + paint(.95, f) * rimLine * 1.5; | |
| 377 | + return col; | |
| 378 | + } | |
| 379 | + NATIVE_EFFECT(skywardShaft) | |
| 380 | + | |
| 381 | + // ---------------------------------------------------------------- 307 Veil Passage | |
| 382 | + // Flying through a stack of translucent liquid veils. Each veil has an organic hole and the | |
| 383 | + // camera threads them one after another along a weaving path. Bass ripples the veils and | |
| 384 | + // bends the holes, low-mids light their folds, high-mids widen the rim halos, highs shimmer | |
| 385 | + // the surfaces, and attacks flare the hole rims in a wave running away from the viewer. | |
| 386 | + float2 boreVeilPath(float id) { return float2(.42 * sin(id * .9) + .2 * sin(id * .37 + 1), .32 * cos(id * .7 + .5)); } | |
| 387 | + | |
| 388 | + float3 veilPassage(Ctx c, constant NativeFrame &f) { | |
| 389 | + const int count = 7; | |
| 390 | + float advance = c.travel * .11; | |
| 391 | + float2 camera = boreVeilPath(float(count) - advance * float(count)); | |
| 392 | + float3 col = deep(.6, f) * .2 + paint(.9, f) * .3 * exp(-length(c.uv) * 1.5); | |
| 393 | + float h = boreAttack(c); | |
| 394 | + for (int k = 0; k < count; ++k) { | |
| 395 | + float2 s = layerSlot(k, count, advance); | |
| 396 | + float sc = layerScale(s.x, 3.2) / c.size, fade = layerFade(s.x); | |
| 397 | + float2 p = c.uv * sc - (boreVeilPath(s.y) - camera); | |
| 398 | + float a = atan2(p.y, p.x), r = length(p); | |
| 399 | + float radius = 1.05 + .16 * sin(3 * a + s.y * 1.7 + c.t * .25) + .09 * sin(5 * a - s.y + c.t * .4) | |
| 400 | + + .1 * c.b.x * sin(7 * a + c.t * 2 + s.y); | |
| 401 | + float d = r - radius, aa = c.px * sc * 1.5; | |
| 402 | + float sheet = smoothstep(-aa, aa, d); | |
| 403 | + float ripple = c.b.x * sin(d * 9 - c.t * 2.5) * exp(-max(d, 0.f) * 1.2); | |
| 404 | + float thick = s.y * .17 + .12 * sin(p.x * .9 + s.y + sin(p.y * 1.1 + c.t * .3)) + .1 * sin(r * 2 - c.t * .6) + ripple * .2; | |
| 405 | + float sheen = pow(.5f + .5f * sin(a * 2 + r * 1.5 + s.y * 2.3 + c.t * .2), 3.f); | |
| 406 | + float2 glint = p * 6 + s.y * 3.1; float glintSeed = hash21(floor(glint) + s.y * 17); | |
| 407 | + float shimmer = step(.72f, glintSeed) * exp(-boreSq(length(fract(glint) - .5) * 5)) * c.b.w * 4 * boreTwinkle(glintSeed, c.t); | |
| 408 | + float lightness = (.1 + .45 * exp(-max(d, 0.f) * 2)) * (.45 + .55 * s.x); | |
| 409 | + float3 veil = filmColor(thick, f) * lightness * (1 + ripple * .7 + sheen * (.3 + c.b.y * 2)) + paint(.9, f) * shimmer * lightness; | |
| 410 | + float flare = c.hit * exp(-boreSq((s.x - (1 - h * .85)) / .14)); | |
| 411 | + float rim = glow(d, .03 + .04 * c.b.z) * (.8 + flare * 4) + glow(d, .2) * .15; | |
| 412 | + col = mix(col, veil, sheet * .6 * fade); | |
| 413 | + col += paint(.75 + s.y * .1, f) * rim * fade; | |
| 414 | + } | |
| 415 | + return col; | |
| 416 | + } | |
| 417 | + NATIVE_EFFECT(veilPassage) | |
| 418 | + | |
| 419 | + // ---------------------------------------------------------------- 308 Glass Pipeworks | |
| 420 | + // Flying through a three-dimensional lattice of glass pipes seen from outside. The glass shows | |
| 421 | + // as bright rims and luminous fluid pulses through the cores: pipes along the flight carry the | |
| 422 | + // bass, cross pipes the low-mids and the risers the high-mids; highs fizz bubbles and attacks | |
| 423 | + // push bright slugs of fluid through the network. | |
| 424 | + float boreLattice(float x) { return x - 4 * floor(x * .25 + .5); } | |
| 425 | + | |
| 426 | + float3 glassPipeworks(Ctx c, constant NativeFrame &f) { | |
| 427 | + float camZ = c.travel * 1.9; | |
| 428 | + float3 eye = float3(2 + .45 * sin(camZ * .12), 2 + .35 * sin(camZ * .15 + 1.2), camZ); | |
| 429 | + float yaw = .35 * sin(c.t * .05), pitch = .22 * sin(c.t * .043 + 1), roll = .3 * sin(c.t * .031); | |
| 430 | + float3 rd = cameraRay(c.uv, float3(sin(yaw), sin(pitch), 1), float3(sin(roll), cos(roll), 0), 1.15); | |
| 431 | + float h = boreAttack(c), slugShift = (1 - h) * 12; | |
| 432 | + float3 fluid = 0; | |
| 433 | + float glassLight = 0, transmit = 1, t = .1; | |
| 434 | + // Sphere-trace between pipes; at each pipe, shade it analytically and pass straight through. | |
| 435 | + for (int i = 0; i < 34; ++i) { | |
| 436 | + float3 p = eye + rd * t; | |
| 437 | + float2 cellZ = floor(p.xy * .25 + .5), cellX = floor(p.yz * .25 + .5), cellY = floor((p.xz - float2(0, 2)) * .25 + .5); | |
| 438 | + // Low-discrepancy pipe seeds (plastic-number sequence): cheap and evenly spread. | |
| 439 | + float3 seeds = fract(float3(dot(cellZ, float2(.7549, .5698)) + .13, dot(cellX, float2(.5698, .7549)) + .41, dot(cellY, float2(.6180, .3820)) + .77)); | |
| 440 | + float2 offset = .7 * (float2(seeds.x, fract(seeds.x * 7.13)) - .5); | |
| 441 | + float3 lattice = float3(boreLattice(p.x), boreLattice(p.y), boreLattice(p.z)); | |
| 442 | + float lz2 = boreLattice(p.z - 2); | |
| 443 | + float2 qz = lattice.xy - offset, qx = lattice.yz, qy = float2(lattice.x, lz2); | |
| 444 | + float3 radius = (.2 + .14 * seeds) * step(.38f, seeds); | |
| 445 | + float3 gap = select(float3(9), float3(length(qz), length(qx), length(qy)) - radius, radius > 0); | |
| 446 | + float d = min(gap.x, min(gap.y, gap.z)); | |
| 447 | + // Pipes in neighbouring cells sit at least this far beyond the cell walls. | |
| 448 | + float3 wall = 2 - float3(max(abs(lattice.x), abs(lattice.y)), max(abs(lattice.y), abs(lattice.z)), max(abs(lattice.x), abs(lz2))); | |
| 449 | + float reach = min(d, min(wall.x, min(wall.y, wall.z)) + 1.25); | |
| 450 | + if (d < .1) { | |
| 451 | + int k = gap.x <= d ? 0 : (gap.y <= d ? 1 : 2); | |
| 452 | + float2 q = k == 0 ? qz : (k == 1 ? qx : qy); | |
| 453 | + float2 v = k == 0 ? rd.xy : (k == 1 ? rd.yz : rd.xz); | |
| 454 | + float vv = max(dot(v, v), 1e-4f), r = radius[k]; | |
| 455 | + float mid = -dot(q, v) / vv, miss = max(dot(q, q) - mid * mid * vv, 0.f); | |
| 456 | + // A near miss skips past the pipe's closest approach instead of crawling along it. | |
| 457 | + if (miss >= r * r || mid < 0) { t += min(max(mid, d), min(.8f, max(reach, .05f))) + .02; continue; } | |
| 458 | + float exitAt = mid + sqrt(max(r * r - miss, 0.f) / vv); | |
| 459 | + float coreR = r * .62, chord = 2 * sqrt(max(coreR * coreR - miss, 0.f) / vv); | |
| 460 | + float3 pm = p + rd * max(mid, 0.f); | |
| 461 | + float along = k == 0 ? pm.z : (k == 1 ? pm.x : pm.y), flow = k == 0 || seeds[k] > .6 ? 1 : -1; | |
| 462 | + float wave = .5 + .5 * sin(along * 1.3 * flow - c.t * 2.2 + seeds[k] * 20); | |
| 463 | + float pulse = wave * wave; pulse *= pulse * wave; | |
| 464 | + float fizz = .5 + .5 * sin(along * 9 + seeds[k] * 40 - c.t * 5); | |
| 465 | + fizz *= fizz; fizz *= fizz; fizz *= fizz; | |
| 466 | + float level = .25 + pulse * (.4 + c.b[k] * 3.5) + fizz * fizz * c.b.w * 3; | |
| 467 | + if (c.hit > .01) { | |
| 468 | + float x = along * flow - seeds[k] * 20 - slugShift; | |
| 469 | + x -= 20 * floor(x / 20 + .5); | |
| 470 | + level += c.hit * exp(-x * x * 2) * 6; | |
| 471 | + } | |
| 472 | + float fade = exp(-t * (.07 + c.fog * .05)) * transmit; | |
| 473 | + float lit = min(chord, 1.2f) * 2.2 + exp(-miss / (coreR * coreR)) * .35; | |
| 474 | + fluid[k] += lit * level * fade; | |
| 475 | + float edge = sqrt(miss) / r; | |
| 476 | + edge *= edge; edge *= edge; | |
| 477 | + glassLight += (edge * edge * 1.1 + .07) * fade; | |
| 478 | + transmit *= .8; | |
| 479 | + t += max(exitAt, 0.f) + .03; | |
| 480 | + if (transmit < .25) break; | |
| 481 | + } else { | |
| 482 | + t += max(reach, .02f) * .9; | |
| 483 | + } | |
| 484 | + if (t > 30) break; | |
| 485 | + } | |
| 486 | + float3 back = deep(.4 + .1 * rd.y, f) * .14 + paint(.55, f) * .05 * (1 + rd.y); | |
| 487 | + return back + paint(.3, f) * fluid.x * 1.2 + paint(.52, f) * fluid.y + paint(.72, f) * fluid.z + paint(.9, f) * glassLight * .85; | |
| 488 | + } | |
| 489 | + NATIVE_EFFECT(glassPipeworks) | |
| 490 | + | |
| 491 | + // ---------------------------------------------------------------- 309 Möbius Ride | |
| 492 | + // Riding just above a wide ribbon of light that winds ahead and twists half a turn every | |
| 493 | + // stretch. The camera banks with the ribbon, so the sky rolls while the ribbon stays under | |
| 494 | + // you and flips over in the distance. Edge lights pulse with their bands, highs twinkle the | |
| 495 | + // sky and attacks fire chevrons racing away along the ribbon. | |
| 496 | + float2 boreRibbonPath(float z) { return float2(2.6 * sin(z * .12) + .9 * sin(z * .29 + 1), 1.4 * sin(z * .15 + 2) + .5 * sin(z * .33)); } | |
| 497 | + float boreRibbonTwist(float z) { return z * PI / 9 + .4 * sin(z * .2); } | |
| 498 | + float boreRibbonField(float3 p, thread float2 &local) { | |
| 499 | + local = rot(p.xy - boreRibbonPath(p.z), -boreRibbonTwist(p.z)); | |
| 500 | + return sdBox2(local, float2(.9, .02)) - .01; | |
| 501 | + } | |
| 502 | + | |
| 503 | + float3 mobiusRide(Ctx c, constant NativeFrame &f) { | |
| 504 | + float camZ = c.travel * 1.6; | |
| 505 | + float tw = boreRibbonTwist(camZ); | |
| 506 | + float2 normal = float2(-sin(tw), cos(tw)); | |
| 507 | + float3 eye = float3(boreRibbonPath(camZ) + normal * .95, camZ); | |
| 508 | + float3 target = float3(boreRibbonPath(camZ + 5), camZ + 5); | |
| 509 | + float3 rd = cameraRay(c.uv, target - eye, float3(normal, 0), 1.1); | |
| 510 | + float t = .05, d = 1, nearest = 9; | |
| 511 | + float2 local = 0; | |
| 512 | + for (int i = 0; i < 64; ++i) { | |
| 513 | + d = boreRibbonField(eye + rd * t, local); | |
| 514 | + nearest = min(nearest, d / (1 + t * .08)); | |
| 515 | + if (d < .0015 + t * .0015 || t > 45) break; | |
| 516 | + t += d * .6; | |
| 517 | + } | |
| 518 | + // Sky: a soft nebula, stars that twinkle with the highs and the ribbon's own aura. | |
| 519 | + float az = atan2(rd.x, rd.z), el = asin(clamp(rd.y, -1.f, 1.f)); | |
| 520 | + float n = fbm2(float2(az * 2.5, el * 2.5) + c.t * .01, 4); | |
| 521 | + float2 starCell = floor(float2(az, el) * 60); | |
| 522 | + float starSeed = hash21(starCell); | |
| 523 | + float star = step(.9f, starSeed) * exp(-boreSq(length(fract(float2(az, el) * 60) - .5) * 5)) * (.4 + c.b.w * 4 * boreTwinkle(starSeed, c.t)); | |
| 524 | + float3 sky = paint(.15 + n * .5, f) * (.08 + .7 * n * n) + paint(.85, f) * star; | |
| 525 | + sky += paint(.7, f) * glow(nearest, .12) * (.35 + c.b.x * .8); | |
| 526 | + if (t > 45 || d > .05) return sky; | |
| 527 | + float3 p = eye + rd * t; | |
| 528 | + float zw = p.z, xs = local.x; | |
| 529 | + bool under = local.y < 0; | |
| 530 | + float foot = t * c.px / 1.1 + .005; | |
| 531 | + // Chevron rungs roll with the bass; three lanes carry the low-mids. | |
| 532 | + float rung = zw * .9 - abs(xs) * .45 - c.t * .5, rungId = floor(rung + .5); | |
| 533 | + float rungs = (1 - smoothstep(.05f, .08f + foot, abs(rung - rungId))) * (.25 + c.b.x * 2.2 * boreSq(.5 + .5 * sin(rungId * .7 - c.t * 2))); | |
| 534 | + float lanes = glow(min(abs(xs), abs(abs(xs) - .45)), .02 + foot) * (.25 + c.b.y * 2); | |
| 535 | + // Lamps along both edges, each lamp on its own band. | |
| 536 | + float lampRun = zw / .8 - c.t * .35, seg = floor(lampRun + .5), sideId = xs > 0 ? 2 : 0; | |
| 537 | + float rail = glow(.9 - abs(xs), .07 + foot); | |
| 538 | + float lamp = rail * pow(.5f + .5f * cos(fract(lampRun) * TAU), 4.f); | |
| 539 | + float band = boreBand(c, seg + sideId); | |
| 540 | + float h = boreAttack(c); | |
| 541 | + float chev = zw - abs(xs) * .7 - camZ - 3 - (1 - h) * 24; | |
| 542 | + float chevrons = c.hit * pow(.5f + .5f * cos(chev * TAU / 1.2), 8.f) * exp(-boreSq(chev / 2.4)); | |
| 543 | + float hue = (under ? .35 : .62) + xs * .1 + zw * .012; | |
| 544 | + float sheen = .5 + .5 * cos(xs * 2.2 + zw * .3); | |
| 545 | + float3 surface = mix(deep(hue + .3, f), paint(hue, f), .3 + .4 * sheen) * (under ? .14 : .22); | |
| 546 | + surface += paint(hue + .2, f) * (lanes + rungs) + paint(.88, f) * (rail * .3 + lamp * (.8 + band * 4)) + paint(.95, f) * chevrons * 3; | |
| 547 | + return mix(sky, surface, exp(-t * (.03 + c.fog * .03))); | |
| 548 | + } | |
| 549 | + NATIVE_EFFECT(mobiusRide) | |
| 550 | + | |
| 551 | + // Coaster versions: the same designs riding the roller-coaster course. | |
| 552 | + NATIVE_COASTER(ringworldDrift, 301, false) | |
| 553 | + NATIVE_COASTER(twinBore, 302, false) | |
| 554 | + NATIVE_COASTER(coilRun, 303, false) | |
| 555 | + NATIVE_COASTER(bellowsPassage, 304, false) | |
| 556 | + NATIVE_COASTER(branchingBore, 305, false) | |
| 557 | + NATIVE_COASTER(skywardShaft, 306, false) | |
| 558 | + NATIVE_COASTER(veilPassage, 307, false) |
Sources/PulseCanvas/Resources/NativeExpansionCommon.metal added
| 1 | + #include <metal_stdlib> | |
| 2 | + using namespace metal; | |
| 3 | + | |
| 4 | + // PulseCanvas native effect prelude. Original procedural code: no external images, | |
| 5 | + // preset equations or third-party shader sources. Classic mathematical forms are | |
| 6 | + // implemented from their definitions. This file is prepended to every Native*.metal | |
| 7 | + // effect file when the renderer compiles the native library. | |
| 8 | + // | |
| 9 | + // Layout matches NativeUniforms in VisualizerRenderer.swift. The first fields match | |
| 10 | + // SpatialFrame so every native pass shares one uniform block. | |
| 11 | + struct NativeFrame { | |
| 12 | + float2 resolution; float time; int scene; | |
| 13 | + float4 rhythm; // attack, drive, attack swell, raw treble (Chaos-scaled) | |
| 14 | + float4 style; // brightness, size, fog, camera zoom | |
| 15 | + float4 camera; // rotation, Chaos, detail, zoom speed | |
| 16 | + float4 colors[5]; | |
| 17 | + float4 bands; // smoothed low, low-mid, high-mid, high (Chaos-scaled) | |
| 18 | + float4 motion; // zoom travel, music clock, procedural time, smoothed energy | |
| 19 | + }; | |
| 20 | + | |
| 21 | + // Everything an effect needs, already normalized. Every audio term is zero at zero Chaos. | |
| 22 | + struct Ctx { | |
| 23 | + float2 uv; // centred, y up; the shorter canvas edge spans [-1, 1] | |
| 24 | + float2 screen; // 0...1 across the canvas | |
| 25 | + float2 extent; // half-size of the canvas in uv units (>= 1 on each axis) | |
| 26 | + float px; // one pixel in uv units | |
| 27 | + float t; // procedural time plus integrated percussion motion (Chaos-scaled) | |
| 28 | + float m; // music clock: advances faster in energetic passages | |
| 29 | + float e; // smoothed musical energy, 0...~1 | |
| 30 | + float hit; // short attack envelope | |
| 31 | + float4 b; // smoothed bands: low, low-mid, high-mid, high | |
| 32 | + float travel; // integrated forward zoom distance | |
| 33 | + float size; // size control, 1 at default | |
| 34 | + float fog; // depth control, 0...1 | |
| 35 | + float detail; // detail control, 0...1 | |
| 36 | + }; | |
| 37 | + | |
| 38 | + constant float PI = 3.14159265; | |
| 39 | + constant float TAU = 6.2831853; | |
| 40 | + | |
| 41 | + // ---------------------------------------------------------------- hashing / noise | |
| 42 | + // Deterministic integer seeds authored for this catalog. Floating coordinates are | |
| 43 | + // treated as IEEE-754 bits; +/- zero share one identity. The three independently | |
| 44 | + // mixed coordinate words supply decorrelated channels without floating hash recipes. | |
| 45 | + uint canvasSeed(uint word) { | |
| 46 | + word ^= word >> 13; | |
| 47 | + word *= 0xA3B19535u; | |
| 48 | + word ^= word >> 17; | |
| 49 | + word *= 0xD74F739Du; | |
| 50 | + word ^= word >> 11; | |
| 51 | + return word; | |
| 52 | + } | |
| 53 | + uint canvasWord(float coordinate) { return coordinate == 0 ? 0u : as_type<uint>(coordinate); } | |
| 54 | + float canvasUnit(uint word) { return float(canvasSeed(word) >> 8) * (1.f / 16777216.f); } | |
| 55 | + uint canvasPair(float2 p) { return canvasSeed(canvasWord(p.x) ^ 0x13A17C9Bu) ^ canvasWord(p.y); } | |
| 56 | + uint canvasTriple(float3 p) { return canvasSeed(canvasPair(p.xy) ^ 0x7259B43Fu) ^ canvasWord(p.z); } | |
| 57 | + float hash11(float p) { return canvasUnit(canvasWord(p) ^ 0x4B7CA815u); } | |
| 58 | + float hash21(float2 p) { return canvasUnit(canvasPair(p)); } | |
| 59 | + float2 hash22(float2 p) { uint seed = canvasPair(p); return float2(canvasUnit(seed), canvasUnit(seed ^ 0xF195ED47u)); } | |
| 60 | + float3 hash33(float3 p) { uint seed = canvasTriple(p); return float3(canvasUnit(seed), canvasUnit(seed ^ 0xF195ED47u), canvasUnit(seed ^ 0x2DB67189u)); } | |
| 61 | + float hash31(float3 p) { return canvasUnit(canvasTriple(p)); } | |
| 62 | + | |
| 63 | + float noise2(float2 p) { | |
| 64 | + float2 i = floor(p), f = fract(p), u = f * f * (3 - 2 * f); | |
| 65 | + return mix(mix(hash21(i), hash21(i + float2(1, 0)), u.x), mix(hash21(i + float2(0, 1)), hash21(i + 1), u.x), u.y); | |
| 66 | + } | |
| 67 | + float noise3(float3 p) { | |
| 68 | + float3 i = floor(p), f = fract(p), u = f * f * (3 - 2 * f); | |
| 69 | + float a = hash31(i), b = hash31(i + float3(1, 0, 0)), c = hash31(i + float3(0, 1, 0)), d = hash31(i + float3(1, 1, 0)); | |
| 70 | + float e = hash31(i + float3(0, 0, 1)), g = hash31(i + float3(1, 0, 1)), h = hash31(i + float3(0, 1, 1)), k = hash31(i + 1); | |
| 71 | + return mix(mix(mix(a, b, u.x), mix(c, d, u.x), u.y), mix(mix(e, g, u.x), mix(h, k, u.x), u.y), u.z); | |
| 72 | + } | |
| 73 | + float fbm2(float2 p, int octaves) { | |
| 74 | + float sum = 0, amplitude = .5; | |
| 75 | + for (int i = 0; i < octaves; ++i) { sum += amplitude * noise2(p); p = float2(p.x * 1.6 - p.y * 1.2, p.x * 1.2 + p.y * 1.6) + 3.1; amplitude *= .5; } | |
| 76 | + return sum; | |
| 77 | + } | |
| 78 | + float fbm3(float3 p, int octaves) { | |
| 79 | + float sum = 0, amplitude = .5; | |
| 80 | + for (int i = 0; i < octaves; ++i) { sum += amplitude * noise3(p); p = p * 2.03 + float3(1.7, -3.1, 2.3); amplitude *= .5; } | |
| 81 | + return sum; | |
| 82 | + } | |
| 83 | + // Smooth divergence-free-looking flow from a noise potential. | |
| 84 | + float2 curl2(float2 p) { | |
| 85 | + const float e = .05; | |
| 86 | + float a = noise2(p + float2(0, e)), b = noise2(p - float2(0, e)); | |
| 87 | + float c = noise2(p + float2(e, 0)), d = noise2(p - float2(e, 0)); | |
| 88 | + return float2(a - b, d - c) / (2 * e); | |
| 89 | + } | |
| 90 | + // Voronoi: x = nearest distance, y = second distance, zw = nearest cell id. | |
| 91 | + float4 voronoi(float2 p, float jitter, float phase) { | |
| 92 | + float2 cell = floor(p), f = fract(p); | |
| 93 | + float first = 8, second = 8; float2 winner = 0; | |
| 94 | + for (int y = -1; y <= 1; ++y) for (int x = -1; x <= 1; ++x) { | |
| 95 | + float2 g = float2(x, y), seed = hash22(cell + g); | |
| 96 | + float2 site = g + .5 + jitter * .5 * sin(phase + seed * TAU); | |
| 97 | + float d = length(site - f); | |
| 98 | + if (d < first) { second = first; first = d; winner = cell + g; } else second = min(second, d); | |
| 99 | + } | |
| 100 | + return float4(first, second, winner); | |
| 101 | + } | |
| 102 | + | |
| 103 | + // ---------------------------------------------------------------- geometry | |
| 104 | + float2 rot(float2 p, float a) { float c = cos(a), s = sin(a); return float2(c * p.x - s * p.y, s * p.x + c * p.y); } | |
| 105 | + float smin(float a, float b, float k) { float h = clamp(.5 + .5 * (b - a) / k, 0.f, 1.f); return mix(b, a, h) - k * h * (1 - h); } | |
| 106 | + float smax(float a, float b, float k) { return -smin(-a, -b, k); } | |
| 107 | + float sdBox(float3 p, float3 b) { float3 q = abs(p) - b; return length(max(q, 0.f)) + min(max(q.x, max(q.y, q.z)), 0.f); } | |
| 108 | + float sdBox2(float2 p, float2 b) { float2 q = abs(p) - b; return length(max(q, 0.f)) + min(max(q.x, q.y), 0.f); } | |
| 109 | + float sdTorus(float3 p, float2 t) { return length(float2(length(p.xz) - t.x, p.y)) - t.y; } | |
| 110 | + float sdCapsule(float3 p, float3 a, float3 b, float r) { float3 pa = p - a, ba = b - a; float h = clamp(dot(pa, ba) / dot(ba, ba), 0.f, 1.f); return length(pa - ba * h) - r; } | |
| 111 | + float sdSegment(float2 p, float2 a, float2 b) { float2 pa = p - a, ba = b - a; float h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-6f), 0.f, 1.f); return length(pa - ba * h); } | |
| 112 | + float sdHex(float2 p, float r) { const float3 k = float3(-.8660254, .5, .57735); p = abs(p); p -= 2 * min(dot(k.xy, p), 0.f) * k.xy; p -= float2(clamp(p.x, -k.z * r, k.z * r), r); return length(p) * sign(p.y); } | |
| 113 | + // Hexagonal tiling: xy = local offset, zw = cell id. | |
| 114 | + float4 hexCell(float2 p) { | |
| 115 | + const float2 s = float2(1, 1.7320508); | |
| 116 | + float2 a = p - s * floor(p / s + .5), b = p - s * (floor((p - s * .5) / s + .5) + .5); | |
| 117 | + return dot(a, a) < dot(b, b) ? float4(a, round(p / s)) : float4(b, round((p - s * .5) / s) + .5); | |
| 118 | + } | |
| 119 | + // Repeat with a stable cell index. | |
| 120 | + float repeatId(float x, float period) { return floor(x / period + .5); } | |
| 121 | + | |
| 122 | + // ---------------------------------------------------------------- shading | |
| 123 | + float3 paint(float phase, constant NativeFrame &f) { | |
| 124 | + float cycle = phase - floor(phase * .5) * 2; | |
| 125 | + float x = (cycle < 1 ? cycle : 2 - cycle) * 4; | |
| 126 | + int i = min(3, int(x)); | |
| 127 | + return mix(f.colors[i].rgb, f.colors[i + 1].rgb, x - float(i)); | |
| 128 | + } | |
| 129 | + float3 deep(float phase, constant NativeFrame &f) { return paint(phase, f) * paint(phase + .5, f); } | |
| 130 | + float glow(float d, float width) { return width * width / (width * width + d * d); } | |
| 131 | + float line(float d, float width, float px) { return 1 - smoothstep(width - px, width + px, abs(d)); } | |
| 132 | + float fill(float d, float px) { return 1 - smoothstep(-px, px, d); } | |
| 133 | + float3 hsvTint(float3 color, float amount) { float l = dot(color, float3(.299, .587, .114)); return mix(float3(l), color, amount); } | |
| 134 | + // Thin-film interference tint, used for soap, oil and opal colors; blended with the palette. | |
| 135 | + float3 filmColor(float thickness, constant NativeFrame &f) { | |
| 136 | + float3 rainbow = .5 + .5 * cos(TAU * (thickness + float3(0, .33, .67))); | |
| 137 | + return mix(paint(thickness, f), rainbow * paint(thickness * .5 + .2, f) * 2, .45); | |
| 138 | + } | |
| 139 | + | |
| 140 | + // ---------------------------------------------------------------- raymarch helpers | |
| 141 | + float3 cameraRay(float2 uv, float3 forward, float3 up, float lens) { | |
| 142 | + float3 w = normalize(forward), u = normalize(cross(up, w)), v = cross(w, u); | |
| 143 | + return normalize(uv.x * u + uv.y * v + lens * w); | |
| 144 | + } | |
| 145 | + // Slot k (back to front) of a forward-moving stack of n layers. x = phase (0 far, 1 at | |
| 146 | + // the viewer), y = a stable layer id that survives the wrap, so layers never pop. | |
| 147 | + float2 layerSlot(int k, int n, float travel) { | |
| 148 | + float shift = travel * float(n); | |
| 149 | + return float2((float(k) + fract(shift)) / float(n), float(k) - floor(shift)); | |
| 150 | + } | |
| 151 | + float layerFade(float phase) { return smoothstep(0.f, .22f, phase) * (1 - smoothstep(.8f, 1.f, phase)); } | |
| 152 | + // Magnification for a layer: far layers are small and dense, near layers large. | |
| 153 | + float layerScale(float phase, float range) { return exp2((1 - phase) * range); } | |
| 154 | + // Seamless scale-space zoom for self-similar patterns: two octaves crossfade at weight 0. | |
| 155 | + float2 octaveZoom(float travel, int octave) { | |
| 156 | + float z = fract(travel); | |
| 157 | + float weight = octave == 0 ? 1 - smoothstep(0.f, 1.f, z) : smoothstep(0.f, 1.f, z); | |
| 158 | + return float2(exp2(float(octave) - z), weight); | |
| 159 | + } | |
| 160 | + // Oblique camera over a ground plane; the horizon sits above the canvas so the plane | |
| 161 | + // fills every aspect ratio. Returns ground x, forward distance and view distance. | |
| 162 | + float3 groundView(float2 uv, float2 extent, float height, float margin) { | |
| 163 | + float horizon = extent.y + margin; | |
| 164 | + float depth = height / max(horizon - uv.y, 1e-3f); | |
| 165 | + return float3(uv.x * depth, depth, depth * length(float2(1, uv.x))); | |
| 166 | + } | |
| 167 | + | |
| 168 | + // ---------------------------------------------------------------- context / output | |
| 169 | + Ctx makeContext(float2 position, constant NativeFrame &f) { | |
| 170 | + Ctx c; | |
| 171 | + float2 res = max(f.resolution, float2(1)); | |
| 172 | + float shortSide = min(res.x, res.y); | |
| 173 | + c.screen = position / res; | |
| 174 | + c.extent = res / shortSide; | |
| 175 | + float2 uv = (position - res * .5) / (shortSide * .5); | |
| 176 | + uv.y = -uv.y; | |
| 177 | + float zoom = clamp(f.style.w, .3f, 2.f); | |
| 178 | + c.uv = rot(uv, f.camera.x) / zoom; | |
| 179 | + c.extent /= zoom; | |
| 180 | + c.px = 2 / (shortSide * zoom); | |
| 181 | + c.travel = f.motion.x; | |
| 182 | + c.m = f.motion.y; | |
| 183 | + // Integrate measured percussion energy; never multiply absolute time by a | |
| 184 | + // changing amplitude, which would jump or reverse the animation on each beat. | |
| 185 | + c.t = f.motion.z + c.m * 3; | |
| 186 | + c.e = clamp(f.motion.w, 0.f, 1.5f); | |
| 187 | + c.hit = clamp(f.rhythm.x, 0.f, 1.f); | |
| 188 | + c.b = clamp(f.bands, 0.f, 1.f); | |
| 189 | + c.size = sqrt(clamp(f.style.y, .3f, 6.f)); | |
| 190 | + c.fog = clamp(f.style.z, 0.f, 1.f); | |
| 191 | + c.detail = clamp(f.camera.z, 0.f, 1.f); | |
| 192 | + return c; | |
| 193 | + } | |
| 194 | + | |
| 195 | + // Music moves each design's elements, never the picture as a whole. Every design gets one of | |
| 196 | + // three motion styles for its family, so neighbouring designs move differently: | |
| 197 | + // tunnels 0 wobble (the tube flexes in lobes that roll around it) | |
| 198 | + // 1 twist (rings at different depths turn, so lines wind into spirals; all of 310–319) | |
| 199 | + // 2 ripple (rings wave in and out as waves run down the bore) | |
| 200 | + // flights 0 slither (lanes bend sideways in an S that runs toward the viewer) | |
| 201 | + // 1 swell (the ground rolls in waves across the lanes) | |
| 202 | + // 2 churn (turbulent ground) | |
| 203 | + // fields 0 eddies, 1 rolling waves, 2 liquid flow | |
| 204 | + // The attack swell keeps each beat moving for about a quarter second and the music's momentum | |
| 205 | + // keeps everything moving between beats. All of it is zero at zero Chaos or in silence; higher | |
| 206 | + // Chaos also raises the gain, so the slider reads as "more chaotic", not just "louder". | |
| 207 | + // Second versions (370–389) and Coaster versions move exactly like the designs they come from. | |
| 208 | + constant short secondVersionSources[20] = {336, 337, 339, 340, 341, 342, 343, 345, 346, 347, 348, 349, 351, 352, 353, 354, 355, 357, 358, 359}; | |
| 209 | + Ctx rhythmicSurface(Ctx c, constant NativeFrame &f, int design) { | |
| 210 | + int scene = design >= 370 && design <= 389 ? int(secondVersionSources[design - 370]) : design; | |
| 211 | + float variant = float((scene - 100) % 7); | |
| 212 | + // Material-lined tunnels (310–319) twist: their fine weaves and scales read best turning, | |
| 213 | + // and the encoder keeps their detail; everything else spreads across the three styles. | |
| 214 | + int style = scene >= 310 && scene <= 319 ? 1 : scene % 3; | |
| 215 | + float2 p = c.uv; | |
| 216 | + float chaos = clamp(f.camera.y, 0.f, 1.f); | |
| 217 | + float gain = .55 + chaos; | |
| 218 | + float beat = min(1.f, c.hit * .7 + clamp(f.rhythm.z, 0.f, 1.f) * .6); | |
| 219 | + float energy = c.e; | |
| 220 | + float bass = c.b.x, body = c.b.y, fine = .5 * (c.b.z + c.b.w); | |
| 221 | + // Slow turbulence shared by every style; its strength follows the music's energy. | |
| 222 | + float2 drift = curl2(p * 1.4 + float2(c.t * .05, -c.t * .04) + variant) * .3; | |
| 223 | + bool tunnel = (scene >= 245 && scene <= 279) || (scene >= 300 && scene <= 319) || (scene >= 360 && scene <= 369); | |
| 224 | + bool drive = (scene >= 200 && scene <= 209) || (scene >= 220 && scene <= 244) || (scene >= 330 && scene <= 339); | |
| 225 | + if (tunnel) { | |
| 226 | + float r = length(p), a = atan2(p.y, p.x); | |
| 227 | + float depth = log(max(r, 1e-3f)); | |
| 228 | + float reach = smoothstep(.04f, .35f, r); | |
| 229 | + float2 radial = p / max(r, 1e-5f); | |
| 230 | + float push = 0, turn = 0; | |
| 231 | + if (style == 0) { | |
| 232 | + push = (beat * .5 + bass * .16 + energy * .1) * sin(a * (3 + variant) + depth * 2 - c.t * .45); | |
| 233 | + } else if (style == 1) { | |
| 234 | + turn = (beat * 1.1 + bass * .32 + energy * .25) * sin(depth * (3.5 + variant * .4) + beat * 6 - c.t * .4); | |
| 235 | + } else { | |
| 236 | + push = (beat * .32 + bass * .14 + energy * .08) * sin(depth * 6 - c.t * 1.6 + variant); | |
| 237 | + turn = body * .2 * sin(a * 3 - depth * 4 + c.t * .5); | |
| 238 | + } | |
| 239 | + turn += (body * .16 + fine * .1) * sin(a * 4 - depth * 6 + c.t * .6); | |
| 240 | + float2 q = rot(p, turn * gain * reach); | |
| 241 | + q += radial * push * gain * r / (1 + r); | |
| 242 | + c.uv = q + drift * energy * gain * .35 * reach; | |
| 243 | + } else if (drive) { | |
| 244 | + float lane = p.x * (2.4 + variant * .2); | |
| 245 | + if (style == 0) { | |
| 246 | + c.uv.x += (beat * .24 + bass * .1 + energy * .06) * gain * sin(p.y * 4 + beat * 6 + c.t * .5 + variant); | |
| 247 | + } else if (style == 1) { | |
| 248 | + c.uv.y += (beat * .2 + bass * .1 + energy * .05) * gain * sin(lane + p.y * 3 - c.t * .5); | |
| 249 | + } else { | |
| 250 | + c.uv += drift * (beat * .35 + bass * .12 + energy * .1) * gain; | |
| 251 | + } | |
| 252 | + c.uv.x += (body * .1 + fine * .1) * gain * sin(p.y * 5 + lane * .5 + c.t * .4); | |
| 253 | + c.uv += drift * energy * gain * .25; | |
| 254 | + } else { | |
| 255 | + if (style == 0) { | |
| 256 | + float2 q = p * (1.2 + variant * .1) + float2(c.t * .06, -c.t * .045); | |
| 257 | + c.uv += curl2(q) * .45 * (beat * .55 + bass * .18 + body * .12 + energy * .1) * gain; | |
| 258 | + } else if (style == 1) { | |
| 259 | + float2 wave = float2(sin(p.y * (3.2 + variant * .2) + p.x * 1.7 + c.t * .6), | |
| 260 | + cos(p.x * (3.8 + variant * .2) - p.y * 2.1 - c.t * .5)); | |
| 261 | + c.uv += wave * float2(beat * .3 + bass * .12 + energy * .05, beat * .22 + body * .16 + energy * .05) * gain; | |
| 262 | + } else { | |
| 263 | + float2 flow = float2(fbm2(p * 1.3 + c.t * .08, 3), fbm2(p * 1.3 + 5.2 - c.t * .07, 3)) - .5; | |
| 264 | + c.uv += flow * (beat * .5 + bass * .2 + body * .14 + energy * .15) * gain; | |
| 265 | + } | |
| 266 | + c.uv += fine * .055 * gain * float2(sin(p.y * 13 - c.t), cos(p.x * 11 + c.t)); | |
| 267 | + c.uv += drift * energy * gain * .3; | |
| 268 | + } | |
| 269 | + return c; | |
| 270 | + } | |
| 271 | + | |
| 272 | + // ---------------------------------------------------------------- roller-coaster course | |
| 273 | + // Coaster versions ride a real tube that winds through space instead of a straight bore. Each | |
| 274 | + // pixel's ray is traced against a tube whose centreline bends away ahead of the camera; the design | |
| 275 | + // is handed the wall's own coordinates (the angle around the tube and the depth along it) as | |
| 276 | + // the uv a straight tunnel has there. The walls stay rigid: they sweep past while the far end | |
| 277 | + // swings away around each bend and drops behind the wall on tight turns, the track climbs and | |
| 278 | + // dives, and the camera banks into each turn. Mirrored in NativeCommon.metal. | |
| 279 | + float2 coasterPath(float z, float seed) { | |
| 280 | + return float2(1.5 * sin(z * .3 + seed) + .6 * sin(z * .55 + seed * 2.3), | |
| 281 | + 1.1 * sin(z * .26 + seed * 1.7 + 1.1) + .5 * sin(z * .5 + seed * .6)); | |
| 282 | + } | |
| 283 | + float2 coasterSlope(float z, float seed) { | |
| 284 | + return float2(.45 * cos(z * .3 + seed) + .33 * cos(z * .55 + seed * 2.3), | |
| 285 | + .286 * cos(z * .26 + seed * 1.7 + 1.1) + .25 * cos(z * .5 + seed * .6)); | |
| 286 | + } | |
| 287 | + // Distance from the tube's axis across its section: round, or square for box corridors. | |
| 288 | + float coasterRadius(float2 q, bool square) { return square ? max(fabs(q.x), fabs(q.y)) : length(q); } | |
| 289 | + // Where the ray is across the tube's section at depth z, relative to the bending centreline. | |
| 290 | + float2 coasterLateral(float2 ray, float z, float along, float2 origin, float2 slope, float seed) { | |
| 291 | + return ray * z - (coasterPath(along + z, seed) - origin - slope * z); | |
| 292 | + } | |
| 293 | + Ctx coasterTube(Ctx c, float seed, float along, bool square) { | |
| 294 | + // The camera rides the centreline. Its view lags the track a little, so each turn swings | |
| 295 | + // the outer wall into view before the far end goes round it, and it banks into the turn. | |
| 296 | + float2 origin = coasterPath(along, seed), slope = coasterSlope(along - 1.2, seed); | |
| 297 | + float2 ray = rot(c.uv, -.3 * (coasterSlope(along + 4, seed).x - slope.x)); | |
| 298 | + float spread = length(ray); | |
| 299 | + float z = .05, inside = .05, gap = 1; | |
| 300 | + float2 lateral = ray * z; | |
| 301 | + for (int i = 0; i < 40; ++i) { | |
| 302 | + lateral = coasterLateral(ray, z, along, origin, slope, seed); | |
| 303 | + gap = 1 - coasterRadius(lateral, square); | |
| 304 | + if (gap < 0) break; | |
| 305 | + inside = z; | |
| 306 | + if (gap < .002 || z > 60) break; | |
| 307 | + z += gap * .85 / (spread + min(2.f, .4f * z + .6f)); | |
| 308 | + } | |
| 309 | + // A step can cross the wall: bisect between the last depth inside and the first outside. | |
| 310 | + if (gap < 0) { | |
| 311 | + float outside = z; | |
| 312 | + for (int i = 0; i < 6; ++i) { | |
| 313 | + z = .5 * (inside + outside); | |
| 314 | + lateral = coasterLateral(ray, z, along, origin, slope, seed); | |
| 315 | + if (coasterRadius(lateral, square) < 1) inside = z; else outside = z; | |
| 316 | + } | |
| 317 | + } | |
| 318 | + float2 uv = lateral / max(coasterRadius(lateral, square), 1e-4f) / z; | |
| 319 | + // Pixel footprint for anti-aliasing: walls bunch up on the inside of a turn. | |
| 320 | + c.px = clamp(max(length(dfdx(uv)), length(dfdy(uv))), c.px * .25f, c.px * 6); | |
| 321 | + c.uv = uv; | |
| 322 | + return c; | |
| 323 | + } | |
| 324 | + // The Coaster versions (390–455) ride the track of the design they come from. | |
| 325 | + Ctx coasterRide(Ctx c, int source, bool box) { return coasterTube(c, float(source) * 1.37, c.travel * 2.4 + c.m * .8, box); } | |
| 326 | + | |
| 327 | + float4 finish(float3 color, float2 position, constant NativeFrame &f) { | |
| 328 | + color = max(color, float3(0)) * max(0.f, f.style.x); | |
| 329 | + color = 1 - exp(-color * 1.55); | |
| 330 | + // Static ordered dither keeps smooth gradients from banding in 8-bit video. | |
| 331 | + float dither = (hash21(floor(position)) - .5) / 255; | |
| 332 | + return float4(saturate(color + dither), 1); | |
| 333 | + } | |
| 334 | + | |
| 335 | + // Each effect is `float3 name(Ctx c, constant NativeFrame &f)`; this emits its fragment. | |
| 336 | + #define NATIVE_EFFECT(name) \ | |
| 337 | + fragment float4 name##Fragment(float4 position [[position]], constant NativeFrame &f [[buffer(0)]]) { \ | |
| 338 | + Ctx c = rhythmicSurface(makeContext(position.xy, f), f, f.scene); \ | |
| 339 | + return finish(name(c, f), position.xy, f); \ | |
| 340 | + } | |
| 341 | + // A design's Coaster version: the same design riding the roller-coaster course (box: square tube). | |
| 342 | + #define NATIVE_COASTER(name, source, box) \ | |
| 343 | + fragment float4 name##CoasterFragment(float4 position [[position]], constant NativeFrame &f [[buffer(0)]]) { \ | |
| 344 | + Ctx c = rhythmicSurface(coasterRide(makeContext(position.xy, f), source, box), f, source); \ | |
| 345 | + return finish(name(c, f), position.xy, f); \ | |
| 346 | + } | |
| 347 | + | |
| 348 | + vertex float4 nativeVertex(uint id [[vertex_id]]) { | |
| 349 | + const float2 p[3] = {float2(-1, -1), float2(3, -1), float2(-1, 3)}; | |
| 350 | + return float4(p[id], 0, 1); | |
| 351 | + } |
Sources/PulseCanvas/Resources/NativeExpansionCosmos.metal added
| 1 | + // Original PulseCanvas designs 350–359. Cosmic phenomena drawn as vivid neon light, not | |
| 2 | + // photographic space art: beams, shells, streams, loops and lensed arcs built from analytic | |
| 3 | + // curves and a little noise. Every band drives its own structures; attacks make local events. | |
| 4 | + | |
| 5 | + // ---------------------------------------------------------------- shared helpers (cosm*) | |
| 6 | + // Ridged noise: thin bright creases, the raw material of filaments. | |
| 7 | + float cosmRidge(float2 p, int octaves) { | |
| 8 | + float sum = 0, amplitude = .5; | |
| 9 | + for (int i = 0; i < octaves; ++i) { | |
| 10 | + float n = 1 - abs(2 * noise2(p) - 1); | |
| 11 | + sum += amplitude * n * n; | |
| 12 | + p = float2(p.x * 1.6 - p.y * 1.2, p.x * 1.2 + p.y * 1.6) + 4.7; | |
| 13 | + amplitude *= .5; | |
| 14 | + } | |
| 15 | + return sum; | |
| 16 | + } | |
| 17 | + // Sparse twinkling specks, one jittered candidate per cell, with no seams at cell edges. | |
| 18 | + float cosmStars(float2 p, float density, float t) { | |
| 19 | + float2 id = floor(p), local = fract(p) - .5, h = hash22(id + 31.7); | |
| 20 | + float on = step(1 - density, hash21(id + 9.1)); | |
| 21 | + float2 offset = local - (h - .5) * .6; | |
| 22 | + float twinkle = .6 + .4 * sin(t * (1.1 + h.x * 2) + h.y * TAU); | |
| 23 | + return on * twinkle * exp(-dot(offset, offset) * 900); | |
| 24 | + } | |
| 25 | + // Distance in uv units to the nearest integer contour of a smooth field v. | |
| 26 | + float cosmContour(float v, float px) { | |
| 27 | + return abs(fract(v + .5) - .5) * px / max(fwidth(v), 1e-5f); | |
| 28 | + } | |
| 29 | + // Lay a two-body composition along the canvas's long axis. | |
| 30 | + float2 cosmLongAxis(float2 p, float2 extent) { | |
| 31 | + return extent.y > extent.x ? float2(p.y, -p.x) : p; | |
| 32 | + } | |
| 33 | + | |
| 34 | + // ---------------------------------------------------------------- 350 Pulsar Beacon | |
| 35 | + float3 pulsarBeacon(Ctx c, constant NativeFrame &f) { | |
| 36 | + float2 p = c.uv / c.size; | |
| 37 | + float spin = c.t * .55; | |
| 38 | + // Attacks shear thin horizontal slices sideways: a glitch flare through the beams. | |
| 39 | + float slice = floor(p.y * 28); | |
| 40 | + float shear = (noise2(float2(slice * 1.37, c.t * 5)) - .5) * c.hit * c.hit * .8; | |
| 41 | + float2 g = p + float2(shear, 0); | |
| 42 | + float r = length(g), a = atan2(g.y, g.x); | |
| 43 | + float lag = (spin - a) - PI * floor((spin - a) / PI); // time since a beam swept here | |
| 44 | + float offset = lag > PI * .5 ? lag - PI : lag; // signed angle to nearest beam | |
| 45 | + float width = .045 + .05 * c.b.x; | |
| 46 | + float cone = exp(-offset * offset / (width * width)) * exp(-r * .25); | |
| 47 | + float spine = glow(r * sin(offset), .004 + .005 * c.b.x) * exp(-r * .4); | |
| 48 | + | |
| 49 | + // Nebula gas, lit by the sweep and fading behind it. | |
| 50 | + float2 drift = float2(c.t * .013, -c.t * .009); | |
| 51 | + float gas = fbm2(p * 1.25 + drift, 5); | |
| 52 | + float strands = cosmRidge(p * 2.3 + gas * 1.6 - drift * 1.5, 4); | |
| 53 | + float cloud = smoothstep(.3f, .78f, gas); | |
| 54 | + float after = (1 - exp(-lag * 30)) * exp(-lag * (2.6 - 1.4 * c.b.y)); | |
| 55 | + float lit = after * (.3 + .7 * cloud) * (.35 + strands * 1.6); | |
| 56 | + float glint = pow(strands, 6.f) * cloud * (.2 + 3 * c.b.w); | |
| 57 | + float pulse = pow(.5 + .5 * cos(TAU * (r * 1.5 - c.t * .4)), 30.f) * cloud * (.15 + 1.6 * c.b.w); | |
| 58 | + | |
| 59 | + // Magnetic loops share the beam axis and spin with it. | |
| 60 | + float2 m = rot(p, -spin); | |
| 61 | + float rm = max(length(m), 1e-3f); | |
| 62 | + float shell = rm * rm * rm / max(m.y * m.y, 1e-6f); | |
| 63 | + float lv = log2(shell) * 1.6; | |
| 64 | + float loopMask = smoothstep(1.2f, .7f, shell) * smoothstep(.03f, .08f, rm); | |
| 65 | + float flowing = .55 + .45 * sin(atan2(m.y, m.x) * 6 - c.t * 3); | |
| 66 | + float loops = glow(cosmContour(lv, c.px) / c.size, .005) * loopMask * flowing * (.25 + 1.8 * c.b.z); | |
| 67 | + | |
| 68 | + float rp = length(p); | |
| 69 | + float star = glow(rp, .02) * 3 + glow(rp, .09) * .5; | |
| 70 | + float flare = (glow(p.y, .005 + .006 * c.hit) * exp(-abs(p.x) * (3.4 - 2.4 * c.hit)) | |
| 71 | + + glow(p.x, .004) * exp(-abs(p.y) * 6)) * (.25 + 2.4 * c.hit); | |
| 72 | + float bars = c.hit * c.hit * smoothstep(.62f, .8f, noise2(float2(slice * 2.1, c.t * 6))) * exp(-r * .9) * .7; | |
| 73 | + | |
| 74 | + float3 col = paint(.02 + gas * .2, f) * (.035 + .12 * gas * gas); | |
| 75 | + col += paint(.22 + strands * .15, f) * cloud * strands * .16; | |
| 76 | + col += paint(.42 + .38 * after, f) * lit * (.75 + .25 * strands); | |
| 77 | + col += paint(.75, f) * (glint + pulse * .6); | |
| 78 | + col += paint(.72, f) * cone * (.35 + 1.9 * c.b.x) * (.3 + .6 * cloud + strands * .7); | |
| 79 | + col += paint(.8, f) * spine * (.8 + 2.5 * c.b.x); | |
| 80 | + col += paint(.58, f) * loops * 1.4; | |
| 81 | + col += paint(.78, f) * (star + flare) + paint(.25, f) * bars; | |
| 82 | + return col; | |
| 83 | + } | |
| 84 | + NATIVE_EFFECT(pulsarBeacon) | |
| 85 | + | |
| 86 | + // ---------------------------------------------------------------- 351 Twin Suns | |
| 87 | + float4 cosmSun(float2 d, float radius, float spin, float hue, float corona, float px, constant NativeFrame &f) { | |
| 88 | + float r = length(d) / radius; | |
| 89 | + float mu = sqrt(max(0.f, 1 - r * r)); | |
| 90 | + float2 sp = rot(d / radius, spin); | |
| 91 | + float cells = noise2(sp * 5 + 3.3) * .6 + noise2(sp * 11 + 8.1) * .4; | |
| 92 | + float3 surface = paint(hue + .2 * mu + .12 * cells, f) * (.7 + 1.1 * mu) + paint(.95, f) * pow(mu, 3.f) * .5; | |
| 93 | + float disc = fill(r - 1, px / radius); | |
| 94 | + float a = atan2(d.y, d.x) + spin * .3; | |
| 95 | + float rays = pow(.5 + .5 * cos(a * 14 + 2 * sin(a * 5 + spin * 2)), 6.f) * exp(-max(r - 1, 0.f) * (2.6 - corona * 1.2)); | |
| 96 | + float halo = glow(max(r - 1, 0.f), .25 + corona * .45) * (.3 + corona * 1.4); | |
| 97 | + float rim = glow(r - 1, .05); | |
| 98 | + float3 col = surface * disc + (paint(hue + .15, f) * (halo + rays * (.25 + corona * 1.5)) + paint(.9, f) * rim * .6) * (1 - disc); | |
| 99 | + return float4(col, disc); | |
| 100 | + } | |
| 101 | + | |
| 102 | + float3 twinSuns(Ctx c, constant NativeFrame &f) { | |
| 103 | + float2 p = cosmLongAxis(c.uv / c.size, c.extent); | |
| 104 | + float phase = c.t * .3; | |
| 105 | + float2 orbit = float2(cos(phase), sin(phase) * .55); | |
| 106 | + float2 s1 = orbit * .42, s2 = -orbit * .74; | |
| 107 | + const float r1 = .23, r2 = .135; | |
| 108 | + | |
| 109 | + // Circumbinary outflow: two trailing arms of glowing filaments that turn with the orbit. | |
| 110 | + float rho = length(p), th = atan2(p.y, p.x); | |
| 111 | + float spiral = 2 * (th - phase) + log(rho + .08) * 3.4; | |
| 112 | + float arms = pow(.5 + .5 * cos(spiral), 2.f); | |
| 113 | + float tex = fbm2(p * 2.1 + float2(c.t * .02, -c.t * .013), 4); | |
| 114 | + float threads = pow(.5 + .5 * cos(spiral * 5 + tex * 5), 10.f); | |
| 115 | + float gas = arms * exp(-rho * .3); | |
| 116 | + float3 col = paint(.02 + tex * .1, f) * (.04 + .1 * tex); | |
| 117 | + col += paint(.25 + tex * .35, f) * gas * (.06 + .2 * tex) * (.6 + 1.2 * c.b.y); | |
| 118 | + col += paint(.5 + .25 * tex, f) * gas * threads * (.22 + 1.5 * c.b.y); | |
| 119 | + | |
| 120 | + // Tidal streams from the larger star to its companion, one strand per band. | |
| 121 | + float2 dv = s2 - s1; float len = length(dv); | |
| 122 | + float2 ax = dv / len, nv = float2(-ax.y, ax.x), rel = p - s1; | |
| 123 | + float u = dot(rel, ax) / len, v = dot(rel, nv), uc = clamp(u, 0.f, 1.f); | |
| 124 | + float ends = smoothstep(-.05f, .15f, u) * smoothstep(1.05f, .85f, u); | |
| 125 | + for (int k = 0; k < 4; ++k) { | |
| 126 | + float fk = float(k), level = c.b[k]; | |
| 127 | + float bend = ((.12 + .06 * fk) * len + .04 * sin(TAU * uc * 1.5 + c.t * .8 + fk * 1.7)) * sin(PI * uc); | |
| 128 | + float dist = abs(v - bend); | |
| 129 | + float flow = pow(.5 + .5 * sin(u * 16 - c.t * 2.4 + fk * 1.9), 3.f); | |
| 130 | + float strand = glow(dist, .009 + .009 * level) * (.35 + .65 * flow) + glow(dist, .06) * .2; | |
| 131 | + col += paint(.55 + .08 * fk + .25 * flow, f) * strand * ends * (.35 + 1.8 * level); | |
| 132 | + } | |
| 133 | + | |
| 134 | + // Attacks erupt a flare loop and an ejected blob from each star. | |
| 135 | + float burst = c.hit * c.hit; | |
| 136 | + float3 flares = 0; | |
| 137 | + for (int k = 0; k < 2; ++k) { | |
| 138 | + float2 s = k == 0 ? s1 : s2; float radius = k == 0 ? r1 : r2; | |
| 139 | + float fa = phase * (k == 0 ? 1.7 : -1.3) + float(k) * 2.4 + .8; | |
| 140 | + float2 dir = float2(cos(fa), sin(fa)); | |
| 141 | + float2 site = s + dir * radius; | |
| 142 | + float loopArc = abs(length(p - site) - radius * (.2 + .9 * c.hit)); | |
| 143 | + float outside = smoothstep(radius, radius * 1.05, length(p - s)); | |
| 144 | + float blob = glow(length(p - s - dir * radius * (1.15 + 2.6 * (1 - c.hit))), .03 + .05 * (1 - c.hit)); | |
| 145 | + flares += paint(.85, f) * (glow(loopArc, .008) * outside * 1.5 + blob) * burst; | |
| 146 | + } | |
| 147 | + | |
| 148 | + // Stars, drawn back to front as the orbit turns. | |
| 149 | + float4 a = cosmSun(p - s1, r1, c.t * .2, .45, c.b.x, c.px, f); | |
| 150 | + float4 b = cosmSun(p - s2, r2, -c.t * .3, .7, c.b.z, c.px, f); | |
| 151 | + bool firstFront = sin(phase) < 0; | |
| 152 | + float4 back = firstFront ? b : a, front = firstFront ? a : b; | |
| 153 | + col = col * (1 - back.w) + back.rgb; | |
| 154 | + col += flares; | |
| 155 | + col = col * (1 - front.w) + front.rgb; | |
| 156 | + col += paint(.9, f) * cosmStars(p * 9, .25, c.t) * .5; | |
| 157 | + return col; | |
| 158 | + } | |
| 159 | + NATIVE_EFFECT(twinSuns) | |
| 160 | + | |
| 161 | + // ---------------------------------------------------------------- 352 Supernova Shell | |
| 162 | + float3 supernovaShell(Ctx c, constant NativeFrame &f) { | |
| 163 | + float2 p = c.uv / c.size; | |
| 164 | + float r = length(p); | |
| 165 | + float2 dirv = p / max(r, 1e-4f); | |
| 166 | + const float R = .64; | |
| 167 | + float wob = noise2(dirv * 2.2 + 11.3) - .5; | |
| 168 | + float Ro = R * (1 + .14 * wob), Ri = Ro * .84; | |
| 169 | + float shell = (sqrt(max(Ro * Ro - r * r, 0.f)) - sqrt(max(Ri * Ri - r * r, 0.f))) / sqrt(Ro * Ro - Ri * Ri); | |
| 170 | + | |
| 171 | + // Filaments drift outward through a seamless two-octave zoom. | |
| 172 | + float coarse = 0, fine = 0, wisp = 0; | |
| 173 | + for (int o = 0; o < 2; ++o) { | |
| 174 | + float2 z = octaveZoom(c.t * .03, o); | |
| 175 | + float2 q = p * z.x; | |
| 176 | + coarse += z.y * cosmRidge(q * 3.1 + 1.7, 3); | |
| 177 | + fine += z.y * cosmRidge(q * 7.3 - 4.1, 3); | |
| 178 | + wisp += z.y * fbm2(q * 2.4 + 9.5, 2); | |
| 179 | + } | |
| 180 | + coarse = pow(coarse / .875, 5.f); | |
| 181 | + fine = pow(fine / .875, 7.f); | |
| 182 | + | |
| 183 | + // Hit: a fresh shock ring races out and lights the filaments it crosses. | |
| 184 | + float Rh = R * (.08 + 1.35 * (1 - c.hit)) * (1 + .1 * wob); | |
| 185 | + float shockBoost = 1 + 2.5 * c.hit * exp(-(r - Rh) * (r - Rh) / .008); | |
| 186 | + float newRing = glow(r - Rh, .012) * c.hit * c.hit * 2; | |
| 187 | + | |
| 188 | + float inner = smoothstep(Ri, Ri * .3, r); | |
| 189 | + float2 kq = p * 8; | |
| 190 | + float2 kid = floor(kq), kl = fract(kq) - .5 - (hash22(kid + 4.4) - .5) * .6; | |
| 191 | + float knot = step(.6, hash21(kid + 1.9)) * exp(-dot(kl, kl) * 60) * smoothstep(.3f, .7f, shell); | |
| 192 | + | |
| 193 | + float Rs = R * (1.15 + .1 * (noise2(dirv * 3.1 + 2.2) - .5)); | |
| 194 | + float forward = glow(r - Rs, .006) * .9 + glow(r - Rs, .05) * .18; | |
| 195 | + | |
| 196 | + float haze = fbm2(p * .9 + float2(4.1, c.t * .01), 3); | |
| 197 | + float3 col = paint(.95 + haze * .1, f) * (.03 + .08 * haze * haze); | |
| 198 | + col += paint(.1 + haze * .3, f) * smoothstep(.5f, .85f, haze) * .1; | |
| 199 | + col += paint(.8 + .1 * wob, f) * shell * (.07 + coarse * (.7 + 2.4 * c.b.x)) * shockBoost; | |
| 200 | + col += paint(.3 + .1 * fine, f) * shell * fine * (.45 + 2.6 * c.b.y) * shockBoost; | |
| 201 | + col += paint(.02 + .08 * wisp, f) * inner * pow(wisp, 3.f) * (.4 + 2.4 * c.b.z); | |
| 202 | + col += paint(.72, f) * knot * (.4 + 3 * c.b.w) * shockBoost; | |
| 203 | + col += paint(.05, f) * forward; | |
| 204 | + col += paint(.7, f) * (newRing + glow(r, .025) * 1.2 + glow(r, .08) * .2); | |
| 205 | + col += paint(.6, f) * cosmStars(p * 11, .2, c.t) * .4; | |
| 206 | + return col; | |
| 207 | + } | |
| 208 | + NATIVE_EFFECT(supernovaShell) | |
| 209 | + | |
| 210 | + // ---------------------------------------------------------------- 353 Galaxy Collision | |
| 211 | + // Two-armed log spiral seen in its own (de-projected) plane: x = arm A, y = arm B, z = disc. | |
| 212 | + float3 cosmSpiral(float2 q, float spin, float wind) { | |
| 213 | + float r = max(length(q), 1e-3f); | |
| 214 | + float phi = atan2(q.y, q.x) - wind * log(r) - spin; | |
| 215 | + float c1 = cos(phi); | |
| 216 | + return float3(pow(max(c1, 0.f), 6.f), pow(max(-c1, 0.f), 6.f), r); | |
| 217 | + } | |
| 218 | + | |
| 219 | + float3 galaxyCollision(Ctx c, constant NativeFrame &f) { | |
| 220 | + float2 p = cosmLongAxis(c.uv / c.size, c.extent); | |
| 221 | + float orbit = c.t * .035; | |
| 222 | + float2 c1 = rot(float2(-.58, .14), orbit), c2 = rot(float2(.62, -.16), orbit); | |
| 223 | + float2 q1 = rot(p - c1, .5 + orbit); q1.y /= .6; | |
| 224 | + float2 q2 = rot(p - c2, -.9 + orbit); q2.y /= .5; | |
| 225 | + float3 g1 = cosmSpiral(q1 * .8, c.t * .16, 2.3), g2 = cosmSpiral(q2 * .9, -c.t * .13, -2.1); | |
| 226 | + float clumps = .45 + .55 * noise2(p * 9 + float2(c.t * .05, 0)); | |
| 227 | + | |
| 228 | + float disc1 = exp(-g1.z * 2.6), disc2 = exp(-g2.z * 3); | |
| 229 | + // Tidal tails: the outer arms keep going on the side facing away from the partner. | |
| 230 | + float2 away1 = normalize(c1 - c2); | |
| 231 | + float tailMask1 = smoothstep(-.2f, .5f, dot(normalize(p - c1 + 1e-4), away1)); | |
| 232 | + float tailMask2 = smoothstep(-.2f, .5f, dot(normalize(p - c2 + 1e-4), -away1)); | |
| 233 | + float tail1 = g1.x * exp(-g1.z * .75) * tailMask1 * smoothstep(.25f, .6f, g1.z); | |
| 234 | + float tail2 = g2.y * exp(-g2.z * .8) * tailMask2 * smoothstep(.25f, .6f, g2.z); | |
| 235 | + | |
| 236 | + // A bridge of stars stretched between the pair. | |
| 237 | + float2 dv = c2 - c1; float len = length(dv); | |
| 238 | + float2 ax = dv / len, rel = p - c1; | |
| 239 | + float u = dot(rel, ax) / len, v = dot(rel, float2(-ax.y, ax.x)); | |
| 240 | + float bridgeDist = abs(v - .16 * len * sin(PI * clamp(u, 0.f, 1.f))); | |
| 241 | + float bridge = glow(bridgeDist, .03) * smoothstep(-.05f, .2f, u) * smoothstep(1.05f, .8f, u); | |
| 242 | + | |
| 243 | + float armA = g1.x * disc1, armB = g1.y * disc1, armC = (g2.x + g2.y) * disc2; | |
| 244 | + float tails = tail1 + tail2 + bridge * .6; | |
| 245 | + | |
| 246 | + // Starburst knots sit on the arms; attacks blossom them with an expanding ring. | |
| 247 | + float2 kq = p * 7, kid = floor(kq), kl = (fract(kq) - .5 - (hash22(kid + 2.7) - .5) * .6) / 7; | |
| 248 | + float kd = length(kl); | |
| 249 | + float knotOn = step(.5, hash21(kid + 6.1)); | |
| 250 | + float host = min(1.f, (armA + armB + armC) * 2 + tails * 2); | |
| 251 | + float knot = knotOn * host * (glow(kd, .006 + .01 * c.hit) * (.6 + 3 * c.hit) | |
| 252 | + + glow(kd - (.015 + .05 * (1 - c.hit)), .004) * c.hit * c.hit * 2); | |
| 253 | + | |
| 254 | + float3 col = paint(0, f) * .07 + paint(.2, f) * exp(-min(length(p - c1), length(p - c2)) * 1.1) * .1; | |
| 255 | + col += paint(.75, f) * armA * clumps * (.5 + 2.4 * c.b.x); | |
| 256 | + col += paint(.52, f) * armB * clumps * (.5 + 2.4 * c.b.y); | |
| 257 | + col += paint(.3, f) * armC * clumps * (.55 + 2.4 * c.b.z); | |
| 258 | + col += paint(.45 + .25 * clumps, f) * tails * clumps * (.45 + 2.2 * c.b.w); | |
| 259 | + col += paint(.3, f) * (disc1 + disc2) * .3; | |
| 260 | + col += paint(.8, f) * (exp(-g1.z * g1.z * 90) * 1.8 + exp(-g2.z * g2.z * 110) * 1.6); | |
| 261 | + col += paint(.78, f) * knot; | |
| 262 | + col += paint(.7, f) * cosmStars(p * 10, .25, c.t) * .5; | |
| 263 | + return col; | |
| 264 | + } | |
| 265 | + NATIVE_EFFECT(galaxyCollision) | |
| 266 | + | |
| 267 | + // ---------------------------------------------------------------- 354 Solar Prominence | |
| 268 | + float3 solarProminence(Ctx c, constant NativeFrame &f) { | |
| 269 | + float2 p = c.uv / c.size; | |
| 270 | + const float Rs = 2.2; | |
| 271 | + float2 C = float2(0, -.3 - .3 * max(c.extent.y - c.extent.x, 0.f) - Rs); | |
| 272 | + float2 d = p - C; float rr = length(d); | |
| 273 | + float h = rr - Rs; // height above the limb | |
| 274 | + float s = atan2(d.x, d.y) * Rs; // arc length along the limb | |
| 275 | + float above = smoothstep(-.004f, .02f, h); | |
| 276 | + | |
| 277 | + // Granulated surface, foreshortened toward the limb. | |
| 278 | + float mu = sqrt(max(0.f, 1 - (rr / Rs) * (rr / Rs))); | |
| 279 | + float2 gq = float2(s, acos(clamp(rr / Rs, 0.f, 1.f)) * Rs) * 7; | |
| 280 | + float4 cell = voronoi(gq + float2(c.t * .05, 0), .9, c.t * .6); | |
| 281 | + float gran = mix(.6f, smoothstep(0.f, .45f, cell.y - cell.x), smoothstep(0.f, .3f, mu)); | |
| 282 | + float plage = smoothstep(.55f, .8f, noise2(gq * .09 + 3.3)) * c.b.x; | |
| 283 | + float3 surface = paint(.5 + .25 * gran * mu + .15 * mu, f) * (.5 + 1.1 * mu) * (.7 + .4 * gran) | |
| 284 | + + paint(.9, f) * plage * gran * 1.2; | |
| 285 | + float disc = 1 - above; | |
| 286 | + | |
| 287 | + float hp = max(h, 0.f); | |
| 288 | + float streamer = pow(noise2(float2(s * 1.4, hp * .3 - c.t * .04)), 2.f); | |
| 289 | + float corona = exp(-hp * 2.2) * (.3 + .9 * streamer) + exp(-hp * .45) * streamer * .3; | |
| 290 | + float spicule = pow(noise2(float2(s * 45, c.t * .7)), 4.f) * 5 * exp(-hp / (.03 + .06 * c.b.w)) * above; | |
| 291 | + float limb = glow(h, .012); | |
| 292 | + // A faint arcade of nested field arches high in the corona. | |
| 293 | + float sa = (floor(s / 1.1) + .5) * 1.1; | |
| 294 | + float2 ea = float2((s - sa) / .55, hp / (.8 + .2 * sin(sa * 3.1 + c.t * .1))); | |
| 295 | + float ela = length(ea); | |
| 296 | + float arcade = glow(cosmContour(ela * 5, c.px) / c.size, .0035) * smoothstep(.98f, .85f, ela) * smoothstep(.2f, .35f, ela); | |
| 297 | + | |
| 298 | + float3 col = surface * disc; | |
| 299 | + col += (paint(0, f) * (.05 + .07 * streamer) + paint(.25 + .35 * streamer, f) * corona * .6) * above; | |
| 300 | + col += paint(.45, f) * arcade * above * (.2 + 1.3 * c.b.y); | |
| 301 | + col += paint(.85, f) * limb * .9 + paint(.3, f) * spicule * (.4 + 1.5 * c.b.w); | |
| 302 | + | |
| 303 | + // Prominence loops: twisted triple-strand arches, each band lifting its own loops. | |
| 304 | + for (int k = 0; k < 6; ++k) { | |
| 305 | + float fk = float(k), level = c.b[k % 4]; | |
| 306 | + float sk = (fk - 2.5) * .95 + .25 * sin(c.t * .05 + fk * 1.3); | |
| 307 | + float w = .2 + .16 * hash11(fk + 3.1); | |
| 308 | + float H = (.26 + .3 * hash11(fk + 8.7)) * (.6 + 1.2 * level) * (1 + .08 * sin(c.t * .3 + fk)); | |
| 309 | + float tilt = .5 * (hash11(fk + 1.9) - .5); | |
| 310 | + float2 e = float2((s - sk - h * tilt) / w, h / H); | |
| 311 | + float el = length(e), along = atan2(e.y, e.x), scale = min(w, H); | |
| 312 | + float rope = 0; | |
| 313 | + for (int j = 0; j < 3; ++j) { | |
| 314 | + float off = .09 * sin(along * 5 + c.t * 1.1 + float(j) * 2.09 + fk); | |
| 315 | + rope += glow((el - 1 - off) * scale, .005 + .003 * level); | |
| 316 | + } | |
| 317 | + float flow = pow(.5 + .5 * sin(along * 7 - c.t * 2.2 + fk * 2), 4.f); | |
| 318 | + float halo = glow((el - 1) * scale, .035) * .3; | |
| 319 | + col += paint(.55 + .3 * flow + .05 * fk, f) * (rope * (.4 + .6 * flow) + halo) * above * (.3 + 1.5 * level); | |
| 320 | + } | |
| 321 | + | |
| 322 | + // Attacks launch an ejection: a bright-fronted bubble rising off the limb. | |
| 323 | + float site = 1.1 * sin(c.t * .045); | |
| 324 | + float lift = 1 - c.hit; | |
| 325 | + float2 eb = float2(s - site, h - (.06 + lift * 1.1)); | |
| 326 | + float rad = .08 + lift * .5; | |
| 327 | + float bubble = length(eb * float2(1, 1.15)) - rad; | |
| 328 | + float cme = glow(bubble, .02 + .03 * lift) * 1.4 + glow(length(eb + float2(0, rad * .5)), .04 + .06 * lift) * .9; | |
| 329 | + col += paint(.88, f) * cme * c.hit * c.hit * above; | |
| 330 | + return col; | |
| 331 | + } | |
| 332 | + NATIVE_EFFECT(solarProminence) | |
| 333 | + | |
| 334 | + // ---------------------------------------------------------------- 355 Quasar Jet | |
| 335 | + float3 quasarJet(Ctx c, constant NativeFrame &f) { | |
| 336 | + float2 p = c.uv / c.size; | |
| 337 | + float ang = atan2(c.extent.y, c.extent.x) * .85 + .1 * sin(c.t * .05); | |
| 338 | + float2 q = rot(p, -ang); | |
| 339 | + float ax = abs(q.x), side = q.x < 0 ? -1.f : 1.f; | |
| 340 | + const float L = 1.15; | |
| 341 | + float reach = smoothstep(L + .15f, L - .25f, ax); | |
| 342 | + float wj = .022 + .06 * ax; | |
| 343 | + float flick = noise2(float2(ax * 7 - c.t * 6, side * 3.7)); | |
| 344 | + float jetLevel = .6 + .4 * flick + c.b.w * 2.6 * flick * flick; | |
| 345 | + float jet = exp(-q.y * q.y / (wj * wj)) * reach / (1 + ax * .6) * jetLevel; | |
| 346 | + float spine = glow(q.y, .0035 + .002 * ax) * reach / (1 + ax) * jetLevel; | |
| 347 | + | |
| 348 | + float helix = 0; | |
| 349 | + for (int j = 0; j < 2; ++j) { | |
| 350 | + float ph = ax * 13 - c.t * 2.2 + float(j) * PI + side; | |
| 351 | + helix += glow(q.y - wj * .85 * sin(ph), .004 + .002 * ax) * (.55 + .45 * cos(ph)); | |
| 352 | + } | |
| 353 | + helix *= reach * (.3 + 1.8 * c.b.z); | |
| 354 | + | |
| 355 | + float knots = 0; | |
| 356 | + for (int k = 0; k < 4; ++k) { | |
| 357 | + float ph = fract(c.t * .05 + float(k) * .25 + (side > 0 ? 0.f : .125f)); | |
| 358 | + knots += glow(length(float2(ax - ph * L, q.y * 1.4)), .018 + .02 * ax) * sin(PI * ph); | |
| 359 | + } | |
| 360 | + float lx = .06 + (1 - c.hit) * L * .85; | |
| 361 | + float launch = glow(length(float2(ax - lx, q.y * 1.3)), .025 + .03 * lx) * c.hit * c.hit * 2.5; | |
| 362 | + | |
| 363 | + // Radio lobes where the jets stall, with hot spots and glowing rims. | |
| 364 | + float2 lc = q - float2(side * L, 0); | |
| 365 | + float lt = fbm2(q * 2.3 + float2(-side * c.t * .04, c.t * .03), 4); | |
| 366 | + float lobeShape = length(lc * float2(.8, 1.2)) - (.34 + .26 * lt); | |
| 367 | + float strands = cosmRidge(lc * 3.4 + float2(c.t * .05, side * 2.3) + lt, 3) / .875; | |
| 368 | + float lobe = (smoothstep(.1f, -.25f, lobeShape) * .85 + exp(-max(lobeShape, 0.f) * 4) * .15) * (.15 + .85 * pow(strands, 3.f)); | |
| 369 | + float lobeRim = glow(lobeShape, .012) * (.2 + .8 * lt); | |
| 370 | + float hotspot = glow(length(lc + float2(side * .12, 0)), .04); | |
| 371 | + | |
| 372 | + float sheathW = .12 + .22 * ax / L; | |
| 373 | + float sheath = exp(-q.y * q.y / (sheathW * sheathW)) * reach; | |
| 374 | + float backflow = noise2(float2(ax * 4 + c.t * .5, q.y * 9)); | |
| 375 | + float cocoon = sheath * (.3 + .7 * backflow) * (.2 + 1.3 * c.b.y); | |
| 376 | + | |
| 377 | + float rp = length(p); | |
| 378 | + float hostGlow = exp(-length(rot(p, .4) * float2(1, 1.6)) * 2.2); | |
| 379 | + float haze = fbm2(p * 1.1 + float2(c.t * .01, 3), 4); | |
| 380 | + | |
| 381 | + float3 col = paint(.02 + haze * .2, f) * (.05 + .14 * haze * haze); | |
| 382 | + col += paint(.3 + .5 * strands, f) * lobe * (.3 + 1.6 * c.b.x) + paint(.85, f) * (lobeRim * .3 + hotspot) * (.5 + 1.2 * c.b.x); | |
| 383 | + col += paint(.45, f) * cocoon; | |
| 384 | + col += paint(.6, f) * jet * .8 + paint(.95, f) * spine * 1.2; | |
| 385 | + col += paint(.8, f) * helix; | |
| 386 | + col += paint(.95, f) * (knots * 1.2 + launch); | |
| 387 | + col += paint(.5, f) * hostGlow * .22 + paint(.98, f) * (glow(rp, .022) * 3 + glow(rp, .1) * .25); | |
| 388 | + col += paint(.9, f) * cosmStars(p * 10, .22, c.t) * .5; | |
| 389 | + return col; | |
| 390 | + } | |
| 391 | + NATIVE_EFFECT(quasarJet) | |
| 392 | + | |
| 393 | + // ---------------------------------------------------------------- 356 Ring Plane Run | |
| 394 | + float3 ringPlaneRun(Ctx c, constant NativeFrame &f) { | |
| 395 | + float2 uv = rot(c.uv / c.size, .1 * sin(c.t * .07)); | |
| 396 | + // Low, gently tilted view across the ring plane; the planet lies far off to the upper left, | |
| 397 | + // so the ringlets sweep diagonally as long, nearly parallel arcs. | |
| 398 | + float den = max(1.1 - .32 * uv.y, .5f); | |
| 399 | + float2 P = uv / den; | |
| 400 | + const float2 C = float2(-9, 11); | |
| 401 | + const float Rref = 14; | |
| 402 | + float2 dp = P - C; | |
| 403 | + float sway = .9 * sin(c.t * .045); // the camera drifts slowly across the ringlets | |
| 404 | + float rho = length(dp) + sway, phi = atan2(dp.y, dp.x); | |
| 405 | + float flowArc = c.travel * 1.6 + c.t * .06; | |
| 406 | + float arc = phi * Rref + flowArc; // along-ring coordinate, streaming with travel | |
| 407 | + | |
| 408 | + // Two shepherd gaps, each with moonlets that scallop the ringlet edges downstream. | |
| 409 | + float wake = 0, gapMask = 1, moonCover = 0; | |
| 410 | + float3 moonBody = 0, moonHalo = 0; | |
| 411 | + for (int g = 0; g < 2; ++g) { | |
| 412 | + float rg = g == 0 ? 13.55 : 14.92; | |
| 413 | + float drift = c.t * (g == 0 ? .11 : .08); | |
| 414 | + float local = arc - drift; | |
| 415 | + float idm = floor(local / 5 + .5); | |
| 416 | + float ds = local - idm * 5; | |
| 417 | + wake += .06 * sin(ds * 3) * exp(-max(ds, 0.f) * .35) * step(0.f, ds) * smoothstep(2.5f, 1.8f, ds) | |
| 418 | + * exp(-(rho - rg) * (rho - rg) * 5); | |
| 419 | + gapMask *= smoothstep(.05f, .13f, abs(rho - rg)); | |
| 420 | + float phiM = (idm * 5 + drift - flowArc) / Rref; | |
| 421 | + float2 Pm = C + (rg - sway) * float2(cos(phiM), sin(phiM)); | |
| 422 | + float uyM = 1.1 * Pm.y / (1 + .32 * Pm.y); | |
| 423 | + float denM = max(1.1 - .32 * uyM, .5f); | |
| 424 | + float radM = .075 * denM; | |
| 425 | + float2 nrm = (uv - float2(Pm.x * denM, uyM)) / radM; | |
| 426 | + float dm = length(nrm); | |
| 427 | + float body = fill(dm - 1, c.px / radM); | |
| 428 | + float lit = clamp(.35 - nrm.x * .5 + nrm.y * .6, 0.f, 1.f) * sqrt(max(0.f, 1 - dm * dm)); | |
| 429 | + moonBody += paint(.55 + .4 * lit, f) * (.12 + 1.4 * lit) * body; | |
| 430 | + moonHalo += paint(.9, f) * glow(max(dm - 1, 0.f) * radM, .015) * .6; | |
| 431 | + moonCover = max(moonCover, body); | |
| 432 | + } | |
| 433 | + float rw = rho + wake; | |
| 434 | + | |
| 435 | + // Ringlets: faint fills edged by glowing lines; each band lights its own family of lines. | |
| 436 | + float rr = rw * 5.5; | |
| 437 | + float n = floor(rr), m = floor(rr + .5); | |
| 438 | + float dens = hash11(n * 1.37 + 2.1); | |
| 439 | + float present = smoothstep(.08f, .2f, dens) * gapMask; | |
| 440 | + float lineDens = hash11(m * 2.31 + .7); | |
| 441 | + float level = c.b[int(m - 4 * floor(m / 4))]; | |
| 442 | + float rim = glow(cosmContour(rr, c.px) / c.size, .003 + .003 * level) * smoothstep(.5f, .2f, fwidth(rr)); | |
| 443 | + float fineLines = glow(cosmContour(rr * 3 + dens, c.px) / c.size, .0016) * smoothstep(.35f, .12f, fwidth(rr * 3)); | |
| 444 | + float clumps = .3 + .7 * smoothstep(.2f, .8f, noise2(float2(arc * .9, rw * 7))); | |
| 445 | + | |
| 446 | + // Attacks drive a spiral density wave outward across the plane. | |
| 447 | + float rhoF = 11.5 + (1 - c.hit) * 5.5; | |
| 448 | + float packet = exp(-(rho - rhoF) * (rho - rhoF) / .1) * c.hit; | |
| 449 | + float ripple = .5 + .5 * sin((rho - rhoF) * 32 - arc * .3); | |
| 450 | + float waveBoost = 1 + 2.6 * packet * ripple; | |
| 451 | + | |
| 452 | + float2 gq = float2(arc, rw) * 2.5, gid = floor(gq); | |
| 453 | + float2 gl = fract(gq) - .5 - (hash22(gid + 1.3) - .5) * .5; | |
| 454 | + float grains = step(.55, hash21(gid + 4.2)) * exp(-dot(gl, gl) * 160) * (.5 + .5 * sin(c.t * 3 + hash21(gid) * TAU)) | |
| 455 | + * (.3 + 2.4 * c.b.w); | |
| 456 | + float body = present * (.06 + .45 * dens * dens) * clumps * waveBoost; | |
| 457 | + | |
| 458 | + float3 col = paint(0, f) * .045; | |
| 459 | + col += paint(.3 + .4 * dens, f) * body; | |
| 460 | + col += paint(.55 + .35 * lineDens, f) * rim * gapMask * (.15 + .85 * lineDens * lineDens) * (.4 + 2 * level) * waveBoost * (.4 + .6 * clumps); | |
| 461 | + col += paint(.7, f) * fineLines * present * (.2 + .5 * dens); | |
| 462 | + col += paint(.95, f) * (grains * present + packet * ripple * .3); | |
| 463 | + col = mix(col, moonBody, moonCover) + moonHalo; | |
| 464 | + | |
| 465 | + // Planetshine from the inner rings warms the side nearest the planet. | |
| 466 | + col *= .7 + .5 * smoothstep(16.5f, 12.f, rho); | |
| 467 | + col = mix(col, paint(.45, f) * .18 + col * .6, smoothstep(.95f, .55f, den) * .6); // far side recedes into haze | |
| 468 | + return col; | |
| 469 | + } | |
| 470 | + NATIVE_EFFECT(ringPlaneRun) | |
| 471 | + | |
| 472 | + // ---------------------------------------------------------------- 357 Magnetosphere | |
| 473 | + float3 magnetosphere(Ctx c, constant NativeFrame &f) { | |
| 474 | + float2 p = cosmLongAxis(c.uv / c.size, c.extent); | |
| 475 | + float2 q = rot(p - float2(-.15, 0), .18 * sin(c.t * .08)); | |
| 476 | + const float Rp = .1; | |
| 477 | + // Dayside compressed by the wind (harder on attacks), nightside stretched into a tail. | |
| 478 | + float press = 1.45 + .4 * c.hit; | |
| 479 | + float xd = q.x * mix(press, 1 / (1 + 1.25 * max(q.x, 0.f)), smoothstep(-.1f, .1f, q.x)); | |
| 480 | + float rd = length(float2(xd, q.y)); | |
| 481 | + float shellL = rd * rd * rd / max(xd * xd, 1e-6f); | |
| 482 | + float lv = log2(shellL) * 2.4; | |
| 483 | + float id = floor(lv + .5); | |
| 484 | + float level = c.b[int(id - 4 * floor(id / 4))]; | |
| 485 | + float lat = atan2(q.y, abs(xd)); | |
| 486 | + float bounce = .55 + .45 * pow(.5 + .5 * sin(lat * 8 - c.t * 3 + id * 1.7), 3.f); | |
| 487 | + float xm = -.62 + .7 * q.y * q.y; // magnetopause | |
| 488 | + float inside = smoothstep(xm - .02, xm + .03, q.x) * smoothstep(Rp, Rp * 1.3, length(q)); | |
| 489 | + float fieldD = cosmContour(lv, c.px) / c.size; | |
| 490 | + float crowd = smoothstep(.45f, .15f, fwidth(lv)); // fade lines where they bunch at the poles | |
| 491 | + float field = (glow(fieldD, .0045 + .003 * level) * bounce * crowd + glow(fieldD, .025) * .15 * crowd + .08 * (1 - crowd)) | |
| 492 | + * inside * (.3 + 1.7 * level); | |
| 493 | + | |
| 494 | + // Solar wind streamlines bending around the bow shock. | |
| 495 | + const float xb0 = -.86; | |
| 496 | + float body = 2.6 * .08 * log(1 + exp((q.x - xb0) / .08)); | |
| 497 | + float y2 = q.y * q.y; | |
| 498 | + float eta = sign(q.y) * sqrt(max(y2 - body, 0.f)); | |
| 499 | + float outside = smoothstep(0.f, .02f, y2 - body); | |
| 500 | + float wv = eta * 9; | |
| 501 | + float windD = cosmContour(wv, c.px) / c.size; | |
| 502 | + float dash = pow(.5 + .5 * sin(q.x * 12 - c.t * 4 + hash11(floor(wv + .5)) * TAU), 6.f); | |
| 503 | + float wind = (glow(windD, .003) * (.25 + dash * (.5 + 2.2 * c.b.w))) * outside * smoothstep(.45f, .15f, fwidth(wv)); | |
| 504 | + float sheathMask = (1 - outside) * (1 - inside) * smoothstep(Rp, Rp * 1.3, length(q)); | |
| 505 | + float sheath = fbm2(q * 4 + float2(-c.t * .3, 0), 3) * sheathMask; | |
| 506 | + float bowD = abs(q.x - xb0 - y2 / 2.6) / sqrt(1 + (2 * q.y / 2.6) * (2 * q.y / 2.6)); | |
| 507 | + float mpD = abs(q.x - xm) / sqrt(1 + (1.4 * q.y) * (1.4 * q.y)); | |
| 508 | + | |
| 509 | + // Attacks fire an interplanetary shock front across the scene. | |
| 510 | + float xf = -2.8 + (1 - c.hit) * 5.4; | |
| 511 | + float shock = glow(q.x - xf - .25 * y2, .02) * c.hit * c.hit * 1.8; | |
| 512 | + | |
| 513 | + float2 pole = float2(0, Rp * .9); | |
| 514 | + float aurora = glow(abs(length((q - pole) * float2(1, 3.2)) - .045), .006) + glow(abs(length((q + pole) * float2(1, 3.2)) - .045), .006); | |
| 515 | + | |
| 516 | + float pr = length(q) / Rp; | |
| 517 | + float disc = fill(pr - 1, c.px / Rp); | |
| 518 | + float2 nrm = q / Rp; | |
| 519 | + float day = clamp(-nrm.x * .9 + .25, 0.f, 1.f) * sqrt(max(0.f, 1 - pr * pr)); | |
| 520 | + | |
| 521 | + float haze = fbm2(p * 1.4 + float2(-c.t * .04, 0), 3); | |
| 522 | + float3 col = paint(.02 + haze * .2, f) * (.05 + .12 * haze * haze); | |
| 523 | + col += paint(.35, f) * sheath * .55; | |
| 524 | + col += paint(.25 + .1 * id, f) * field * .9 + paint(.15, f) * wind; | |
| 525 | + col += paint(.8, f) * (glow(bowD, .006) * .9 + glow(bowD, .05) * .2) + paint(.6, f) * glow(mpD, .005) * inside * .4; | |
| 526 | + col += paint(.92, f) * shock + paint(.95, f) * aurora * (.3 + 2 * c.b.z); | |
| 527 | + col = mix(col, paint(.55 + .3 * day, f) * (.12 + 1.3 * day), disc) + paint(.9, f) * glow(max(pr - 1, 0.f) * Rp, .012) * .7; | |
| 528 | + col += paint(.9, f) * cosmStars(p * 9, .2, c.t) * .4; | |
| 529 | + return col; | |
| 530 | + } | |
| 531 | + NATIVE_EFFECT(magnetosphere) | |
| 532 | + | |
| 533 | + // ---------------------------------------------------------------- 358 Cosmic Web | |
| 534 | + struct CosmCells { float d1; float d3; float edge; float2 a; float2 b; }; | |
| 535 | + CosmCells cosmCells(float2 p, float phase) { | |
| 536 | + float2 cell = floor(p), fp = fract(p); | |
| 537 | + float d1 = 8, d2 = 8, d3 = 8; float2 a = 0, b = 0, sa = 0, sb = 0; | |
| 538 | + for (int y = -1; y <= 1; ++y) for (int x = -1; x <= 1; ++x) { | |
| 539 | + float2 g = float2(x, y), id = cell + g, h = hash22(id); | |
| 540 | + float2 site = g + .5 + .4 * sin(phase * (.4 + .3 * h) + h * TAU); | |
| 541 | + float d = length(site - fp); | |
| 542 | + if (d < d1) { d3 = d2; d2 = d1; b = a; sb = sa; d1 = d; a = id; sa = site; } | |
| 543 | + else if (d < d2) { d3 = d2; d2 = d; b = id; sb = site; } | |
| 544 | + else if (d < d3) d3 = d; | |
| 545 | + } | |
| 546 | + CosmCells k; | |
| 547 | + k.d1 = d1; k.d3 = d3; k.a = a; k.b = b; | |
| 548 | + k.edge = abs(dot(fp - .5 * (sa + sb), normalize(sb - sa + 1e-5))); | |
| 549 | + return k; | |
| 550 | + } | |
| 551 | + | |
| 552 | + float3 cosmicWeb(Ctx c, constant NativeFrame &f) { | |
| 553 | + float haze = fbm2(c.uv * .8 + float2(c.t * .01, 0), 3); | |
| 554 | + float3 col = paint(.02 + haze * .2, f) * (.04 + .12 * haze * haze); | |
| 555 | + for (int k = 0; k < 6; ++k) { | |
| 556 | + float2 s = layerSlot(k, 6, c.travel * .09); | |
| 557 | + float sc = layerScale(s.x, 2.4) / c.size; | |
| 558 | + float2 q = rot(c.uv * sc, s.y * 1.1) + hash22(float2(s.y, 7.3)) * 40; | |
| 559 | + q += (float2(noise2(q * .5), noise2(q * .5 + 9.1)) - .5) * .7; | |
| 560 | + CosmCells v = cosmCells(q, c.t * .25 + s.y); | |
| 561 | + float edge = v.edge / sc, node = (v.d3 - v.d1) / sc; | |
| 562 | + float pair = hash21(v.a + v.b); | |
| 563 | + int band = int(pair * 3.999); | |
| 564 | + float level = c.b[band]; | |
| 565 | + float strength = fract(pair * 7.3); // some filaments thick and bright, some faint | |
| 566 | + float fade = layerFade(s.x) * (.3 + .7 * s.x) * (1 - c.fog * .5 * (1 - s.x)); | |
| 567 | + float beads = .5 + .5 * noise2(q * 3.5 + s.y); | |
| 568 | + float pulseAlong = .6 + .4 * sin(v.d1 * 9 - c.t * 2 + hash21(v.a) * TAU); | |
| 569 | + float wide = (.0015 + .004 * s.x) * (.6 + strength); | |
| 570 | + float fil = (glow(edge, wide * (1 + 1.2 * level)) * (.3 + 2 * level) * beads * pulseAlong | |
| 571 | + + glow(edge, .03 * (.4 + s.x)) * .1) * (.3 + .9 * strength); | |
| 572 | + float lightUp = step(.45, hash21(v.a + 3.3)); | |
| 573 | + float flare = 1 + 3.5 * c.hit * lightUp; | |
| 574 | + float hub = glow(node, .007 + .014 * s.x) * (.7 * flare) + glow(node, .06 * (.4 + s.x)) * .22 * flare; | |
| 575 | + col += (paint(.25 + s.y * .11 + float(band) * .1, f) * fil + paint(.75, f) * hub) * fade; | |
| 576 | + } | |
| 577 | + return col; | |
| 578 | + } | |
| 579 | + NATIVE_EFFECT(cosmicWeb) | |
| 580 | + | |
| 581 | + // ---------------------------------------------------------------- 359 Einstein Ring | |
| 582 | + float3 cosmGalaxySource(float2 d, float spin, float hue, constant NativeFrame &f) { | |
| 583 | + float r = length(d); | |
| 584 | + float phi = atan2(d.y, d.x) - 2.6 * log(r + .02); | |
| 585 | + float arms = pow(.5 + .5 * cos(2 * phi - spin), 5.f); | |
| 586 | + float body = exp(-r * 6) * (.15 + .85 * arms) * 1.4 + exp(-r * r * 300) * 1.8; | |
| 587 | + return paint(hue + .3 * exp(-r * 6), f) * body; | |
| 588 | + } | |
| 589 | + | |
| 590 | + float3 einsteinRing(Ctx c, constant NativeFrame &f) { | |
| 591 | + float2 th = c.uv / c.size; | |
| 592 | + float r = max(length(th), 1e-3f); | |
| 593 | + // Point lens plus a slowly turning external shear; mass breathes with the bass. | |
| 594 | + float thetaE = .56 * (1 + .3 * c.b.x); | |
| 595 | + float2 beta = th - thetaE * thetaE * th / (r * r); | |
| 596 | + float sa = c.t * .03; | |
| 597 | + float2 sh = float2(cos(2 * sa), sin(2 * sa)) * .1; | |
| 598 | + beta -= float2(sh.x * th.x + sh.y * th.y, sh.y * th.x - sh.x * th.y); | |
| 599 | + float centre = smoothstep(.06f, .22f, r); | |
| 600 | + | |
| 601 | + float bg = fbm2(beta * 1.6 + float2(3, c.t * .01), 4); | |
| 602 | + float3 col = paint(1 - bg * .15, f) * (.035 + .05 * bg * bg) * centre; | |
| 603 | + col += paint(.1 + bg * .8, f) * pow(smoothstep(.4f, .9f, bg), 2.f) * .25 * centre; | |
| 604 | + for (int j = 0; j < 5; ++j) { | |
| 605 | + float fj = float(j); | |
| 606 | + float2 home = float2(cos(fj * 2.4 + 1), sin(fj * 2.4 + 1)) * (.1 + .36 * fract(fj * .618 + .2)); | |
| 607 | + float2 sp = rot(home, c.t * (.04 + .015 * fj) * (j % 2 == 0 ? 1 : -1)); | |
| 608 | + float2 d = rot(beta - sp, fj * 1.3 + c.t * .1); | |
| 609 | + d.y /= .6; | |
| 610 | + float level = c.b[j % 4]; | |
| 611 | + col += cosmGalaxySource(d * (1.1 + fj * .12), c.t * .3 + fj, .05 + fj * .22, f) * (.4 + 1.9 * level) * centre; | |
| 612 | + } | |
| 613 | + // Attacks slide a bright new source behind the lens: a ring forms, then breaks into arcs. | |
| 614 | + float2 sh2 = rot(float2(-.08 + (1 - c.hit) * .9, .04), c.t * .07); | |
| 615 | + float flash = length(beta - sh2); | |
| 616 | + col += paint(.75, f) * (glow(flash, .03) * 2 + glow(flash, .1) * .4) * c.hit * c.hit * centre; | |
| 617 | + col += paint(.6, f) * cosmStars(beta * 9, .25, c.t) * .5 * centre; | |
| 618 | + col += paint(.9, f) * glow(r, .05) * .3; | |
| 619 | + return col; | |
| 620 | + } | |
| 621 | + NATIVE_EFFECT(einsteinRing) |
Sources/PulseCanvas/Resources/NativeExpansionCosmosII.metal added
| 1 | + // Second versions of designs whose original and final review clips were both red-tagged. | |
| 2 | + // Original PulseCanvas designs 350–359. Cosmic phenomena drawn as vivid neon light, not | |
| 3 | + // photographic space art: beams, shells, streams, loops and lensed arcs built from analytic | |
| 4 | + // curves and a little noise. Every band drives its own structures; attacks make local events. | |
| 5 | + | |
| 6 | + // ---------------------------------------------------------------- shared helpers (cosm*) | |
| 7 | + // Ridged noise: thin bright creases, the raw material of filaments. | |
| 8 | + float cosmRidge(float2 p, int octaves) { | |
| 9 | + float sum = 0, amplitude = .5; | |
| 10 | + for (int i = 0; i < octaves; ++i) { | |
| 11 | + float n = 1 - abs(2 * noise2(p) - 1); | |
| 12 | + sum += amplitude * n * n; | |
| 13 | + p = float2(p.x * 1.6 - p.y * 1.2, p.x * 1.2 + p.y * 1.6) + 4.7; | |
| 14 | + amplitude *= .5; | |
| 15 | + } | |
| 16 | + return sum; | |
| 17 | + } | |
| 18 | + // Sparse twinkling specks, one jittered candidate per cell, with no seams at cell edges. | |
| 19 | + float cosmStars(float2 p, float density, float t) { | |
| 20 | + float2 id = floor(p), local = fract(p) - .5, h = hash22(id + 31.7); | |
| 21 | + float on = step(1 - density, hash21(id + 9.1)); | |
| 22 | + float2 offset = local - (h - .5) * .6; | |
| 23 | + float twinkle = .6 + .4 * sin(t * (1.1 + h.x * 2) + h.y * TAU); | |
| 24 | + return on * twinkle * exp(-dot(offset, offset) * 900); | |
| 25 | + } | |
| 26 | + // Distance in uv units to the nearest integer contour of a smooth field v. | |
| 27 | + float cosmContour(float v, float px) { | |
| 28 | + return abs(fract(v + .5) - .5) * px / max(fwidth(v), 1e-5f); | |
| 29 | + } | |
| 30 | + // Level of band i (0...3) for a data-dependent index, without dynamic vector indexing. | |
| 31 | + float cosmBand(float4 bands, float i) { | |
| 32 | + return dot(bands, saturate(1 - abs(float4(0, 1, 2, 3) - i))); | |
| 33 | + } | |
| 34 | + // Raised cosine in [0, 1], clamped so pow() never sees a rounding-negative base. | |
| 35 | + float cosmWave(float x) { return saturate(.5f + .5f * cos(x)); } | |
| 36 | + // A fixed oblique rotation, so value-noise lattice planes never line up with polar axes. | |
| 37 | + float3 cosmTilt(float3 p) { | |
| 38 | + return float3(.80f * p.x + .36f * p.y + .48f * p.z, -.48f * p.x + .80f * p.y + .36f * p.z, -.36f * p.x - .48f * p.y + .80f * p.z); | |
| 39 | + } | |
| 40 | + // Sharp crest of a ridge value (1 on the crest), widened where it would fall below a pixel. | |
| 41 | + float cosmCrest(float ridge, float sharpness) { | |
| 42 | + float k = min(sharpness, .8f / max(fwidth(ridge), 1e-4f)); | |
| 43 | + return exp(-k * (1 - ridge)) * sqrt(k / sharpness); | |
| 44 | + } | |
| 45 | + // Lay a two-body composition along the canvas's long axis. | |
| 46 | + float2 cosmLongAxis(float2 p, float2 extent) { | |
| 47 | + return extent.y > extent.x ? float2(p.y, -p.x) : p; | |
| 48 | + } | |
| 49 | + | |
| 50 | + | |
| 51 | + // ---------------------------------------------------------------- 351 Twin Suns | |
| 52 | + // A glowing star: saturated limb-darkened body with a soft edge, a neon rim, corona and rays. | |
| 53 | + float4 cosmSun(float2 d, float radius, float spin, float hue, float corona, constant NativeFrame &f) { | |
| 54 | + float r = length(d) / radius; | |
| 55 | + float mu = sqrt(max(0.f, 1 - r * r)); | |
| 56 | + float2 sp = rot(d / radius, spin); | |
| 57 | + float cells = noise2(sp * 5 + 3.3) * .6 + noise2(sp * 11 + 8.1) * .4; | |
| 58 | + float3 surface = paint(hue + .22 * mu + .1 * cells, f) * (.3 + .55 * mu * (.6 + .6 * cells)) | |
| 59 | + + paint(.92, f) * pow(mu, 8.f) * .45; | |
| 60 | + float disc = 1 - smoothstep(.9f, 1.02f, r); | |
| 61 | + float a = atan2(d.y, d.x) + spin * .3; | |
| 62 | + float outer = max(r - 1, 0.f); | |
| 63 | + float rays = pow(cosmWave(a * 14 + 2 * sin(a * 5 + spin * 2)), 8.f) * exp(-outer * (3.2 - corona * 1.6)); | |
| 64 | + float halo = glow(outer, .2 + corona * .35) * (.22 + corona * .8); | |
| 65 | + float rim = glow(r - .98, .035) * .9 + glow(r - .98, .012); | |
| 66 | + float3 col = surface * disc + paint(hue + .3, f) * rim * (.5 + .8 * corona) | |
| 67 | + + paint(hue + .1, f) * (halo + rays * (.2 + corona * 1.2)) * (1 - disc); | |
| 68 | + return float4(col, disc); | |
| 69 | + } | |
| 70 | + | |
| 71 | + float3 twinSunsII(Ctx c, constant NativeFrame &f) { | |
| 72 | + float2 p = cosmLongAxis(c.uv / c.size, c.extent); | |
| 73 | + float phase = c.t * .3; | |
| 74 | + // The heavy primary rides close to the canvas centre while the companion swings wide along | |
| 75 | + // the long axis, so the forward-zoom echo of the primary reads as its own corona. | |
| 76 | + float span = clamp(max(c.extent.x, c.extent.y) / c.size, 1.f, 1.8f); | |
| 77 | + float2 orbit = float2(cos(phase) * (.62 + .35 * span), sin(phase) * .55); | |
| 78 | + float2 s1 = -orbit * .2, s2 = orbit * .8; | |
| 79 | + const float r1 = .2, r2 = .075; | |
| 80 | + | |
| 81 | + // Circumbinary outflow: trailing arms of fine glowing threads that turn with the orbit. | |
| 82 | + float rho = length(p), th = atan2(p.y, p.x); | |
| 83 | + float spiral = 2 * (th - phase) + log(rho + .08) * 3.4; | |
| 84 | + float arms = pow(cosmWave(spiral), 3.f); | |
| 85 | + float tex = fbm2(p * 2.1 + float2(c.t * .02, -c.t * .013), 4); | |
| 86 | + float threads = pow(cosmWave(spiral * 5 + tex * 5), 14.f); | |
| 87 | + float reachArms = exp(-rho * .45); | |
| 88 | + float3 col = deep(.2 + .25 * tex, f) * (.025 + .09 * tex * tex); | |
| 89 | + col += paint(.12 + .3 * tex, f) * pow(cosmWave(spiral), 1.5f) * reachArms * (.05 + .16 * tex) * (.6 + 1.2 * c.b.y); | |
| 90 | + col += paint(.35 + .4 * arms, f) * threads * arms * reachArms * (.3 + 1.6 * c.b.y); | |
| 91 | + | |
| 92 | + // Tidal streams pulled from the companion onto the primary, one strand per band. | |
| 93 | + float2 dv = s1 - s2; float len = length(dv); | |
| 94 | + float2 ax = dv / len, nv = float2(-ax.y, ax.x), rel = p - s2; | |
| 95 | + float u = dot(rel, ax) / len, v = dot(rel, nv), uc = clamp(u, 0.f, 1.f); | |
| 96 | + float ends = smoothstep(-.05f, .12f, u) * smoothstep(1.02f, .85f, u); | |
| 97 | + for (int k = 0; k < 4; ++k) { | |
| 98 | + float fk = float(k), level = c.b[k]; | |
| 99 | + float bend = ((.1 + .07 * fk) * len + .05 * sin(TAU * uc * 1.5 + c.t * .8 + fk * 1.7)) * sin(PI * uc) * (k % 2 == 0 ? 1.f : -.7f); | |
| 100 | + float dist = abs(v - bend); | |
| 101 | + float flow = pow(cosmWave(u * 18 - c.t * 2.4 + fk * 1.9 - PI * .5), 4.f); | |
| 102 | + float strand = glow(dist, .006 + .008 * level) * (.3 + .7 * flow) + glow(dist, .035) * .12; | |
| 103 | + col += paint(.25 + .17 * fk + .12 * flow, f) * strand * ends * (.3 + 1.9 * level); | |
| 104 | + } | |
| 105 | + | |
| 106 | + // Attacks erupt a flare loop and an ejected blob from each star. | |
| 107 | + float burst = c.hit * (.6 + .4 * c.hit) * 1.8; | |
| 108 | + float3 flares = 0; | |
| 109 | + for (int k = 0; k < 2; ++k) { | |
| 110 | + float2 s = k == 0 ? s1 : s2; float radius = k == 0 ? r1 : r2; | |
| 111 | + float fa = phase * (k == 0 ? 1.7 : -1.3) + float(k) * 2.4 + .8; | |
| 112 | + float2 dir = float2(cos(fa), sin(fa)); | |
| 113 | + float2 site = s + dir * radius; | |
| 114 | + float loopArc = abs(length(p - site) - radius * (.3 + 1.4 * c.hit)); | |
| 115 | + float outside = smoothstep(radius, radius * 1.05, length(p - s)); | |
| 116 | + float blob = glow(length(p - s - dir * radius * (1.15 + 3 * (1 - c.hit))), .04 + .06 * (1 - c.hit)); | |
| 117 | + flares += paint(.7, f) * (glow(loopArc, .008) * outside * 1.5 + blob) * burst; | |
| 118 | + } | |
| 119 | + | |
| 120 | + // Stars, drawn back to front; they swap only at full separation, never while overlapping. | |
| 121 | + float4 a = cosmSun(p - s1, r1, c.t * .2, .3, c.b.x, f); | |
| 122 | + float4 b = cosmSun(p - s2, r2, -c.t * .3, .62, .35 + c.b.z, f); | |
| 123 | + bool firstFront = sin(phase) > 0; | |
| 124 | + float4 back = firstFront ? b : a, front = firstFront ? a : b; | |
| 125 | + col = col * (1 - back.w) + back.rgb; | |
| 126 | + col += flares; | |
| 127 | + col = col * (1 - front.w) + front.rgb; | |
| 128 | + col += paint(.8, f) * cosmStars(p * 9, .25, c.t) * .5; | |
| 129 | + return col; | |
| 130 | + } | |
| 131 | + NATIVE_EFFECT(twinSunsII) | |
| 132 | + | |
| 133 | + // ---------------------------------------------------------------- 352 Supernova Shell | |
| 134 | + float3 supernovaShellII(Ctx c, constant NativeFrame &f) { | |
| 135 | + float2 p = c.uv / c.size; | |
| 136 | + float r = length(p); | |
| 137 | + float2 dirv = p / max(r, 1e-4f); | |
| 138 | + const float R = .64; | |
| 139 | + float wob = noise2(dirv * 2.2 + 11.3) - .5; | |
| 140 | + float Ro = R * (1 + .14 * wob), Ri = Ro * .78; | |
| 141 | + float shell = (sqrt(max(Ro * Ro - r * r, 0.f)) - sqrt(max(Ri * Ri - r * r, 0.f))) / sqrt(Ro * Ro - Ri * Ri); | |
| 142 | + | |
| 143 | + // Rayleigh-Taylor fingers: ridges of a noise field stretched along the radius. They drift | |
| 144 | + // outward in log radius, so the forward-zoom echo lines up with the fingers themselves. | |
| 145 | + // The music clock drives the expansion, so energetic passages push the fingers out faster. | |
| 146 | + float lr = log(max(r, .03f)); | |
| 147 | + float3 fq = float3(dirv * 6.5, lr * 1.25 - c.t * .05 - c.m * .45); | |
| 148 | + float ridgeA = 1 - abs(2 * noise3(cosmTilt(fq)) - 1); | |
| 149 | + float ridgeB = 1 - abs(2 * noise3(cosmTilt(fq * float3(1.8, 1.8, 1.5) + 7.3).zxy) - 1); | |
| 150 | + float fingerA = cosmCrest(ridgeA, 16), fingerB = cosmCrest(ridgeB, 22); | |
| 151 | + float bead = smoothstep(.62f, .9f, noise3(cosmTilt(fq * float3(1, 1, 5) + 2.1).yzx)); | |
| 152 | + float band = smoothstep(Ri * .35f, Ri, r) * smoothstep(Ro * 1.06f, Ro * .97f, r); | |
| 153 | + float tip = smoothstep(Ri * .8f, Ro, r); | |
| 154 | + | |
| 155 | + // Hit: a fresh shock ring races out and lights the fingers it crosses. | |
| 156 | + float Rh = R * (.08 + 1.35 * (1 - c.hit)) * (1 + .1 * wob); | |
| 157 | + float shockBoost = 1 + 2.5 * c.hit * exp(-(r - Rh) * (r - Rh) / .008); | |
| 158 | + float newRing = (glow(r - Rh, .012) * 2.2 + glow(r - Rh, .06) * .4) * c.hit; | |
| 159 | + | |
| 160 | + float inner = smoothstep(Ri, Ri * .25f, r); | |
| 161 | + float wisp = fbm2(p * 3 + float2(c.t * .02, 1.3), 3); | |
| 162 | + float Rs = R * (1.15 + .1 * (noise2(dirv * 3.1 + 2.2) - .5)); | |
| 163 | + float forward = glow(r - Rs, .006) * .9 + glow(r - Rs, .045) * .2; | |
| 164 | + float outside = smoothstep(Rs * .98f, Rs * 1.1f, r); | |
| 165 | + | |
| 166 | + float haze = fbm2(p * .9 + float2(4.1, c.t * .01), 3); | |
| 167 | + float3 col = deep(.9 + haze * .2, f) * (.05 + .12 * haze * haze); | |
| 168 | + col += paint(.95 + .1 * haze, f) * smoothstep(.5f, .85f, haze) * .06 * outside; | |
| 169 | + col += paint(.92, f) * shell * shell * .1; | |
| 170 | + col += paint(mix(.8f, .6f, tip), f) * band * fingerA * (.38 + 2 * c.b.x) * shockBoost; | |
| 171 | + col += paint(.06 + .12 * tip, f) * band * fingerB * (.24 + 2 * c.b.y) * shockBoost; | |
| 172 | + col += paint(.5, f) * band * fingerA * bead * (.3 + 3 * c.b.w) * shockBoost; | |
| 173 | + col += paint(1 - .1 * wisp, f) * inner * pow(wisp, 3.f) * (.4 + 1.8 * c.b.z); | |
| 174 | + col += paint(.02, f) * forward; | |
| 175 | + col += paint(.65, f) * newRing + paint(.5, f) * (glow(r, .02) * 1.4 + glow(r, .07) * .25); | |
| 176 | + col += paint(.6, f) * cosmStars(p * 11, .2, c.t) * .4 * outside; | |
| 177 | + return col; | |
| 178 | + } | |
| 179 | + NATIVE_EFFECT(supernovaShellII) | |
| 180 | + | |
| 181 | + // ---------------------------------------------------------------- 353 Galaxy Collision | |
| 182 | + // Two-armed log spiral in its own (de-projected) plane: x = arm A, y = arm B (broad), | |
| 183 | + // z = arm A spine, w = arm B spine (thin glowing cores). Radius returned separately. | |
| 184 | + float4 cosmSpiral(float2 q, float spin, float wind, thread float &r) { | |
| 185 | + r = max(length(q), 1e-3f); | |
| 186 | + float c1 = cos(atan2(q.y, q.x) - wind * log(r) - spin); | |
| 187 | + float a = max(c1, 0.f), b = max(-c1, 0.f); | |
| 188 | + return float4(pow(a, 6.f), pow(b, 6.f), pow(a, 110.f), pow(b, 110.f)); | |
| 189 | + } | |
| 190 | + | |
| 191 | + float3 galaxyCollisionII(Ctx c, constant NativeFrame &f) { | |
| 192 | + float2 p = cosmLongAxis(c.uv / c.size, c.extent); | |
| 193 | + float orbit = c.t * .035; | |
| 194 | + // A close pair near the centre: the forward-zoom echo lands on their own discs and tails. | |
| 195 | + float2 c1 = rot(float2(-.36, .1), orbit), c2 = rot(float2(.4, -.1), orbit); | |
| 196 | + float2 q1 = rot(p - c1, .5 + orbit); q1.y /= .6; | |
| 197 | + float2 q2 = rot(p - c2, -.9 + orbit); q2.y /= .5; | |
| 198 | + float r1, r2; | |
| 199 | + float4 g1 = cosmSpiral(q1 * .8, c.t * .16, 2.3, r1), g2 = cosmSpiral(q2 * .9, -c.t * .13, -2.1, r2); | |
| 200 | + float clumps = .45 + .55 * noise2(p * 9 + float2(c.t * .05, 0)); | |
| 201 | + | |
| 202 | + float disc1 = exp(-r1 * 2.6), disc2 = exp(-r2 * 3); | |
| 203 | + // Tidal tails: the outer arms keep going on the side facing away from the partner. | |
| 204 | + float2 away1 = normalize(c1 - c2); | |
| 205 | + float tailMask1 = smoothstep(-.2f, .5f, dot(normalize(p - c1 + 1e-4), away1)) * smoothstep(.25f, .6f, r1); | |
| 206 | + float tailMask2 = smoothstep(-.2f, .5f, dot(normalize(p - c2 + 1e-4), -away1)) * smoothstep(.25f, .6f, r2); | |
| 207 | + float tail1 = (g1.x * .6 + g1.z) * exp(-r1 * .75) * tailMask1; | |
| 208 | + float tail2 = (g2.y * .6 + g2.w) * exp(-r2 * .8) * tailMask2; | |
| 209 | + | |
| 210 | + // A bridge of stars stretched between the pair. | |
| 211 | + float2 dv = c2 - c1; float len = length(dv); | |
| 212 | + float2 ax = dv / len, rel = p - c1; | |
| 213 | + float u = dot(rel, ax) / len, v = dot(rel, float2(-ax.y, ax.x)); | |
| 214 | + float bridgeDist = abs(v - .16 * len * sin(PI * clamp(u, 0.f, 1.f))); | |
| 215 | + float bridge = (glow(bridgeDist, .025) + glow(bridgeDist, .005)) * smoothstep(-.05f, .2f, u) * smoothstep(1.05f, .8f, u); | |
| 216 | + | |
| 217 | + float armA = (g1.x * .35 + g1.z * 2.1) * disc1, armB = (g1.y * .35 + g1.w * 2.1) * disc1; | |
| 218 | + float armC = ((g2.x + g2.y) * .35 + (g2.z + g2.w) * 2.1) * disc2; | |
| 219 | + float tails = tail1 + tail2 + bridge * .5; | |
| 220 | + | |
| 221 | + // Starburst knots sit on the arms; attacks blossom them with an expanding ring. | |
| 222 | + float2 kq = p * 7, kid = floor(kq), kl = (fract(kq) - .5 - (hash22(kid + 2.7) - .5) * .6) / 7; | |
| 223 | + float kd = length(kl); | |
| 224 | + float knotOn = step(.6, hash21(kid + 6.1)); | |
| 225 | + float host = min(1.f, (armA + armB + armC) * 2 + tails * 2); | |
| 226 | + float knot = knotOn * host * (glow(kd, .006 + .014 * c.hit) * (.6 + 5 * c.hit) | |
| 227 | + + glow(kd - (.02 + .08 * (1 - c.hit)), .005) * c.hit * 3 * smoothstep(.5f, .9f, host)); | |
| 228 | + | |
| 229 | + float3 col = paint(0, f) * .05 + paint(.2, f) * exp(-min(length(p - c1), length(p - c2)) * 1.3) * .08; | |
| 230 | + col += paint(.75, f) * armA * clumps * (.5 + 2.4 * c.b.x); | |
| 231 | + col += paint(.55, f) * armB * clumps * (.5 + 2.4 * c.b.y); | |
| 232 | + col += paint(.3, f) * armC * clumps * (.55 + 2.4 * c.b.z); | |
| 233 | + col += paint(.45 + .25 * clumps, f) * tails * clumps * (.45 + 2.2 * c.b.w); | |
| 234 | + col += paint(.3, f) * (disc1 + disc2) * .1; | |
| 235 | + col += paint(.8, f) * (exp(-r1 * r1 * 90) * 1.8 + exp(-r2 * r2 * 110) * 1.6); | |
| 236 | + col += paint(.78, f) * knot; | |
| 237 | + col += paint(.7, f) * cosmStars(p * 10, .25, c.t) * .5; | |
| 238 | + return col; | |
| 239 | + } | |
| 240 | + NATIVE_EFFECT(galaxyCollisionII) | |
| 241 | + | |
| 242 | + // ---------------------------------------------------------------- 354 Solar Prominence | |
| 243 | + float3 solarProminenceII(Ctx c, constant NativeFrame &f) { | |
| 244 | + float2 p = c.uv / c.size; | |
| 245 | + const float Rs = 2.2; | |
| 246 | + // The limb crosses just below the canvas centre, so the forward-zoom echo of the limb | |
| 247 | + // stays on the limb instead of drawing a second horizon. | |
| 248 | + float2 C = float2(0, -.1 - Rs); | |
| 249 | + float2 d = p - C; float rr = length(d); | |
| 250 | + float h = rr - Rs; // height above the limb | |
| 251 | + float s = atan2(d.x, d.y) * Rs; // arc length along the limb | |
| 252 | + float above = smoothstep(-.004f, .02f, h); | |
| 253 | + | |
| 254 | + // Granulated surface, foreshortened toward the limb. | |
| 255 | + float mu = sqrt(max(0.f, 1 - (rr / Rs) * (rr / Rs))); | |
| 256 | + float2 gq = float2(s, acos(clamp(rr / Rs, 0.f, 1.f)) * Rs) * 9; | |
| 257 | + float4 cell = voronoi(gq + float2(c.t * .05, 0), .9, c.t * .6); | |
| 258 | + float granule = exp(-cell.x * cell.x * 4.5) * smoothstep(0.f, .14f, cell.y - cell.x); | |
| 259 | + float gran = mix(.55f, granule, smoothstep(0.f, .3f, mu)); | |
| 260 | + float plage = smoothstep(.55f, .8f, noise2(gq * .09 + 3.3)) * c.b.x; | |
| 261 | + float sink = .3 + .7 * exp(max(-h, 0.f) * -2.2); // the deep disc settles darker than the limb | |
| 262 | + // Glowing granules in hot orange over crimson lanes: saturated at every brightness. | |
| 263 | + float3 surface = (mix(paint(.04, f) * .3, paint(.2 + .32 * gran, f) * (.55 + .5 * mu), gran) | |
| 264 | + + paint(.75, f) * plage * gran * 1.1) * sink; | |
| 265 | + float disc = 1 - above; | |
| 266 | + | |
| 267 | + float hp = max(h, 0.f); | |
| 268 | + float streamer = pow(noise2(float2(s * 1.4, hp * .3 - c.t * .04)), 2.f); | |
| 269 | + float corona = exp(-hp * 2.2) * (.3 + .9 * streamer) + exp(-hp * .45) * streamer * .3; | |
| 270 | + float spicule = pow(noise2(float2(s * 45, c.t * .7)), 4.f) * 5 * exp(-hp / (.03 + .06 * c.b.w)) * above; | |
| 271 | + float limb = glow(h, .012); | |
| 272 | + float tall = 1 + .45 * max(c.extent.y - c.extent.x, 0.f); // taller loops on portrait canvases | |
| 273 | + // A faint arcade of nested field arches high in the corona. | |
| 274 | + float sa = (floor(s / 1.1) + .5) * 1.1; | |
| 275 | + float2 ea = float2((s - sa) / .55, hp / ((.8 + .2 * sin(sa * 3.1 + c.t * .1)) * tall)); | |
| 276 | + float ela = length(ea); | |
| 277 | + float arcade = glow(cosmContour(ela * 5, c.px) / c.size, .0035) * smoothstep(.98f, .85f, ela) * smoothstep(.2f, .35f, ela); | |
| 278 | + | |
| 279 | + float3 col = surface * disc; | |
| 280 | + col += (paint(0, f) * (.05 + .07 * streamer) + paint(.25 + .35 * streamer, f) * corona * .6) * above; | |
| 281 | + col += paint(.45, f) * arcade * above * (.2 + 1.3 * c.b.y); | |
| 282 | + col += paint(.85, f) * limb * .9 + paint(.3, f) * spicule * (.4 + 1.5 * c.b.w); | |
| 283 | + | |
| 284 | + // Prominence loops: twisted triple-strand arches, each band lifting its own loops. | |
| 285 | + for (int k = 0; k < 6; ++k) { | |
| 286 | + float fk = float(k), level = c.b[k % 4]; | |
| 287 | + float sk = (fk - 2.5) * .95 + .25 * sin(c.t * .05 + fk * 1.3); | |
| 288 | + float w = .2 + .16 * hash11(fk + 3.1); | |
| 289 | + float H = (.26 + .3 * hash11(fk + 8.7)) * (.6 + 1.2 * level) * (1 + .08 * sin(c.t * .3 + fk)) * tall; | |
| 290 | + float tilt = .5 * (hash11(fk + 1.9) - .5); | |
| 291 | + float2 e = float2((s - sk - h * tilt) / w, h / H); | |
| 292 | + float el = length(e), along = atan2(e.y, e.x), scale = min(w, H); | |
| 293 | + float rope = 0; | |
| 294 | + for (int j = 0; j < 3; ++j) { | |
| 295 | + float off = .09 * sin(along * 5 + c.t * 1.1 + float(j) * 2.09 + fk); | |
| 296 | + rope += glow((el - 1 - off) * scale, .005 + .003 * level); | |
| 297 | + } | |
| 298 | + float flow = pow(cosmWave(along * 7 - c.t * 2.2 + fk * 2 - PI * .5), 4.f); | |
| 299 | + float halo = glow((el - 1) * scale, .035) * .3; | |
| 300 | + col += paint(.55 + .3 * flow + .05 * fk, f) * (rope * (.4 + .6 * flow) + halo) * above * (.3 + 1.5 * level); | |
| 301 | + } | |
| 302 | + | |
| 303 | + // Attacks launch an ejection: a bright-fronted bubble rising off the limb. | |
| 304 | + float site = 1.1 * sin(c.t * .045); | |
| 305 | + float lift = 1 - c.hit; | |
| 306 | + float2 eb = float2(s - site, h - (.06 + lift * 1.1)); | |
| 307 | + float rad = .08 + lift * .5; | |
| 308 | + float bubble = length(eb * float2(1, 1.15)) - rad; | |
| 309 | + float cme = glow(bubble, .02 + .03 * lift) * 1.4 + glow(length(eb + float2(0, rad * .5)), .04 + .06 * lift) * .9; | |
| 310 | + col += paint(.88, f) * cme * c.hit * (.5 + .5 * c.hit) * 2 * above; | |
| 311 | + return col * .85; | |
| 312 | + } | |
| 313 | + NATIVE_EFFECT(solarProminenceII) | |
| 314 | + | |
| 315 | + // ---------------------------------------------------------------- 355 Quasar Jet | |
| 316 | + float3 quasarJetII(Ctx c, constant NativeFrame &f) { | |
| 317 | + float2 p = c.uv / c.size; | |
| 318 | + float ang = atan2(c.extent.y, c.extent.x) * .85 + .17 * sin(c.t * .09); | |
| 319 | + float2 q = rot(p, -ang); | |
| 320 | + float ax = abs(q.x), side = q.x < 0 ? -1.f : 1.f; | |
| 321 | + const float L = 1.15; | |
| 322 | + float reach = smoothstep(L + .15f, L - .25f, ax); | |
| 323 | + float wj = .022 + .06 * ax; | |
| 324 | + float flick = noise2(float2(ax * 7 - c.t * 6, side * 3.7)); | |
| 325 | + float jetLevel = .6 + .4 * flick + c.b.w * 2.6 * flick * flick; | |
| 326 | + float jet = exp(-q.y * q.y / (wj * wj)) * reach / (1 + ax * .6) * jetLevel; | |
| 327 | + float spine = glow(q.y, .0035 + .002 * ax) * reach / (1 + ax) * jetLevel; | |
| 328 | + | |
| 329 | + float helix = 0; | |
| 330 | + for (int j = 0; j < 2; ++j) { | |
| 331 | + float ph = ax * 13 - c.t * 2.2 + float(j) * PI + side; | |
| 332 | + helix += glow(q.y - wj * .85 * sin(ph), .004 + .002 * ax) * (.55 + .45 * cos(ph)); | |
| 333 | + } | |
| 334 | + helix *= reach * (.3 + 1.8 * c.b.z); | |
| 335 | + | |
| 336 | + float knots = 0; | |
| 337 | + for (int k = 0; k < 4; ++k) { | |
| 338 | + float ph = fract(c.t * .075 + float(k) * .25 + (side > 0 ? 0.f : .125f)); | |
| 339 | + knots += glow(length(float2(ax - ph * L, q.y * 1.4)), .018 + .02 * ax) * sin(PI * ph); | |
| 340 | + } | |
| 341 | + float lx = .06 + (1 - c.hit) * L * .85; | |
| 342 | + float launch = (glow(length(float2(ax - lx, q.y * 1.3)), .03 + .035 * lx) * 3 + glow(length(float2(ax - lx, q.y)), .15) * .4) | |
| 343 | + * c.hit * reach; | |
| 344 | + | |
| 345 | + // Radio lobes where the jets stall, with hot spots and glowing rims. | |
| 346 | + float2 lc = q - float2(side * L, 0); | |
| 347 | + float lt = fbm2(q * 2.3 + float2(-side * c.t * .04, c.t * .03), 4); | |
| 348 | + float lobeShape = length(lc * float2(.8, 1.2)) - (.34 + .26 * lt); | |
| 349 | + float strands = cosmRidge(lc * 3.4 + float2(c.t * .05, side * 2.3) + lt, 3) / .875; | |
| 350 | + float lobe = (smoothstep(.1f, -.25f, lobeShape) * .85 + exp(-max(lobeShape, 0.f) * 4) * .15) * (.15 + .85 * pow(strands, 3.f)); | |
| 351 | + float lobeRim = glow(lobeShape, .012) * (.2 + .8 * lt); | |
| 352 | + float hotspot = glow(length(lc + float2(side * .12, 0)), .04); | |
| 353 | + | |
| 354 | + float sheathW = .12 + .22 * ax / L; | |
| 355 | + float sheath = exp(-q.y * q.y / (sheathW * sheathW)) * reach; | |
| 356 | + float backflow = noise2(float2(ax * 4 + c.t * .5, q.y * 9)); | |
| 357 | + float cocoon = sheath * (.3 + .7 * backflow) * (.2 + 1.3 * c.b.y); | |
| 358 | + | |
| 359 | + float rp = length(p); | |
| 360 | + float hostGlow = exp(-length(rot(p, .4) * float2(1, 1.6)) * 2.2); | |
| 361 | + float haze = fbm2(p * 1.1 + float2(c.t * .05, 3), 4); | |
| 362 | + | |
| 363 | + float3 col = paint(.02 + haze * .2, f) * (.05 + .14 * haze * haze); | |
| 364 | + col += paint(.3 + .5 * strands, f) * lobe * (.3 + 1.6 * c.b.x) + paint(.85, f) * (lobeRim * .3 + hotspot) * (.5 + 1.2 * c.b.x); | |
| 365 | + col += paint(.45, f) * cocoon; | |
| 366 | + col += paint(.6, f) * jet * .8 + paint(.95, f) * spine * 1.2; | |
| 367 | + col += paint(.8, f) * helix; | |
| 368 | + col += paint(.95, f) * (knots * 1.2 + launch); | |
| 369 | + col += paint(.5, f) * hostGlow * .22 + paint(.98, f) * (glow(rp, .022) * 3 + glow(rp, .1) * .25); | |
| 370 | + col += paint(.9, f) * cosmStars(p * 10, .22, c.t) * .5; | |
| 371 | + return col * .85; | |
| 372 | + } | |
| 373 | + NATIVE_EFFECT(quasarJetII) | |
| 374 | + | |
| 375 | + | |
| 376 | + // ---------------------------------------------------------------- 357 Magnetosphere | |
| 377 | + float3 magnetosphereII(Ctx c, constant NativeFrame &f) { | |
| 378 | + float2 p = cosmLongAxis(c.uv / c.size, c.extent); | |
| 379 | + // The planet sits at the canvas centre, where the forward-zoom echo of the dipole field | |
| 380 | + // lands on the field itself. | |
| 381 | + float2 q = rot(p, .25 * sin(c.t * .14)); | |
| 382 | + const float Rp = .12; | |
| 383 | + // Dayside compressed by the wind (harder on attacks), nightside stretched into a tail. | |
| 384 | + float press = 1.45 + .15 * sin(c.t * .3) + .4 * c.hit; | |
| 385 | + float xd = q.x * mix(press, 1 / (1 + 1.25 * max(q.x, 0.f)), smoothstep(-.1f, .1f, q.x)); | |
| 386 | + float flap = .2 * sin(q.x * 2.2 - c.t * .8) * smoothstep(0.f, 1.5f, q.x); // the tail flaps in the wind | |
| 387 | + float rd = length(float2(xd, q.y + flap)); | |
| 388 | + float shellL = rd * rd * rd / max(xd * xd, 1e-6f); | |
| 389 | + float lv = log2(shellL) * 2.4 - c.t * .22; // field shells drift steadily outward | |
| 390 | + float id = floor(lv + .5); | |
| 391 | + float level = cosmBand(c.b, id - 4 * floor(id / 4)); | |
| 392 | + float lat = atan2(q.y, abs(xd)); | |
| 393 | + float bounce = .55 + .45 * pow(cosmWave(lat * 8 - c.t * 3 + id * 1.7 - PI * .5), 3.f); | |
| 394 | + float xm = -.62 + .7 * q.y * q.y; // magnetopause | |
| 395 | + float inside = smoothstep(xm - .02, xm + .03, q.x) * smoothstep(Rp, Rp * 1.3, length(q)); | |
| 396 | + float fieldD = cosmContour(lv, c.px) / c.size; | |
| 397 | + float crowd = smoothstep(.45f, .15f, fwidth(lv)); // fade lines where they bunch at the poles | |
| 398 | + float field = (glow(fieldD, .0045 + .003 * level) * bounce * crowd + glow(fieldD, .025) * .15 * crowd + .08 * (1 - crowd)) | |
| 399 | + * inside * (.3 + 1.7 * level); | |
| 400 | + | |
| 401 | + // Solar wind streamlines bending around the bow shock. | |
| 402 | + const float xb0 = -.86; | |
| 403 | + float body = 2.6 * .08 * log(1 + exp((q.x - xb0) / .08)); | |
| 404 | + float y2 = q.y * q.y; | |
| 405 | + float eta = sign(q.y) * sqrt(max(y2 - body, 0.f)); | |
| 406 | + float outside = smoothstep(0.f, .02f, y2 - body); | |
| 407 | + float wv = eta * 9; | |
| 408 | + float windD = cosmContour(wv, c.px) / c.size; | |
| 409 | + float dash = pow(cosmWave(q.x * 12 - c.t * 4 + hash11(floor(wv + .5)) * TAU - PI * .5), 6.f); | |
| 410 | + float wind = (glow(windD, .003) * (.25 + dash * (.5 + 2.2 * c.b.w))) * outside * smoothstep(.45f, .15f, fwidth(wv)); | |
| 411 | + float sheathMask = (1 - outside) * (1 - inside) * smoothstep(Rp, Rp * 1.3, length(q)); | |
| 412 | + float sheath = fbm2(q * 4 + float2(-c.t * .3, 0), 3) * sheathMask; | |
| 413 | + float bowD = abs(q.x - xb0 - y2 / 2.6) / sqrt(1 + (2 * q.y / 2.6) * (2 * q.y / 2.6)); | |
| 414 | + float mpD = abs(q.x - xm) / sqrt(1 + (1.4 * q.y) * (1.4 * q.y)); | |
| 415 | + | |
| 416 | + // Attacks fire an interplanetary shock front across the scene. | |
| 417 | + float xf = -2.8 + (1 - c.hit) * 5.4; | |
| 418 | + float shockD = q.x - xf - .25 * y2; | |
| 419 | + float shock = (glow(shockD, .02) * 2 + glow(shockD, .12) * .35 * step(shockD, 0.f)) * c.hit; | |
| 420 | + | |
| 421 | + float2 pole = float2(0, Rp * .9); | |
| 422 | + float aurora = glow(abs(length((q - pole) * float2(1, 3.2)) - .045), .006) + glow(abs(length((q + pole) * float2(1, 3.2)) - .045), .006); | |
| 423 | + | |
| 424 | + float pr = length(q) / Rp; | |
| 425 | + float disc = fill(pr - 1, c.px / Rp); | |
| 426 | + float2 nrm = q / Rp; | |
| 427 | + float day = clamp(-nrm.x * .9 + .25, 0.f, 1.f) * sqrt(max(0.f, 1 - pr * pr)); | |
| 428 | + | |
| 429 | + float haze = fbm2(p * 1.4 + float2(-c.t * .12, 0), 3); | |
| 430 | + float3 col = paint(.02 + haze * .2, f) * (.05 + .12 * haze * haze); | |
| 431 | + col += paint(.35, f) * sheath * .55; | |
| 432 | + col += paint(.25 + .1 * id, f) * field * .9 + paint(.15, f) * wind; | |
| 433 | + col += paint(.8, f) * (glow(bowD, .006) * .9 + glow(bowD, .05) * .2) + paint(.6, f) * glow(mpD, .005) * inside * .4; | |
| 434 | + col += paint(.92, f) * shock + paint(.95, f) * aurora * (.3 + 2 * c.b.z); | |
| 435 | + float dayRim = glow((pr - 1) * Rp, .005) * clamp(.45 - nrm.x * .7, 0.f, 1.f); | |
| 436 | + col = mix(col, deep(.1 + .2 * day, f) * .25 + paint(.4 + .3 * day, f) * day * .75, disc); | |
| 437 | + col += paint(.75, f) * dayRim * 1.3 + paint(.5, f) * glow(max(pr - 1, 0.f) * Rp, .02) * .35; | |
| 438 | + col += paint(.9, f) * cosmStars(p * 9, .2, c.t) * .4; | |
| 439 | + return col; | |
| 440 | + } | |
| 441 | + NATIVE_EFFECT(magnetosphereII) | |
| 442 | + | |
| 443 | + // ---------------------------------------------------------------- 358 Nebular Filaments | |
| 444 | + struct CosmCells { float d1; float d3; float edge; float2 a; float2 b; }; | |
| 445 | + CosmCells cosmCells(float2 p, float phase) { | |
| 446 | + float2 cell = floor(p), fp = fract(p); | |
| 447 | + float d1 = 64, d2 = 64, d3 = 64; float2 a = 0, b = 0, sa = 0, sb = 0; | |
| 448 | + float cosine, sine = sincos(phase, cosine); // every site circles its cell at one rate | |
| 449 | + for (int y = -1; y <= 1; ++y) for (int x = -1; x <= 1; ++x) { | |
| 450 | + float2 g = float2(x, y), id = cell + g; | |
| 451 | + uint seed = canvasSeed(canvasPair(id)); // one mix, split into two channels | |
| 452 | + float2 o = float2(float(seed & 0xFFFFu), float(seed >> 16)) * (.6f / 65536.f) - .3f; | |
| 453 | + float2 site = g + .5 + float2(o.x * cosine - o.y * sine, o.x * sine + o.y * cosine); | |
| 454 | + float2 delta = site - fp; | |
| 455 | + float d = dot(delta, delta); | |
| 456 | + bool first = d < d1, second = d < d2; // branch-free insertion keeps SIMD lanes together | |
| 457 | + d3 = second ? d2 : min(d3, d); | |
| 458 | + d2 = first ? d1 : (second ? d : d2); | |
| 459 | + b = first ? a : (second ? id : b); | |
| 460 | + sb = first ? sa : (second ? site : sb); | |
| 461 | + d1 = first ? d : d1; a = first ? id : a; sa = first ? site : sa; | |
| 462 | + } | |
| 463 | + CosmCells k; | |
| 464 | + k.d1 = sqrt(d1); k.d3 = sqrt(d3); k.a = a; k.b = b; | |
| 465 | + k.edge = abs(dot(fp - .5 * (sa + sb), normalize(sb - sa + 1e-5))); | |
| 466 | + return k; | |
| 467 | + } | |
| 468 | + | |
| 469 | + float3 cosmicWebII(Ctx c, constant NativeFrame &f) { | |
| 470 | + float2 p = c.uv / c.size; | |
| 471 | + float r = length(p); | |
| 472 | + // A supercluster sits ahead: the web crowds toward it, brightens and feeds it great filaments. | |
| 473 | + float well = exp(-r * 1.5), pull = 1 + 1.3 * exp(-r * 1.3); | |
| 474 | + float haze = fbm2(c.uv * .8 + float2(c.t * .01, 0), 2); | |
| 475 | + float3 col = paint(.02 + haze * .2, f) * (.03 + .1 * haze * haze) + paint(.45, f) * well * .08; | |
| 476 | + float bend = atan2(p.y, p.x) + .35 * sin(r * 2.2 - c.t * .12); | |
| 477 | + float spoke = glow(r * abs(sin(3 * bend)) / 3, .004 + .012 * r) * smoothstep(.05f, .25f, r) * exp(-r * .45); | |
| 478 | + for (int k = 0; k < 4; ++k) { | |
| 479 | + float2 s = layerSlot(k, 4, c.travel * .07); | |
| 480 | + float sc = layerScale(s.x, 2) * pull; | |
| 481 | + float2 q = rot(p * sc, s.y * 1.1) + hash22(float2(s.y, 7.3)) * 40; | |
| 482 | + q += .32 * sin(q.yx * float2(.9, 1.1) + float2(s.y, s.y * 1.7 + 2)); // bend the filaments | |
| 483 | + CosmCells v = cosmCells(q, c.t * .25 + s.y); | |
| 484 | + float edge = v.edge / sc, node = (v.d3 - v.d1) / sc; | |
| 485 | + float pair = hash21(v.a + v.b); | |
| 486 | + float band = floor(pair * 3.999); | |
| 487 | + float level = cosmBand(c.b, band); | |
| 488 | + float strength = fract(pair * 7.3); // some filaments thick and bright, some faint | |
| 489 | + float fade = layerFade(s.x) * (.3 + .7 * s.x) * (1 - c.fog * .5 * (1 - s.x)) * (.42 + .5 * well); | |
| 490 | + float beads = .55 + .45 * sin(q.x * 6.3 + s.y) * sin(q.y * 5.7 - s.y); | |
| 491 | + float pulseAlong = .6 + .4 * sin(v.d1 * 9 - c.t * 2 + hash21(v.a) * TAU); | |
| 492 | + float wide = (.0015 + .004 * s.x) * (.6 + strength) * (1 + 1.5 * exp(-node * sc * 4)); // thicker near clusters | |
| 493 | + float fil = (glow(edge, wide * (1 + 1.2 * level)) * (.4 + 2.2 * level) * beads * pulseAlong | |
| 494 | + + glow(edge, .03 * (.4 + s.x)) * .08) * (.3 + 1.1 * strength); | |
| 495 | + float lightUp = step(.45, hash21(v.a + 3.3)); | |
| 496 | + float flare = 1 + 3.5 * c.hit * lightUp; | |
| 497 | + float hub = glow(node, .009 + .018 * s.x) * flare + glow(node, .07 * (.4 + s.x)) * .28 * flare; | |
| 498 | + col += (paint(.25 + s.y * .11 + band * .1, f) * fil + paint(.75, f) * hub) * fade; | |
| 499 | + } | |
| 500 | + col += paint(.6, f) * spoke * (.4 + 1.2 * c.b.x); | |
| 501 | + col += paint(.78, f) * (glow(r, .03) * 1.2 + glow(r, .15) * .15) * (1 + 1.5 * c.hit); | |
| 502 | + return col * .8; | |
| 503 | + } | |
| 504 | + NATIVE_EFFECT(cosmicWebII) | |
| 505 | + | |
| 506 | + // ---------------------------------------------------------------- 359 Einstein Ring | |
| 507 | + float3 cosmGalaxySource(float2 d, float spin, float hue, constant NativeFrame &f) { | |
| 508 | + float r = length(d); | |
| 509 | + float phi = atan2(d.y, d.x) - 2.6 * log(r + .02); | |
| 510 | + float arms = pow(cosmWave(2 * phi - spin), 5.f); | |
| 511 | + float body = exp(-r * 6) * (.15 + .85 * arms) * 1.4 + exp(-r * r * 300) * 1.8; | |
| 512 | + return paint(hue + .3 * exp(-r * 6), f) * body; | |
| 513 | + } | |
| 514 | + | |
| 515 | + float3 einsteinRingII(Ctx c, constant NativeFrame &f) { | |
| 516 | + float2 th = c.uv / c.size; | |
| 517 | + float r = max(length(th), 1e-3f); | |
| 518 | + // Point lens plus a slowly turning external shear; mass breathes with the bass. | |
| 519 | + float thetaE = .56 * (1 + .3 * c.b.x); | |
| 520 | + float2 beta = th - thetaE * thetaE * th / (r * r); | |
| 521 | + float sa = c.t * .03; | |
| 522 | + float2 sh = float2(cos(2 * sa), sin(2 * sa)) * .1; | |
| 523 | + beta -= float2(sh.x * th.x + sh.y * th.y, sh.y * th.x - sh.x * th.y); | |
| 524 | + float centre = smoothstep(.06f, .22f, r); | |
| 525 | + | |
| 526 | + float bg = fbm2(beta * 1.6 + float2(3, c.t * .01), 4); | |
| 527 | + float3 col = deep(.9 + bg * .2, f) * (.04 + .1 * bg * bg) * centre; | |
| 528 | + col += paint(.1 + bg * .8, f) * pow(smoothstep(.45f, .9f, bg), 2.f) * .12 * centre; | |
| 529 | + // A field of faint background galaxies, sheared into tangential arclets around the lens. | |
| 530 | + float2 gq = beta * 3.2 + float2(7.1, 2.3); | |
| 531 | + float2 gid = floor(gq); | |
| 532 | + float3 gh = hash33(float3(gid, 4.7)); | |
| 533 | + float2 home = (gid + .5 - float2(7.1, 2.3)) / 3.2; // each galaxy lies along its circle | |
| 534 | + float2 go = rot(fract(gq) - .5 - (gh.xy - .5) * .45, -atan2(home.y, home.x) + (gh.z - .5) * .5) * float2(2.4, 1); | |
| 535 | + float arclet = exp(-dot(go, go) * 55) * step(.3f, gh.x) * smoothstep(thetaE * .75f, thetaE * 1.05f, r); | |
| 536 | + col += paint(gh.z > .5 ? .02 + .2 * gh.y : .74 + .22 * gh.y, f) * arclet * (.35 + 1.2 * c.b.w) * centre; | |
| 537 | + // A compact source almost exactly behind the lens: its image is a crisp near-complete ring | |
| 538 | + // on the Einstein radius, which swells and contracts with the lens mass. | |
| 539 | + float2 b0 = .05 * float2(cos(c.t * .11), sin(c.t * .13)); | |
| 540 | + float d0 = length(beta - b0); | |
| 541 | + col += paint(.02 + 2 * d0, f) * (exp(-d0 * d0 * 1400) * 2.2 + exp(-d0 * 12) * .35) * (.5 + 1.4 * c.b.x) * centre; | |
| 542 | + for (int j = 0; j < 5; ++j) { | |
| 543 | + float fj = float(j); | |
| 544 | + float2 home = float2(cos(fj * 2.4 + 1), sin(fj * 2.4 + 1)) * (.1 + .36 * fract(fj * .618 + .2)); | |
| 545 | + float2 sp = rot(home, c.t * (.04 + .015 * fj) * (j % 2 == 0 ? 1 : -1)); | |
| 546 | + float2 d = rot(beta - sp, fj * 1.3 + c.t * .1); | |
| 547 | + d.y /= .6; | |
| 548 | + float level = c.b[j % 4]; | |
| 549 | + float hue = j % 2 == 0 ? .02 + fj * .04 : .72 + fj * .05; // cool and hot sources alternate | |
| 550 | + col += cosmGalaxySource(d * (1.5 + fj * .15), c.t * .3 + fj, hue, f) * (.6 + 2.8 * level) * centre; | |
| 551 | + } | |
| 552 | + // Attacks slide a bright new source behind the lens: a ring forms, then breaks into arcs. | |
| 553 | + float2 sh2 = rot(float2(-.08 + (1 - c.hit) * .9, .04), c.t * .07); | |
| 554 | + float flash = length(beta - sh2); | |
| 555 | + col += paint(.75, f) * (glow(flash, .035) * 3 + glow(flash, .12) * .6) * c.hit * centre; | |
| 556 | + col += paint(.6, f) * cosmStars(beta * 9, .25, c.t) * .5 * centre; | |
| 557 | + col += paint(.9, f) * glow(r, .05) * .3; | |
| 558 | + return col; | |
| 559 | + } | |
| 560 | + NATIVE_EFFECT(einsteinRingII) |
Sources/PulseCanvas/Resources/NativeExpansionFlight.metal added
| 1 | + // Original PulseCanvas designs 330–339. Flights that are not roads: canopies, strata, | |
| 2 | + // pillar forests, parallax silhouettes, river deltas, auroras, waterfalls, orbits, comets | |
| 3 | + // and cloud seas. Every scene is analytic (plane, sphere and layer intersections); no | |
| 4 | + // preset formulas, textures or third-party shader sources are used. | |
| 5 | + | |
| 6 | + // ---------------------------------------------------------------- 330 Canopy Flight | |
| 7 | + // Rows of hanging crystals are evaluated analytically at their own depth. The floor is a | |
| 8 | + // mirror: the same rows are reused with world height reflected, so the reflection is exact. | |
| 9 | + | |
| 10 | + constant float CANOPY_CEIL = 1.f; | |
| 11 | + constant float CANOPY_FLOOR = -.85f; | |
| 12 | + constant float CANOPY_ROW = 1.15f; | |
| 13 | + constant float CANOPY_COL = .95f; | |
| 14 | + | |
| 15 | + float canopy_rhombus(float2 q, float2 r) { | |
| 16 | + q = abs(q); | |
| 17 | + return (q.x * r.y + q.y * r.x - r.x * r.y) / length(r); | |
| 18 | + } | |
| 19 | + | |
| 20 | + struct CanopyPendant { float2 anchor; float wire; float2 size; float sway; float energy; float3 tone; }; | |
| 21 | + | |
| 22 | + CanopyPendant canopy_make(float rowId, float cell, float stagger, Ctx c, constant NativeFrame &f) { | |
| 23 | + CanopyPendant k; | |
| 24 | + float3 h = hash33(float3(rowId, cell, 3.1)); | |
| 25 | + k.anchor = float2((cell + stagger + (h.x - .5f) * .3f) * CANOPY_COL, CANOPY_CEIL); | |
| 26 | + k.wire = .05f + .38f * h.y; | |
| 27 | + k.size = float2(.06f + .05f * h.z, .13f + .14f * hash21(float2(cell, rowId + .5f))); | |
| 28 | + k.sway = (.07f + .34f * c.b.x) * sin(c.t * 1.05f + h.x * 6.28f + rowId * .4f) + .025f * sin(c.t * 2.3f + h.y * 9); | |
| 29 | + float band = c.b[int(h.z * 3.99f)]; | |
| 30 | + float ripple = c.hit * pow(.5f + .5f * sin(rowId * .75f + cell * .45f - c.t * 2.4f), 6.f) * 3.2f; | |
| 31 | + k.energy = .5f + 1.9f * band + ripple; | |
| 32 | + k.tone = paint(h.x * .5f + rowId * .06f + cell * .11f, f); | |
| 33 | + return k; | |
| 34 | + } | |
| 35 | + | |
| 36 | + float3 canopy_pendant(float2 w, CanopyPendant k, float pw, Ctx c, constant NativeFrame &f) { | |
| 37 | + float2 q = rot(w - k.anchor, -k.sway); | |
| 38 | + float2 local = q - float2(0, -k.wire - k.size.y); | |
| 39 | + float body = canopy_rhombus(local, k.size); | |
| 40 | + float facet = local.x > 0 ? .45f : 1.f; | |
| 41 | + float ridge = glow(local.x, pw * 1.5f + .004f) * .8f + glow(local.y, pw * 1.5f + .004f) * .5f; | |
| 42 | + float core = exp(-dot(local / k.size, local / k.size) * 2.5f); | |
| 43 | + float inside = fill(body, pw); | |
| 44 | + float3 col = k.tone * inside * (facet * (.3f + .35f * (1 - abs(local.y) / k.size.y)) + ridge + core * .6f) * k.energy; | |
| 45 | + col += k.tone * glow(body, .01f + pw) * .9f * k.energy; | |
| 46 | + col += k.tone * glow(body, .09f) * .07f * k.energy; | |
| 47 | + float wireD = sdSegment(q, float2(0), float2(0, -k.wire)); | |
| 48 | + col += k.tone * glow(wireD, pw + .003f) * .3f; | |
| 49 | + float tip = length(q - float2(0, -k.wire - 2 * k.size.y)); | |
| 50 | + col += paint(.92f, f) * glow(tip, .008f + pw) * (.35f + 3 * c.b.w); | |
| 51 | + return col; | |
| 52 | + } | |
| 53 | + | |
| 54 | + // A crystal seen in the dark mirror: a soft vertical smear of its light. | |
| 55 | + float3 canopy_reflection(float2 w, CanopyPendant k) { | |
| 56 | + float2 center = k.anchor + rot(float2(0, -k.wire - k.size.y), k.sway); | |
| 57 | + float2 d = w - center; | |
| 58 | + float spread = k.size.x * (1.4f + .5f * abs(d.y)); | |
| 59 | + float streak = exp(-d.x * d.x / (spread * spread)) * exp(-abs(d.y) * 1.1f) * smoothstep(-2.6f, -1.6f, w.y); | |
| 60 | + return k.tone * streak * k.energy * .4f; | |
| 61 | + } | |
| 62 | + | |
| 63 | + float3 canopy_ceiling(float2 w, float dz, Ctx c, constant NativeFrame &f) { | |
| 64 | + float3 col = deep(.3f, f) * .025f; | |
| 65 | + float row0 = floor(w.y / CANOPY_ROW); | |
| 66 | + for (int r = 0; r < 2; ++r) { | |
| 67 | + float rowId = row0 + float(r); | |
| 68 | + float stagger = hash11(rowId + .37f); | |
| 69 | + float cellF = w.x / CANOPY_COL - stagger; | |
| 70 | + float cell = floor(cellF + .5f); | |
| 71 | + float other = cell + (cellF > cell ? 1 : -1); | |
| 72 | + for (int m = 0; m < 2; ++m) { | |
| 73 | + CanopyPendant k = canopy_make(rowId, m == 0 ? cell : other, stagger, c, f); | |
| 74 | + float2 d = w - float2(k.anchor.x, rowId * CANOPY_ROW); | |
| 75 | + float r2 = dot(d, d); | |
| 76 | + col += k.tone * (exp(-r2 * 30) * .25f + glow(sqrt(r2), .02f) * .2f) * k.energy; | |
| 77 | + } | |
| 78 | + } | |
| 79 | + return col * exp(-dz * (.05f + .1f * c.fog)); | |
| 80 | + } | |
| 81 | + | |
| 82 | + float3 canopyFlightScene(Ctx c, constant NativeFrame &f) { | |
| 83 | + const float lens = 1.3f; | |
| 84 | + const int rows = 12; | |
| 85 | + float2 p = rot(c.uv, .06f * sin(c.travel * .05f + .8f)) / c.size; | |
| 86 | + float camZ = c.travel * 2.4f; | |
| 87 | + float camX = 1.1f * sin(c.travel * .06f) + .2f * sin(c.t * .04f); | |
| 88 | + float ay = max(abs(p.y), .015f); | |
| 89 | + float3 col; | |
| 90 | + if (p.y > 0) { | |
| 91 | + float dz = CANOPY_CEIL * lens / ay; | |
| 92 | + col = canopy_ceiling(float2(p.x * dz / lens + camX, dz + camZ), dz, c, f); | |
| 93 | + } else { | |
| 94 | + float dzFloor = -CANOPY_FLOOR * lens / ay; | |
| 95 | + float2 fw = float2(p.x * dzFloor / lens + camX, dzFloor + camZ); | |
| 96 | + float wobble = .025f * sin(fw.y * 3.1f + sin(fw.x * 2.3f) + c.t * .9f); | |
| 97 | + float dz = (CANOPY_CEIL - 2 * CANOPY_FLOOR) * lens / ay; | |
| 98 | + col = canopy_ceiling(float2(p.x * dz / lens + camX + wobble * dz, dz + camZ), dz, c, f) * .35f; | |
| 99 | + col += deep(.65f, f) * .05f * (.6f + .4f * noise2(fw * 2)); | |
| 100 | + } | |
| 101 | + col += paint(.55f, f) * exp(-ay * 7.f) * .12f + paint(.8f, f) * glow(ay, .015f) * .08f; | |
| 102 | + float base = floor(camZ / CANOPY_ROW); | |
| 103 | + for (int j = rows; j >= 1; --j) { | |
| 104 | + float rowId = base + float(j); | |
| 105 | + float dz = rowId * CANOPY_ROW - camZ; | |
| 106 | + float fade = smoothstep(float(rows) * CANOPY_ROW, float(rows - 4) * CANOPY_ROW, dz) * smoothstep(.25f, .9f, dz) | |
| 107 | + * exp(-dz * (.07f + .1f * c.fog)); | |
| 108 | + float scale = dz / lens; | |
| 109 | + float2 w = float2(p.x * scale + camX, p.y * scale); | |
| 110 | + bool mirrored = w.y < CANOPY_FLOOR; | |
| 111 | + if (mirrored) { | |
| 112 | + w.y = 2 * CANOPY_FLOOR - w.y; | |
| 113 | + w.x += .05f * sin(w.y * 3 + rowId + c.t * 1.3f) * (1 - w.y); | |
| 114 | + } | |
| 115 | + if (mirrored ? w.y > 3.5f : (w.y < -.05f || w.y > CANOPY_CEIL + .1f)) continue; | |
| 116 | + float stagger = hash11(rowId + .37f); | |
| 117 | + float cellF = w.x / CANOPY_COL - stagger; | |
| 118 | + float cell = floor(cellF + .5f); | |
| 119 | + float other = cell + (cellF > cell ? 1 : -1); | |
| 120 | + CanopyPendant a = canopy_make(rowId, cell, stagger, c, f); | |
| 121 | + CanopyPendant b = canopy_make(rowId, other, stagger, c, f); | |
| 122 | + float3 light; | |
| 123 | + if (mirrored) light = canopy_reflection(w, a) + canopy_reflection(w, b); | |
| 124 | + else { | |
| 125 | + float pw = c.px * scale * 1.2f; | |
| 126 | + light = canopy_pendant(w, a, pw, c, f) + canopy_pendant(w, b, pw, c, f); | |
| 127 | + } | |
| 128 | + col += light * fade; | |
| 129 | + } | |
| 130 | + return col; | |
| 131 | + } | |
| 132 | + // The reviewed look, with a faint palette floor so tall frames stay covered when zoomed out. | |
| 133 | + float3 canopyFlight(Ctx c, constant NativeFrame &f) { return max(canopyFlightScene(c, f), paint(.9, f) * .06); } | |
| 134 | + NATIVE_EFFECT(canopyFlight) | |
| 135 | + | |
| 136 | + // ---------------------------------------------------------------- 331 Strata Glide | |
| 137 | + // A thin gap between two vast planes. Each plane carries its own flowing strata: broad | |
| 138 | + // warm layers below, finer cross-cut layers above. Seams between layers glow. | |
| 139 | + | |
| 140 | + float3 strata_plane(float2 w, float dz, bool upper, Ctx c, constant NativeFrame &f) { | |
| 141 | + float s; | |
| 142 | + if (upper) { | |
| 143 | + s = (w.y - w.x) * .26f + 1.6f * fbm2(float2(w.x * .16f + c.t * .03f, w.y * .1f), 3) + c.t * .05f; | |
| 144 | + s += c.b.z * .5f * sin(w.x * .55f - w.y * .3f + c.t * .5f); | |
| 145 | + s *= 5.f; | |
| 146 | + } else { | |
| 147 | + s = (w.x + w.y) * .24f + 1.8f * fbm2(float2(w.x * .12f, w.y * .08f - c.t * .04f), 3) - c.t * .06f; | |
| 148 | + s += c.b.y * .6f * sin(w.x * .5f + w.y * .3f + c.t * .45f); | |
| 149 | + s *= 3.6f; | |
| 150 | + } | |
| 151 | + s += .3f * sin(s * 1.3f); | |
| 152 | + float idx = floor(s), fr = fract(s); | |
| 153 | + float aa = fwidth(s); | |
| 154 | + float detail = 1 - smoothstep(.15f, .6f, aa); | |
| 155 | + float seamD = min(fr, 1 - fr); | |
| 156 | + float seam = (1 - smoothstep(0.f, .03f + aa * 1.5f, seamD)) * detail; | |
| 157 | + float wide = exp(-seamD * 10); | |
| 158 | + float phase = idx * .23f + (upper ? .5f : 0.f); | |
| 159 | + float grain = .75f + .25f * sin(fr * 23 + idx); | |
| 160 | + float layer = mix(.11f, (.04f + .2f * fr * fr) * grain, detail); | |
| 161 | + float3 col = paint(phase, f) * layer * (upper ? .6f + 1.6f * c.b.z : .7f + 1.5f * c.b.y); | |
| 162 | + float hitSeam = (idx - 3 * floor(idx / 3)) == 0 ? 1.f : .2f; | |
| 163 | + float run = pow(.5f + .5f * cos(dz * .5f - c.t * 4.f + idx * .3f), 4.f); | |
| 164 | + col += paint(.88f + idx * .05f, f) * (seam * .9f + wide * .22f * detail) * (1 + c.hit * hitSeam * run * 5); | |
| 165 | + float glint = pow(noise2(w * float2(3.f, 1.5f) + c.t * .3f), 10.f); | |
| 166 | + col += paint(.95f, f) * glint * wide * c.b.w * 14 * detail * smoothstep(1.f, 2.5f, dz); | |
| 167 | + return col; | |
| 168 | + } | |
| 169 | + | |
| 170 | + float3 strataGlide(Ctx c, constant NativeFrame &f) { | |
| 171 | + const float lens = 1.25f; | |
| 172 | + float2 p = c.uv; | |
| 173 | + float camZ = c.travel * 2.6f; | |
| 174 | + float camX = .8f * sin(c.travel * .05f); | |
| 175 | + float gap = .42f * (1 + .5f * c.b.x) * c.size; | |
| 176 | + bool upper = p.y > 0; | |
| 177 | + float ay = max(abs(p.y), .004f); | |
| 178 | + float dz = gap * lens / ay; | |
| 179 | + float2 w = float2(p.x * dz / lens + camX, dz + camZ); | |
| 180 | + float3 col = strata_plane(w, dz, upper, c, f); | |
| 181 | + float3 haze = mix(paint(.62f, f), paint(.8f, f), .5f + .5f * sin(p.x * .7f + c.t * .1f)) * .16f; | |
| 182 | + col = mix(haze, col, exp(-dz * (.03f + .06f * c.fog))); | |
| 183 | + col += paint(.85f, f) * (exp(-ay * 16) * .3f + glow(ay, .008f) * .35f); | |
| 184 | + return col; | |
| 185 | + } | |
| 186 | + NATIVE_EFFECT(strataGlide) | |
| 187 | + | |
| 188 | + // ---------------------------------------------------------------- 332 Pillar Forest | |
| 189 | + // The camera weaves along a clear path through an endless grid of luminous columns. A 2D | |
| 190 | + // grid walk finds the columns front to back; height along each column comes from the ray. | |
| 191 | + | |
| 192 | + float pillar_path(float z) { return 1.3f * sin(z * .23f) + .55f * sin(z * .51f + 1.3f); } | |
| 193 | + float pillar_slope(float z) { return 1.3f * .23f * cos(z * .23f) + .55f * .51f * cos(z * .51f + 1.3f); } | |
| 194 | + | |
| 195 | + float3 pillarForest(Ctx c, constant NativeFrame &f) { | |
| 196 | + const float lens = 1.15f; | |
| 197 | + float camZ = c.travel * 1.4f; | |
| 198 | + float slope = pillar_slope(camZ); | |
| 199 | + float2 p = rot(c.uv, -slope * .12f) / c.size; | |
| 200 | + float yaw = atan(slope) * .75f; | |
| 201 | + float camY = .3f * sin(c.t * .11f); | |
| 202 | + float2 ro = float2(pillar_path(camZ), camZ); | |
| 203 | + float pitch = .3f + .12f * sin(c.t * .07f); | |
| 204 | + float up = p.y * cos(pitch) + lens * sin(pitch); | |
| 205 | + float2 flat = rot(float2(p.x, lens * cos(pitch) - p.y * sin(pitch)), -yaw); | |
| 206 | + float flatLength = max(length(flat), 1e-3f); | |
| 207 | + float2 rd = flat / flatLength; | |
| 208 | + rd = float2(abs(rd.x) < 1e-4f ? 1e-4f : rd.x, abs(rd.y) < 1e-4f ? 1e-4f : rd.y); | |
| 209 | + float rise = up / flatLength; | |
| 210 | + float elevation = atan2(up, flatLength); | |
| 211 | + float fogK = .26f + .3f * c.fog; | |
| 212 | + float3 fogColor = deep(.55f, f) * .05f + paint(.5f, f) * exp(-elevation * elevation * 9) * .12f + paint(.72f, f) * smoothstep(.4f, 1.4f, elevation) * .2f; | |
| 213 | + float3 col = 0; | |
| 214 | + float trans = 1; | |
| 215 | + float2 cell = floor(ro); | |
| 216 | + float2 stepDir = float2(rd.x > 0 ? 1 : -1, rd.y > 0 ? 1 : -1); | |
| 217 | + float2 tDelta = abs(1 / rd); | |
| 218 | + float2 tMax = (cell + max(stepDir, 0.f) - ro) / rd; | |
| 219 | + for (int i = 0; i < 16; ++i) { | |
| 220 | + float3 h = hash33(float3(cell, 3.7)); | |
| 221 | + float2 center = cell + .5f + (h.xy - .5f) * .2f; | |
| 222 | + bool present = h.z > .62f && abs(center.x - pillar_path(center.y)) > .8f; | |
| 223 | + if (present) { | |
| 224 | + float r = .06f + .14f * fract(h.x * 7.31f); | |
| 225 | + float2 o = ro - center; | |
| 226 | + float s0 = -dot(o, rd); | |
| 227 | + float side = o.x * rd.y - o.y * rd.x; | |
| 228 | + float dPerp = abs(side); | |
| 229 | + if (s0 > 0) { | |
| 230 | + float aa = c.px * s0 / lens * 1.3f + .002f; | |
| 231 | + float cover = smoothstep(r + aa, r - aa, dPerp); | |
| 232 | + float u = clamp(side / r, -1.f, 1.f); | |
| 233 | + float sHit = s0 - sqrt(max(r * r - dPerp * dPerp, 0.f)); | |
| 234 | + float y = camY + sHit * rise; | |
| 235 | + float ndv = sqrt(max(1 - u * u, 0.f)); | |
| 236 | + float band = c.b[int(fract(h.z * 13.7f) * 3.99f)]; | |
| 237 | + float energy = .6f + 2.f * band; | |
| 238 | + float rings = pow(.5f + .5f * cos((y * .55f - c.t * .5f + h.x * 5) * TAU), 18.f); | |
| 239 | + float surge = pow(.5f + .5f * cos((y * .2f - c.t * 1.3f + h.y * 3) * TAU), 24.f); | |
| 240 | + float3 tone = paint(.3f + h.x * .5f + y * .03f, f); | |
| 241 | + float segment = .75f + .25f * sin(y * 1.7f + h.y * 9 + c.t * .3f); | |
| 242 | + float3 pc = tone * (.22f + .3f * ndv) * energy * segment; | |
| 243 | + pc += paint(.95f, f) * pow(ndv, 6.f) * .3f * energy; | |
| 244 | + pc += paint(.92f + h.y * .08f, f) * (rings * (.5f + 2.5f * c.hit) + surge * c.hit * 4); | |
| 245 | + float fog = exp(-sHit * fogK); | |
| 246 | + col += trans * cover * mix(fogColor, pc, fog); | |
| 247 | + col += trans * (1 - cover) * tone * (glow(dPerp - r, .04f + .04f * band) * .4f + glow(dPerp - r, .25f) * .06f) * energy * fog; | |
| 248 | + trans *= 1 - cover; | |
| 249 | + } | |
| 250 | + } | |
| 251 | + if (trans < .02f) break; | |
| 252 | + if (tMax.x < tMax.y) { cell.x += stepDir.x; tMax.x += tDelta.x; } | |
| 253 | + else { cell.y += stepDir.y; tMax.y += tDelta.y; } | |
| 254 | + } | |
| 255 | + return col + trans * fogColor; | |
| 256 | + } | |
| 257 | + NATIVE_EFFECT(pillarForest) | |
| 258 | + | |
| 259 | + // ---------------------------------------------------------------- 333 Parallax Express | |
| 260 | + // A sideways window view: far hills, crystal spires, arch domes and near pylons slide | |
| 261 | + // laterally at increasing speeds. Each layer has its own band; attacks flare the pylons. | |
| 262 | + | |
| 263 | + struct ExpressSpire { float height; float ridge; float id; }; | |
| 264 | + | |
| 265 | + ExpressSpire express_spires(float x, float width, float seed, float lift) { | |
| 266 | + ExpressSpire s; s.height = -9; s.ridge = 9; s.id = 0; | |
| 267 | + float cell = floor(x / width); | |
| 268 | + for (int k = -1; k <= 1; ++k) { | |
| 269 | + float id = cell + float(k); | |
| 270 | + float3 h = hash33(float3(id, seed, 2.7)); | |
| 271 | + float apex = (id + .2f + .6f * h.x) * width; | |
| 272 | + float tall = (.3f + .7f * h.y) * lift; | |
| 273 | + float y = tall - abs(x - apex) * (2.4f + 2.6f * h.z); | |
| 274 | + if (y > s.height) { s.height = y; s.ridge = x - apex; s.id = id; } | |
| 275 | + } | |
| 276 | + return s; | |
| 277 | + } | |
| 278 | + | |
| 279 | + float express_hills(float x, float seed) { | |
| 280 | + return .55f * noise2(float2(x * .45f, seed)) + .3f * noise2(float2(x * 1.2f, seed + 4)) + .15f * noise2(float2(x * 3.1f, seed + 9)); | |
| 281 | + } | |
| 282 | + | |
| 283 | + float3 parallaxExpress(Ctx c, constant NativeFrame &f) { | |
| 284 | + float2 p = c.uv / c.size; | |
| 285 | + float span = c.extent.y / c.size; | |
| 286 | + float y = p.y / span; | |
| 287 | + float x = p.x; | |
| 288 | + float run = c.travel * 1.1f; | |
| 289 | + float px = c.px / span * 1.5f; | |
| 290 | + // Sky: deep gradient with slow glowing ribbons and faint stars. | |
| 291 | + float drift = noise2(float2(x * .35f - run * .04f, y * 2.5f)); | |
| 292 | + float3 col = mix(paint(.3f, f) * .3f, deep(.75f, f) * .07f, smoothstep(-.1f, 1.f, y)); | |
| 293 | + col += paint(.55f + y * .2f, f) * pow(.5f + .5f * sin(y * 9 + drift * 4 + c.t * .1f), 10.f) * .22f * smoothstep(0.f, .4f, y); | |
| 294 | + float2 star = float2(x * 18 - run * .4f, y * 18); | |
| 295 | + float2 sid = floor(star); | |
| 296 | + float sh = hash21(sid); | |
| 297 | + col += paint(.9f, f) * glow(length(fract(star) - .5f - (hash22(sid) - .5f) * .6f), .04f) * step(.88f, sh) * (.3f + 2 * c.b.w * sh) * smoothstep(.1f, .5f, y); | |
| 298 | + // Far ridge (bass). | |
| 299 | + float xa = x * .8f + run * .12f; | |
| 300 | + float ha = .05f + .4f * express_hills(xa, 1.3f) + .07f * c.b.x * sin(xa * 2.3f + c.t * .4f); | |
| 301 | + float da = y - ha; | |
| 302 | + col = mix(col, deep(.25f, f) * .12f + paint(.25f, f) * .18f * exp(da * 7), smoothstep(px, -px, da)); | |
| 303 | + col += paint(.22f + xa * .03f, f) * glow(da, .01f) * (.45f + 2.f * c.b.x); | |
| 304 | + // Crystal spires (low-mid). | |
| 305 | + float xb = x + run * .38f; | |
| 306 | + ExpressSpire sp = express_spires(xb, .3f, 3, .8f + .4f * c.b.y); | |
| 307 | + float hb = -.4f + sp.height; | |
| 308 | + float db = y - hb; | |
| 309 | + float3 sh3 = hash33(float3(sp.id, 5, 1)); | |
| 310 | + float3 spireTone = paint(.4f + sh3.x * .4f, f); | |
| 311 | + float facet = sp.ridge > 0 ? .35f : 1.f; | |
| 312 | + float3 spireFill = deep(.4f, f) * .06f + spireTone * (.03f + .16f * facet * exp(db * 4.f)); | |
| 313 | + spireFill += spireTone * glow(sp.ridge, .005f) * .5f * smoothstep(.0f, -.4f, db) * (.4f + 1.6f * c.b.y); | |
| 314 | + col = mix(col, spireFill, smoothstep(px, -px, db)); | |
| 315 | + col += spireTone * glow(db, .007f) * (.6f + 2.f * c.b.y); | |
| 316 | + // Neon arches (high-mid): outlines with a faint veil inside. | |
| 317 | + float xc = x + run * .85f; | |
| 318 | + float period = .9f; | |
| 319 | + float u = (fract(xc / period) - .5f) * period; | |
| 320 | + float aid = floor(xc / period); | |
| 321 | + float radius = .27f + .08f * hash11(aid); | |
| 322 | + float base = -.64f; | |
| 323 | + float dome = length(float2(u, y - base)) - radius; | |
| 324 | + float3 archTone = paint(.7f + hash11(aid + 3) * .25f, f); | |
| 325 | + float above = step(base, y); | |
| 326 | + col = mix(col, deep(.75f, f) * .05f, smoothstep(px, -px, y - base)); | |
| 327 | + col = mix(col, col * .55f + archTone * .05f, smoothstep(px, -px, dome) * above); | |
| 328 | + col += archTone * glow(dome, .008f) * (.6f + 2.2f * c.b.z) * above; | |
| 329 | + col += archTone * glow(dome + .06f, .005f) * (.25f + 1.4f * c.b.z) * above; | |
| 330 | + col += archTone * glow(y - base, .008f) * .6f; | |
| 331 | + // Near light bars streaking past, with a low ground edge (attacks flare them). | |
| 332 | + float xd = x + run * 2.6f; | |
| 333 | + float pid = floor(xd / 1.4f); | |
| 334 | + float pu = (fract(xd / 1.4f) - .5f) * 1.4f; | |
| 335 | + float ground = -.84f + .025f * sin(xd * 2.1f); | |
| 336 | + float dg = y - ground; | |
| 337 | + float flash = 1 + 4 * c.hit; | |
| 338 | + float3 nearTone = paint(.15f + hash11(pid + 7) * .35f, f); | |
| 339 | + float bar = glow(pu, .03f + .02f * hash11(pid)) * smoothstep(.95f, .2f, y); | |
| 340 | + col += nearTone * bar * .35f * flash; | |
| 341 | + col = mix(col, deep(.15f, f) * .1f + nearTone * .14f * exp(dg * 5), smoothstep(px, -px, dg)); | |
| 342 | + col += nearTone * glow(dg, .01f) * .8f * flash; | |
| 343 | + float streaks = pow(.5f + .5f * sin(y * 70 + hash11(floor(y * 11)) * 6), 20.f) * smoothstep(.0f, -.12f, dg); | |
| 344 | + col += paint(.6f + hash11(floor(y * 11)) * .35f, f) * streaks * (.3f + 1.2f * c.b.w) * (.6f + .4f * sin(xd * 3 + y * 40)) * flash; | |
| 345 | + return col; | |
| 346 | + } | |
| 347 | + NATIVE_EFFECT(parallaxExpress) | |
| 348 | + | |
| 349 | + // ---------------------------------------------------------------- 334 Delta Flyover | |
| 350 | + // Looking straight down on a delta of light. Meandering trunks run downstream; each | |
| 351 | + // spawns distributaries that peel off, diverge and taper out; fine capillaries glow | |
| 352 | + // around them. Every channel has a world-space id, so the scroll never pops. | |
| 353 | + | |
| 354 | + constant float DELTA_TRUNK = 2.3f; | |
| 355 | + constant float DELTA_CELL = 1.5f; | |
| 356 | + | |
| 357 | + float delta_trunk(float i, float y) { | |
| 358 | + float h = hash11(i + .71f); | |
| 359 | + return (i + .5f) * DELTA_TRUNK + DELTA_TRUNK * (.26f * sin(y * .21f + h * 6.3f) + .12f * sin(y * .53f + h * 17)); | |
| 360 | + } | |
| 361 | + | |
| 362 | + float3 deltaFlyover(Ctx c, constant NativeFrame &f) { | |
| 363 | + float zoom = exp2(.35f * sin(c.t * .031f)); | |
| 364 | + float2 p = rot(c.uv / c.size, .25f * sin(c.t * .023f)) * 2.2f * zoom; | |
| 365 | + float2 w = p + float2(1.5f * sin(c.travel * .03f), c.travel * 1.4f); | |
| 366 | + float px = c.px / c.size * 2.2f * zoom; | |
| 367 | + float terrain = fbm2(w * float2(.8f, .45f), 3); | |
| 368 | + float3 col = deep(.3f + terrain * .3f, f) * (.025f + .07f * terrain); | |
| 369 | + float lagoon = fbm2(w * float2(.35f, .2f) + 11, 3); | |
| 370 | + col += paint(.35f + lagoon * .3f, f) * smoothstep(.5f, .68f, lagoon) * .07f; | |
| 371 | + col += paint(.55f, f) * glow(lagoon - .5f, .012f) * .06f; | |
| 372 | + float surge = c.hit * 4; | |
| 373 | + float trunkLight = 0, branchLight = 0, twigLight = 0, wet = 0; | |
| 374 | + float i0 = floor(w.x / DELTA_TRUNK), j0 = floor(w.y / DELTA_CELL); | |
| 375 | + for (int k = -1; k <= 1; ++k) { | |
| 376 | + float i = i0 + float(k); | |
| 377 | + float trunkX = delta_trunk(i, w.y); | |
| 378 | + float trunkD = abs(w.x - trunkX); | |
| 379 | + float pulse = pow(.5f + .5f * sin(w.y * 1.2f + c.t * 3 + i * 2.1f), 10.f); | |
| 380 | + float flow = .7f + .3f * sin(w.y * 6 + c.t * 2.4f + i); | |
| 381 | + trunkLight += (smoothstep(.085f + px, .085f - px, trunkD) * flow * .9f + glow(trunkD, .2f) * .45f) * (1 + surge * pulse); | |
| 382 | + wet += exp(-trunkD * 1.5f); | |
| 383 | + for (int m = 0; m < 4; ++m) { | |
| 384 | + float j = j0 + float(m); | |
| 385 | + float3 h = hash33(float3(i, j, 4.4)); | |
| 386 | + if (h.x < .3f) continue; | |
| 387 | + float start = (j + .3f + .4f * h.y) * DELTA_CELL; | |
| 388 | + float len = DELTA_CELL * (1.6f + 1.4f * h.z); | |
| 389 | + float t = (start - w.y) / len; | |
| 390 | + if (t < 0 || t > 1) continue; | |
| 391 | + float side = h.x > .65f ? 1.f : -1.f; | |
| 392 | + float spread = DELTA_TRUNK * (.25f + .3f * h.y) * pow(smoothstep(0.f, 1.f, t), .7f); | |
| 393 | + float branchX = trunkX + side * spread + .08f * sin(w.y * 2.3f + h.z * 9) * t; | |
| 394 | + float d = abs(w.x - branchX); | |
| 395 | + float taper = (1 - t) * smoothstep(0.f, .08f, t); | |
| 396 | + float width = .02f + .035f * (1 - t); | |
| 397 | + float bpulse = pow(.5f + .5f * sin(w.y * 1.6f + c.t * 3.4f + j * 3.3f + i), 10.f); | |
| 398 | + branchLight += (smoothstep(width + px, width - px, d) + glow(d, width * 3) * .45f) * taper * (1 + surge * bpulse); | |
| 399 | + wet += exp(-d * 2.5f) * taper; | |
| 400 | + // Twigs peel off the branch in short sub-cells. | |
| 401 | + float sub = DELTA_CELL * .4f; | |
| 402 | + float k0 = floor(w.y / sub); | |
| 403 | + for (int q = 0; q < 3; ++q) { | |
| 404 | + float kk = k0 + float(q); | |
| 405 | + float3 g = hash33(float3(i * 7 + j, kk, 9.1)); | |
| 406 | + float tStart = (kk + .5f) * sub; | |
| 407 | + float tLen = sub * (1.2f + g.z); | |
| 408 | + float u = (tStart - w.y) / tLen; | |
| 409 | + float parentT = (start - tStart) / len; | |
| 410 | + if (g.x < .35f || u < 0 || u > 1 || parentT < .03f || parentT > .9f) continue; | |
| 411 | + float tSide = g.y > .5f ? 1.f : -1.f; | |
| 412 | + float twigX = branchX + tSide * (.18f + .2f * g.z) * pow(u, .7f); | |
| 413 | + float td = abs(w.x - twigX); | |
| 414 | + float tTaper = (1 - u) * smoothstep(0.f, .1f, u) * smoothstep(.03f, .15f, parentT) * smoothstep(.9f, .6f, parentT); | |
| 415 | + twigLight += (smoothstep(.012f + px, .006f, td) + glow(td, .03f) * .35f) * tTaper; | |
| 416 | + } | |
| 417 | + } | |
| 418 | + } | |
| 419 | + col += paint(.92f, f) * trunkLight * (.45f + 1.8f * c.b.x); | |
| 420 | + col += paint(.66f, f) * branchLight * (.45f + 1.9f * c.b.y); | |
| 421 | + col += paint(.45f, f) * twigLight * (.35f + 2.f * c.b.z); | |
| 422 | + col += deep(.6f, f) * min(wet, 1.5f) * .05f; | |
| 423 | + float2 sparkleCell = floor(w * 7); | |
| 424 | + float3 sh = hash33(float3(sparkleCell, 2.9)); | |
| 425 | + float sparkle = glow(length(w * 7 - sparkleCell - .2f - sh.xy * .6f), .07f) * step(.75f, sh.z) * (.5f + .5f * sin(c.t * 4 + sh.x * 30)); | |
| 426 | + col += paint(.97f, f) * sparkle * min(trunkLight + branchLight, 1.f) * (.2f + 4 * c.b.w); | |
| 427 | + return col; | |
| 428 | + } | |
| 429 | + NATIVE_EFFECT(deltaFlyover) | |
| 430 | + | |
| 431 | + // ---------------------------------------------------------------- 335 Aurora Overpass | |
| 432 | + // Curtains hang across the sky at stable depths; each folds along its length, and folds | |
| 433 | + // seen edge-on glow brighter. The dark plain mirrors the same curtains. | |
| 434 | + | |
| 435 | + float3 auroraOverpass(Ctx c, constant NativeFrame &f) { | |
| 436 | + const float lens = 1.2f, camH = .6f, gapZ = 1.9f; | |
| 437 | + const int sheets = 11; | |
| 438 | + float2 p = c.uv / c.size; | |
| 439 | + float vy = p.y + .42f; | |
| 440 | + bool ground = vy < 0; | |
| 441 | + float camZ = c.travel * 2.1f; | |
| 442 | + float camX = 1.2f * sin(c.travel * .045f); | |
| 443 | + float3 col; | |
| 444 | + if (ground) { | |
| 445 | + float dg = camH * lens / max(-vy, .01f); | |
| 446 | + float2 g = float2(p.x * dg / lens + camX, dg + camZ); | |
| 447 | + col = deep(.6f, f) * .06f + paint(.5f, f) * .05f * noise2(g * float2(1.5f, .6f)); | |
| 448 | + col += paint(.6f, f) * exp(vy * 9) * .2f; | |
| 449 | + } else { | |
| 450 | + col = mix(paint(.55f, f) * .2f, deep(.75f, f) * .12f, saturate(vy * .7f)); | |
| 451 | + float2 star = p * 24; | |
| 452 | + float2 sid = floor(star); | |
| 453 | + col += paint(.9f, f) * glow(length(fract(star) - .5f), .05f) * step(.9f, hash21(sid)) * .5f; | |
| 454 | + } | |
| 455 | + float base = floor(camZ / gapZ); | |
| 456 | + for (int j = sheets; j >= 1; --j) { | |
| 457 | + float id = base + float(j); | |
| 458 | + float dz0 = id * gapZ - camZ; | |
| 459 | + float3 h = hash33(float3(id, 5.3, 1.9)); | |
| 460 | + float k1 = .5f + .35f * h.x, ph = h.y * TAU; | |
| 461 | + float amp = .8f + 1.2f * c.b.x; | |
| 462 | + float x0 = p.x * dz0 / lens + camX; | |
| 463 | + float arg = x0 * k1 + ph + c.t * .3f; | |
| 464 | + float arg2 = x0 * k1 * 2.4f - c.t * .45f + ph * 2; | |
| 465 | + float dz = dz0 + amp * (sin(arg) + .45f * sin(arg2)); | |
| 466 | + if (dz < .25f) continue; | |
| 467 | + float x = p.x * dz / lens + camX; | |
| 468 | + float y = vy * dz / lens; | |
| 469 | + float gain = 1; | |
| 470 | + if (ground) { y = -2 * camH - y; x += .05f * sin(y * 5 + c.t); gain = .3f; } | |
| 471 | + float lower = .65f + .55f * h.z + .3f * sin(x * .23f + id * 1.7f + c.t * .1f); | |
| 472 | + float v = y - lower; | |
| 473 | + float pw = c.px * dz / lens * 2; | |
| 474 | + float edge = smoothstep(-.04f - pw, .04f + pw, v) * exp(-max(v, 0.f) * (1.1f + .6f * h.x)); | |
| 475 | + float slope = amp * k1 * (cos(arg) + 1.08f * cos(arg2)); | |
| 476 | + float fold = min(sqrt(1 + slope * slope) - 1, 2.5f); | |
| 477 | + float rays = (.45f + .55f * noise2(float2(x * 3.2f + id * 11, c.t * .18f + id))) * (.7f + .3f * noise2(float2(x * 9, id * 3 + c.t * .3f))); | |
| 478 | + float band = c.b[int(h.z * 3.99f)]; | |
| 479 | + float lift = c.hit * pow(.5f + .5f * sin(x * .45f - c.t * .9f + id * 2.3f), 6.f) * (.5f + fold) * 2.5f; | |
| 480 | + float fade = smoothstep(float(sheets) * gapZ, float(sheets - 3) * gapZ, dz0) * smoothstep(.25f, 1.2f, dz) * exp(-dz * (.02f + .06f * c.fog)); | |
| 481 | + float3 tone = paint(.75f - min(max(v, 0.f) * .2f, .45f) + h.x * .2f + id * .05f, f); | |
| 482 | + float rim = glow(v, .035f + pw) * smoothstep(-.4f, 0.f, v) * .6f; | |
| 483 | + col += tone * (edge * rays * (.25f + .9f * fold) + rim) * (.4f + 1.8f * band + lift) * fade * gain; | |
| 484 | + } | |
| 485 | + return col; | |
| 486 | + } | |
| 487 | + NATIVE_EFFECT(auroraOverpass) | |
| 488 | + | |
| 489 | + // ---------------------------------------------------------------- 336 Cascade Climb | |
| 490 | + // Climbing the face of a vast waterfall. The camera looks up the wall; ledges with wavy | |
| 491 | + // lips pass below, threads of falling light run down each sheet and mist rises off lips. | |
| 492 | + | |
| 493 | + float cascade_lip(float n, float x) { return n * 2.6f + .3f * sin(x * .7f + n * 1.9f) + .14f * sin(x * 1.9f + n); } | |
| 494 | + | |
| 495 | + float3 cascadeClimb(Ctx c, constant NativeFrame &f) { | |
| 496 | + const float lens = 1.25f, pitch = .45f, wallD = 2.f; | |
| 497 | + float2 p = c.uv / c.size; | |
| 498 | + float camY = c.travel * 1.5f; | |
| 499 | + float camX = .5f * sin(c.travel * .06f); | |
| 500 | + float cp = cos(pitch), sp = sin(pitch); | |
| 501 | + float ry = p.y * cp + lens * sp, rz = lens * cp - p.y * sp; | |
| 502 | + float s = wallD / max(rz, .03f); | |
| 503 | + float x = camX + p.x * s, y = camY + ry * s; | |
| 504 | + float n = floor(y / 2.6f); | |
| 505 | + float lipBelow = cascade_lip(n, x); | |
| 506 | + if (lipBelow > y) { n -= 1; lipBelow = cascade_lip(n, x); } | |
| 507 | + float lipAbove = cascade_lip(n + 1, x); | |
| 508 | + float above = y - lipBelow; | |
| 509 | + // Sheets of falling light, each fed by one band. | |
| 510 | + float sheetCoord = x * .85f + .35f * sin(y * .15f + x * .3f); | |
| 511 | + float sheetId = floor(sheetCoord); | |
| 512 | + float sheetEdge = fract(sheetCoord); | |
| 513 | + float band = c.b[int(sheetId - 4 * floor(sheetId / 4))]; | |
| 514 | + float threadX = x * 7; | |
| 515 | + float threadId = floor(threadX); | |
| 516 | + float th = hash21(float2(threadId, 4.2f)); | |
| 517 | + float phase = y * (.45f + .3f * th) + c.t * (.5f + .45f * th) + th * 13; | |
| 518 | + float fall = pow(.5f + .5f * sin(phase * TAU), 3.f); | |
| 519 | + float profile = pow(1 - abs(fract(threadX) - .5f) * 2, 3.f); | |
| 520 | + float aa = fwidth(threadX); | |
| 521 | + float detail = 1 - smoothstep(.25f, .7f, aa); | |
| 522 | + float threads = mix(.18f, profile * (.3f + .9f * fall), detail); | |
| 523 | + float sheetMask = smoothstep(0.f, .1f, sheetEdge) * smoothstep(1.f, .9f, sheetEdge); | |
| 524 | + float recess = 1 - .55f * smoothstep(.45f, 0.f, lipAbove - y); | |
| 525 | + float3 water = paint(.35f + sheetId * .11f + y * .008f, f) * (.16f + .2f * noise2(float2(x * 2, y * .5f + c.t * .4f)) + threads * (.35f + 1.6f * band)); | |
| 526 | + float3 col = mix(deep(.4f, f) * .12f, water, .25f + .75f * sheetMask) * recess; | |
| 527 | + // Lips glow where water curls over. | |
| 528 | + float lipGlow = glow(above, .035f + aa * .02f) + glow(lipAbove - y, .035f + aa * .02f); | |
| 529 | + col += paint(.88f + sheetId * .03f, f) * lipGlow * .9f * (.7f + .6f * band); | |
| 530 | + // Mist rising off the lower lip; attacks burst it. | |
| 531 | + float burstSel = smoothstep(.2f, .9f, .5f + .5f * sin(n * 2.1f + c.t * .35f)); | |
| 532 | + float burst = c.hit * burstSel; | |
| 533 | + float mist = fbm2(float2(x * 1.1f, (y - c.t * .35f) * 1.4f), 3); | |
| 534 | + float rise = exp(-max(above, 0.f) * (2.4f - 1.5f * burst)); | |
| 535 | + col += paint(.6f + mist * .2f, f) * mist * rise * (.55f + 3.2f * burst); | |
| 536 | + float spray = pow(noise2(float2(x * 22, y * 22 - c.t * 5)), 12.f); | |
| 537 | + col += paint(.95f, f) * spray * rise * (.6f + 9 * c.b.w) * detail; | |
| 538 | + // Far reaches of the falls dissolve into bright mist. | |
| 539 | + float far = 1 - exp(-s * .045f); | |
| 540 | + col = mix(col, paint(.55f, f) * .45f + paint(.85f, f) * .1f, saturate(far * (.8f + .4f * c.fog))); | |
| 541 | + // Near spray drifting past the lens. | |
| 542 | + float near = pow(.5f + .5f * sin(p.x * 2.7f + 1.3f * sin(p.x * 1.4f + 2)), 8.f) * pow(.5f + .5f * sin(p.y * 1.6f + c.travel * 3 + c.t * .8f), 4.f); | |
| 543 | + col += paint(.7f, f) * near * .18f; | |
| 544 | + return col; | |
| 545 | + } | |
| 546 | + NATIVE_EFFECT(cascadeClimb) | |
| 547 | + | |
| 548 | + // ---------------------------------------------------------------- 337 Night Orbit | |
| 549 | + // A low orbit over the dark side of a planet. A ray-sphere hit gives surface coordinates; | |
| 550 | + // two voronoi networks, nodes and dust glow on the surface, with a bright limb above. | |
| 551 | + | |
| 552 | + float3 orbit_space(float3 rd, float spin, Ctx c, constant NativeFrame &f) { | |
| 553 | + float3 rs = float3(rd.x, rd.y * cos(spin) - rd.z * sin(spin), rd.y * sin(spin) + rd.z * cos(spin)); | |
| 554 | + float3 col = deep(.7f, f) * .08f + paint(.65f, f) * .1f * noise3(rs * 2.5f) * noise3(rs * 5 + 3); | |
| 555 | + float3 cell = floor(rs * 70); | |
| 556 | + float3 hs = hash33(cell); | |
| 557 | + float3 site = (cell + .25f + hs * .5f) / 70; | |
| 558 | + float star = glow(length(rs - site) * 70, .06f) * step(.8f, hs.x); | |
| 559 | + col += paint(.85f + hs.y * .15f, f) * star * (.4f + .8f * hs.z); | |
| 560 | + return col; | |
| 561 | + } | |
| 562 | + | |
| 563 | + float3 nightOrbit(Ctx c, constant NativeFrame &f) { | |
| 564 | + const float R = 5.f, H = .5f, lens = 1.25f, pitch = .17f; | |
| 565 | + float2 p = rot(c.uv, .07f * sin(c.t * .05f)) / c.size; | |
| 566 | + float cp = cos(pitch), sp = sin(pitch); | |
| 567 | + float3 rd = normalize(float3(p.x, p.y * cp - lens * sp, lens * cp + p.y * sp)); | |
| 568 | + float3 ro = float3(0, R + H, 0); | |
| 569 | + float orbit = c.travel * .9f; | |
| 570 | + float b = dot(ro, rd), disc = b * b - (dot(ro, ro) - R * R); | |
| 571 | + float closest = sqrt(max(dot(ro, ro) - b * b, 0.f)) - R; | |
| 572 | + float3 col; | |
| 573 | + if (disc > 0 && -b - sqrt(disc) > 0) { | |
| 574 | + float s = -b - sqrt(disc); | |
| 575 | + float3 P = ro + rd * s, n = P / R; | |
| 576 | + float facing = max(dot(n, -rd), .05f); | |
| 577 | + float2 q = float2(atan2(P.z, P.y) * R + orbit, asin(clamp(n.x, -1.f, 1.f)) * R) * .9f; | |
| 578 | + float foot = c.px * s / lens / facing * .9f; | |
| 579 | + float detail = 1 - smoothstep(.04f, .22f, foot); | |
| 580 | + float land = smoothstep(.36f, .6f, fbm2(q * .17f + 2, 3)); | |
| 581 | + float4 v1 = voronoi(q * .7f, .9f, 0); | |
| 582 | + float4 v2 = voronoi(q * 2.1f + 7, .9f, 0); | |
| 583 | + float art = glow(v1.y - v1.x, .04f + foot * .7f) * (.5f + .5f * hash21(v1.zw)); | |
| 584 | + float web = glow(v2.y - v2.x, .05f + foot * 2) * detail; | |
| 585 | + float node = glow(v1.x, .05f + foot) * step(.35f, hash21(v1.zw + 3)); | |
| 586 | + float dust = pow(noise2(q * 6), 6.f) * detail; | |
| 587 | + float2 rel = q - float2(orbit * .9f + 2.6f, 0); | |
| 588 | + float dist = length(rel * float2(1, 1.3f)); | |
| 589 | + float ring = c.hit * pow(.5f + .5f * sin(dist * 2.2f - c.t * 3.2f), 10.f) * exp(-dist * .2f); | |
| 590 | + float lift = 1 + 3 * ring; | |
| 591 | + col = deep(.45f + land * .2f, f) * (.05f + .07f * land); | |
| 592 | + col += paint(.1f + hash21(v1.zw) * .3f, f) * art * (.4f + .6f * land) * (.5f + 1.8f * c.b.x) * lift; | |
| 593 | + col += paint(.45f + hash21(v2.zw) * .25f, f) * web * (.15f + .6f * land) * (.4f + 1.8f * c.b.y) * lift; | |
| 594 | + col += paint(.9f, f) * node * land * (.5f + 2.5f * c.b.z) * lift; | |
| 595 | + col += paint(.75f, f) * dust * land * (.4f + 5 * c.b.w); | |
| 596 | + col += paint(.5f, f) * ring * .5f; | |
| 597 | + float haze = pow(1 - facing, 4.f); | |
| 598 | + col = mix(col, paint(.3f, f) * .5f, haze * (.7f + .3f * c.fog)); | |
| 599 | + } else { | |
| 600 | + col = orbit_space(rd, orbit / R, c, f); | |
| 601 | + } | |
| 602 | + float alt = max(closest, 0.f); | |
| 603 | + float limbSide = .6f + .4f * sin(atan2(rd.x, rd.y + .3f) * 1.3f + c.t * .03f); | |
| 604 | + col += paint(.25f + alt * 2, f) * (exp(-alt * 22) * .9f + exp(-alt * 5) * .3f) * limbSide; | |
| 605 | + col += paint(.95f, f) * glow(closest, .006f) * .5f * limbSide; | |
| 606 | + return col; | |
| 607 | + } | |
| 608 | + NATIVE_EFFECT(nightOrbit) | |
| 609 | + | |
| 610 | + // ---------------------------------------------------------------- 338 Comet Chase | |
| 611 | + // Chasing a comet head that hangs ahead and to one side. The ion and dust tails stream | |
| 612 | + // out of it toward the camera; debris layers fly past on stable depth slots. | |
| 613 | + | |
| 614 | + float3 cometChase(Ctx c, constant NativeFrame &f) { | |
| 615 | + float2 p = c.uv / c.size; | |
| 616 | + float2 ext = c.extent / c.size; | |
| 617 | + float2 head = float2(.36f * ext.x, .3f * ext.y) + .05f * float2(sin(c.t * .31f), cos(c.t * .23f)); | |
| 618 | + float2 d = p - head; | |
| 619 | + float r = max(length(d), 1e-3f); | |
| 620 | + float a = atan2(d.y, d.x); | |
| 621 | + float lr = log(r); | |
| 622 | + float axis = -2.6f + .08f * sin(c.t * .17f); | |
| 623 | + float rel = a - axis; | |
| 624 | + rel = atan2(sin(rel), cos(rel)); | |
| 625 | + // Background: nebula haze and fixed stars. | |
| 626 | + float3 col = deep(.55f, f) * .18f + paint(.6f, f) * .07f * noise2(p * 1.3f + 4); | |
| 627 | + float2 star = p * 30; | |
| 628 | + float2 sid = floor(star); | |
| 629 | + col += paint(.85f, f) * glow(length(fract(star) - .5f - (hash22(sid) - .5f) * .6f), .05f) * step(.88f, hash21(sid)) * .45f; | |
| 630 | + // Dust tail: broad, curved, striated. | |
| 631 | + float curved = rel + .35f * lr; | |
| 632 | + float dustWidth = .55f + .3f * c.b.x; | |
| 633 | + float dust = exp(-curved * curved / (dustWidth * dustWidth)); | |
| 634 | + float striae = .55f + .45f * sin(curved * 26 + sin(lr * 3 - c.travel * 2) * 1.5f); | |
| 635 | + float stream = .6f + .4f * pow(.5f + .5f * sin(lr * 7 - c.travel * 5 + curved * 3), 3.f); | |
| 636 | + float reach = smoothstep(.02f, .2f, r); | |
| 637 | + col += paint(.2f + curved * .25f + r * .1f, f) * dust * striae * stream * reach * (.45f + 1.6f * c.b.x); | |
| 638 | + // Ion tail: narrow, straight filaments. | |
| 639 | + float ion = rel + .55f; | |
| 640 | + float ionCore = exp(-ion * ion * 40); | |
| 641 | + float fil = pow(.5f + .5f * cos(ion * 110 + noise2(float2(lr * 3 - c.travel * 3, ion * 20)) * 6), 6.f); | |
| 642 | + float kink = .5f + .5f * sin(lr * 11 - c.travel * 7 + ion * 30); | |
| 643 | + col += paint(.62f + ion * .3f, f) * ionCore * (.25f + fil * (.6f + kink)) * reach * (.4f + 1.8f * c.b.y); | |
| 644 | + // Coma, nucleus and jets. | |
| 645 | + col += paint(.8f, f) * (glow(r, .13f) * .9f + glow(r, .45f) * .3f); | |
| 646 | + col += paint(.97f, f) * glow(r, .012f) * 1.2f; | |
| 647 | + float jets = pow(.5f + .5f * cos(a * 5 + c.t * .5f), 10.f) * exp(-r * 7); | |
| 648 | + col += paint(.9f, f) * jets * (.3f + 2.2f * c.b.z); | |
| 649 | + // Debris on forward-moving depth slots. | |
| 650 | + for (int k = 0; k < 5; ++k) { | |
| 651 | + float2 slot = layerSlot(k, 5, c.travel * .25f); | |
| 652 | + float scale = layerScale(slot.x, 3.2f); | |
| 653 | + float2 q = d * scale * 3 + float2(slot.y * 3.7f, slot.y * 1.9f); | |
| 654 | + float2 cell = floor(q); | |
| 655 | + float3 h = hash33(float3(cell, slot.y)); | |
| 656 | + float2 site = cell + .2f + h.xy * .6f; | |
| 657 | + float glint = glow(length(q - site), .04f + .02f * h.z) * step(.72f, h.z); | |
| 658 | + float twinkle = .5f + .5f * sin(c.t * 3 + h.x * 20); | |
| 659 | + col += paint(.85f + h.y * .15f, f) * glint * (.4f + twinkle * (.3f + 2.5f * c.b.w)) * layerFade(slot.x) * 1.4f; | |
| 660 | + } | |
| 661 | + // Attack: a ring of fragments shed from the head. | |
| 662 | + float sector = floor(a / (TAU / 18)); | |
| 663 | + float sh = hash11(sector + 3.3f); | |
| 664 | + float fa = (sector + .5f) * (TAU / 18); | |
| 665 | + float fr = .08f + (1.1f - c.hit) * (.5f + .5f * sh); | |
| 666 | + float2 frag = head + float2(cos(fa), sin(fa)) * fr; | |
| 667 | + col += paint(.92f, f) * glow(length(p - frag), .025f) * c.hit * 2.5f; | |
| 668 | + col += paint(.85f, f) * glow(r - fr, .03f) * c.hit * .6f * (.5f + .5f * sin(a * 9 + sh)); | |
| 669 | + return col; | |
| 670 | + } | |
| 671 | + NATIVE_EFFECT(cometChase) | |
| 672 | + | |
| 673 | + // ---------------------------------------------------------------- 339 Cloud Sea | |
| 674 | + // Skimming a sea of cloud tops. Voronoi puffs with billowing detail glow from inside; | |
| 675 | + // light from below leaks through the crevices between them. | |
| 676 | + | |
| 677 | + float3 cloudSea(Ctx c, constant NativeFrame &f) { | |
| 678 | + const float lens = 1.2f, camH = .45f; | |
| 679 | + float2 p = c.uv / c.size; | |
| 680 | + float horizon = .38f; | |
| 681 | + float vy = horizon - p.y; | |
| 682 | + float camZ = c.travel * 2.2f; | |
| 683 | + float camX = .9f * sin(c.travel * .05f); | |
| 684 | + float3 col; | |
| 685 | + if (vy > 0) { | |
| 686 | + float dz = camH * lens / max(vy, .006f); | |
| 687 | + float2 w = float2(p.x * dz / lens + camX, dz + camZ); | |
| 688 | + float2 cw = w * float2(.75f, .55f); | |
| 689 | + float billow = fbm2(cw * 2.1f + float2(c.t * .05f, 0), 3); | |
| 690 | + float4 v = voronoi(cw + (billow - .5f) * .6f, .9f, c.t * .3f); | |
| 691 | + float puff = saturate(1 - v.x / .75f); | |
| 692 | + float crevice = 1 - smoothstep(0.f, .14f, v.y - v.x); | |
| 693 | + float3 h = hash33(float3(v.zw, 2.2)); | |
| 694 | + float band = c.b[int(h.z * 3.99f)]; | |
| 695 | + float flashSel = smoothstep(.55f, .95f, .5f + .5f * sin(h.x * TAU + c.t * .7f)); | |
| 696 | + float flash = c.hit * flashSel * 4; | |
| 697 | + float3 tone = paint(h.x * .6f + .1f, f); | |
| 698 | + float top = puff * (.5f + .5f * billow); | |
| 699 | + col = deep(.45f + h.y * .2f, f) * .1f + paint(.6f + billow * .2f, f) * top * .3f; | |
| 700 | + col += tone * pow(puff, 1.6f) * (.25f + 1.5f * band + flash) * (.6f + .5f * billow); | |
| 701 | + col += paint(.88f, f) * crevice * (.35f + .6f * c.b.x) * (.6f + .4f * billow); | |
| 702 | + float fog = exp(-dz * (.035f + .07f * c.fog)); | |
| 703 | + col = mix(paint(.55f, f) * .55f, col, fog); | |
| 704 | + } else { | |
| 705 | + float up = -vy; | |
| 706 | + col = mix(paint(.55f, f) * .55f, deep(.8f, f) * .14f + paint(.75f, f) * .08f, saturate(up * 1.3f)); | |
| 707 | + float streak = pow(.5f + .5f * sin(up * 14 + noise2(float2(p.x * .8f - c.travel * .1f, up * 3)) * 3), 8.f); | |
| 708 | + col += paint(.7f + up * .2f, f) * streak * .2f * exp(-up * 1.5f); | |
| 709 | + } | |
| 710 | + col += paint(.85f, f) * exp(-abs(vy) * 16) * .25f; | |
| 711 | + return col; | |
| 712 | + } | |
| 713 | + NATIVE_EFFECT(cloudSea) |
Sources/PulseCanvas/Resources/NativeExpansionFlightII.metal added
| 1 | + // Second versions of designs whose original and final review clips were both red-tagged. | |
| 2 | + // Original PulseCanvas designs 330–339. Flights that are not roads: canopies, strata, | |
| 3 | + // pillar forests, parallax silhouettes, river deltas, auroras, waterfalls, orbits, comets | |
| 4 | + // and cloud seas. Every scene is analytic (plane, sphere and layer intersections); no | |
| 5 | + // preset formulas, textures or third-party shader sources are used. | |
| 6 | + | |
| 7 | + // A point light inside a hashed grid cell. It fades to exactly zero before the cell | |
| 8 | + // border, so neighbouring cells never show seams. | |
| 9 | + float flight_spark(float d, float width, float reach) { return glow(d, width) * smoothstep(reach, reach * .4f, d); } | |
| 10 | + | |
| 11 | + // ---------------------------------------------------------------- 330 Canopy Flight | |
| 12 | + // Rows of hanging crystals are evaluated analytically at their own depth. The floor is a | |
| 13 | + // dark mirror: the same rows are reused with world height reflected, and each crystal | |
| 14 | + // shows there as a soft vertical smear of its light. Bass sways the pendants, each | |
| 15 | + // crystal follows one band, and attacks run a ripple of light along the rows. | |
| 16 | + | |
| 17 | + constant float CANOPY_CEIL = 1.f; | |
| 18 | + constant float CANOPY_FLOOR = -.85f; | |
| 19 | + constant float CANOPY_ROW = 1.15f; | |
| 20 | + constant float CANOPY_COL = .95f; | |
| 21 | + | |
| 22 | + float canopy_rhombus(float2 q, float2 r) { | |
| 23 | + q = abs(q); | |
| 24 | + return (q.x * r.y + q.y * r.x - r.x * r.y) / length(r); | |
| 25 | + } | |
| 26 | + | |
| 27 | + struct CanopyPendant { float2 anchor; float wire; float2 size; float sway; float energy; float3 tone; }; | |
| 28 | + | |
| 29 | + CanopyPendant canopy_make(float rowId, float cell, float stagger, Ctx c, constant NativeFrame &f) { | |
| 30 | + CanopyPendant k; | |
| 31 | + float3 h = hash33(float3(rowId, cell, 3.1)); | |
| 32 | + k.anchor = float2((cell + stagger + (h.x - .5f) * .3f) * CANOPY_COL, CANOPY_CEIL); | |
| 33 | + k.wire = .05f + .38f * h.y; | |
| 34 | + k.size = float2(.06f + .05f * h.z, .13f + .14f * hash21(float2(cell, rowId + .5f))); | |
| 35 | + k.sway = (.07f + .34f * c.b.x) * sin(c.t * 1.05f + h.x * 6.28f + rowId * .4f) + .025f * sin(c.t * 2.3f + h.y * 9); | |
| 36 | + float band = c.b[int(h.z * 3.99f)]; | |
| 37 | + float ripple = c.hit * pow(.5f + .5f * sin(rowId * .75f + cell * .45f - c.t * 2.4f), 6.f) * 3.2f; | |
| 38 | + k.energy = .5f + 1.9f * band + ripple; | |
| 39 | + k.tone = paint(h.x * .5f + rowId * .06f + cell * .11f, f); | |
| 40 | + return k; | |
| 41 | + } | |
| 42 | + | |
| 43 | + float3 canopy_pendant(float2 w, CanopyPendant k, float pw, Ctx c, constant NativeFrame &f) { | |
| 44 | + float2 q = rot(w - k.anchor, -k.sway); | |
| 45 | + float2 local = q - float2(0, -k.wire - k.size.y); | |
| 46 | + float body = canopy_rhombus(local, k.size); | |
| 47 | + float facet = local.x > 0 ? .45f : 1.f; | |
| 48 | + float ridge = glow(local.x, pw * 1.5f + .004f) * .8f + glow(local.y, pw * 1.5f + .004f) * .5f; | |
| 49 | + float core = exp(-dot(local / k.size, local / k.size) * 2.5f); | |
| 50 | + float inside = fill(body, pw); | |
| 51 | + float3 col = k.tone * inside * (facet * (.3f + .35f * (1 - abs(local.y) / k.size.y)) + ridge + core * .6f) * k.energy; | |
| 52 | + col += k.tone * glow(body, .01f + pw) * .9f * k.energy; | |
| 53 | + col += k.tone * glow(body, .09f) * .07f * k.energy; | |
| 54 | + float wireD = sdSegment(q, float2(0), float2(0, -k.wire)); | |
| 55 | + col += k.tone * glow(wireD, pw + .003f) * .3f; | |
| 56 | + float tip = length(q - float2(0, -k.wire - 2 * k.size.y)); | |
| 57 | + col += paint(.92f, f) * glow(tip, .008f + pw) * (.35f + 3 * c.b.w); | |
| 58 | + return col; | |
| 59 | + } | |
| 60 | + | |
| 61 | + // A crystal seen in the dark mirror: a soft vertical smear of its light. | |
| 62 | + float3 canopy_reflection(float2 w, CanopyPendant k) { | |
| 63 | + float2 center = k.anchor + rot(float2(0, -k.wire - k.size.y), k.sway); | |
| 64 | + float2 d = w - center; | |
| 65 | + float spread = k.size.x * (1.4f + .5f * abs(d.y)); | |
| 66 | + float streak = exp(-d.x * d.x / (spread * spread)) * exp(-abs(d.y) * 1.1f) * smoothstep(CANOPY_FLOOR, CANOPY_FLOOR + .6f, w.y) * smoothstep(3.4f, 2.4f, w.y); | |
| 67 | + return k.tone * streak * k.energy * .4f; | |
| 68 | + } | |
| 69 | + | |
| 70 | + float3 canopy_ceiling(float2 w, float dz, Ctx c, constant NativeFrame &f) { | |
| 71 | + float3 col = paint(.3f + .1f * sin(w.x * .4f + w.y * .2f), f) * .055f; | |
| 72 | + float row0 = floor(w.y / CANOPY_ROW); | |
| 73 | + for (int r = 0; r < 2; ++r) { | |
| 74 | + float rowId = row0 + float(r); | |
| 75 | + float stagger = hash11(rowId + .37f); | |
| 76 | + float cellF = w.x / CANOPY_COL - stagger; | |
| 77 | + float cell = floor(cellF + .5f); | |
| 78 | + float other = cell + (cellF > cell ? 1 : -1); | |
| 79 | + for (int m = 0; m < 2; ++m) { | |
| 80 | + CanopyPendant k = canopy_make(rowId, m == 0 ? cell : other, stagger, c, f); | |
| 81 | + float2 d = w - float2(k.anchor.x, rowId * CANOPY_ROW); | |
| 82 | + float r2 = dot(d, d); | |
| 83 | + col += k.tone * (exp(-r2 * 30) * .25f + glow(sqrt(r2), .02f) * .2f) * k.energy; | |
| 84 | + } | |
| 85 | + } | |
| 86 | + return col * exp(-dz * (.05f + .1f * c.fog)); | |
| 87 | + } | |
| 88 | + | |
| 89 | + | |
| 90 | + // ---------------------------------------------------------------- 331 Strata Glide | |
| 91 | + // A thin gap between two vast planes. Each plane carries its own flowing strata: broad | |
| 92 | + // warm layers below, finer cross-cut layers above. Seams between layers glow. | |
| 93 | + | |
| 94 | + float3 strata_plane(float2 w, float dz, bool upper, Ctx c, constant NativeFrame &f) { | |
| 95 | + float s; | |
| 96 | + if (upper) { | |
| 97 | + s = (w.y - w.x) * .26f + 1.6f * fbm2(float2(w.x * .16f + c.t * .03f, w.y * .1f), 3) + c.t * .035f; | |
| 98 | + s += c.b.z * .5f * sin(w.x * .55f - w.y * .3f + c.t * .5f); | |
| 99 | + s *= 5.f; | |
| 100 | + } else { | |
| 101 | + s = (w.x + w.y) * .24f + 1.8f * fbm2(float2(w.x * .12f, w.y * .08f - c.t * .04f), 3) - c.t * .042f; | |
| 102 | + s += c.b.y * .6f * sin(w.x * .5f + w.y * .3f + c.t * .45f); | |
| 103 | + s *= 3.6f; | |
| 104 | + } | |
| 105 | + s += .3f * sin(s * 1.3f); | |
| 106 | + float idx = floor(s), fr = fract(s); | |
| 107 | + float aa = fwidth(s); | |
| 108 | + float detail = 1 - smoothstep(.15f, .6f, aa); | |
| 109 | + float seamD = min(fr, 1 - fr); | |
| 110 | + float seam = (1 - smoothstep(0.f, .03f + aa * 1.5f, seamD)) * detail; | |
| 111 | + float wide = exp(-seamD * 10); | |
| 112 | + float phase = .12f + .6f * fract(idx * .23f + (upper ? .5f : 0.f)); | |
| 113 | + float grain = .75f + .25f * sin(fr * 23 + idx); | |
| 114 | + float layer = mix(.11f, (.04f + .2f * fr * fr) * grain, detail); | |
| 115 | + float3 col = paint(phase, f) * layer * (upper ? .6f + 1.6f * c.b.z : .7f + 1.5f * c.b.y); | |
| 116 | + float hitSeam = (idx - 3 * floor(idx / 3)) == 0 ? 1.f : .2f; | |
| 117 | + float run = pow(.5f + .5f * cos(dz * .5f - c.t * 4.f + idx * .3f), 4.f); | |
| 118 | + col += paint(.88f + idx * .05f, f) * (seam * .9f + wide * .22f * detail) * (1 + c.hit * hitSeam * run * 5); | |
| 119 | + float glint = pow(noise2(w * float2(3.f, 1.5f) + c.t * .3f), 10.f); | |
| 120 | + col += paint(.95f, f) * glint * wide * c.b.w * 14 * detail * smoothstep(1.f, 2.5f, dz); | |
| 121 | + return col; | |
| 122 | + } | |
| 123 | + | |
| 124 | + | |
| 125 | + // ---------------------------------------------------------------- 332 Pillar Forest | |
| 126 | + // The camera weaves along a clear path through an endless grid of luminous columns and | |
| 127 | + // looks slightly up, so the columns converge overhead. A 2D grid walk finds them front to | |
| 128 | + // back; height along each column comes from the ray. Each column follows one band and | |
| 129 | + // attacks send bright rings racing up the columns. | |
| 130 | + | |
| 131 | + float pillar_path(float z) { return 1.3f * sin(z * .23f) + .55f * sin(z * .51f + 1.3f); } | |
| 132 | + float pillar_slope(float z) { return 1.3f * .23f * cos(z * .23f) + .55f * .51f * cos(z * .51f + 1.3f); } | |
| 133 | + | |
| 134 | + | |
| 135 | + // ---------------------------------------------------------------- 333 Parallax Express | |
| 136 | + // A sideways window view: a far ridge, crystal spires, neon arches and near light bars | |
| 137 | + // slide laterally at increasing speeds. Each layer has its own band; attacks flare the | |
| 138 | + // near layer. | |
| 139 | + | |
| 140 | + struct ExpressSpire { float height; float ridge; float id; }; | |
| 141 | + | |
| 142 | + ExpressSpire express_spires(float x, float width, float seed, float lift) { | |
| 143 | + ExpressSpire s; s.height = -9; s.ridge = 9; s.id = 0; | |
| 144 | + float cell = floor(x / width); | |
| 145 | + for (int k = -1; k <= 1; ++k) { | |
| 146 | + float id = cell + float(k); | |
| 147 | + float3 h = hash33(float3(id, seed, 2.7)); | |
| 148 | + float apex = (id + .2f + .6f * h.x) * width; | |
| 149 | + float tall = (.3f + .7f * h.y) * lift; | |
| 150 | + float y = tall - abs(x - apex) * (2.4f + 2.6f * h.z); | |
| 151 | + if (y > s.height) { s.height = y; s.ridge = x - apex; s.id = id; } | |
| 152 | + } | |
| 153 | + return s; | |
| 154 | + } | |
| 155 | + | |
| 156 | + float express_hills(float x, float seed) { | |
| 157 | + return .55f * noise2(float2(x * .45f, seed)) + .3f * noise2(float2(x * 1.2f, seed + 4)) + .15f * noise2(float2(x * 3.1f, seed + 9)); | |
| 158 | + } | |
| 159 | + | |
| 160 | + | |
| 161 | + // ---------------------------------------------------------------- 334 Delta Flyover | |
| 162 | + // Looking straight down on a delta of light. Meandering trunks run downstream; each | |
| 163 | + // spawns distributaries that peel off, diverge and taper out, and twigs peel off those. | |
| 164 | + // Every channel has a world-space id, so the scroll never pops. Trunks, distributaries | |
| 165 | + // and twigs each follow one band; attacks send surges down the channels. | |
| 166 | + | |
| 167 | + constant float DELTA_TRUNK = 2.3f; | |
| 168 | + constant float DELTA_CELL = 1.5f; | |
| 169 | + | |
| 170 | + float delta_trunk(float i, float y) { | |
| 171 | + float h = hash11(i + .71f); | |
| 172 | + return (i + .5f) * DELTA_TRUNK + DELTA_TRUNK * (.26f * sin(y * .21f + h * 6.3f) + .12f * sin(y * .53f + h * 17)); | |
| 173 | + } | |
| 174 | + | |
| 175 | + | |
| 176 | + // ---------------------------------------------------------------- 335 Aurora Overpass | |
| 177 | + // Curtains hang across the sky at stable depths; each folds along its length, and folds | |
| 178 | + // seen edge-on glow brighter. The dark plain mirrors the same curtains. | |
| 179 | + | |
| 180 | + | |
| 181 | + // ---------------------------------------------------------------- 336 Cascade Climb | |
| 182 | + // Climbing the face of a vast waterfall. Tiers of falls drop between wavy ledges; each | |
| 183 | + // fall is a column of downward-streaming light fed by one band, and mist boils up at | |
| 184 | + // its foot. The camera rises with travel and looks slightly up the wall. | |
| 185 | + | |
| 186 | + constant float CASCADE_TIER = 2.4f; | |
| 187 | + constant float CASCADE_COLUMN = 1.15f; | |
| 188 | + | |
| 189 | + float cascade_lip(float n, float x) { return n * CASCADE_TIER + .28f * sin(x * .7f + n * 1.9f) + .12f * sin(x * 1.9f + n); } | |
| 190 | + | |
| 191 | + float3 cascadeClimbII(Ctx c, constant NativeFrame &f) { | |
| 192 | + const float lens = 1.25f, pitch = .24f, wallD = 2.f; | |
| 193 | + float2 p = c.uv / c.size; | |
| 194 | + float camY = c.travel * 1.5f; | |
| 195 | + float camX = .6f * sin(c.travel * .05f); | |
| 196 | + float cp = cos(pitch), sp = sin(pitch); | |
| 197 | + float ry = p.y * cp + lens * sp, rz = lens * cp - p.y * sp; | |
| 198 | + float s = wallD / max(rz, .03f); | |
| 199 | + float x = camX + p.x * s, y = camY + ry * s; | |
| 200 | + float n = floor(y / CASCADE_TIER); | |
| 201 | + float lipBelow = cascade_lip(n, x); | |
| 202 | + if (lipBelow > y) { n -= 1; lipBelow = cascade_lip(n, x); } | |
| 203 | + float lipAbove = cascade_lip(n + 1, x); | |
| 204 | + float above = y - lipBelow, below = lipAbove - y; | |
| 205 | + // Rock face. | |
| 206 | + float rock = fbm2(float2(x * 1.4f, y * 1.1f), 3); | |
| 207 | + float3 col = deep(.35f + rock * .3f, f) * (.03f + .06f * rock) + paint(.4f, f) * pow(rock, 4.f) * .1f; | |
| 208 | + // Falls: meandering columns that change from tier to tier. | |
| 209 | + float xw = x + .07f * sin(y * .5f + n * 2.3f); | |
| 210 | + float colId = floor(xw / CASCADE_COLUMN); | |
| 211 | + float3 h = hash33(float3(colId, n, 6.6)); | |
| 212 | + float band = c.b[int(fract(h.z * 7.13f) * 3.99f)]; | |
| 213 | + float local = abs(fract(xw / CASCADE_COLUMN) - .5f) * CASCADE_COLUMN; | |
| 214 | + float width = (h.x < .15f ? 0.f : .2f + .26f * h.y) + .08f * band; | |
| 215 | + float fall = smoothstep(width, width - .08f, local) * smoothstep(0.f, .08f, below + .05f); | |
| 216 | + float streakA = fbm2(float2(xw * 7.f, y * .32f + c.t * .9f + h.x * 9), 3); | |
| 217 | + float streakB = noise2(float2(xw * 17.f, y * .55f + c.t * 1.5f)); | |
| 218 | + float speedUp = smoothstep(0.f, 1.4f, below); | |
| 219 | + float water = pow(streakA, 1.6f) * 1.6f + streakB * .35f * speedUp; | |
| 220 | + float edgeLight = exp(-(width - local) * 9); | |
| 221 | + float3 waterTone = paint(.45f + h.x * .3f + streakA * .2f, f); | |
| 222 | + float foam = smoothstep(.55f, .8f, streakA + streakB * .3f) * speedUp; | |
| 223 | + col = mix(col, waterTone * (.04f + water * .34f + edgeLight * .16f) * (.5f + 1.7f * band) + paint(.9f, f) * foam * .28f, fall); | |
| 224 | + // Lips glow where water curls over the ledge. | |
| 225 | + float lipPx = c.px * wallD * lens / max(rz * rz, .01f); | |
| 226 | + float lipLine = glow(below, .03f + lipPx) * (.4f + .8f * fall) + glow(above, .03f + lipPx) * .4f; | |
| 227 | + col += paint(.9f, f) * lipLine * .8f; | |
| 228 | + // Mist boils up from the foot of each fall; attacks burst it. | |
| 229 | + float burst = c.hit * smoothstep(.15f, .85f, .5f + .5f * sin(n * 2.1f + colId * 1.3f + c.t * .35f)); | |
| 230 | + float mist = fbm2(float2(x * 1.2f, (y - c.t * .4f) * 1.3f), 3); | |
| 231 | + float footing = smoothstep(width + .5f, width - .2f, local) * (h.x < .2f ? .3f : 1.f); | |
| 232 | + float rise = exp(-max(above, 0.f) * (1.7f - 1.f * burst)) * smoothstep(-.05f, .05f, above); | |
| 233 | + col += paint(.66f + mist * .25f, f) * smoothstep(.2f, .7f, mist) * rise * (.5f + 1.3f * footing) * (.9f + 3.f * burst); | |
| 234 | + float churn = exp(-max(above, 0.f) * 5) * smoothstep(-.03f, .03f, above) * fall * (.5f + .5f * streakB); | |
| 235 | + col += paint(.9f, f) * churn * (.7f + 1.4f * band + 2 * burst); | |
| 236 | + col += paint(.85f, f) * exp(-max(below, 0.f) * 7) * fall * (.15f + .4f * streakA) * (.6f + band); | |
| 237 | + float spray = flight_spark(length(fract(float2(x * 9, y * 9 - c.t * 6)) - .5f), .05f, .45f) * step(.8f, hash21(floor(float2(x * 9, y * 9 - c.t * 6)))); | |
| 238 | + col += paint(.95f, f) * spray * rise * footing * (.3f + 5 * c.b.w); | |
| 239 | + // The far reaches dissolve into bright haze. | |
| 240 | + float far = 1 - exp(-s * .05f); | |
| 241 | + col = mix(col, paint(.5f, f) * .3f + paint(.8f, f) * .06f, saturate(far * (.75f + .4f * c.fog))); | |
| 242 | + return col; | |
| 243 | + } | |
| 244 | + NATIVE_EFFECT(cascadeClimbII) | |
| 245 | + | |
| 246 | + // ---------------------------------------------------------------- 337 Night Orbit | |
| 247 | + // A low orbit over the dark side of a planet. A ray-sphere hit gives surface coordinates; | |
| 248 | + // two voronoi networks, nodes and dust glow on the surface, with a bright limb above. | |
| 249 | + | |
| 250 | + float3 orbit_space(float3 rd, float spin, Ctx c, constant NativeFrame &f) { | |
| 251 | + float3 rs = float3(rd.x, rd.y * cos(spin) - rd.z * sin(spin), rd.y * sin(spin) + rd.z * cos(spin)); | |
| 252 | + float3 col = deep(.7f, f) * .08f + paint(.65f, f) * .1f * noise3(rs * 2.5f) * noise3(rs * 5 + 3); | |
| 253 | + float3 cell = floor(rs * 70); | |
| 254 | + float3 hs = hash33(cell); | |
| 255 | + float3 site = (cell + .25f + hs * .5f) / 70; | |
| 256 | + float star = flight_spark(length(rs - site) * 70, .06f, .25f) * step(.8f, hs.x); | |
| 257 | + col += paint(.85f + hs.y * .15f, f) * star * (.4f + .8f * hs.z); | |
| 258 | + return col; | |
| 259 | + } | |
| 260 | + | |
| 261 | + float3 nightOrbitII(Ctx c, constant NativeFrame &f) { | |
| 262 | + const float R = 5.f, H = .5f, lens = 1.25f, pitch = .6f; | |
| 263 | + float2 p = rot(c.uv, .07f * sin(c.t * .05f)) / c.size; | |
| 264 | + float cp = cos(pitch), sp = sin(pitch); | |
| 265 | + float3 rd = normalize(float3(p.x, p.y * cp - lens * sp, lens * cp + p.y * sp)); | |
| 266 | + float3 ro = float3(0, R + H, 0); | |
| 267 | + float orbit = c.travel * .9f; | |
| 268 | + float b = dot(ro, rd), disc = b * b - (dot(ro, ro) - R * R); | |
| 269 | + float closest = (b < 0 ? sqrt(max(dot(ro, ro) - b * b, 0.f)) : length(ro)) - R; | |
| 270 | + float3 col; | |
| 271 | + if (disc > 0 && -b - sqrt(disc) > 0) { | |
| 272 | + float s = -b - sqrt(disc); | |
| 273 | + float3 P = ro + rd * s, n = P / R; | |
| 274 | + float facing = max(dot(n, -rd), .05f); | |
| 275 | + float2 q = float2(atan2(P.z, P.y) * R + orbit, asin(clamp(n.x, -1.f, 1.f)) * R) * .9f; | |
| 276 | + float foot = c.px * s / lens / facing * .9f; | |
| 277 | + float detail = 1 - smoothstep(.02f, .1f, foot); | |
| 278 | + float land = smoothstep(.26f, .46f, fbm2(q * .15f + 2, 3)); | |
| 279 | + float4 v1 = voronoi(q * 1.7f, .9f, 0); | |
| 280 | + float4 v2 = voronoi(q * 5.f + 7, .9f, 0); | |
| 281 | + float art = glow(v1.y - v1.x, .02f + foot * 1.7f) * (.4f + .6f * hash21(v1.zw)); | |
| 282 | + float web = glow(v2.y - v2.x, .025f + foot * 5.f) * detail; | |
| 283 | + float node = glow(v1.x, .045f + foot * 1.7f) * step(.2f, hash21(v1.zw + 3)); | |
| 284 | + float2 dustCell = floor(q * 9); | |
| 285 | + float3 dh = hash33(float3(dustCell, 1.7)); | |
| 286 | + float dust = flight_spark(length(q * 9 - dustCell - .2f - dh.xy * .6f), .08f, .2f) * step(.55f, dh.z) * detail * (.5f + .5f * sin(c.t * 3 + dh.x * 40)); | |
| 287 | + float2 rel = q - float2(orbit * .9f + 2.6f, 0); | |
| 288 | + float dist = length(rel * float2(1, 1.3f)); | |
| 289 | + float ring = c.hit * pow(.5f + .5f * sin(dist * 2.2f - c.t * 3.2f), 10.f) * exp(-dist * .2f); | |
| 290 | + float lift = 1 + 3 * ring; | |
| 291 | + col = deep(.45f + land * .2f, f) * (.02f + .035f * land) + paint(.35f + .1f * art, f) * (1 - land) * (.03f + .03f * noise2(q * 2.5f)); | |
| 292 | + col += paint(.3f + hash21(v1.zw) * .25f, f) * (art * .8f + exp(-(v1.y - v1.x) * 7) * .12f) * (.25f + .75f * land) * (.45f + 1.9f * c.b.x) * lift; | |
| 293 | + col += paint(.55f + hash21(v2.zw) * .2f, f) * web * (.35f + .65f * land) * (.35f + 1.9f * c.b.y) * lift * .6f; | |
| 294 | + col += paint(.92f, f) * node * land * (.45f + 2.6f * c.b.z) * lift; | |
| 295 | + col += paint(.8f, f) * dust * land * (.3f + 4 * c.b.w); | |
| 296 | + col += paint(.5f, f) * ring * .35f; | |
| 297 | + float haze = pow(1 - facing, 6.f); | |
| 298 | + col = mix(col, paint(.3f, f) * .3f, haze * (.5f + .3f * c.fog)); | |
| 299 | + } else { | |
| 300 | + col = orbit_space(rd, orbit / R, c, f); | |
| 301 | + } | |
| 302 | + float limbSide = .6f + .4f * sin(rd.x * 2.2f + c.t * .03f); | |
| 303 | + float alt = abs(closest); | |
| 304 | + float sky = closest > 0 ? 1.f : .25f; | |
| 305 | + col += paint(.25f + alt * 2, f) * (exp(-alt * 22) * .8f + exp(-alt * 5) * .25f) * limbSide * sky; | |
| 306 | + col += paint(.95f, f) * glow(closest, .006f) * .5f * limbSide; | |
| 307 | + return col; | |
| 308 | + } | |
| 309 | + NATIVE_EFFECT(nightOrbitII) | |
| 310 | + | |
| 311 | + // ---------------------------------------------------------------- 338 Comet Chase | |
| 312 | + // Chasing a comet head that hangs ahead and to one side. The ion and dust tails stream | |
| 313 | + // out of it toward the camera; debris layers fly past on stable depth slots. | |
| 314 | + | |
| 315 | + | |
| 316 | + // ---------------------------------------------------------------- 339 Cloud Sea | |
| 317 | + // Skimming a sea of cloud tops. The deck is a billowing height field traced with a short | |
| 318 | + // march; tops catch sky light, while coloured lights on a world grid glow up through the | |
| 319 | + // thin valleys between billows. Each light has its own band. | |
| 320 | + | |
| 321 | + constant float CLOUD_LIGHT = 2.f; | |
| 322 | + | |
| 323 | + float cloud_height(float2 w, float drift) { | |
| 324 | + float2 q = w * 1.2f + float2(drift, 0); | |
| 325 | + float a = abs(2 * noise2(q) - 1), b = abs(2 * noise2(q * 2.4f + 5.2f) - 1), d = abs(2 * noise2(q * 5.3f + 1.7f) - 1); | |
| 326 | + return .26f * sqrt(a) + .1f * sqrt(b) + .035f * d; | |
| 327 | + } | |
| 328 | + | |
| 329 | + float3 cloud_light(float2 w, Ctx c, constant NativeFrame &f) { | |
| 330 | + float2 cell = floor(w / CLOUD_LIGHT); | |
| 331 | + float2 d = w - (cell + .5f) * CLOUD_LIGHT; | |
| 332 | + float3 h = hash33(float3(cell, 8.3)); | |
| 333 | + float falloff = 1 - smoothstep(0.f, CLOUD_LIGHT * .55f, length(d)); | |
| 334 | + float band = c.b[int(h.z * 3.99f)]; | |
| 335 | + float select = smoothstep(.55f, .95f, .5f + .5f * sin(h.x * TAU + c.t * .6f)); | |
| 336 | + float energy = .45f + 2.4f * band + c.hit * select * 6; | |
| 337 | + return paint(.15f + h.x * .7f, f) * falloff * falloff * energy; | |
| 338 | + } | |
| 339 | + | |
| 340 | + float3 cloudSeaII(Ctx c, constant NativeFrame &f) { | |
| 341 | + const float lens = 1.2f, camH = .75f, top = .42f; | |
| 342 | + float2 p = c.uv / c.size; | |
| 343 | + float horizon = .34f; | |
| 344 | + float vy = horizon - p.y; | |
| 345 | + float camZ = c.travel * 1.5f; | |
| 346 | + float camX = .9f * sin(c.travel * .05f); | |
| 347 | + float drift = c.t * .04f; | |
| 348 | + float3 haze = paint(.55f, f) * .28f + paint(.8f, f) * .05f; | |
| 349 | + float3 col; | |
| 350 | + if (vy > 0) { | |
| 351 | + float3 rd = float3(p.x, -vy, lens); | |
| 352 | + float t = (camH - top) / vy; | |
| 353 | + float3 pos = float3(camX, camH, camZ) + rd * t; | |
| 354 | + float gap = pos.y - cloud_height(pos.xz, drift); | |
| 355 | + float prevT = t, prevGap = gap; | |
| 356 | + for (int i = 0; i < 24 && gap > 0; ++i) { | |
| 357 | + prevT = t; prevGap = gap; | |
| 358 | + t += max(gap * .55f / vy, .015f + t * .012f); | |
| 359 | + pos = float3(camX, camH, camZ) + rd * t; | |
| 360 | + gap = pos.y - cloud_height(pos.xz, drift); | |
| 361 | + } | |
| 362 | + if (gap < 0) t = mix(prevT, t, prevGap / max(prevGap - gap, 1e-4f)); | |
| 363 | + pos = float3(camX, camH, camZ) + rd * t; | |
| 364 | + float2 w = pos.xz; | |
| 365 | + float e = .02f + t * .004f; | |
| 366 | + float hc = cloud_height(w, drift); | |
| 367 | + float3 n = normalize(float3(hc - cloud_height(w + float2(e, 0), drift), e, hc - cloud_height(w + float2(0, e), drift))); | |
| 368 | + float thin = 1 - saturate(hc / .3f); | |
| 369 | + float2 q = w * 1.2f + float2(drift, 0); | |
| 370 | + float creaseA = abs(2 * noise2(q) - 1), creaseB = abs(2 * noise2(q * 2.4f + 5.2f) - 1); | |
| 371 | + float crease = exp(-creaseA * 9) + .5f * exp(-creaseB * 12); | |
| 372 | + float3 inner = cloud_light(w, c, f); | |
| 373 | + float sky = saturate(n.y * .5f - n.z * .5f + .2f); | |
| 374 | + float rim = pow(1 - saturate(dot(n, -normalize(rd))), 3.f); | |
| 375 | + float3 lit = paint(.6f + hc * .8f, f) * sky * sky * .14f + inner * (.06f + thin * thin * .6f + crease * 1.8f) | |
| 376 | + + (paint(.88f, f) * .12f + inner * .35f) * rim * (.5f + 1.2f * c.b.x); | |
| 377 | + float depth = t * lens; | |
| 378 | + col = mix(haze, lit, exp(-depth * (.035f + .07f * c.fog))); | |
| 379 | + } else { | |
| 380 | + float up = -vy; | |
| 381 | + col = mix(haze, deep(.8f, f) * .1f + paint(.75f, f) * .05f, saturate(up * 1.4f)); | |
| 382 | + float streak = pow(.5f + .5f * sin(up * 14 + noise2(float2(p.x * .8f - c.travel * .1f, up * 3)) * 3), 8.f); | |
| 383 | + col += paint(.7f + up * .2f, f) * streak * .15f * exp(-up * 1.5f); | |
| 384 | + } | |
| 385 | + col += paint(.85f, f) * exp(-abs(vy) * 18) * .2f; | |
| 386 | + return col; | |
| 387 | + } | |
| 388 | + NATIVE_EFFECT(cloudSeaII) |
Sources/PulseCanvas/Resources/NativeExpansionFractal.metal added
| 1 | + // Original PulseCanvas designs 360–364. Escape-time fractals that twist into each other: endless spiral dives, | |
| 2 | + // braided Julia sets, Newton basins, Phoenix spirals and a Droste recursion. Every form is computed from its | |
| 3 | + // mathematical definition. Seamless zooms use exact self-similarity (linearisation at a repelling fixed point) | |
| 4 | + // or crossfaded layers, so float32 precision never runs out and nothing resets. | |
| 5 | + | |
| 6 | + // ---------------------------------------------------------------- complex helpers | |
| 7 | + float2 frc_mul(float2 a, float2 b) { return float2(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); } | |
| 8 | + float2 frc_div(float2 a, float2 b) { return float2(a.x * b.x + a.y * b.y, a.y * b.x - a.x * b.y) / max(dot(b, b), 1e-30f); } | |
| 9 | + float2 frc_polar(float radius, float angle) { return radius * float2(cos(angle), sin(angle)); } | |
| 10 | + float frc_band(float4 b, float id) { return b[int(id - 4 * floor(id / 4))]; } | |
| 11 | + | |
| 12 | + // ---------------------------------------------------------------- 360 Julia Dive | |
| 13 | + // Zoom into the repelling fixed point of z^2 + k. Near that point the Julia set is exactly self-similar | |
| 14 | + // under multiplication by its multiplier lambda, so starting the orbit at fixedPoint + w * lambda^-2(n+u) | |
| 15 | + // and iterating (the Poincare linearisation, done in offset form so float32 keeps every digit) makes | |
| 16 | + // depth u and u + 1 identical: an endless, exact dive with no crossfade. A multiplier just past -1 gives | |
| 17 | + // a two-armed spiral that turns as you fall in. | |
| 18 | + float3 juliaDive(Ctx c, constant NativeFrame &f) { | |
| 19 | + float mag = 1.12 + .012 * sin(c.t * .043); | |
| 20 | + float arg = 2.953 + .025 * sin(c.t * .029 + 1.3); | |
| 21 | + float2 lam = frc_polar(mag, arg); | |
| 22 | + float2 fixedPoint = lam * .5; | |
| 23 | + float2 k = fixedPoint - frc_mul(fixedPoint, fixedPoint); | |
| 24 | + // One octave is two iterations: the zoom factor lambda^2 with a residual twist that winds the arms. | |
| 25 | + const int per = 2; | |
| 26 | + float logMag = per * log(mag), logArg = per * arg - TAU; | |
| 27 | + float u = fract(c.travel * .8); | |
| 28 | + const int pre = 15; | |
| 29 | + float shrink = -(float(pre) + u); | |
| 30 | + float2 zoom = frc_polar(exp(shrink * logMag) * .3 / c.size, shrink * logArg); | |
| 31 | + float2 drift = float2(sin(c.t * .07), cos(c.t * .053)) * .14 * (c.extent - .6); | |
| 32 | + float2 p = rot(c.uv - drift, c.t * .06); | |
| 33 | + float2 d = frc_mul(p, zoom), dd = zoom; | |
| 34 | + // Orbit-trap layers: four trap shapes, each summed over its own window of orbit depth. | |
| 35 | + float4 trapGlow = float4(0); | |
| 36 | + float mu = 0, de = 0; bool escaped = false; | |
| 37 | + const int steps = per * pre + 40; | |
| 38 | + for (int i = 0; i < steps; ++i) { | |
| 39 | + dd = 2 * frc_mul(lam * .5 + d, dd); | |
| 40 | + d = frc_mul(d, lam + d); | |
| 41 | + float2 z = fixedPoint + d; | |
| 42 | + float depth = float(i) - per * (pre + u); | |
| 43 | + if (depth > -4 && depth < 17) { | |
| 44 | + float4 offset = float4(depth) - float4(1, 4.5, 8, 11.5); | |
| 45 | + float4 window = exp(-offset * offset * .18); | |
| 46 | + float4 q = float4(length(z), abs(length(z - k) - .3), abs(z.y - z.x * .4), abs(length(z) - .85)); | |
| 47 | + float4 g = float4(.035, .018, .014, .012) / (float4(.035, .018, .014, .012) + q); | |
| 48 | + trapGlow += window * g * g; | |
| 49 | + } | |
| 50 | + float r2 = dot(z, z); | |
| 51 | + if (r2 > 1024) { | |
| 52 | + float r = sqrt(r2); | |
| 53 | + mu = float(i) + 1 - log2(log(r)); | |
| 54 | + de = .5 * r * log(r) / max(length(dd), 1e-20f); | |
| 55 | + escaped = true; | |
| 56 | + break; | |
| 57 | + } | |
| 58 | + } | |
| 59 | + // Orbits still bounded after the fixed budget form the glowing body of the arms. The budget is a | |
| 60 | + // fixed escape-time phase, so it does not move when the octave wraps. | |
| 61 | + float phase = escaped ? min(mu - per * (pre + u), 38.f) : 38; | |
| 62 | + float inner = smoothstep(24.f, 38.f, phase); | |
| 63 | + float dist = escaped && phase < 38 ? de : 0; | |
| 64 | + float body = exp(-dist * 30) * (1 - inner); | |
| 65 | + float core = glow(dist, .003 + .004 * c.b.w) * (1 - inner); | |
| 66 | + float hue = phase * .07 + .3 * sin(c.t * .05); | |
| 67 | + float band = phase * .25; | |
| 68 | + float wave = .5 + .5 * cos(band * TAU); | |
| 69 | + float3 col = paint(.02, f) * (.1 + .06 * wave) + paint(.3 + .15 * wave, f) * .05 * wave; | |
| 70 | + col += paint(.45, f) * .22 * exp(-dist * 9) * (1 - inner) + paint(.62 + hue * .2, f) * .45 * body; | |
| 71 | + col += deep(.55, f) * inner * .26 + paint(.4, f) * inner * .05; | |
| 72 | + float contour = line(fract(band + .5) - .5, .035, .05); | |
| 73 | + col += paint(.28 + .3 * wave, f) * contour * (.22 + .4 * body); | |
| 74 | + col += paint(.9, f) * core * .8; | |
| 75 | + float4 lit = float4(.1, .09, .08, .08) + c.b * float4(1.3, 1.2, 1.1, 1.1); | |
| 76 | + col += paint(.05 + phase * .01, f) * trapGlow.x * lit.x * 1.4; | |
| 77 | + col += paint(.3 + phase * .01, f) * trapGlow.y * lit.y; | |
| 78 | + col += paint(.55 + phase * .01, f) * trapGlow.z * lit.z; | |
| 79 | + col += paint(.78, f) * trapGlow.w * lit.w; | |
| 80 | + col *= .72; | |
| 81 | + // Attack: a bright ripple runs inward along the escape-time contours toward the arms. | |
| 82 | + float front = 4 + 14 * (1 - c.hit); | |
| 83 | + float ripple = glow(phase - front, .9) * (line(fract(band + .5) - .5, .12, .06) + .6 * body) * (1 - inner * .7); | |
| 84 | + col += paint(.88, f) * c.hit * 3.2 * ripple; | |
| 85 | + return col; | |
| 86 | + } | |
| 87 | + NATIVE_EFFECT(juliaDive) | |
| 88 | + | |
| 89 | + // ---------------------------------------------------------------- 361 Julia Braid | |
| 90 | + struct FrcOrbit { float pot; float de; float trap; float inside; }; | |
| 91 | + FrcOrbit frc_julia(float2 z, float scale, float2 k, int steps) { | |
| 92 | + FrcOrbit o; o.trap = 9; o.inside = 1; o.pot = float(steps); o.de = 0; | |
| 93 | + float2 dz = float2(scale, 0); | |
| 94 | + for (int i = 0; i < steps; ++i) { | |
| 95 | + dz = 2 * frc_mul(z, dz); | |
| 96 | + z = frc_mul(z, z) + k; | |
| 97 | + o.trap = min(o.trap, abs(length(z) - .6)); | |
| 98 | + float r2 = dot(z, z); | |
| 99 | + if (r2 > 400) { | |
| 100 | + float r = sqrt(r2); | |
| 101 | + o.pot = float(i) + 1 - log2(log(r)); | |
| 102 | + o.de = .5 * r * log(r) / max(length(dz), 1e-20f); | |
| 103 | + o.inside = 0; | |
| 104 | + break; | |
| 105 | + } | |
| 106 | + } | |
| 107 | + return o; | |
| 108 | + } | |
| 109 | + | |
| 110 | + float3 juliaBraid(Ctx c, constant NativeFrame &f) { | |
| 111 | + float2 p = c.uv / c.size; | |
| 112 | + // The two sets revolve around each other while counter-rotating, so their filaments keep winding through. | |
| 113 | + float orbit = c.travel * .06 + c.t * .02; | |
| 114 | + float spin = c.travel * .05 + c.t * .015; | |
| 115 | + float2 offset = float2(cos(orbit), sin(orbit)) * .22 * float2(c.extent.x / max(c.extent.y, 1.f), 1); | |
| 116 | + float2 kA = float2(-.8, .18) + .02 * float2(cos(c.travel * .021 + c.t * .03), sin(c.travel * .017 + c.t * .023)); | |
| 117 | + float2 kB = float2(-.55, .62) + .02 * float2(cos(c.travel * .019 - c.t * .027 + 2), sin(c.travel * .023 - c.t * .021 + 1)); | |
| 118 | + float scaleA = .82, scaleB = .9; | |
| 119 | + float2 zA = rot(p - offset, spin) * scaleA; | |
| 120 | + float2 zB = rot(p + offset, -spin * 1.3 + 1.2) * scaleB; | |
| 121 | + FrcOrbit a = frc_julia(zA, scaleA, kA, 36); | |
| 122 | + FrcOrbit b = frc_julia(zB, scaleB, kB, 36); | |
| 123 | + float wa = .0035 + .006 * c.b.x, wb = .0035 + .006 * c.b.w; | |
| 124 | + float lineA = a.inside > .5 ? 0 : glow(a.de, wa) + .12 * glow(a.de, wa * 4); | |
| 125 | + float lineB = b.inside > .5 ? 0 : glow(b.de, wb) + .12 * glow(b.de, wb * 4); | |
| 126 | + float3 colA = paint(.05 + a.pot * .008, f) * lineA * (.9 + 1.2 * c.b.y); | |
| 127 | + float3 colB = paint(.62 + b.pot * .008, f) * lineB * (.9 + 1.2 * c.b.z); | |
| 128 | + colA += a.inside > .5 ? paint(.15, f) * (.05 + .3 * glow(a.trap, .03) * (1 + c.b.y)) : float3(0); | |
| 129 | + colB += b.inside > .5 ? paint(.75, f) * (.05 + .3 * glow(b.trap, .03) * (1 + c.b.z)) : float3(0); | |
| 130 | + // Over/under weave that slides along the filaments. | |
| 131 | + float r = length(p), ang = atan2(p.y, p.x); | |
| 132 | + float over = smoothstep(-.35f, .35f, sin(ang * 3 + r * 4.5 - c.t * .35)); | |
| 133 | + float occA = saturate(lineA), occB = saturate(lineB); | |
| 134 | + float3 col = mix(colA * (1 - .8 * occB) + colB, colB * (1 - .8 * occA) + colA, over); | |
| 135 | + // Equipotential ripples of both sets wind around each other behind the filaments. | |
| 136 | + float ringA = a.inside > .5 ? 0 : pow(.5 + .5 * cos(a.pot * 1.8 - c.t * .5), 8.f); | |
| 137 | + float ringB = b.inside > .5 ? 0 : pow(.5 + .5 * cos(b.pot * 1.8 + c.t * .5), 8.f); | |
| 138 | + float fadeA = smoothstep(1.5f, 5.f, a.pot) * (1 - occA), fadeB = smoothstep(1.5f, 5.f, b.pot) * (1 - occB); | |
| 139 | + col += paint(.97, f) * .06 + paint(.0, f) * .025; | |
| 140 | + col += paint(.1, f) * ringA * fadeA * (.16 + .2 * c.b.x) + paint(.72, f) * ringB * fadeB * (.16 + .2 * c.b.w); | |
| 141 | + col *= .78; | |
| 142 | + // Attack: the crossings of the two sets flare. | |
| 143 | + col += paint(.92, f) * c.hit * 4 * occA * occB + paint(.5, f) * c.hit * .6 * glow(a.de, .03) * glow(b.de, .03); | |
| 144 | + return col; | |
| 145 | + } | |
| 146 | + NATIVE_EFFECT(juliaBraid) | |
| 147 | + | |
| 148 | + // ---------------------------------------------------------------- 362 Newton Vortex | |
| 149 | + // Newton's method for a cubic whose roots orbit with their centroid fixed at zero. Near infinity the | |
| 150 | + // Newton map is z -> 2z/3, so starting the orbit at Z * 1.5^n linearises it exactly: the picture is | |
| 151 | + // self-similar under Z -> 1.5 Z. A conformal log-spiral map that gains nine octaves per turn then | |
| 152 | + // winds the basins seamlessly into the centre, and iteration-count stripes swirl around them. | |
| 153 | + float3 newtonVortex(Ctx c, constant NativeFrame &f) { | |
| 154 | + float2 p = c.uv / c.size; | |
| 155 | + float a0 = c.t * .06, a1 = c.t * -.045 + 2.2; | |
| 156 | + float2 r0 = frc_polar(1 + .18 * sin(c.t * .11), a0); | |
| 157 | + float2 r1 = frc_polar(1 + .2 * sin(c.t * .083 + 1.7), a0 + a1 * .15 + 2.1); | |
| 158 | + float2 r2 = -r0 - r1; | |
| 159 | + float2 e2 = frc_mul(r0, r1) + frc_mul(r1, r2) + frc_mul(r2, r0); | |
| 160 | + float2 e3 = frc_mul(frc_mul(r0, r1), r2); | |
| 161 | + const float ln15 = .4054651; | |
| 162 | + const float tau = 9 * ln15 / TAU; | |
| 163 | + float r = max(length(p), 1e-5f), th = atan2(p.y, p.x), lr = log(r); | |
| 164 | + float u = fract(c.travel * .55); | |
| 165 | + float logZ = log(2.2f) + u * ln15 - lr + tau * th; | |
| 166 | + float argZ = -th - tau * lr + c.t * .11; | |
| 167 | + const int pre = 10; | |
| 168 | + float2 z = frc_polar(exp(logZ + pre * ln15), argZ); | |
| 169 | + int root = 0; float mu = 0; bool done = false; | |
| 170 | + const float tol = .002; | |
| 171 | + for (int i = 0; i < 40; ++i) { | |
| 172 | + float2 z2 = frc_mul(z, z); | |
| 173 | + float2 num = frc_mul(z2, z) + frc_mul(e2, z) - e3; | |
| 174 | + float2 den = 3 * z2 + e2; | |
| 175 | + z -= frc_div(num, den); | |
| 176 | + float d0 = length(z - r0), d1 = length(z - r1), d2 = length(z - r2); | |
| 177 | + float dm = min(d0, min(d1, d2)); | |
| 178 | + if (dm < tol) { | |
| 179 | + root = d0 == dm ? 0 : (d1 == dm ? 1 : 2); | |
| 180 | + mu = float(i) - log2(max(log(max(dm, 1e-30f)) / log(tol), 1.f)); | |
| 181 | + done = true; | |
| 182 | + break; | |
| 183 | + } | |
| 184 | + } | |
| 185 | + if (!done) { | |
| 186 | + float s0 = dot(z, r0), s1 = dot(z, r1), s2 = dot(z, r2); | |
| 187 | + root = s0 >= max(s1, s2) ? 0 : (s1 >= s2 ? 1 : 2); | |
| 188 | + mu = 40; | |
| 189 | + } | |
| 190 | + float phase = mu - pre - logZ / ln15; | |
| 191 | + float edge = smoothstep(2.5f, 6.f, phase); | |
| 192 | + float rid = float(root); | |
| 193 | + float lit = c.b[root]; | |
| 194 | + float stripe = pow(.5 + .5 * cos(mu * TAU), 2.f); | |
| 195 | + float3 basin = paint(.08 + rid * .22 + stripe * .12, f) * (.07 + .26 * stripe + .3 * lit * stripe) + deep(.3 + rid * .2, f) * .06; | |
| 196 | + float3 col = basin; | |
| 197 | + col += paint(.55 + rid * .1, f) * smoothstep(1.f, 4.f, phase) * (.2 + .35 * lit); | |
| 198 | + col += paint(.9, f) * edge * (.3 + 1.1 * c.b.w); | |
| 199 | + col *= .85; | |
| 200 | + // Attack: a bright ring runs inward along the basin boundaries as the attack decays. | |
| 201 | + float front = 1.7 * c.hit; | |
| 202 | + col += paint(.95, f) * c.hit * 3.5 * edge * glow(r - front, .07 + .1 * r); | |
| 203 | + col *= smoothstep(.0f, .12f + c.fog * .2f, r) * .85 + .15; | |
| 204 | + return col; | |
| 205 | + } | |
| 206 | + NATIVE_EFFECT(newtonVortex) | |
| 207 | + | |
| 208 | + // ---------------------------------------------------------------- 363 Phoenix Spiral | |
| 209 | + // The Phoenix recurrence z' = z^2 + k + p * z_prev. Four nested layers at octave scales travel toward | |
| 210 | + // the viewer around a wandering centre, twisting as they grow, so feathers keep unfurling from the depth. | |
| 211 | + // Only the feather edges and veins emit light, so the layers read as depth instead of a muddy blend. | |
| 212 | + float3 phoenixSpiral(Ctx c, constant NativeFrame &f) { | |
| 213 | + float2 centre = float2(sin(c.t * .043) * .3, cos(c.t * .037) * .22) * (c.extent - .4); | |
| 214 | + float2 p = (c.uv - centre) / c.size; | |
| 215 | + float rr = length(p); | |
| 216 | + float3 col = paint(.08, f) * .2 + paint(.4, f) * .3 * exp(-rr * 2); | |
| 217 | + for (int layer = 0; layer < 4; ++layer) { | |
| 218 | + float2 s = layerSlot(layer, 4, c.travel * .06); | |
| 219 | + float fade = layerFade(s.x); | |
| 220 | + float scale = layerScale(s.x, 6.f) * .4; | |
| 221 | + float twist = s.x * 2.6 + c.hit * .45 * (s.x - .45) + s.y * 2.39996 + c.t * .03; | |
| 222 | + float2 z = rot(p, twist).yx * scale; | |
| 223 | + float2 dz = float2(scale, 0), prev = float2(0), dprev = float2(0); | |
| 224 | + float2 k = float2(.38 + .012 * sin(s.y * 1.3 + c.t * .05), .01 * cos(s.y * .7)); | |
| 225 | + float2 pk = float2(-.17 + .03 * cos(s.y * 2.1 + c.t * .03), 0); | |
| 226 | + float vein = 9, mu = 24, de = 0; bool escaped = false; | |
| 227 | + for (int i = 0; i < 24; ++i) { | |
| 228 | + float2 nextDz = 2 * frc_mul(z, dz) + frc_mul(pk, dprev); | |
| 229 | + float2 next = frc_mul(z, z) + k + frc_mul(pk, prev); | |
| 230 | + dprev = dz; dz = nextDz; prev = z; z = next; | |
| 231 | + vein = min(vein, abs(z.x * .8 + z.y * .6)); | |
| 232 | + float r2 = dot(z, z); | |
| 233 | + if (r2 > 256) { float r = sqrt(r2); mu = float(i) + 1 - log2(log(r)); de = .5 * r * log(r) / max(length(dz), 1e-20f); escaped = true; break; } | |
| 234 | + } | |
| 235 | + float band = frc_band(c.b, s.y); | |
| 236 | + float depthLight = fade * (.3 + .7 * s.x); | |
| 237 | + // Feather outline, barbs (escape-time bands hugging the edge) and veins inside the wings. | |
| 238 | + float edge = escaped ? glow(de, .005 + .005 * band) : 0; | |
| 239 | + float barbs = escaped ? pow(.5 + .5 * cos(mu * 2.2), 3.f) * exp(-de * 25) : 0; | |
| 240 | + float veins = escaped ? 0 : glow(vein, .015 + .01 * band); | |
| 241 | + float3 layerCol = paint(.45 + .45 * s.x, f) * edge * (.8 + 1.4 * band); | |
| 242 | + layerCol += paint(.3 + .4 * s.x + mu * .01, f) * barbs * (.35 + .6 * band); | |
| 243 | + layerCol += paint(.2 + .4 * s.x, f) * (veins * (.3 + .8 * band) + (escaped ? 0 : .12)); | |
| 244 | + layerCol += paint(.95, f) * glow(de, .0025) * (escaped ? 1 : 0) * 1.5 * c.hit * smoothstep(.3f, .7f, s.x); | |
| 245 | + col += layerCol * depthLight; | |
| 246 | + } | |
| 247 | + return col; | |
| 248 | + } | |
| 249 | + NATIVE_EFFECT(phoenixSpiral) | |
| 250 | + | |
| 251 | + // ---------------------------------------------------------------- 364 Droste Fractal | |
| 252 | + // A framed Julia picture that holds a copy of itself inside its inner frame. The complex logarithm of | |
| 253 | + // the screen, multiplied by (1 - i 2 lnS / 2pi), makes one turn equal two recursion levels, so the frames | |
| 254 | + // twist into an endless double spiral (Escher's construction); travel slides along the log-scale axis. | |
| 255 | + float3 drosteFractal(Ctx c, constant NativeFrame &f) { | |
| 256 | + float2 p = c.uv / c.size; | |
| 257 | + const float S = 2.8, lnS = 1.0296194; | |
| 258 | + const float k = 2 * lnS / TAU; // two recursion levels per turn | |
| 259 | + float r = max(length(p), 1e-5f), th = atan2(p.y, p.x), lr = log(r); | |
| 260 | + float2 w = float2(lr + k * th, th - k * lr); | |
| 261 | + float flow = c.travel * .16; | |
| 262 | + float level = w.x / lnS - flow; | |
| 263 | + float2 z = frc_polar(exp((fract(level) - 1) * lnS), w.y + c.t * .03); | |
| 264 | + float m = max(abs(z.x), abs(z.y)); | |
| 265 | + if (m < 1 / S) { z *= S; m *= S; } | |
| 266 | + // One full turn descends two recursion levels, so the seam-free ring coordinate is log_S(r): the | |
| 267 | + // recursion rings are concentric on screen and drift outward with travel (stable ids per ring). | |
| 268 | + float ring = lr / lnS - flow; | |
| 269 | + // Frame seams at |z|inf = 1 and 1/S, measured in outer-level units on both sides. | |
| 270 | + float seam = min(1 - m, (m - 1 / S) * S); | |
| 271 | + float pxz = c.px * length(z) * sqrt(1 + k * k) / r; | |
| 272 | + // The Julia picture between the frames. | |
| 273 | + float2 q = rot(z, .6) * 1.25; | |
| 274 | + float2 kj = float2(-.122 + .02 * sin(c.t * .05), .745 + .02 * cos(c.t * .04)); | |
| 275 | + float2 dq = float2(1.25, 0); | |
| 276 | + float trap = 9, mu = 28, de = 0; bool escaped = false; | |
| 277 | + for (int i = 0; i < 28; ++i) { | |
| 278 | + dq = 2 * frc_mul(q, dq); | |
| 279 | + q = frc_mul(q, q) + kj; | |
| 280 | + trap = min(trap, abs(q.x) + abs(q.y) * .5); | |
| 281 | + float r2 = dot(q, q); | |
| 282 | + if (r2 > 256) { float rq = sqrt(r2); mu = float(i) + 1 - log2(log(rq)); de = .5 * rq * log(rq) / max(length(dq), 1e-20f); escaped = true; break; } | |
| 283 | + } | |
| 284 | + // Each band lights every fourth ring; smooth windows keep the ring edges seamless. | |
| 285 | + float4 window = pow(.5 + .5 * cos((float4(ring) - float4(0, 1, 2, 3)) * TAU / 4), float4(6)); | |
| 286 | + float ringLit = .6 + .9 * dot(window, c.b); | |
| 287 | + float edge = escaped ? glow(de, max(.008f, pxz * 1.5f)) : .25; | |
| 288 | + float ringHue = .1 * sin(ring * 1.5708); | |
| 289 | + float stripe = pow(.5 + .5 * cos(mu * 2.2), 3.f) * smoothstep(1.f, 5.f, mu); | |
| 290 | + float cycle = .5 + .5 * cos(atan2(q.y, q.x)); | |
| 291 | + float3 picture = escaped ? paint(.18 + mu * .025 + ringHue, f) * (.14 + .3 * stripe) + paint(.45, f) * .3 * smoothstep(5.f, 16.f, mu) | |
| 292 | + : paint(.22 + .3 * cycle + ringHue, f) * (.08 + .12 * cycle) * (.6 + .4 * cos(log(trap + 1e-4f) * 5)) | |
| 293 | + + paint(.6, f) * glow(trap, .04) * .45; | |
| 294 | + picture += paint(.7, f) * edge * .9; | |
| 295 | + picture *= ringLit; | |
| 296 | + float frameMask = smoothstep(.015f, .07f, seam); | |
| 297 | + float3 frame = paint(.8, f) * glow(seam, .007 + pxz) * 1.3 + paint(.45, f) * glow(seam, .045) * .45; | |
| 298 | + float3 col = picture * frameMask + frame; | |
| 299 | + // Attack: one ring of the recursion flashes. | |
| 300 | + float ringPos = lr / lnS + 1.2; | |
| 301 | + float flash = c.hit * exp(-ringPos * ringPos * 3); | |
| 302 | + col += paint(.75, f) * flash * (1.6 * frameMask * edge + 1.2 * glow(seam, .02 + pxz)) + paint(.4, f) * flash * .25; | |
| 303 | + col *= smoothstep(.0f, .1f + c.fog * .15f, r) * .9 + .1; | |
| 304 | + return col; | |
| 305 | + } | |
| 306 | + NATIVE_EFFECT(drosteFractal) |
Sources/PulseCanvas/Resources/NativeExpansionFractalTunnel.metal added
| 1 | + // Original PulseCanvas designs 365–369. Flights through fractal tunnels: fractal sets wrapped onto tube walls, intertwined fractal tubes, a raymarched quaternion Julia and a loxodromic double spiral. The owner asked for "fractals twisting into each other ... through a fractal tunnel". Vivid and glowing; avoid the look of the withdrawn 126 Fractal Throat (grey folded-box blades) and the kept 61 Menger Nave / 60 Mandel Bloom. | |
| 2 | + // Escape-time sets, distance estimates and the Koenigs linearisation are implemented from their definitions. | |
| 3 | + | |
| 4 | + // ---------------------------------------------------------------- complex helpers (ft_) | |
| 5 | + float2 ft_mul(float2 a, float2 b) { return float2(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); } | |
| 6 | + float2 ft_sq(float2 a) { return float2(a.x * a.x - a.y * a.y, 2 * a.x * a.y); } | |
| 7 | + float2 ft_div(float2 a, float2 b) { return float2(a.x * b.x + a.y * b.y, a.y * b.x - a.x * b.y) / max(dot(b, b), 1e-20f); } | |
| 8 | + float2 ft_exp(float2 a) { return exp(a.x) * float2(cos(a.y), sin(a.y)); } | |
| 9 | + float2 ft_log(float2 a) { return float2(.5f * log(max(dot(a, a), 1e-30f)), atan2(a.y, a.x)); } | |
| 10 | + float2 ft_sqrt(float2 a) { | |
| 11 | + float m = length(a); | |
| 12 | + return float2(sqrt(max(.5f * (m + a.x), 0.f)), (a.y < 0 ? -1.f : 1.f) * sqrt(max(.5f * (m - a.x), 0.f))); | |
| 13 | + } | |
| 14 | + // Triangle wave: 1 at integers, 0 at half-integers; a continuous mirror fold. | |
| 15 | + float ft_tri(float x) { return abs(fract(x) * 2 - 1); } | |
| 16 | + // Band level for a continuous family index with period 4; neighbouring families blend. | |
| 17 | + float ft_band(float x, float4 b) { | |
| 18 | + float ph = x - 4 * floor(x * .25f), sum = 0; | |
| 19 | + for (int i = 0; i < 4; ++i) { float d = abs(ph - float(i)); d = min(d, 4 - d); sum += max(0.f, 1 - d) * b[i]; } | |
| 20 | + return sum; | |
| 21 | + } | |
| 22 | + | |
| 23 | + // ---------------------------------------------------------------- 365 Mandelbrot Wormhole | |
| 24 | + // The tube wall is parameterised by the multiplier mu of the main cardioid (c = mu/2 - mu^2/4): | |
| 25 | + // the tunnel angle is the internal angle, so every crown carries the ring of bulbs that sits on | |
| 26 | + // the cardioid; |mu| swings in and out of the boundary along depth, so crowns of bulbs, their | |
| 27 | + // filaments and the cardioid interior stream past and twist into the vanishing point. | |
| 28 | + float3 mandelbrotWormhole(Ctx c, constant NativeFrame &f) { | |
| 29 | + float2 p = c.uv / c.size + float2(sin(c.t * .11f), cos(c.t * .09f)) * .05f; | |
| 30 | + float r = max(length(p), 1e-3f), ang = atan2(p.y, p.x); | |
| 31 | + float near = -log(r) + 1.2f; // log-polar distance from the viewer | |
| 32 | + float depth = near + c.travel * .55f; | |
| 33 | + float s = .15f + .07f * sin(depth * 1.3f + c.t * .1f) + .28f * sin(depth * 6.f); | |
| 34 | + float theta = 3 * ang + depth * .9f + c.t * .05f; // three crowns around, twisting with depth | |
| 35 | + float2 mu = exp(s) * float2(cos(theta), sin(theta)); | |
| 36 | + float2 cc = .5f * mu - .25f * ft_sq(mu); | |
| 37 | + float cpu = max(length(fwidth(cc)), 1e-7f) / c.px; | |
| 38 | + | |
| 39 | + // Analytic components: main cardioid (multiplier mu or 2 - mu) and the period-2 disc. | |
| 40 | + float2 mirror = float2(2, 0) - mu; | |
| 41 | + float mainR = min(length(mu), length(mirror)); | |
| 42 | + float twoR = 4 * length(cc + float2(1, 0)); | |
| 43 | + float2 z = 0, dz = 0; float m2 = 0, atom = 1e9; int per = 1; bool escaped = false; int n = 0; | |
| 44 | + if (mainR >= 1 && twoR >= 1) { | |
| 45 | + for (n = 0; n < 64; ++n) { | |
| 46 | + dz = 2 * ft_mul(z, dz) + float2(1, 0); | |
| 47 | + z = ft_sq(z) + cc; | |
| 48 | + m2 = dot(z, z); | |
| 49 | + if (m2 < atom) { atom = m2; per = n + 1; } | |
| 50 | + if (m2 > 1e4) { escaped = true; break; } | |
| 51 | + } | |
| 52 | + } else per = mainR < 1 ? 1 : 2; | |
| 53 | + | |
| 54 | + float front = 1.2f + (1 - c.hit) * 4.5f; | |
| 55 | + float wave = c.hit * exp(-(near - front) * (near - front) * 5); | |
| 56 | + float3 col; | |
| 57 | + if (escaped) { | |
| 58 | + float nu = float(n) + 1 - log2(.5f * log(m2)); | |
| 59 | + float de = .25f * sqrt(m2 / max(dot(dz, dz), 1e-20f)) * log(m2) / cpu; | |
| 60 | + // High-mid lights the halo and equipotential threads, treble the neon filaments. | |
| 61 | + float halo = exp(-de * 40); | |
| 62 | + float neon = glow(de, .0035f + .003f * c.detail + .004f * c.b.w); | |
| 63 | + float equip = pow(ft_tri(nu * .5f), 12.f) * exp(-de * 6); | |
| 64 | + col = deep(.9f + nu * .03f, f) * .06f; | |
| 65 | + col += paint(.75f + nu * .035f, f) * (.2f * halo + .16f * equip) * (1 + 3 * c.b.z); | |
| 66 | + col += paint(.05f + .08f * sin(nu * .4f), f) * neon * (1 + 2 * c.b.w + 2.5f * wave); | |
| 67 | + col += paint(.95f, f) * halo * wave * .7f; | |
| 68 | + } else { | |
| 69 | + // Components light by period: cardioid with the bass, period 2 low-mid, 3 high-mid, 4+ treble. | |
| 70 | + float fam = float(min(per, 4) - 1); | |
| 71 | + float lit = 1 + 3 * c.b[int(fam)]; | |
| 72 | + float edge = per == 1 ? mainR : twoR; | |
| 73 | + float rim = per <= 2 ? pow(edge, 24.f) : smoothstep(.0f, .5f, sqrt(atom)); | |
| 74 | + float body = per <= 2 ? pow(edge, 4.f) : rim; | |
| 75 | + float2 m = per == 1 ? (length(mu) < 1 ? mu : mirror) : cc + float2(1, 0); | |
| 76 | + float spokes = line(sin(atan2(m.y, m.x) * (per == 1 ? 7 : 4) + c.t * .2f), .08f, .03f) * body; | |
| 77 | + float level = line(sin(log(1.0001f - edge) * 5 - c.t * .6f), .12f, .06f) * (1 - rim) * smoothstep(.3f, .9f, edge); | |
| 78 | + col = per == 1 ? deep(.15f, f) * .1f + paint(.02f, f) * (.18f * spokes + .7f * rim) * lit + paint(.85f, f) * (body * .06f + level * .18f) * lit | |
| 79 | + : paint(.3f + .22f * fam, f) * (.08f + .3f * body + .5f * rim + .15f * spokes + .2f * level) * lit; | |
| 80 | + col += paint(.9f, f) * rim * wave * 1.5f; | |
| 81 | + } | |
| 82 | + float fade = smoothstep(.01f, .2f, r) * exp(-near * .12f * (.4f + c.fog)) * .72f; | |
| 83 | + return col * fade + paint(.88f, f) * glow(r, .05f) * .5f + deep(.4f, f) * .03f; | |
| 84 | + } | |
| 85 | + NATIVE_EFFECT(mandelbrotWormhole) | |
| 86 | + | |
| 87 | + // ---------------------------------------------------------------- 366 Burning Ship Abyss | |
| 88 | + // A twisting square shaft. Each wall shows the Burning Ship's armada (hulls, masts and | |
| 89 | + // rigging) mirrored at the waterline and at the mast tips, so spires hang from both sides of | |
| 90 | + // every hull as you descend; the walls fold at their centres and corners. | |
| 91 | + float3 burningShipAbyss(Ctx c, constant NativeFrame &f) { | |
| 92 | + float2 p = c.uv / c.size; | |
| 93 | + float r0 = max(length(p), 1e-3f); | |
| 94 | + p = rot(p, -.3f * log(r0) + c.t * .035f); | |
| 95 | + float2 a = abs(p); | |
| 96 | + float d = max(max(a.x, a.y), 1e-3f); | |
| 97 | + float u = min(a.x, a.y) / d; | |
| 98 | + float near = 1.2f - log(d); | |
| 99 | + float depth = near + c.travel * .5f; | |
| 100 | + float v = depth * 1.5f; | |
| 101 | + // Side walls and floor/ceiling show different stretches of the armada; they meet at the corners. | |
| 102 | + float x0 = a.x > a.y ? -1.97f : -1.84f; | |
| 103 | + float2 cc = float2(mix(x0, -1.55f, u), -.004f - .15f * (1 - ft_tri(v))); | |
| 104 | + float cpu = max(length(fwidth(cc)), 1e-8f) / c.px; | |
| 105 | + | |
| 106 | + float2 z = 0; float md = 0, m2 = 0, trap = 1e9; bool escaped = false; int n = 0; | |
| 107 | + for (n = 0; n < 56; ++n) { | |
| 108 | + md = 2 * sqrt(m2) * md + 1; | |
| 109 | + z = abs(z); | |
| 110 | + z = float2(z.x * z.x - z.y * z.y, 2 * z.x * z.y) + cc; | |
| 111 | + m2 = dot(z, z); | |
| 112 | + trap = min(trap, abs(z.y)); | |
| 113 | + if (m2 > 1e4) { escaped = true; break; } | |
| 114 | + } | |
| 115 | + float mast = (cc.x + 1.93f) / .08f; | |
| 116 | + float lit = 1 + 3.2f * ft_band(mast, c.b); | |
| 117 | + float front = .8f + (1 - c.hit) * 5; | |
| 118 | + float ring = c.hit * exp(-(near - front) * (near - front) * 7); | |
| 119 | + float3 col; | |
| 120 | + if (escaped) { | |
| 121 | + float nu = float(n) + 1 - log2(.5f * log(m2)); | |
| 122 | + float de = .25f * sqrt(m2) * log(m2) / md / cpu; | |
| 123 | + float heat = saturate(nu / 40.f); | |
| 124 | + float halo = exp(-de * 200), neon = glow(de, .0015f); | |
| 125 | + float flame = pow(ft_tri(nu * .5f), 8.f); | |
| 126 | + col = deep(.2f + heat * .3f, f) * (.05f + .25f * heat * heat); | |
| 127 | + col += paint(.55f + .1f * sin(nu * .7f), f) * flame * heat * .18f; | |
| 128 | + col += paint(.15f + heat * .6f, f) * (pow(heat, 2.2f) * 1.1f + .1f * heat) * (.7f + .3f * flame) * lit; | |
| 129 | + col += paint(.6f, f) * neon * lit * .3f + paint(1.f, f) * (neon + flame * halo + .4f * flame * heat) * ring * 1.6f; | |
| 130 | + } else { | |
| 131 | + col = (paint(.62f, f) * .3f + paint(.95f, f) * .35f * glow(trap, .02f)) * lit + paint(.9f, f) * ring * .5f; | |
| 132 | + } | |
| 133 | + col += paint(.3f, f) * glow(1 - u, .012f) * .3f; // the shaft's corner seams | |
| 134 | + float fade = smoothstep(.01f, .25f, d) * exp(-near * .05f * (.4f + c.fog)); | |
| 135 | + return col * fade + deep(.3f, f) * glow(d, .12f) * .5f; | |
| 136 | + } | |
| 137 | + NATIVE_EFFECT(burningShipAbyss) | |
| 138 | + | |
| 139 | + // ---------------------------------------------------------------- 367 Fractal Double Helix | |
| 140 | + // Two raymarched helical tubes braid around the flight axis, weaving in and out; each wall | |
| 141 | + // carries a tiled, living Julia set (its own parameter orbiting), shaded with rim light and a | |
| 142 | + // neon halo in the gaps. | |
| 143 | + float3 fractalDoubleHelix(Ctx c, constant NativeFrame &f) { | |
| 144 | + float2 uv = c.uv / c.size; | |
| 145 | + // Every z frequency below divides a 16-unit period, so the camera wraps without a seam. | |
| 146 | + float camZ = c.travel * 1.25f; | |
| 147 | + camZ -= 16 * floor(camZ / 16); | |
| 148 | + float2 sway = float2(.1f * sin(c.t * .13f), .08f * cos(c.t * .11f)); | |
| 149 | + float3 ro = float3(sway, camZ); | |
| 150 | + float3 rd = cameraRay(uv, float3(.1f * sin(c.t * .07f), .08f * cos(c.t * .09f), 1), float3(0, 1, 0), 1.2f); | |
| 151 | + const float K = PI / 2, R = .8f; | |
| 152 | + float spin = c.t * .12f; | |
| 153 | + float rhoA = .25f + .12f * c.b.x, rhoB = .25f + .12f * c.b.y; | |
| 154 | + float tt = .05f, gA = 0, gB = 0, dA = 1, dB = 1; bool hit = false; | |
| 155 | + float3 q = ro; | |
| 156 | + for (int i = 0; i < 48; ++i) { | |
| 157 | + q = ro + rd * tt; | |
| 158 | + float ph = q.z * K + spin, weave = .3f * sin(q.z * (PI / 8) + c.t * .2f); | |
| 159 | + float2 h = float2(cos(ph), sin(ph)); | |
| 160 | + dA = length(q.xy - h * R * (1 + weave)) - rhoA; dB = length(q.xy + h * R * (1 - weave)) - rhoB; | |
| 161 | + float dd = min(dA, dB); | |
| 162 | + gA += exp(-max(dA, 0.f) * 5); gB += exp(-max(dB, 0.f) * 5); | |
| 163 | + if (dd < .0015f * tt) { hit = true; break; } | |
| 164 | + tt += dd * .7f; | |
| 165 | + if (tt > 22) break; | |
| 166 | + } | |
| 167 | + bool strandA = dA < dB; | |
| 168 | + float ph = q.z * K + spin, weave = .3f * sin(q.z * (PI / 8) + c.t * .2f); | |
| 169 | + float sgn = strandA ? 1 : -1; | |
| 170 | + float2 h = float2(cos(ph), sin(ph)) * R * (1 + sgn * weave) * sgn; | |
| 171 | + float2 a2 = q.xy - h; | |
| 172 | + float2 local = rot(a2, -ph); | |
| 173 | + float psi = atan2(local.y, local.x); | |
| 174 | + // Rays that slip between the strands meet the enclosing fractal tunnel wall. | |
| 175 | + const float wallR = 2.6f; | |
| 176 | + float ra = dot(rd.xy, rd.xy), rb = dot(ro.xy, rd.xy), rc = dot(ro.xy, ro.xy) - wallR * wallR; | |
| 177 | + float tw = (-rb + sqrt(max(rb * rb - ra * rc, 0.f))) / max(ra, 1e-6f); | |
| 178 | + float3 qw = ro + rd * tw; | |
| 179 | + float thw = atan2(qw.y, qw.x) + qw.z * (PI / 24); | |
| 180 | + float2 zj = hit ? (2 * float2(ft_tri(q.z * 1.125f + (strandA ? 0 : .5f)), ft_tri(psi / PI)) - 1) * 1.45f | |
| 181 | + : (2 * float2(ft_tri(qw.z * .375f), ft_tri(thw * 3 / PI)) - 1) * 1.45f; | |
| 182 | + float zpx = max(length(fwidth(zj)), 1e-6f) / c.px; | |
| 183 | + // Living Julia sets: parameters glide just inside the main cardioid's rim. | |
| 184 | + float ca = c.t * .05f + (hit ? (strandA ? 0 : 2.2f) : 4.1f); | |
| 185 | + float2 em = .97f * float2(cos(ca), sin(ca)); | |
| 186 | + float2 cj = .5f * em - .25f * ft_sq(em); | |
| 187 | + float m2 = dot(zj, zj), md = 1, trap = 1e9; bool escaped = false; int n = 0; | |
| 188 | + for (n = 0; n < 32; ++n) { | |
| 189 | + md *= 2 * sqrt(m2); | |
| 190 | + zj = ft_sq(zj) + cj; | |
| 191 | + m2 = dot(zj, zj); | |
| 192 | + trap = min(trap, abs(sqrt(m2) - .4f)); | |
| 193 | + if (m2 > 64) { escaped = true; break; } | |
| 194 | + } | |
| 195 | + float hueBase = hit ? (strandA ? .05f : .6f) : .3f; | |
| 196 | + float bandFill = strandA ? c.b.x : c.b.y, bandLine = strandA ? c.b.z : c.b.w; | |
| 197 | + if (!hit) { bandFill = 0; bandLine = .5f * (c.b.z + c.b.w); } | |
| 198 | + float3 tex; | |
| 199 | + if (escaped) { | |
| 200 | + float nu = float(n) + 1 - log2(.5f * log(m2)); | |
| 201 | + float de = .25f * sqrt(m2) * log(m2) / max(md, 1e-6f) / zpx; | |
| 202 | + float bands = pow(ft_tri(nu * .5f), 4.f); | |
| 203 | + tex = deep(hueBase + .1f, f) * .07f + paint(hueBase + nu * .03f, f) * (.03f + .2f * bands) * exp(-de * 4) | |
| 204 | + + paint(hueBase + .45f, f) * glow(de, .005f + .004f * bandLine) * (1 + 2.5f * bandLine); | |
| 205 | + } else { | |
| 206 | + // Koenigs coordinate of the attracting fixed point em/2: a rose of spokes and rings. | |
| 207 | + float2 kz = ft_div(zj - .5f * em, ft_exp(float(n) * float2(log(.97f), ca))); | |
| 208 | + float rose = pow(.5f + .5f * cos(atan2(kz.y, kz.x) * 5 + log(max(length(kz), 1e-6f)) * 3 - c.t * .5f), 3.f); | |
| 209 | + tex = paint(hueBase + .3f + .2f * rose, f) * (.06f + .5f * rose) * (.7f + 1.8f * bandFill); | |
| 210 | + } | |
| 211 | + float pulseZ = camZ + 1.5f + (1 - c.hit) * 14; | |
| 212 | + float3 col; | |
| 213 | + if (hit) { | |
| 214 | + float2 nxy = normalize(a2); | |
| 215 | + float3 nrm = normalize(float3(nxy, dot(nxy, R * K * float2(sin(ph), -cos(ph)) * sgn))); | |
| 216 | + float facing = abs(dot(nrm, rd)); | |
| 217 | + float rim = pow(1 - facing, 3.f); | |
| 218 | + float pulse = c.hit * exp(-(q.z - pulseZ) * (q.z - pulseZ) * 2); | |
| 219 | + col = tex * (.5f + .7f * facing) + paint(hueBase + .1f, f) * rim * .8f + paint(.95f, f) * pulse * 1.5f; | |
| 220 | + col *= exp(-tt * .07f * (.4f + c.fog)); | |
| 221 | + } else { | |
| 222 | + float pulse = c.hit * exp(-(qw.z - pulseZ) * (qw.z - pulseZ) * .5f); | |
| 223 | + col = (tex * .4f + paint(.9f, f) * pulse * .5f) * exp(-(qw.z - camZ) * .09f * (.4f + c.fog)); | |
| 224 | + } | |
| 225 | + if (!hit) col += paint(.25f, f) * gA * .006f + paint(.75f, f) * gB * .006f; | |
| 226 | + col += paint(.9f, f) * glow(length(uv - sway * 1.2f), .08f) * .35f; | |
| 227 | + return col; | |
| 228 | + } | |
| 229 | + NATIVE_EFFECT(fractalDoubleHelix) | |
| 230 | + | |
| 231 | + // ---------------------------------------------------------------- 368 Quaternion Bloom | |
| 232 | + // Distance estimate of a quaternion Julia set, q <- q^2 + c, sliced into 3D by a rotating | |
| 233 | + // 4D plane. |dq| is tracked as a scalar because the quaternion norm is multiplicative. | |
| 234 | + float ft_qjulia(float3 p, float4 cq, float2 slice, thread float4 &trap) { | |
| 235 | + float4 q = float4(p.x, p.y * slice.x, p.z, p.y * slice.y); | |
| 236 | + float m2 = dot(q, q), md2 = 1; | |
| 237 | + trap = float4(1e3); | |
| 238 | + for (int i = 0; i < 8; ++i) { | |
| 239 | + md2 *= 4 * m2; | |
| 240 | + q = float4(q.x * q.x - dot(q.yzw, q.yzw), 2 * q.x * q.yzw) + cq; | |
| 241 | + m2 = dot(q, q); | |
| 242 | + if (i < 3) trap = min(trap, float4(abs(q.x), abs(q.y), abs(length(q.yzw) - .5f), abs(sqrt(m2) - .8f))); | |
| 243 | + if (m2 > 256) break; | |
| 244 | + } | |
| 245 | + return .25f * sqrt(m2 / md2) * log(m2); | |
| 246 | + } | |
| 247 | + float3 quaternionBloom(Ctx c, constant NativeFrame &f) { | |
| 248 | + float2 uv = c.uv / c.size; | |
| 249 | + float az = c.travel * .21f + c.t * .02f, el = .35f * sin(c.travel * .07f + 1); | |
| 250 | + float dist = 1.85f - .25f * sin(c.travel * .11f); | |
| 251 | + float3 ro = dist * float3(cos(el) * sin(az), sin(el), cos(el) * cos(az)); | |
| 252 | + float3 rd = cameraRay(uv, -ro, float3(0, 1, 0), 1.35f); | |
| 253 | + float sa = c.t * .06f; | |
| 254 | + float2 slice = float2(cos(sa), sin(sa)); | |
| 255 | + float ca = c.t * .045f; | |
| 256 | + float4 cq = float4(-.2f + .07f * sin(ca), .4f + .1f * sin(ca * .8f + 1), -.4f + .1f * cos(ca * .6f), -.4f + .08f * sin(ca * 1.1f + 2)); | |
| 257 | + float bR = 1.5f, bb = dot(ro, rd), cc0 = dot(ro, ro) - bR * bR, disc = bb * bb - cc0; | |
| 258 | + float haloAcc = 0; bool hit = false; float tt = 0; float4 trap = 1e3; float steps = 0; | |
| 259 | + if (disc > 0) { | |
| 260 | + float t0 = max(-bb - sqrt(disc), 0.f), t1 = -bb + sqrt(disc); | |
| 261 | + tt = t0; | |
| 262 | + float dd = 1; | |
| 263 | + for (int i = 0; i < 32; ++i) { | |
| 264 | + dd = ft_qjulia(ro + rd * tt, cq, slice, trap); | |
| 265 | + haloAcc += exp(-max(dd, 0.f) * 20); | |
| 266 | + if (dd < .003f * tt) break; | |
| 267 | + tt += max(dd, .002f); | |
| 268 | + steps += 1; | |
| 269 | + if (tt > t1) { dd = 1; break; } | |
| 270 | + } | |
| 271 | + hit = dd < .03f; | |
| 272 | + } | |
| 273 | + float r = length(uv), ang = atan2(uv.y, uv.x); | |
| 274 | + // A corona of soft petals unfolding behind the bloom. | |
| 275 | + float lr = log(max(r, 1e-3f)); | |
| 276 | + float petals = pow(.5f + .5f * cos(ang * 7 + sin(lr * 2.5f - c.t * .3f) * 1.2f - c.t * .08f), 4.f); | |
| 277 | + float veil = pow(.5f + .5f * cos(ang * 4 - lr * 3 + c.t * .15f), 6.f); | |
| 278 | + float3 col = deep(.55f, f) * .07f + paint(.45f + .25f * petals, f) * (petals * .2f + veil * .08f) * smoothstep(.25f, 1.2f, r) * exp(-r * .4f); | |
| 279 | + col += paint(.45f, f) * haloAcc * .025f; | |
| 280 | + if (hit) { | |
| 281 | + float3 pos = ro + rd * tt; | |
| 282 | + float4 tmp; | |
| 283 | + const float e = .003f; | |
| 284 | + float d0 = ft_qjulia(pos, cq, slice, trap); | |
| 285 | + float3 nrm = normalize(float3(ft_qjulia(pos + float3(e, 0, 0), cq, slice, tmp) - d0, | |
| 286 | + ft_qjulia(pos + float3(0, e, 0), cq, slice, tmp) - d0, | |
| 287 | + ft_qjulia(pos + float3(0, 0, e), cq, slice, tmp) - d0)); | |
| 288 | + float facing = max(0.f, -dot(nrm, rd)); | |
| 289 | + float rim = pow(1 - facing, 2.5f); | |
| 290 | + float diff = max(0.f, dot(nrm, normalize(float3(.5f, .8f, .3f)))); | |
| 291 | + float shell = .2f + (1 - c.hit) * 1.4f; | |
| 292 | + float flare = c.hit * exp(-(length(pos) - shell) * (length(pos) - shell) * 30); | |
| 293 | + float3 vc = 0; | |
| 294 | + for (int k = 0; k < 4; ++k) vc += paint(.6f + .1f * float(k), f) * glow(trap[k], .01f + .012f * c.b[k]) * (.35f + 3 * c.b[k] + 3 * flare); | |
| 295 | + float ao = 1 - steps / 48; | |
| 296 | + float3 base = paint(.3f + .6f * saturate(trap.w * 1.5f), f) * (.12f + .6f * diff) * ao; | |
| 297 | + col = base + vc * .5f + paint(.95f, f) * rim * 1.1f; | |
| 298 | + } | |
| 299 | + return col; | |
| 300 | + } | |
| 301 | + NATIVE_EFFECT(quaternionBloom) | |
| 302 | + | |
| 303 | + // ---------------------------------------------------------------- 369 Loxodrome Fractal | |
| 304 | + // Bipolar coordinates W = log((p - source) / (p - sink)) feed a loxodromic flow through the | |
| 305 | + // exponential picture of a Julia set at its repelling fixed point alpha. The Koenigs relation | |
| 306 | + // G(f(z)) = 2 G(z) makes that picture exactly periodic under w -> w + log(lambda), so the | |
| 307 | + // detail streams out of one spiral pole and into the other without ever resetting. | |
| 308 | + float3 loxodromeFractal(Ctx c, constant NativeFrame &f) { | |
| 309 | + float2 p = c.uv / c.size; | |
| 310 | + float2 axis = rot(c.extent.x >= c.extent.y ? float2(1, 0) : float2(0, 1), .3f * sin(c.t * .05f)); | |
| 311 | + float sep = .55f * max(c.extent.x, c.extent.y) / c.size; | |
| 312 | + float2 side = float2(-axis.y, axis.x) * .12f; | |
| 313 | + float2 p1 = -axis * sep + side, p2 = axis * sep - side; | |
| 314 | + float2 W = ft_log(ft_div(p - p1, p - p2)); | |
| 315 | + float dW = length(p2 - p1) / max(length(p - p1) * length(p - p2), 1e-6f); | |
| 316 | + | |
| 317 | + float ca = c.t * .03f; | |
| 318 | + float2 cj = float2(-.05f, .84f) + .025f * float2(cos(ca), sin(ca * 1.3f)); | |
| 319 | + float2 alpha = .5f * (float2(1, 0) - ft_sqrt(float2(1, 0) - 4 * cj)); | |
| 320 | + float2 lam = 2 * alpha; | |
| 321 | + float2 L = ft_log(lam); | |
| 322 | + // w = A W with A (2 pi i) = 2 pi i + L: one turn around a pole is one level deeper. | |
| 323 | + float2 A = float2(1, 0) + ft_div(L, float2(0, TAU)); | |
| 324 | + float2 w = ft_mul(A, W) - L.x * c.travel * .9f * float2(1, .6f) + float2(0, c.t * .06f); | |
| 325 | + float k = floor(w.x / L.x); | |
| 326 | + float2 wr = w - k * L; | |
| 327 | + const float sigma = .05f; | |
| 328 | + const int pre = 8; | |
| 329 | + float2 delta = sigma * ft_exp(wr - float(pre) * L); | |
| 330 | + float2 ddelta = delta; // d delta / d w' | |
| 331 | + for (int i = 0; i < pre; ++i) { | |
| 332 | + ddelta = ft_mul(ddelta, lam + 2 * delta); | |
| 333 | + delta = ft_mul(delta, lam + delta); | |
| 334 | + } | |
| 335 | + float2 z = alpha + delta, dz = ddelta; | |
| 336 | + float m2 = dot(z, z), trap = 1e9; bool escaped = false; int n = 0; | |
| 337 | + for (n = 0; n < 40; ++n) { | |
| 338 | + dz = 2 * ft_mul(z, dz); | |
| 339 | + z = ft_sq(z) + cj; | |
| 340 | + m2 = dot(z, z); | |
| 341 | + trap = min(trap, length(z - alpha)); | |
| 342 | + if (m2 > 1e4) { escaped = true; break; } | |
| 343 | + } | |
| 344 | + float wpx = length(A) * dW; | |
| 345 | + float front = mix(-3.5f, 3.5f, 1 - c.hit); | |
| 346 | + float wave = c.hit * exp(-(W.x - front) * (W.x - front) * 1.2f); | |
| 347 | + float3 col; | |
| 348 | + if (escaped) { | |
| 349 | + float nu = float(n) + 1 - log2(.5f * log(m2)) - k; | |
| 350 | + float de = .25f * sqrt(m2 / max(dot(dz, dz), 1e-30f)) * log(m2) / max(wpx, 1e-6f); | |
| 351 | + float lit = 1 + 3 * ft_band(nu * .5f, c.b); | |
| 352 | + float halo = exp(-de * 18), neon = glow(de, .004f); | |
| 353 | + float flow = pow(ft_tri(nu * .5f), 8.f) * exp(-de * 3); | |
| 354 | + col = deep(.3f + nu * .02f, f) * .12f + paint(.45f + .25f * sin(nu * .3f), f) * (.3f * halo + .16f * flow) * lit; | |
| 355 | + col += paint(.92f, f) * neon * (1 + 3 * wave) + paint(1.f, f) * halo * wave * .6f; | |
| 356 | + } else { | |
| 357 | + col = deep(.2f, f) * .25f + paint(.7f, f) * glow(trap, .05f) * .4f; | |
| 358 | + } | |
| 359 | + float pole = min(length(p - p1), length(p - p2)); | |
| 360 | + col *= smoothstep(.0f, .12f, pole) * (.3f + .55f * pow(abs(W.y) / PI, 1.5f)); | |
| 361 | + col += paint(.92f, f) * glow(length(p - p1), .07f) * .7f + paint(.55f, f) * glow(length(p - p2), .07f) * .5f; | |
| 362 | + return col; | |
| 363 | + } | |
| 364 | + NATIVE_EFFECT(loxodromeFractal) | |
| 365 | + | |
| 366 | + // Coaster versions: the same designs riding the roller-coaster course. | |
| 367 | + NATIVE_COASTER(mandelbrotWormhole, 365, false) | |
| 368 | + NATIVE_COASTER(burningShipAbyss, 366, false) | |
| 369 | + NATIVE_COASTER(fractalDoubleHelix, 367, false) |
Sources/PulseCanvas/Resources/NativeExpansionKinetic.metal added
| 1 | + // Original PulseCanvas designs 320–329. Dancing visuals as physical-material choreography: | |
| 2 | + // kinetic installations and physical phenomena that move with the music. Every design is | |
| 3 | + // a pure function of its uniforms. Procedural time (which already integrates the music | |
| 4 | + // clock) drives the main motion; each band drives its own group of elements and every | |
| 5 | + // attack starts a local event (a ring, a strike, a splash, a pluck) that runs outward | |
| 6 | + // while the attack envelope decays. | |
| 7 | + | |
| 8 | + // ---------------------------------------------------------------- shared helpers | |
| 9 | + // Attack envelope normalised by Chaos: 1 at an attack onset, decaying to 0. | |
| 10 | + float kin_attack(Ctx c, constant NativeFrame &f) { return saturate(c.hit / max(f.camera.y, .05f)); } | |
| 11 | + // Progress of the latest attack's event: 0 at the onset, running toward 1 as it decays. | |
| 12 | + float kin_age(float attack) { return 1 - pow(attack, .35f); } | |
| 13 | + // Strength of the attack's event: fades with the envelope and scales with Chaos. | |
| 14 | + float kin_strength(float attack, constant NativeFrame &f) { return sqrt(attack) * f.camera.y; } | |
| 15 | + float kin_sq(float x) { return x * x; } | |
| 16 | + float kin_wrap(float a) { return a - TAU * floor(a / TAU + .5); } | |
| 17 | + | |
| 18 | + // ---------------------------------------------------------------- 320 Pin Art | |
| 19 | + // A pin-screen relief seen at an angle: a dense lattice of polished pins whose heads are | |
| 20 | + // pushed out by unseen forms gliding behind the screen, so a relief of pin heads and | |
| 21 | + // exposed shafts rises and falls. Bass presses the broad forms further out, the low mids | |
| 22 | + // roll a long swell across the screen, the high mids ring fine ripples, highs glint pin | |
| 23 | + // heads and every attack presses a sharp ring through that spreads from a drifting point. | |
| 24 | + constant float kin_pinSlant = .36; | |
| 25 | + | |
| 26 | + float kin_pinRelief(float2 q, float2 ext, Ctx c, float age, float strength) { | |
| 27 | + float t = c.t * .13 + c.travel * .05, span = min(ext.x, ext.y); | |
| 28 | + float h = 0; | |
| 29 | + for (int k = 0; k < 3; ++k) { | |
| 30 | + float fk = float(k); | |
| 31 | + float2 centre = float2(sin(t * (1.1 + fk * .23) + fk * 2.1), sin(t * (.83 + fk * .17) + fk * 4.3)) * ext * .6; | |
| 32 | + float radius = span * (.42 + .1 * sin(t * .7 + fk * 1.9)); | |
| 33 | + float2 d = q - centre; | |
| 34 | + h += (1.8 + 2.6 * c.b.x) * exp(-dot(d, d) / (radius * radius)); | |
| 35 | + } | |
| 36 | + h += (.2 + 1.7 * c.b.y) * kin_sq(.5 + .5 * sin(dot(q, float2(.2, .13)) - c.t * .8)); | |
| 37 | + float2 o = float2(sin(t * 1.7), cos(t * 1.3)) * ext * .4; | |
| 38 | + float r = length(q - o); | |
| 39 | + h += c.b.z * 1.6 * (.5 + .5 * sin(r * 1.3 - c.t * 3)) * exp(-r / span * 1.2); | |
| 40 | + float2 a = float2(sin(t * 2.3 + 1), cos(t * 1.9)) * ext * .35; | |
| 41 | + float ring = abs(length(q - a) - (1 + age * span * .9)) - .9; | |
| 42 | + h += strength * 5 * (1 - smoothstep(-.3f, .3f, ring)); | |
| 43 | + return h; | |
| 44 | + } | |
| 45 | + | |
| 46 | + float3 pinArt(Ctx c, constant NativeFrame &f) { | |
| 47 | + float lean = 1 + .18 * c.uv.y / c.extent.y; | |
| 48 | + float cell = .088 * c.size; | |
| 49 | + float2 q = c.uv * lean / cell, ext = c.extent / cell; | |
| 50 | + float px = c.px * lean / cell; | |
| 51 | + float attack = kin_attack(c, f), age = kin_age(attack), strength = kin_strength(attack, f); | |
| 52 | + float column = floor(q.x - kin_pinSlant * q.y + .5), row = floor(q.y + .5); | |
| 53 | + float2 hole = q - float2(column + kin_pinSlant * row, row); | |
| 54 | + float bounce = kin_pinRelief(q, ext, c, age, strength); | |
| 55 | + // the dark perforated plate, warmed by light thrown back from the raised pins | |
| 56 | + float3 col = deep(.25, f) * .1 + paint(.3, f) * .035 * bounce; | |
| 57 | + col *= .4 + .6 * smoothstep(.1f, .16f, length(hole)); | |
| 58 | + int top = int(floor(q.y + .45)); | |
| 59 | + const float3 light = normalize(float3(-.5, .45, .75)); | |
| 60 | + const float3 halfway = normalize(light + float3(0, 0, 1)); | |
| 61 | + float behind = 0; | |
| 62 | + for (int n = 0; n < 6; ++n) { | |
| 63 | + float j = float(top - n); | |
| 64 | + float2 base = float2(column + kin_pinSlant * j, j); | |
| 65 | + float e = clamp(.25 + kin_pinRelief(base, ext, c, age, strength), 0.f, 5.f); | |
| 66 | + // a pin standing proud of the pin behind it faces the light | |
| 67 | + float facing = n == 0 ? .5f : saturate(.5f + .45f * (e - behind)); | |
| 68 | + behind = e; | |
| 69 | + float2 tip = base + e * float2(kin_pinSlant, 1); | |
| 70 | + float id = hash21(float2(column, j)); | |
| 71 | + float ds = sdSegment(q, base, tip), across = saturate(ds / .065); | |
| 72 | + float shaft = 1 - smoothstep(.065 - px, .065 + px, ds); | |
| 73 | + float along = saturate(dot(q - base, float2(kin_pinSlant, 1)) / max(e * 1.0648f, .01f)); | |
| 74 | + float3 shaftColor = paint(.2 + .06 * e, f) * (.12 + .1 * e * along) * (1.3 - across * across) + paint(.9, f) * .1 * e * along * kin_sq(1 - across); | |
| 75 | + col = mix(col, shaftColor, shaft); | |
| 76 | + float radius = .34 + .02 * e; | |
| 77 | + float2 dv = (q - tip) / radius; | |
| 78 | + float rr = length(dv); | |
| 79 | + float head = 1 - smoothstep(1 - px / radius, 1 + px / radius, rr); | |
| 80 | + float3 normal = float3(dv, sqrt(max(0.f, 1 - rr * rr))); | |
| 81 | + float diffuse = saturate(dot(normal, light)); | |
| 82 | + float spec = pow(saturate(dot(normal, halfway)), 36.f); | |
| 83 | + float glint = c.b.w * 5 * pow(.5 + .5 * sin(c.t * 2.1 + id * 70), 30.f); | |
| 84 | + float3 headColor = paint(.06 + .18 * e + .04 * id, f) * (.2 + .85 * diffuse) * (.22 + .3 * e) * (.55 + .9 * facing); | |
| 85 | + headColor += paint(.97, f) * spec * (.25 + .18 * e + glint) + paint(.95, f) * glint * .15; | |
| 86 | + col = mix(col, headColor, head); | |
| 87 | + } | |
| 88 | + return col; | |
| 89 | + } | |
| 90 | + NATIVE_EFFECT(pinArt) | |
| 91 | + | |
| 92 | + // ---------------------------------------------------------------- 321 Kinetic Rain | |
| 93 | + // A kinetic installation: hundreds of glowing drops hang on fine threads in a deep grid, | |
| 94 | + // seen from slightly above, and their heights trace one morphing surface coloured by | |
| 95 | + // height. Each band shapes its own wave in the surface (bass a broad swell, low mids a | |
| 96 | + // diagonal roll, high mids a tight cross ripple, highs a sparkle on the drops) and each | |
| 97 | + // attack sends a raised, flaring ring wave across the grid. | |
| 98 | + float kin_rainSurface(float2 g, Ctx c, float age, float strength) { | |
| 99 | + float t = c.t * .4 + c.travel * .15; | |
| 100 | + float y = .5 * sin(g.x * .38 + t * .9) * cos(g.y * .33 - t * .6) + .3 * sin((g.x + g.y) * .24 - t * .7); | |
| 101 | + y += c.b.x * 1.1 * sin(length(g - float2(0, 8)) * .42 - c.t * 1.2); | |
| 102 | + y += c.b.y * .75 * sin(g.x * .62 - g.y * .3 + c.t * 1.05); | |
| 103 | + y += c.b.z * .4 * sin(g.y * 1.15 + g.x * .3 - c.t * 2.2); | |
| 104 | + float r = length(g - float2(sin(c.t * .13) * 3, 6.5)); | |
| 105 | + y += strength * 1.6 * exp(-kin_sq(r - age * 13) * .4); | |
| 106 | + return y; | |
| 107 | + } | |
| 108 | + | |
| 109 | + float3 kineticRain(Ctx c, constant NativeFrame &f) { | |
| 110 | + float attack = kin_attack(c, f), age = kin_age(attack), strength = kin_strength(attack, f); | |
| 111 | + float focal = 1.45 * max(1.f, c.extent.y * .82) * c.size; | |
| 112 | + const float pitch = .3, spacing = .72; | |
| 113 | + float cs = cos(pitch), sn = sin(pitch); | |
| 114 | + float2 uv = c.uv; | |
| 115 | + float3 ray = float3(uv.x, uv.y * cs - focal * sn, uv.y * sn + focal * cs); | |
| 116 | + float3 col = paint(.95, f) * .03 + paint(.75, f) * .05 * exp(-kin_sq(uv.y - .25) * 2); | |
| 117 | + for (int k = 0; k < 16; ++k) { | |
| 118 | + float z = 1.1 + float(k) * .8; | |
| 119 | + float x = (floor(z / ray.z * uv.x / spacing) + .5) * spacing; | |
| 120 | + float2 g = float2(x, z); | |
| 121 | + float surface = kin_rainSurface(g, c, age, strength); | |
| 122 | + float y = -2 + surface; | |
| 123 | + float yc = y * cs + z * sn, zc = -y * sn + z * cs; | |
| 124 | + float2 drop = float2(x, yc) * focal / zc; | |
| 125 | + float ty = y + 7, tzc = max(-ty * sn + z * cs, .3f); | |
| 126 | + float2 anchor = float2(x, ty * cs + z * sn) * focal / tzc; | |
| 127 | + float rs = .085 * focal / zc; | |
| 128 | + float d = length(uv - drop); | |
| 129 | + float fade = exp(-float(k) * (.03 + .05 * c.fog)); | |
| 130 | + float3 tint = paint(.08 + surface * .5 + .5 + float(k) * .01, f); | |
| 131 | + float core = smoothstep(rs + c.px, rs * .4, d); | |
| 132 | + float halo = exp(-d * d / (rs * rs * 2.8)); | |
| 133 | + float spec = exp(-length_squared(uv - drop - rs * float2(-.3, .35)) / kin_sq(rs * .3)); | |
| 134 | + float sparkle = c.b.w * 3 * pow(.5 + .5 * sin(c.t * 2.7 + hash21(g) * 80), 24.f); | |
| 135 | + float thickness = .006 * focal / zc, width = max(thickness, c.px * .8); | |
| 136 | + float strand = (1 - smoothstep(width * .5, width * 1.5, sdSegment(uv, drop, anchor))) * thickness / width; | |
| 137 | + float lit = exp(-max(uv.y - drop.y, 0.f) * 1.6); | |
| 138 | + col += fade * (tint * (core * 1.3 + halo * .6 + strand * (.1 + .5 * lit)) + paint(.98, f) * (spec * .7 + sparkle * core)); | |
| 139 | + } | |
| 140 | + return col; | |
| 141 | + } | |
| 142 | + NATIVE_EFFECT(kineticRain) | |
| 143 | + | |
| 144 | + // ---------------------------------------------------------------- 322 Plasma Globe | |
| 145 | + // A large glass plasma globe seen close up: luminous filaments reach from the central | |
| 146 | + // electrode to the glass, wander slowly, fan into branches near the glass and burn bright | |
| 147 | + // where they touch it, inside a violet gas glow. Each band strengthens, thickens and | |
| 148 | + // stirs its own filaments and every attack fires a burst of fresh filaments outward. | |
| 149 | + float3 plasmaGlobe(Ctx c, constant NativeFrame &f) { | |
| 150 | + float attack = kin_attack(c, f), age = kin_age(attack), strength = kin_strength(attack, f); | |
| 151 | + float2 ext = c.extent; | |
| 152 | + float radius = .95 * (min(ext.x, ext.y) + .3 * (max(ext.x, ext.y) - min(ext.x, ext.y))) * c.size; | |
| 153 | + float2 p = c.uv; | |
| 154 | + float r = length(p), a = atan2(p.y, p.x), rn = r / radius; | |
| 155 | + float t = c.t * .3 + c.travel * .1; | |
| 156 | + float inside = 1 - smoothstep(radius - c.px * 2, radius + c.px * 2, r); | |
| 157 | + float3 col = deep(.35, f) * (.18 + .25 * rn * rn) * inside + paint(.25, f) * .1 * exp(-max(r - radius, 0.f) * 1.6) * (1 - inside); | |
| 158 | + col += paint(.3, f) * .1 * inside * fbm2(p * 2.5 + float2(t, -t * .7), 3); | |
| 159 | + for (int k = 0; k < 9; ++k) { | |
| 160 | + float fk = float(k), band = c.b[k & 3]; | |
| 161 | + float tilt = .55 + .45 * sin(t * .4 + fk * 2.3); | |
| 162 | + float reach = radius * (.62 + .36 * tilt) * (.9 + .12 * band); | |
| 163 | + float s = r / reach; | |
| 164 | + float heading = fk * TAU / 9 + .7 * sin(t * (.5 + .07 * fk) + fk * 1.7) + t * .25; | |
| 165 | + float wander = (.3 + .5 * band) * s * sin(rn * 3.1 - c.t * .9 + fk * 3.1) + .06 * s * sin(r * 14 - c.t * 4 + fk * 5); | |
| 166 | + float fork = smoothstep(.4f, 1.f, s); | |
| 167 | + float ending = 1 - smoothstep(.97f, 1.03f, s); | |
| 168 | + float contact = 1 + 3 * exp(-kin_sq((s - 1) * 14)); | |
| 169 | + for (int j = -1; j <= 1; ++j) { | |
| 170 | + float fj = float(j); | |
| 171 | + float branch = heading + wander + fj * fork * (.2 + .06 * sin(t * 2 + fk + fj)) + fork * fork * .08 * sin(r * 24 - c.t * 6 + fk * 3 + fj * 2); | |
| 172 | + float d = abs(kin_wrap(a - branch)) * r; | |
| 173 | + float weight = j == 0 ? 1.f : fork; | |
| 174 | + float width = radius * (.004 + .006 * band) * (1.4 - .7 * s) * (j == 0 ? 1.f : .7f); | |
| 175 | + float core = exp(-d * d / (width * width)), halo = glow(d, width * 6); | |
| 176 | + col += (paint(.92, f) * core + paint(.42 + .12 * fj + .1 * band, f) * halo * .35) * weight * ending * contact * (.45 + 1.4 * band); | |
| 177 | + } | |
| 178 | + } | |
| 179 | + for (int k = 0; k < 6; ++k) { | |
| 180 | + float fk = float(k); | |
| 181 | + float heading = fk * TAU / 6 + t * 1.3 + .4 * sin(fk * 4.1); | |
| 182 | + float reach = radius * (.3 + .7 * sqrt(age)); | |
| 183 | + float s = r / reach; | |
| 184 | + float branch = heading + .25 * s * sin(rn * 5 - c.t * 3 + fk * 2); | |
| 185 | + float d = abs(kin_wrap(a - branch)) * r, width = radius * .009 * (1.3 - .6 * s); | |
| 186 | + col += (paint(.97, f) * exp(-d * d / (width * width)) + paint(.6, f) * glow(d, width * 5) * .4) * (1 - smoothstep(.95f, 1.05f, s)) * strength * 3; | |
| 187 | + } | |
| 188 | + float electrode = radius * .09; | |
| 189 | + col += paint(.88, f) * (fill(r - electrode, c.px * 2) * (.7 + .3 * noise2(p * 40 / radius + c.t)) + glow(r, electrode * 1.4) * (.6 + 1.5 * strength)); | |
| 190 | + col += paint(.8, f) * glow(r - radius, radius * .006) * .5 + paint(.95, f) * .35 * exp(-kin_sq((r - radius * .9) * 30 / radius)) * exp(-kin_sq(kin_wrap(a - 2.2) * 3)); | |
| 191 | + return col; | |
| 192 | + } | |
| 193 | + NATIVE_EFFECT(plasmaGlobe) | |
| 194 | + | |
| 195 | + // ---------------------------------------------------------------- 323 Jacob's Ladder | |
| 196 | + // Rows of Jacob's ladders at three depths: electric arcs bridge pairs of diverging rails, | |
| 197 | + // climb as they stretch and bow upward, flicker and break at the top while the next arc | |
| 198 | + // strikes at the base. Bass thickens the arcs, each band powers its own ladders, highs | |
| 199 | + // make the arcs crackle and every attack strikes a fresh arc at the base with sparks. | |
| 200 | + float3 kin_ladderLayer(float2 uv, float scale, float period, float lift, float layer, Ctx c, constant NativeFrame &f, float age, float strength) { | |
| 201 | + float2 p = uv / scale; | |
| 202 | + p.y -= lift; | |
| 203 | + p.x += (layer == 1 ? period * .5 : layer * .13) + c.travel * (.03 + .02 * layer); | |
| 204 | + float cell = floor(p.x / period + .5); | |
| 205 | + float lx = p.x - cell * period, y = p.y; | |
| 206 | + float seed = hash21(float2(cell, layer * 7.1)); | |
| 207 | + float band = c.b[int(abs(cell) + layer) & 3]; | |
| 208 | + float px = c.px / scale; | |
| 209 | + const float gap = .045, spread = .17, height = 2.1; | |
| 210 | + float3 col = 0.f; | |
| 211 | + float heat = 0; | |
| 212 | + for (int j = 0; j < 2; ++j) { | |
| 213 | + float fj = float(j); | |
| 214 | + float phase = fract(c.t * (.12 + .04 * seed) + fj * .5 + seed); | |
| 215 | + float life = smoothstep(0.f, .05f, phase) * (1 - smoothstep(.84f, .98f, phase)); | |
| 216 | + float ya = .08 + phase * (height - .45); | |
| 217 | + float halfSpan = gap + spread * ya, xs = lx / halfSpan; | |
| 218 | + float bow = (.1 + 1.5 * phase * phase) * halfSpan; | |
| 219 | + float sway = .22 * sin(c.t * 3.1 + fj * 2 + seed * 9) * phase * halfSpan; | |
| 220 | + float crackle = (.008 + .022 * c.b.w) * (sin(xs * 7 + c.t * 17 + fj * 5) + .5 * sin(xs * 19 - c.t * 29 + seed * 30)); | |
| 221 | + float curve = ya + (bow + sway * xs + crackle * (.4 + phase)) * (1 - xs * xs); | |
| 222 | + float d = abs(y - curve) / (1 + abs(2 * bow * xs / halfSpan) * .7); | |
| 223 | + float spanMask = 1 - smoothstep(.98f, 1.04f, abs(xs)); | |
| 224 | + float width = (.026 + .05 * c.b.x) * (1 - .35 * phase); | |
| 225 | + float flicker = .8 + .2 * sin(c.t * 41 + fj * 9 + seed * 40); | |
| 226 | + float energy = life * flicker * (.5 + 1.6 * band) * (1.15 - .4 * phase); | |
| 227 | + col += (paint(.97, f) * exp(-d * d / (width * width * .3)) * 1.5 + paint(.7, f) * exp(-d * d / (width * width * 2.5)) * .7 + paint(.55, f) * glow(d, width * 4) * .45) * spanMask * energy; | |
| 228 | + col += paint(.4, f) * glow(d, .35) * .08 * smoothstep(1.8f, 1.f, abs(xs)) * energy; | |
| 229 | + heat += exp(-kin_sq(y - ya) * 50) * energy; | |
| 230 | + // the arc breaks into sparks at the top | |
| 231 | + float breakup = smoothstep(.8f, .92f, phase) * life; | |
| 232 | + float2 sparkAt = float2(lx, y) - float2(sin(seed * 20 + fj) * halfSpan * .6, curve * 0 + ya + bow + .1 * (phase - .8) * 6); | |
| 233 | + col += paint(.9, f) * glow(length(sparkAt), .02) * breakup * band; | |
| 234 | + } | |
| 235 | + // A fresh arc strikes at the base on each attack and throws sparks upward. | |
| 236 | + { | |
| 237 | + float ya = .05 + age * .45, halfSpan = gap + spread * ya, xs = lx / halfSpan; | |
| 238 | + float curve = ya + (.12 + .06 * sin(xs * 11 + c.t * 29)) * halfSpan * (1 - xs * xs); | |
| 239 | + float d = abs(y - curve), width = .025 + .03 * strength; | |
| 240 | + col += (paint(.99, f) * exp(-d * d / (width * width)) * 1.4 + paint(.65, f) * glow(d, width * 4) * .6) * (1 - smoothstep(.98f, 1.04f, abs(xs))) * strength * 4; | |
| 241 | + heat += exp(-kin_sq(y - ya) * 50) * strength * 3; | |
| 242 | + for (int k = 0; k < 5; ++k) { | |
| 243 | + float3 h = hash33(float3(cell, layer, float(k))); | |
| 244 | + float2 spark = float2((h.x - .5) * .9 * age, .05 + age * (.5 + h.y * 1.1) - age * age * .6); | |
| 245 | + col += paint(.92, f) * glow(length(float2(lx, y) - spark), .014) * strength * 1.6; | |
| 246 | + } | |
| 247 | + } | |
| 248 | + float yc = clamp(y, 0.f, height); | |
| 249 | + float railD = abs(abs(lx) - (gap + spread * yc)) * .986 + max(-y, 0.f) + max(y - height, 0.f); | |
| 250 | + float rail = 1 - smoothstep(.016 - px, .016 + px, railD); | |
| 251 | + float sheen = 1 - kin_sq(saturate(railD / .016)); | |
| 252 | + col = mix(col, paint(.3, f) * (.25 + .35 * sheen) + paint(.95, f) * min(heat, 2.f) * .7 * sheen, rail); | |
| 253 | + col += paint(.5, f) * glow(railD, .025) * (.05 + .25 * min(heat, 2.f)); | |
| 254 | + col += paint(.95, f) * glow(length(float2(abs(lx) - gap - spread * height, y - height)), .03) * .25; | |
| 255 | + float post = sdBox2(float2(abs(lx) - gap, y + .12), float2(.03, .12)); | |
| 256 | + col = mix(col, paint(.2, f) * .3, fill(post, px)); | |
| 257 | + return col; | |
| 258 | + } | |
| 259 | + | |
| 260 | + float3 jacobsLadder(Ctx c, constant NativeFrame &f) { | |
| 261 | + float attack = kin_attack(c, f), age = kin_age(attack), strength = kin_strength(attack, f); | |
| 262 | + float2 uv = c.uv / c.size; | |
| 263 | + float ey = c.extent.y / c.size; | |
| 264 | + float3 col = deep(.25, f) * .16 + paint(.35, f) * .08 * exp(-kin_sq(uv.y / ey + .3) * 1.5); | |
| 265 | + col += kin_ladderLayer(uv, .3 * ey, 1.9, -.9, 0, c, f, age, strength) * .35; | |
| 266 | + col += kin_ladderLayer(uv, .55 * ey, 2.6, -1.25, 1, c, f, age, strength) * .65; | |
| 267 | + col += kin_ladderLayer(uv, ey, 5, -1.08, 2, c, f, age, strength); | |
| 268 | + return col; | |
| 269 | + } | |
| 270 | + NATIVE_EFFECT(jacobsLadder) | |
| 271 | + | |
| 272 | + // ---------------------------------------------------------------- 324 Hanging Mobile | |
| 273 | + // A large balanced hanging mobile in front of a lit wall: nested wire arms turn on their | |
| 274 | + // pivots and carry glowing flat shapes that spin on their own wires, while each translucent | |
| 275 | + // shape throws a soft coloured shadow on the wall behind. Each arm swings with its own | |
| 276 | + // band, shapes brighten with their arm's band and every attack sets one arm spinning. | |
| 277 | + constant float kin_mobileFocal = 3.2, kin_mobileWall = 1.4; | |
| 278 | + constant float3 kin_mobileLight = float3(-1.6, 2.6, -9); | |
| 279 | + | |
| 280 | + float2 kin_mobileProject(float3 p) { return p.xy * kin_mobileFocal / (kin_mobileFocal + p.z); } | |
| 281 | + float2 kin_mobileShadow(float3 p) { | |
| 282 | + float3 s = p + (p - kin_mobileLight) * (kin_mobileWall - p.z) / (p.z - kin_mobileLight.z); | |
| 283 | + return kin_mobileProject(s); | |
| 284 | + } | |
| 285 | + float kin_mobileOutline(float2 q, int kind) { | |
| 286 | + if (kind == 0) return length(q) - 1; | |
| 287 | + if (kind == 1) return max(length(q - float2(.6, 0)), length(q + float2(.6, 0))) - 1.1; | |
| 288 | + if (kind == 2) return max(length(q) - 1, .85 - length(q - float2(.5, .3))); | |
| 289 | + float2 r = abs(q); return max(r.x * .866 + q.y * .5, -q.y) - .55; | |
| 290 | + } | |
| 291 | + float3 kin_mobileArm(float3 pivot, float angle, float tilt, float left, float right, thread float3 &leftEnd) { | |
| 292 | + float2 dir = float2(cos(angle), sin(angle)); | |
| 293 | + leftEnd = pivot + float3(-dir.x * left, tilt * left, -dir.y * left); | |
| 294 | + return pivot + float3(dir.x * right, -tilt * right, dir.y * right); | |
| 295 | + } | |
| 296 | + | |
| 297 | + | |
| 298 | + // ---------------------------------------------------------------- 325 Prism Carousel | |
| 299 | + // Glass prisms ride a slowly turning carousel and spin on their own axes, each splitting a | |
| 300 | + // light beam into a broad spectral fan that sweeps across the dark wall above and glints | |
| 301 | + // in the glossy floor below. Each prism follows its own band (its fan widens and | |
| 302 | + // brightens), highs sparkle in the glass and every attack flicks the front prisms so | |
| 303 | + // their fans sweep across the wall. | |
| 304 | + float3 kin_prismFans(float2 p, float yC, float rx, float ry, float flick, Ctx c, constant NativeFrame &f) { | |
| 305 | + float3 col = 0.f; | |
| 306 | + float texture = .82 + .18 * noise2(p * 9); | |
| 307 | + for (int k = 0; k < 6; ++k) { | |
| 308 | + float fk = float(k), band = c.b[k & 3]; | |
| 309 | + float around = fk * TAU / 6 + c.t * .09 + c.travel * .06; | |
| 310 | + float near = .5 - .5 * sin(around); | |
| 311 | + float2 origin = float2(rx * cos(around), yC + ry * sin(around)); | |
| 312 | + float spin = c.t * (.2 + .045 * fk) + fk * 1.7 + band * .9 + flick * near * near; | |
| 313 | + float heading = PI * .5 + 1.15 * sin(spin); | |
| 314 | + float spread = .2 + .08 * sin(spin * 1.3 + fk) + .22 * band; | |
| 315 | + float2 d = p - origin; | |
| 316 | + float dist = length(d); | |
| 317 | + float s = kin_wrap(atan2(d.y, d.x) - heading) / spread; | |
| 318 | + float reach = .5 + .35 * near + .4 * band; | |
| 319 | + float fan = smoothstep(1.f, .7f, abs(s)) * smoothstep(.12f, .45f, dist) * exp(-kin_sq(max(dist - reach, 0.f)) * 1.2); | |
| 320 | + float edge = exp(-kin_sq((abs(s) - .85) * 9)) * .5; | |
| 321 | + col += (paint(.5 + .5 * s, f) * (1 + edge) + paint(.97, f) * edge * .3) * fan * (.35 + 1.2 * band) * (.6 + .4 * near) * texture / (.6 + dist * .9); | |
| 322 | + } | |
| 323 | + return col; | |
| 324 | + } | |
| 325 | + | |
| 326 | + float3 prismCarouselScene(Ctx c, constant NativeFrame &f) { | |
| 327 | + float attack = kin_attack(c, f), age = kin_age(attack), strength = kin_strength(attack, f); | |
| 328 | + float2 p = c.uv / c.size, ext = c.extent / c.size; | |
| 329 | + float yC = -ext.y * .5, rx = min(ext.x * .66, 1.25f), ry = .2; | |
| 330 | + float flick = 2.6 * strength * sin(age * PI) + .5 * strength; | |
| 331 | + float3 col = paint(.95, f) * .03 + deep(.9, f) * .06 * (1 - smoothstep(-1.f, 1.f, p.y / ext.y)); | |
| 332 | + float floorY = yC - ry - .06; | |
| 333 | + if (p.y > floorY) { | |
| 334 | + col += kin_prismFans(p, yC, rx, ry, flick, c, f); | |
| 335 | + } else { | |
| 336 | + float2 m = float2(p.x + .015 * sin(p.y * 50 + c.t), 2 * floorY - p.y); | |
| 337 | + col += kin_prismFans(m, yC, rx, ry, flick, c, f) * .3 * exp((p.y - floorY) * 1.5); | |
| 338 | + col *= .8 + .2 * sin(p.y * 90 / ext.y); | |
| 339 | + } | |
| 340 | + // the carousel: a glowing rim, spokes and the turning prisms | |
| 341 | + float2 e = (p - float2(0, yC)) / float2(rx, ry); | |
| 342 | + float rim = abs(length(e) - 1) * ry; | |
| 343 | + col += paint(.85, f) * glow(rim, .005) * .5 + paint(.3, f) * glow(rim, .04) * .12; | |
| 344 | + float hub = length(e); | |
| 345 | + float spokes = abs(sin((atan2(e.y, e.x) - c.t * .09) * 3)) * hub * ry; | |
| 346 | + col += paint(.7, f) * glow(spokes, .003) * .25 * step(hub, 1.f); | |
| 347 | + for (int k = 0; k < 6; ++k) { | |
| 348 | + float fk = float(k), band = c.b[k & 3]; | |
| 349 | + float around = fk * TAU / 6 + c.t * .09 + c.travel * .06; | |
| 350 | + float near = .5 - .5 * sin(around); | |
| 351 | + float2 origin = float2(rx * cos(around), yC + ry * sin(around)); | |
| 352 | + float spin = c.t * (.2 + .045 * fk) + fk * 1.7 + band * .9 + flick * near * near; | |
| 353 | + float scale = .085 * (.7 + .45 * near); | |
| 354 | + float2 q = p - origin - float2(0, scale * .55); | |
| 355 | + float2 face = float2(q.x / max(abs(cos(spin)), .25f), q.y) / scale; | |
| 356 | + float tri = max(abs(face.x) * .866 + face.y * .5, -face.y) - .5; | |
| 357 | + float body = fill(tri * scale, c.px * 1.5); | |
| 358 | + float glint = c.b.w * 2.5 * pow(.5 + .5 * sin(c.t * 3 + fk * 11), 12.f); | |
| 359 | + float3 glass = paint(.5 + .35 * face.x, f) * (.35 + .6 * band) + paint(.97, f) * (glint + .5 * smoothstep(.15f, -.2f, face.x * sin(spin) + face.y * .4)); | |
| 360 | + col = mix(col, glass, body * .85); | |
| 361 | + col += paint(.95, f) * glow(tri * scale, .006) * (.4 + .7 * band + strength * 3 * near * near); | |
| 362 | + } | |
| 363 | + return col; | |
| 364 | + } | |
| 365 | + // The reviewed look, with a faint palette floor so tall frames stay covered when zoomed out. | |
| 366 | + float3 prismCarousel(Ctx c, constant NativeFrame &f) { return max(prismCarouselScene(c, f), paint(.9, f) * .06); } | |
| 367 | + NATIVE_EFFECT(prismCarousel) | |
| 368 | + | |
| 369 | + // ---------------------------------------------------------------- 326 Cone Splash | |
| 370 | + // A low close-up across a vibrating membrane covered in pools of coloured paint. Paint | |
| 371 | + // leaps off it in crowns with lobed rims, flung droplets and a central jet that rises as | |
| 372 | + // each crown collapses, while ripples run through the wet paint. Each paint colour rides | |
| 373 | + // its own band (its splashes leap higher and its pools pulse), bass flexes the membrane | |
| 374 | + // and every attack throws a large crown up from the front of the membrane. | |
| 375 | + constant float kin_splashEye = .55; | |
| 376 | + | |
| 377 | + float3 kin_splashCrown(float2 uv, float horizon, float focal, float2 site, float age, float scale, float hue, float seed, Ctx c, constant NativeFrame &f) { | |
| 378 | + float3 col = 0.f; | |
| 379 | + float rc = scale * (.1 + .5 * sqrt(age)); | |
| 380 | + float crown = scale * .9 * sin(PI * min(age * 1.6 + .12, 1.f)) * (1 - .35 * age); | |
| 381 | + float across = (uv.x * site.y / focal - site.x) / rc; | |
| 382 | + if (abs(across) < 1.02) { | |
| 383 | + float sx = sqrt(max(0.f, 1 - across * across)); | |
| 384 | + for (int side = 0; side < 2; ++side) { | |
| 385 | + float facing = side == 0 ? 1.f : -1.f; | |
| 386 | + float z = site.y + facing * rc * sx; | |
| 387 | + float theta = atan2(facing * sx, across); | |
| 388 | + float rim = crown * (.5 + .5 * pow(.5f + .5f * cos(9 * theta + seed * 20), 3.f)); | |
| 389 | + float vb = horizon - kin_splashEye * focal / z, vt = horizon + (rim - kin_splashEye) * focal / z; | |
| 390 | + float sheet = smoothstep(vb - c.px, vb + c.px, uv.y) * (1 - smoothstep(vt - c.px * 2, vt + c.px, uv.y)); | |
| 391 | + float height = saturate((uv.y - vb) / max(vt - vb, 1e-4f)); | |
| 392 | + float3 tint = paint(hue, f) * (.35 + .55 * (.5 + .5 * across) + .4 * height) * (side == 0 ? .55f : 1.f); | |
| 393 | + col = mix(col, tint, sheet * (side == 0 ? .7f : .9f)); | |
| 394 | + col += paint(hue + .1, f) * glow(uv.y - vt, .004 * focal / z) * .6 * step(vb, uv.y); | |
| 395 | + } | |
| 396 | + } | |
| 397 | + float flight = max(age - .3, 0.f); | |
| 398 | + float rd = rc + flight * scale * .9; | |
| 399 | + float lift = crown * .9 + flight * scale * 2.4 - flight * flight * scale * 4; | |
| 400 | + float across2 = (uv.x * site.y / focal - site.x) / rd; | |
| 401 | + if (flight > 0 && abs(across2) < 1.1 && lift > -.1) { | |
| 402 | + for (int side = 0; side < 2; ++side) { | |
| 403 | + float facing = side == 0 ? 1.f : -1.f; | |
| 404 | + float theta = atan2(facing * sqrt(max(0.f, 1 - across2 * across2)), across2); | |
| 405 | + float lobe = round(theta * 9 / TAU + seed * 20 / TAU) - seed * 20 / TAU; | |
| 406 | + float a = lobe * TAU / 9; | |
| 407 | + float3 drop = float3(site.x + rd * cos(a), lift, site.y + rd * sin(a)); | |
| 408 | + float2 s = float2(drop.x, drop.y - kin_splashEye) * focal / drop.z + float2(0, horizon); | |
| 409 | + float r = scale * .045 * focal / drop.z; | |
| 410 | + float d = length(uv - s); | |
| 411 | + col += paint(hue, f) * (smoothstep(r + c.px, r * .5, d) * .9 + glow(d, r * 1.5) * .25) + paint(.95, f) * exp(-length_squared(uv - s - r * float2(-.3, .3)) / kin_sq(r * .3)) * .5; | |
| 412 | + } | |
| 413 | + } | |
| 414 | + float jet = max(age - .45, 0.f) / .55; | |
| 415 | + if (jet > 0) { | |
| 416 | + float hj = scale * 1.7 * sin(PI * jet); | |
| 417 | + float2 b = float2(site.x, -kin_splashEye) * focal / site.y + float2(0, horizon); | |
| 418 | + float2 tp = float2(site.x, hj - kin_splashEye) * focal / site.y + float2(0, horizon); | |
| 419 | + float width = scale * .05 * focal / site.y; | |
| 420 | + float d = sdSegment(uv, b, tp); | |
| 421 | + col += paint(hue + .05, f) * (smoothstep(width + c.px, width * .3, d) * .9 + glow(d, width) * .2); | |
| 422 | + float dt = length(uv - tp - float2(0, width * 1.6)); | |
| 423 | + col += paint(hue, f) * smoothstep(width * 1.6 + c.px, width * .6, dt) + paint(.95, f) * glow(dt, width * .5) * .3; | |
| 424 | + } | |
| 425 | + return col; | |
| 426 | + } | |
| 427 | + | |
| 428 | + float3 coneSplashScene(Ctx c, constant NativeFrame &f) { | |
| 429 | + float attack = kin_attack(c, f), age = kin_age(attack), strength = kin_strength(attack, f); | |
| 430 | + float2 uv = c.uv; | |
| 431 | + float focal = 1.5 * c.size * max(1.f, c.extent.y * .8); | |
| 432 | + float horizon = c.extent.y * .22; | |
| 433 | + // backdrop: dark studio with soft coloured light pools above the membrane's rim | |
| 434 | + float3 col = paint(.95, f) * .025; | |
| 435 | + for (int k = 0; k < 4; ++k) { | |
| 436 | + float2 o = float2(sin(c.t * .05 + float(k) * 1.9) * c.extent.x * .8, horizon + .35 + .35 * sin(float(k) * 2.3 + c.t * .04)); | |
| 437 | + col += paint(float(k) * .25 + .05, f) * .06 * exp(-length_squared(uv - o) * 2.2); | |
| 438 | + } | |
| 439 | + float2 sites[6]; float ages[6], scales[6], hues[6], seeds[6]; | |
| 440 | + for (int k = 0; k < 5; ++k) { | |
| 441 | + float clock = c.t * .1 + float(k) / 5; | |
| 442 | + float id = floor(clock); | |
| 443 | + float3 h = hash33(float3(id, float(k), 3.7)); | |
| 444 | + int paintIndex = int(h.z * 3.99); | |
| 445 | + sites[k] = float2((h.x * 2 - 1) * .9 * c.extent.x, 1.7 + h.y * 2.6); | |
| 446 | + ages[k] = fract(clock); | |
| 447 | + scales[k] = (.8 + .35 * h.y) * (.65 + 1.2 * c.b[paintIndex]); | |
| 448 | + hues[k] = float(paintIndex) * .25 + .05; | |
| 449 | + seeds[k] = h.x + h.y; | |
| 450 | + } | |
| 451 | + sites[5] = float2(sin(c.t * .05) * .6 * c.extent.x, 1.8); | |
| 452 | + ages[5] = age; scales[5] = strength * 2.4; hues[5] = .8; seeds[5] = .3; | |
| 453 | + if (uv.y < horizon) { | |
| 454 | + float z = kin_splashEye * focal / (horizon - uv.y); | |
| 455 | + float2 g = float2(uv.x * z / focal, z); | |
| 456 | + float2 m = g * .5 + float2(0, c.travel * .08); | |
| 457 | + m += .7 * float2(fbm2(m * .7 + float2(c.t * .02, 0), 2), fbm2(m * .7 + 5.2, 2)); | |
| 458 | + float marble = noise2(m * 1.4) * 4; | |
| 459 | + int paintIndex = min(int(marble), 3); | |
| 460 | + float seam = smoothstep(0.f, .12f, .5f - abs(fract(marble) - .5f)); | |
| 461 | + float band = c.b[paintIndex]; | |
| 462 | + float ripple = 0; | |
| 463 | + for (int k = 0; k < 6; ++k) { | |
| 464 | + float r = length(g - sites[k]); | |
| 465 | + float front = scales[k] * (.2 + 2.2 * ages[k]); | |
| 466 | + ripple += sin((r - front) * 16) * exp(-kin_sq(r - front) * 5) * (1 - ages[k]) * min(scales[k], 1.2f); | |
| 467 | + } | |
| 468 | + ripple += c.b.x * .7 * sin(length(g - float2(0, 4)) * 5 - c.t * 3) + band * .5 * sin(g.x * 3 + g.y * 2 - c.t * 2); | |
| 469 | + float fresnel = smoothstep(1.f, 7.f, z); | |
| 470 | + float sheen = pow(saturate(.55 + .45 * sin(g.x * 1.3 + ripple * 1.8 + c.t * .2)), 5.f) * (.25 + .75 * fresnel); | |
| 471 | + float fade = exp(-z * (.05 + .08 * c.fog)); | |
| 472 | + float3 tint = paint(float(paintIndex) * .25 + .05, f); | |
| 473 | + float3 surface = (tint * seam * (.07 + .2 * band + .05 * ripple) + tint * sheen * seam * (.6 + .6 * band) + paint(.97, f) * pow(sheen, 4.f) * .35) * fade; | |
| 474 | + col = mix(col, surface, smoothstep(0.f, .015f, horizon - uv.y)); | |
| 475 | + } | |
| 476 | + for (int k = 0; k < 6; ++k) { | |
| 477 | + if (scales[k] < .01) continue; | |
| 478 | + col += kin_splashCrown(uv, horizon, focal, sites[k], ages[k], scales[k], hues[k], seeds[k], c, f) * (k == 5 ? 1.4f : 1.f); | |
| 479 | + } | |
| 480 | + return col; | |
| 481 | + } | |
| 482 | + // The reviewed look, with a faint palette floor so tall frames stay covered when zoomed out. | |
| 483 | + float3 coneSplash(Ctx c, constant NativeFrame &f) { return max(coneSplashScene(c, f), paint(.9, f) * .06); } | |
| 484 | + NATIVE_EFFECT(coneSplash) | |
| 485 | + | |
| 486 | + // ---------------------------------------------------------------- 327 Wind Tunnel | |
| 487 | + // A side view into a wind tunnel: dyed smoke streamlines flow past a cylinder, an airfoil | |
| 488 | + // and a small post, bending around them and rolling up into alternating vortex streets in | |
| 489 | + // their wakes. Bass raises the flow speed (the streamlines tighten and stream faster), the | |
| 490 | + // low and high mids strengthen the shedding behind the two cylinders, highs shimmer in the | |
| 491 | + // wakes and every attack sheds one strong vortex behind the cylinder. | |
| 492 | + float kin_windVortex(float2 p, float2 centre, float strength, float core) { | |
| 493 | + float2 d = p - centre; | |
| 494 | + return strength * .5 * log(dot(d, d) + core * core); | |
| 495 | + } | |
| 496 | + | |
| 497 | + float3 windTunnel(Ctx c, constant NativeFrame &f) { | |
| 498 | + float attack = kin_attack(c, f), age = kin_age(attack), strength = kin_strength(attack, f); | |
| 499 | + float2 p = c.uv / c.size, ext = c.extent / c.size; | |
| 500 | + float flow = 1 + .35 * c.b.x; | |
| 501 | + const int count = 3; | |
| 502 | + float2 centres[count] = {float2(-ext.x * .55, ext.y * .28), float2(ext.x * .3, ext.y * .5), float2(-ext.x * .05, -ext.y * .4)}; | |
| 503 | + float radii[count] = {.24, .13, .12}; | |
| 504 | + float shed[count] = {.5 + 1.2 * c.b.y, .4 + 1.2 * c.b.z, .25 + .6 * c.b.z}; | |
| 505 | + // smoke wobble in the wakes | |
| 506 | + float2 q = p; | |
| 507 | + for (int o = 0; o < count; ++o) { | |
| 508 | + float behind = smoothstep(0.f, .4f, p.x - centres[o].x) * exp(-kin_sq((p.y - centres[o].y) / (radii[o] * 3))); | |
| 509 | + q += behind * (.025 + .05 * c.b.w) * float2(noise2(p * 6 - float2(c.t * 2, 0)) - .5, noise2(p * 6 + 7.3 - float2(c.t * 2, 0)) - .5); | |
| 510 | + } | |
| 511 | + float psi = q.y * flow, along = q.x; | |
| 512 | + for (int o = 0; o < count; ++o) { | |
| 513 | + float2 d = q - centres[o]; | |
| 514 | + float r2 = max(dot(d, d), 1e-4f), R2 = radii[o] * radii[o]; | |
| 515 | + if (o == 2) { d = rot(d, .18); d.x *= .32; r2 = max(dot(d, d), 1e-4f); } | |
| 516 | + psi -= flow * R2 * d.y / r2; | |
| 517 | + along += R2 * d.x / r2; | |
| 518 | + float clock = c.t * .32 + float(o) * .37; | |
| 519 | + for (int j = 0; j < 4; ++j) { | |
| 520 | + float n = floor(clock) - float(j); | |
| 521 | + float ageV = fract(clock) + float(j); | |
| 522 | + float sign = n - 2 * floor(n * .5) < .5 ? 1.f : -1.f; | |
| 523 | + float2 pos = centres[o] + float2(radii[o] * (1.3 + ageV * 2.4), sign * radii[o] * .5); | |
| 524 | + float fade = smoothstep(0.f, .7f, ageV) * (1 - smoothstep(2.6f, 4.f, ageV)); | |
| 525 | + psi += kin_windVortex(q, pos, sign * shed[o] * fade * radii[o], radii[o] * .45); | |
| 526 | + } | |
| 527 | + } | |
| 528 | + psi += kin_windVortex(q, centres[2] + float2(-.03, .02), .12 + .25 * c.b.z, .05); | |
| 529 | + float2 kickAt = centres[0] + float2(radii[0] * (1.3 + age * 4), radii[0] * .4); | |
| 530 | + psi += kin_windVortex(q, kickAt, strength * 1.4 * radii[0], radii[0] * .4); | |
| 531 | + float spacing = .075; | |
| 532 | + float lines = psi / spacing, index = floor(lines + .5); | |
| 533 | + float aa = max(fwidth(lines), 1e-4f); | |
| 534 | + float offset = abs(lines - index); | |
| 535 | + float core = 1 - smoothstep(.06f, .06f + aa * 1.5f, offset); | |
| 536 | + float halo = exp(-offset * offset * 18); | |
| 537 | + float dash = .55 + .45 * sin(along * 7 - c.t * 2.2 + index * 1.7); | |
| 538 | + float sheet = .5 + .5 * cos(TAU * lines); | |
| 539 | + float hue = fract(index * .137) * .7 + .15; | |
| 540 | + float3 col = deep(.3, f) * .1 + paint(hue, f) * (.06 + .1 * sheet) + paint(hue, f) * (core * (.5 + .5 * dash) + halo * .35 * dash) * (.8 + .4 * c.b.x); | |
| 541 | + col += paint(.95, f) * glow(length(p - kickAt), .06) * strength * 1.2; | |
| 542 | + col += paint(.9, f) * c.b.w * .6 * pow(noise2(p * 30 + float2(-c.t * 3, 0)), 8.f) * core; | |
| 543 | + // obstacles: dark solids with bright rims and a stagnation glint | |
| 544 | + for (int o = 0; o < count; ++o) { | |
| 545 | + float2 d = p - centres[o]; | |
| 546 | + float sd; | |
| 547 | + if (o == 2) { | |
| 548 | + float2 l = rot(d, .18); | |
| 549 | + float x = saturate(l.x / .72 + .5); | |
| 550 | + float thick = .55 * (.2969 * sqrt(x) - .126 * x - .3516 * x * x + .2843 * x * x * x - .1015 * x * x * x * x); | |
| 551 | + sd = max(abs(l.y) - thick * .72, abs(l.x) - .36); | |
| 552 | + } else sd = length(d) - radii[o]; | |
| 553 | + float solid = fill(sd, c.px); | |
| 554 | + col = mix(col, deep(.2, f) * .15, solid); | |
| 555 | + col += paint(.85, f) * glow(sd, .006) * .5 + paint(.95, f) * glow(length(d + float2(radii[o], 0)), .02) * .3 * (1 - solid); | |
| 556 | + } | |
| 557 | + return col; | |
| 558 | + } | |
| 559 | + NATIVE_EFFECT(windTunnel) | |
| 560 | + | |
| 561 | + // ---------------------------------------------------------------- 328 Tensegrity Pulse | |
| 562 | + // A slowly turning tensegrity sculpture: six glowing struts float apart, held only by a | |
| 563 | + // web of taut cables, with guy cables running out to the room. Each band tightens its own | |
| 564 | + // cable group (the cables glow and ring in fast standing waves), bass makes the struts | |
| 565 | + // burn brighter and every attack plucks a cable hard while a ripple runs through the | |
| 566 | + // whole structure. | |
| 567 | + constant float3 kin_tensVertex[12] = { | |
| 568 | + float3(0, 1, 1.618034), float3(0, 1, -1.618034), float3(0, -1, 1.618034), float3(0, -1, -1.618034), | |
| 569 | + float3(1.618034, 0, 1), float3(-1.618034, 0, 1), float3(1.618034, 0, -1), float3(-1.618034, 0, -1), | |
| 570 | + float3(1, 1.618034, 0), float3(1, -1.618034, 0), float3(-1, 1.618034, 0), float3(-1, -1.618034, 0)}; | |
| 571 | + constant int kin_tensCable[48] = {0, 4, 0, 5, 0, 8, 0, 10, 1, 6, 1, 7, 1, 8, 1, 10, 2, 4, 2, 5, 2, 9, 2, 11, | |
| 572 | + 3, 6, 3, 7, 3, 9, 3, 11, 4, 8, 4, 9, 5, 10, 5, 11, 6, 8, 6, 9, 7, 10, 7, 11}; | |
| 573 | + | |
| 574 | + float3 tensegrityPulse(Ctx c, constant NativeFrame &f) { | |
| 575 | + float attack = kin_attack(c, f), age = kin_age(attack), strength = kin_strength(attack, f); | |
| 576 | + float2 uv = c.uv; | |
| 577 | + float unit = min(c.extent.x, c.extent.y) * c.size; | |
| 578 | + float yaw = c.t * .1 + c.travel * .06, pitch = .45 + .2 * sin(c.t * .05); | |
| 579 | + float cy = cos(yaw), sy = sin(yaw), cp = cos(pitch), sp = sin(pitch); | |
| 580 | + float2 screen[12]; float depth[12]; | |
| 581 | + for (int i = 0; i < 12; ++i) { | |
| 582 | + float3 v = kin_tensVertex[i]; | |
| 583 | + v *= 1 + strength * .12 * sin(age * 9 - float(i) * 1.3); | |
| 584 | + v = float3(v.x * cy + v.z * sy, v.y, -v.x * sy + v.z * cy); | |
| 585 | + v = float3(v.x, v.y * cp - v.z * sp, v.y * sp + v.z * cp); | |
| 586 | + float s = 6 / (6 + v.z); | |
| 587 | + screen[i] = v.xy * s * unit * .46; | |
| 588 | + depth[i] = s; | |
| 589 | + } | |
| 590 | + float3 col = deep(.3, f) * .12 + paint(.25, f) * .08 * exp(-dot(uv, uv) / (unit * unit) * .6); | |
| 591 | + int plucked = int(floor(c.t * .37)) % 24; | |
| 592 | + float lineWidth = max(.0035 * unit, c.px * .7); | |
| 593 | + for (int m = 0; m < 24; ++m) { | |
| 594 | + float2 a = screen[kin_tensCable[2 * m]], b = screen[kin_tensCable[2 * m + 1]]; | |
| 595 | + float band = c.b[m & 3]; | |
| 596 | + float2 ab = b - a; | |
| 597 | + float len = length(ab); | |
| 598 | + float2 dir = ab / len; | |
| 599 | + float2 rel = uv - a; | |
| 600 | + float along = saturate(dot(rel, dir) / len); | |
| 601 | + float side = dir.x * rel.y - dir.y * rel.x; | |
| 602 | + float pluck = m == plucked ? strength * 2.5 : 0.f; | |
| 603 | + float amp = len * (.004 + .035 * band + .05 * pluck) * sin(PI * along * (1 + float(m % 3))) * cos(c.t * (7 + float(m % 5)) + float(m)); | |
| 604 | + float d = length(float2(max(abs(dot(rel, dir) - len * .5) - len * .5, 0.f), side - amp)); | |
| 605 | + float shade = .6 + .4 * (depth[kin_tensCable[2 * m]] + depth[kin_tensCable[2 * m + 1]] - 1.6); | |
| 606 | + col += paint(.55 + .35 * band + .1 * float(m & 3) * .5, f) * ((1 - smoothstep(lineWidth * .5, lineWidth * 1.5, d)) * (.5 + 1.1 * band + pluck) + glow(d, lineWidth * 4) * (.12 + .5 * band + pluck)) * shade; | |
| 607 | + } | |
| 608 | + // guy cables out to the room | |
| 609 | + for (int g = 0; g < 6; ++g) { | |
| 610 | + int v = g == 0 ? 8 : g == 1 ? 10 : g == 2 ? 9 : g == 3 ? 11 : g == 4 ? 4 : 7; | |
| 611 | + float2 anchor = float2(g == 4 ? 1.1 : g == 5 ? -1.1 : (g % 2 == 0 ? .6 : -.6), g < 2 ? 1.1 : g < 4 ? -1.1 : .1) * c.extent * 1.05; | |
| 612 | + float d = sdSegment(uv, screen[v], anchor); | |
| 613 | + float band = c.b[g & 3]; | |
| 614 | + col += paint(.3 + .15 * float(g & 3), f) * ((1 - smoothstep(lineWidth * .4, lineWidth * 1.2, d)) * (.25 + .6 * band) + glow(d, lineWidth * 5) * (.05 + .2 * band)); | |
| 615 | + } | |
| 616 | + for (int s = 0; s < 6; ++s) { | |
| 617 | + int i0 = 2 * s, i1 = 2 * s + 1; | |
| 618 | + float2 a = screen[i0], b = screen[i1]; | |
| 619 | + float persp = (depth[i0] + depth[i1]) * .5; | |
| 620 | + float radius = .03 * unit * persp; | |
| 621 | + float d = sdSegment(uv, a, b); | |
| 622 | + float across = saturate(d / radius); | |
| 623 | + float body = 1 - smoothstep(radius - c.px, radius + c.px, d); | |
| 624 | + float3 strut = paint(.82 + .08 * float(s & 1), f) * (.6 + .9 * c.b.x) * (1.2 - across * across) * (.5 + .6 * persp); | |
| 625 | + col = mix(col, strut, body); | |
| 626 | + col += paint(.7, f) * glow(d - radius, radius * .9) * (.2 + .5 * c.b.x); | |
| 627 | + col += paint(.95, f) * (glow(length(uv - a), radius * .8) + glow(length(uv - b), radius * .8)) * .35; | |
| 628 | + } | |
| 629 | + return col; | |
| 630 | + } | |
| 631 | + NATIVE_EFFECT(tensegrityPulse) | |
| 632 | + | |
| 633 | + // ---------------------------------------------------------------- 329 Shadow Modulator | |
| 634 | + // A kinetic light sculpture in an empty room: perforated metal screens, tinted glass | |
| 635 | + // panels and rods orbit and spin around a bare lamp, and the room's walls and floor are | |
| 636 | + // swept by their moving projections: magnified grids of light spots, coloured panes and | |
| 637 | + // rod shadows. Each band turns its own screen and tints its own light, and every attack | |
| 638 | + // swings an extra perforated screen through the beam. | |
| 639 | + float kin_modulatorPattern(float2 l, int kind, float t) { | |
| 640 | + if (kind == 0) { float4 h = hexCell(l * 14); return smoothstep(.3f, .24f, length(h.xy)); } | |
| 641 | + if (kind == 1) return smoothstep(.15f, .3f, abs(fract(length(l) * 9 - t * .2) - .5)); | |
| 642 | + if (kind == 2) { float2 g = abs(fract(l * 6) - .5); return smoothstep(.32f, .28f, max(g.x, g.y)); } | |
| 643 | + return smoothstep(.2f, .3f, abs(fract(atan2(l.y, l.x) * 1.91 + length(l) * 4) - .5)); | |
| 644 | + } | |
| 645 | + | |
| 646 | + float3 shadowModulator(Ctx c, constant NativeFrame &f) { | |
| 647 | + float attack = kin_attack(c, f), age = kin_age(attack), strength = kin_strength(attack, f); | |
| 648 | + float focal = 1.25 * c.size; | |
| 649 | + float3 dir = float3(c.uv, focal); | |
| 650 | + // room: back wall, floor, ceiling and side walls | |
| 651 | + float tb = 4.2 / dir.z; | |
| 652 | + float tf = dir.y < 0 ? -1.25 / dir.y : 1e5; | |
| 653 | + float tc = dir.y > 0 ? 2.6 / dir.y : 1e5; | |
| 654 | + float ts = 3.8 / max(abs(dir.x), 1e-4f); | |
| 655 | + float tw = min(min(tb, ts), min(tf, tc)); | |
| 656 | + float3 hit = dir * tw; | |
| 657 | + float3 normal = tw == tb ? float3(0, 0, -1) : tw == tf ? float3(0, 1, 0) : tw == tc ? float3(0, -1, 0) : float3(-sign(dir.x), 0, 0); | |
| 658 | + float3 lamp = float3(0, .35, 2.2); | |
| 659 | + float t = c.t * .2 + c.travel * .07; | |
| 660 | + float3 toLamp = lamp - hit; | |
| 661 | + float dist2 = dot(toLamp, toLamp); | |
| 662 | + float lambert = saturate(dot(normal, toLamp) * rsqrt(dist2)); | |
| 663 | + float3 transmit = float3(1); | |
| 664 | + float3 seen = float3(0); float seenAlpha = 0; | |
| 665 | + for (int k = 0; k < 5; ++k) { | |
| 666 | + float fk = float(k); | |
| 667 | + float band = k < 4 ? c.b[k] : 0.f; | |
| 668 | + float orbit = k < 4 ? fk * TAU / 4 + t * (.6 + .15 * fk) : -1.9 + .6 * sin(t * .7) + 2.6 * strength * (1 + sin(age * PI)); | |
| 669 | + float reach = k < 4 ? .38 + .07 * fk : .3; | |
| 670 | + float3 centre = lamp + float3(reach * cos(orbit), .3 * sin(fk * 1.7 + t * .5), reach * sin(orbit)); | |
| 671 | + float spin = orbit + t * (1.1 + .3 * fk) * (k & 1 ? -1.f : 1.f) + band * 1.4; | |
| 672 | + float lean = .35 * sin(t * .8 + fk * 2.1); | |
| 673 | + float3 n = normalize(float3(cos(spin) * cos(lean), sin(lean), sin(spin) * cos(lean))); | |
| 674 | + float3 e1 = normalize(cross(n, float3(0, 1, 0))), e2 = cross(e1, n); | |
| 675 | + float size = k < 4 ? .2 + .03 * fk : .17; | |
| 676 | + int kind = k < 4 ? k : 0; | |
| 677 | + float3 tint = k == 1 || k == 3 ? paint(.15 + .3 * fk, f) * (.8 + .8 * band) : float3(1); | |
| 678 | + // shadow on the room | |
| 679 | + float3 ray = hit - lamp; | |
| 680 | + float denom = dot(ray, n); | |
| 681 | + float s = dot(centre - lamp, n) / (abs(denom) > 1e-4 ? denom : 1e-4); | |
| 682 | + if (s > 0 && s < 1) { | |
| 683 | + float3 at = lamp + ray * s - centre; | |
| 684 | + float2 l = float2(dot(at, e1), dot(at, e2)) / size; | |
| 685 | + float blur = .03 + .05 * (1 - s); | |
| 686 | + float inside = smoothstep(1 + blur, 1 - blur, length(l)); | |
| 687 | + float open = kin_modulatorPattern(l, kind, c.t); | |
| 688 | + float3 pass = k == 1 || k == 3 ? mix(tint, float3(1.4), open) : float3(open * 1.2); | |
| 689 | + transmit *= mix(float3(1), pass, inside); | |
| 690 | + } | |
| 691 | + // the sculpture itself as seen by the camera | |
| 692 | + float sv = dot(centre, n) / dot(dir, n); | |
| 693 | + if (sv > 0 && sv < tw) { | |
| 694 | + float3 at = dir * sv - centre; | |
| 695 | + float2 l = float2(dot(at, e1), dot(at, e2)) / size; | |
| 696 | + float inside = smoothstep(1.02f, .98f, length(l)); | |
| 697 | + float open = kin_modulatorPattern(l, kind, c.t); | |
| 698 | + float lit = abs(dot(n, normalize(lamp - dir * sv))); | |
| 699 | + float3 face = (k == 1 || k == 3 ? tint * .5 : paint(.3, f) * .25) * (.4 + lit) + paint(.85, f) * .3 * pow(lit, 8.f); | |
| 700 | + float cover = inside * (1 - open * .85) * (1 - seenAlpha); | |
| 701 | + seen += face * cover + paint(.9, f) * glow(abs(length(l) - 1) * size, .004) * .3; | |
| 702 | + seenAlpha += cover; | |
| 703 | + } | |
| 704 | + } | |
| 705 | + // rods sweeping around the lamp | |
| 706 | + float shadowRods = 1; | |
| 707 | + for (int k = 0; k < 3; ++k) { | |
| 708 | + float fk = float(k); | |
| 709 | + float around = fk * TAU / 3 - t * (.8 + .2 * c.b[(k + 1) & 3]); | |
| 710 | + float3 a = lamp + float3(.6 * cos(around), -.55, .6 * sin(around)); | |
| 711 | + float3 b = a + float3(.25 * sin(t + fk), 1.2, .25 * cos(t * .7 + fk)); | |
| 712 | + float3 u = hit - lamp, v = b - a, w0 = lamp - a; | |
| 713 | + float uu = dot(u, u), uv = dot(u, v), vv = dot(v, v), uw = dot(u, w0), vw = dot(v, w0); | |
| 714 | + float den = max(uu * vv - uv * uv, 1e-5f); | |
| 715 | + float sc = saturate((uv * vw - vv * uw) / den), tcl = saturate((uu * vw - uv * uw) / den); | |
| 716 | + float d = length(w0 + u * sc - v * tcl); | |
| 717 | + float r = .018 * (1 + 5 * (1 - sc)); | |
| 718 | + shadowRods *= mix(1.f, smoothstep(r * .5, r * 1.5, d), step(.05f, sc)); | |
| 719 | + } | |
| 720 | + float3 lampColor = paint(.7, f); | |
| 721 | + float3 col = lampColor * (1.6 * lambert / (.4 + dist2 * .35)) * transmit * shadowRods + deep(.4, f) * .05; | |
| 722 | + col = mix(col, seen, saturate(seenAlpha)); | |
| 723 | + float2 lampScreen = lamp.xy * focal / lamp.z; | |
| 724 | + col += paint(.9, f) * glow(length(c.uv - lampScreen), .03) * .8; | |
| 725 | + return col; | |
| 726 | + } | |
| 727 | + NATIVE_EFFECT(shadowModulator) |
Sources/PulseCanvas/Resources/NativeExpansionMaterial.metal added
| 1 | + // Original PulseCanvas designs 340–349. Full-frame materials in motion: liquids, films and crafts with vivid color, in the spirit of the kept Flow designs (Silk Cascade, Ink Bloom, Oil Marble, Chrome Metaballs) but with new materials. | |
| 2 | + // Every design is Form scale: the material itself moves with procedural time and the music; | |
| 3 | + // audio terms are zero at zero Chaos. | |
| 4 | + | |
| 5 | + // ---------------------------------------------------------------- shared helpers | |
| 6 | + // A wandering point for attack events: a smooth path of the music clock, so each attack | |
| 7 | + // lands somewhere new without anything jumping between frames. | |
| 8 | + float2 mat_eventPoint(Ctx c, float seed, float reach) { | |
| 9 | + return float2(sin(c.m * 2.3 + seed * 4.1), sin(c.m * 1.7 + seed * 2.7 + 1.3)) * c.extent / c.size * reach; | |
| 10 | + } | |
| 11 | + // Picks a changing subset of elements for each attack; continuous in the music clock. | |
| 12 | + float mat_pick(float seed, Ctx c) { | |
| 13 | + float s = .5 + .5 * sin(c.m * 3.7 + seed * TAU); | |
| 14 | + return s * s * s; | |
| 15 | + } | |
| 16 | + | |
| 17 | + // ---------------------------------------------------------------- 340 Acrylic Cells | |
| 18 | + // A poured acrylic skin: bold paint layers stream across the canvas, cells open in the | |
| 19 | + // cell-forming streams and white lacing webs the thin layers. Bass opens the cells, low-mids | |
| 20 | + // push the pour, high-mids thicken the lacing, highs freckle micro-cells; attacks open a | |
| 21 | + // bloom of fresh cells. | |
| 22 | + float acr_hue(float index) { return fract(index * .382 + .13); } | |
| 23 | + float3 acr_layer(float index, constant NativeFrame &f) { | |
| 24 | + float kind = hash11(index * 2.71 + 8.3); | |
| 25 | + if (kind < .28) return deep(acr_hue(index) + .5, f) * .1; | |
| 26 | + return paint(acr_hue(index), f) * (.42 + .22 * kind); | |
| 27 | + } | |
| 28 | + float3 acrylicCells(Ctx c, constant NativeFrame &f) { | |
| 29 | + float2 p = c.uv / c.size; | |
| 30 | + float t = c.t; | |
| 31 | + float2 base = p * .85 + float2(t * .03 + c.travel * .06, -t * .012); | |
| 32 | + float2 warp = float2(fbm2(base * .9 + float2(0, t * .02), 3), fbm2(base * .9 + float2(4.3, 1.7 - t * .018), 3)); | |
| 33 | + float2 q = base + (warp - .5) * (1.35 + c.b.y * 1.6); | |
| 34 | + float3 white = mix(paint(.55, f), paint(.95, f), .5) * .7; | |
| 35 | + // Stacked pour layers run along the flow. | |
| 36 | + float s = q.y * 1.1 + q.x * .42 + .3 * sin(q.x * 1.2 + t * .04); | |
| 37 | + float layer = s * 2.3; | |
| 38 | + float index = floor(layer), fr = fract(layer); | |
| 39 | + float aa = clamp(c.px / c.size * 9, .004f, .2f); | |
| 40 | + float3 color = mix(acr_layer(index, f), acr_layer(index + 1, f), smoothstep(1 - aa, 1.f, fr)); | |
| 41 | + float boundary = min(fr, 1 - fr); | |
| 42 | + color = mix(color, white, exp(-boundary / .018) * step(.5, hash11(index * 5.3 + 1)) * .75); | |
| 43 | + // Cells: voronoi along the flow, open only in the cell-forming streams. | |
| 44 | + float2 along = normalize(float2(1.1, -.42)); | |
| 45 | + float2 cq = float2(dot(q, along) * 2.6, dot(q, float2(-along.y, along.x)) * 4.4); | |
| 46 | + float4 v = voronoi(cq, .9, t * .12); | |
| 47 | + float2 seed = hash22(v.zw); | |
| 48 | + float2 site = v.zw + .5 + .45 * sin(t * .12 + seed * TAU); | |
| 49 | + float2 local = cq - site; | |
| 50 | + float region = smoothstep(.36, .6, noise2(q * .8 + 11.3)); | |
| 51 | + float2 event = mat_eventPoint(c, .3, .6); | |
| 52 | + float near = exp(-dot(p - event, p - event) * 2.2); | |
| 53 | + float pick = mat_pick(seed.x, c); | |
| 54 | + float radius = (.1 + .26 * seed.y) * region * (.7 + c.b.x * 1.5); | |
| 55 | + radius += (.16 + .12 * seed.y) * c.hit * (pick + near * 1.6); | |
| 56 | + radius = min(radius, .46f); | |
| 57 | + float present = smoothstep(0.f, .03f, radius); | |
| 58 | + float aac = c.px / c.size * 4.4 * 1.5; | |
| 59 | + float inside = (1 - smoothstep(radius - aac, radius + aac, v.x)) * present; | |
| 60 | + float3 cellColor = paint(acr_hue(index) + .5 + seed.x * .25, f) * .8; | |
| 61 | + float inner = 1 - smoothstep(radius * .45 - aac, radius * .45 + aac, v.x); | |
| 62 | + cellColor = mix(cellColor, seed.x > .5 ? deep(acr_hue(index), f) * .12 : paint(acr_hue(index) + .25, f) * .9, inner * step(.3, seed.x)); | |
| 63 | + float2 lit = local + float2(.3, -.3) * radius; | |
| 64 | + float dome = exp(-dot(lit, lit) / max(radius * radius * .1, 1e-4f)); | |
| 65 | + cellColor += white * dome * .45; | |
| 66 | + float rim = exp(-abs(v.x - radius) / (.018 + .02 * c.b.x)) * present; | |
| 67 | + float halo = exp(-max(v.x - radius, 0.f) / .05) * (1 - inside) * present; | |
| 68 | + color = mix(color * (1 - .75 * halo), cellColor, inside); | |
| 69 | + color += white * rim * (.4 + c.hit * (pick + near) * 1.6); | |
| 70 | + // Lacing and micro-cells on a finer web. | |
| 71 | + float4 web = voronoi(cq * 2.3 + 5.1, .85, t * .1); | |
| 72 | + float lace = 1 - smoothstep(.012, .045 + c.b.z * .07, web.y - web.x); | |
| 73 | + float laceRegion = smoothstep(.42, .68, noise2(q * 1.1 + 4.7)) * (1 - inside); | |
| 74 | + color = mix(color, white, lace * laceRegion * (.45 + c.b.z * 1.1)); | |
| 75 | + float freckle = 1 - smoothstep(.04 + .12 * c.b.w, .07 + .12 * c.b.w, web.x); | |
| 76 | + color = mix(color, paint(hash21(web.zw), f) * .8, freckle * smoothstep(.02f, .1f, c.b.w) * (1 - inside) * region); | |
| 77 | + // Wet gloss: a slow window reflection across the pour. | |
| 78 | + float gloss = exp(-pow(dot(p, float2(.6, .8)) - 1.3 * sin(t * .045), 2.f) * 2.5); | |
| 79 | + color += white * gloss * .08; | |
| 80 | + return color; | |
| 81 | + } | |
| 82 | + NATIVE_EFFECT(acrylicCells) | |
| 83 | + | |
| 84 | + // ---------------------------------------------------------------- 341 Molten Glass | |
| 85 | + // Thick canes of molten glass are pulled across a dark furnace. Each cane has an | |
| 86 | + // incandescent core, a cooling glossy skin and twisted threads inside. Bass stretches the | |
| 87 | + // canes and necks them thin, low-mids sway them, high-mids light the threads, highs glint | |
| 88 | + // trapped seeds; attacks fold a kink into the canes and flare it white-hot. | |
| 89 | + float3 moltenGlass(Ctx c, constant NativeFrame &f) { | |
| 90 | + float2 p = c.uv / c.size; | |
| 91 | + float2 ext = c.extent / c.size; | |
| 92 | + float t = c.t; | |
| 93 | + float stretch = 1 + c.b.x * .9; | |
| 94 | + float3 color = deep(.03, f) * .04 + paint(.03, f) * .06 * fbm2(p * 1.4 + float2(t * .02, -t * .05), 3); | |
| 95 | + float2 event = mat_eventPoint(c, 1.7, .7); | |
| 96 | + const int count = 5; | |
| 97 | + for (int k = 0; k < count; ++k) { | |
| 98 | + float fk = float(k); | |
| 99 | + float seed = hash11(fk * 3.71 + .37); | |
| 100 | + float side = (k & 1) == 0 ? 1. : -1.; | |
| 101 | + float angle = side * (.12 + .3 * seed) + .1 * sin(t * .04 + fk * 1.3); | |
| 102 | + float2 center = float2(.25 * sin(fk * 2.1), (fk - 2) / 2 * ext.y * .78); | |
| 103 | + float2 q = rot(p - center, -angle); | |
| 104 | + float2 eq = rot(event - center, -angle); | |
| 105 | + float pick = mat_pick(seed, c); | |
| 106 | + float level = c.b[k % 4]; | |
| 107 | + float x = q.x / stretch; | |
| 108 | + float amp = .08 + .06 * seed + c.b.y * .16; | |
| 109 | + float frequency = 1.1 + .9 * seed; | |
| 110 | + float phase = t * (.16 + .08 * seed) + seed * 9; | |
| 111 | + float yc = amp * sin(x * frequency + phase) + .05 * sin(x * 2.7 - phase * 1.3); | |
| 112 | + float slope = (amp * frequency * cos(x * frequency + phase) + .135 * cos(x * 2.7 - phase * 1.3)) / stretch; | |
| 113 | + float kink = exp(-pow((q.x - eq.x) / .4, 2.f)) * c.hit * (.45 + pick); | |
| 114 | + yc += kink * .35 * sin((q.x - eq.x) * 5); | |
| 115 | + float neckAt = sin(t * .05 + seed * 6) * ext.x * .6; | |
| 116 | + float neck = exp(-pow((q.x - neckAt) / (.55 * stretch), 2.f)) * (.15 + c.b.x * .5); | |
| 117 | + float width = (.13 + .07 * seed) * (1 - neck); | |
| 118 | + float u = (q.y - yc) / sqrt(1 + slope * slope) / width; | |
| 119 | + float aa = c.px / c.size / width * 1.5; | |
| 120 | + float body = 1 - smoothstep(1 - aa, 1 + aa, abs(u)); | |
| 121 | + float uc = clamp(u, -1.f, 1.f); | |
| 122 | + float nz = sqrt(max(0.f, 1 - uc * uc)); | |
| 123 | + float heat = (.6 + .3 * sin(x * .8 - t * .1 + seed * 7) + .55 * level) * (1 - neck * .6) + kink * 2.4; | |
| 124 | + // Glowing glass: emission peaks inside the cane, so there is no dark side. | |
| 125 | + float emission = heat * (.3 + .7 * nz * nz); | |
| 126 | + float twist = asin(uc) * 2 + x * (7 + 4 * seed) * side - t * (.35 + seed * .3); | |
| 127 | + float strand = smoothstep(.35f, .75f, sin(twist)) * nz; | |
| 128 | + float3 glass = paint(.12 + .72 * min(emission, 1.2f), f) * emission * 1.05; | |
| 129 | + glass += paint(.88, f) * strand * (.08 + c.b.z * .9) * heat; | |
| 130 | + float3 n = float3(0, uc, nz); | |
| 131 | + float specular = pow(max(0.f, dot(n, normalize(float3(0, .58, .81)))), 220.f); | |
| 132 | + glass += paint(.95, f) * specular * 1.3; | |
| 133 | + glass += paint(.35, f) * pow(1 - nz, 8.f) * .35 * heat; | |
| 134 | + // Trapped seeds (tiny bubbles) glint with the highs. | |
| 135 | + float segment = floor(x * 2.5 + seed * 17); | |
| 136 | + float2 bubbleSeed = hash22(float2(segment, fk)); | |
| 137 | + float2 bubble = float2((fract(x * 2.5 + seed * 17) - .2 - .6 * bubbleSeed.x) * .4 * stretch, (u - (bubbleSeed.y - .5) * 1.2) * width); | |
| 138 | + glass += paint(.95, f) * glow(length(bubble) - .01, .005) * (.04 + c.b.w * 2.4) * nz; | |
| 139 | + // Translucent: canes behind still glow through, dimmed by the glass in front. | |
| 140 | + float outside = max(abs(u) - 1, 0.f) * width; | |
| 141 | + color += paint(.2 + .3 * min(heat, 1.f), f) * exp(-outside * 10) * .14 * heat * (1 - body); | |
| 142 | + color = color * (1 - .6 * body) + glass * body; | |
| 143 | + } | |
| 144 | + return color; | |
| 145 | + } | |
| 146 | + NATIVE_EFFECT(moltenGlass) | |
| 147 | + | |
| 148 | + // ---------------------------------------------------------------- 342 Liquid Crystal | |
| 149 | + // A nematic film between crossed polarisers: interference colours set by the film's | |
| 150 | + // retardation, dark brushes radiating from drifting defects. Each band twists the director | |
| 151 | + // in its own region; attacks tear a defect pair out of the uniform field. | |
| 152 | + float lc_pair(float2 p, float2 center, float2 offset) { | |
| 153 | + // +1/2 at center + offset and -1/2 at center - offset. Exactly zero when the offset is | |
| 154 | + // zero, so pairs can be born and annihilate continuously. | |
| 155 | + float2 a = p - center - offset, b = p - center + offset; | |
| 156 | + return .5 * atan2(a.y * b.x - a.x * b.y, a.x * b.x + a.y * b.y); | |
| 157 | + } | |
| 158 | + float3 liquidCrystal(Ctx c, constant NativeFrame &f) { | |
| 159 | + float2 p = c.uv / c.size; | |
| 160 | + float2 ext = c.extent / c.size; | |
| 161 | + float t = c.t; | |
| 162 | + float theta = 1.3 * fbm2(p * .8 + float2(t * .02, -t * .015), 3) + .3 * sin(p.x * .8 + t * .06) + .25 * cos(p.y * 1.1 - t * .05); | |
| 163 | + theta += .22 * noise2(p * 4 + float2(t * .05, 0)); | |
| 164 | + bool wide = ext.x >= ext.y; | |
| 165 | + int columns = wide ? 4 : 2, rows = wide ? 2 : 4; | |
| 166 | + for (int i = 0; i < 8; ++i) { | |
| 167 | + float fi = float(i); | |
| 168 | + int column = i % columns, row = i / columns; | |
| 169 | + float2 seed = hash22(float2(fi, 3.1)); | |
| 170 | + float2 cell = float2((float(column) + .5) / float(columns), (float(row) + .5) / float(rows)) * 2 - 1; | |
| 171 | + float2 at = cell * ext * .85 + (seed - .5) * .5 + float2(sin(t * (.05 + seed.x * .04) + fi * 2.1), cos(t * (.045 + seed.y * .04) + fi * 1.3)) * .3; | |
| 172 | + float charge = ((column + row) & 1) == 0 ? .5 : -.5; | |
| 173 | + if (i == 1) charge = 1; | |
| 174 | + if (i == 6) charge = -1; | |
| 175 | + theta += charge * atan2(p.y - at.y, p.x - at.x); | |
| 176 | + } | |
| 177 | + for (int k = 0; k < 4; ++k) { | |
| 178 | + float angle = float(k) * 1.5708 + .7 + t * .03; | |
| 179 | + float2 at = float2(cos(angle), sin(angle)) * ext * .55; | |
| 180 | + theta += c.b[k] * 1.5 * exp(-dot(p - at, p - at) * 1.1); | |
| 181 | + } | |
| 182 | + float flare = 0; | |
| 183 | + for (int j = 0; j < 3; ++j) { | |
| 184 | + float fj = float(j); | |
| 185 | + float pick = mat_pick(fj * .31 + .1, c); | |
| 186 | + float2 at = mat_eventPoint(c, fj * 2.3, .6); | |
| 187 | + float separation = (c.hit * .5 + c.e * .1) * (.3 + pick); | |
| 188 | + float2 direction = float2(cos(fj * 2.1 + t * .1), sin(fj * 2.1 + t * .1)); | |
| 189 | + theta += lc_pair(p, at, direction * separation); | |
| 190 | + flare += c.hit * (.3 + pick) * exp(-dot(p - at, p - at) * 4); | |
| 191 | + } | |
| 192 | + float polarizer = t * .04; | |
| 193 | + float brush = sin(2 * (theta - polarizer)); | |
| 194 | + float intensity = brush * brush; | |
| 195 | + float retardation = 1 + 5.5 * fbm2(p * .6 + float2(t * .015, 3.7), 3) + .5 * length(p) + .12 * sin(t * .07); | |
| 196 | + float3 color = filmColor(retardation, f) * (.02 + .9 * pow(intensity, 1.3f)); | |
| 197 | + color += paint(.9, f) * pow(intensity, 12.f) * .1; | |
| 198 | + color += paint(.85, f) * flare * intensity * .9; | |
| 199 | + return color; | |
| 200 | + } | |
| 201 | + NATIVE_EFFECT(liquidCrystal) | |
| 202 | + | |
| 203 | + // ---------------------------------------------------------------- 343 Incense Drift | |
| 204 | + // Ribbons of incense smoke rise from below the frame, twist as thin lit sheets and curl | |
| 205 | + // into loops on rising eddies before melting into a lit haze. Each plume follows its band, | |
| 206 | + // bass thickens them all, low-mids spin the eddies; attacks curl a new loop. | |
| 207 | + float3 incenseDrift(Ctx c, constant NativeFrame &f) { | |
| 208 | + float2 p = c.uv / c.size; | |
| 209 | + float2 ext = c.extent / c.size; | |
| 210 | + float t = c.t; | |
| 211 | + float h = clamp(p.y / ext.y * .5 + .5, 0.f, 1.f); | |
| 212 | + float2 q = p + curl2(p * 1.1 + float2(0, -t * .12)) * (.015 + .09 * h * h); | |
| 213 | + for (int j = 0; j < 4; ++j) { | |
| 214 | + float fj = float(j); | |
| 215 | + float cycle = t * .022 + fj * .25; | |
| 216 | + float life = fract(cycle); | |
| 217 | + float2 seed = hash22(float2(floor(cycle), fj)); | |
| 218 | + float2 at = float2((seed.x - .5) * 1.7 * ext.x, mix(-.4, 1.1, life) * ext.y); | |
| 219 | + float spin = (1.6 + c.b.y * 1.6) * sin(PI * life) * (seed.y < .5 ? -1. : 1.); | |
| 220 | + float2 d = q - at; | |
| 221 | + q = at + rot(d, spin * exp(-dot(d, d) * 5)); | |
| 222 | + } | |
| 223 | + float2 event = mat_eventPoint(c, .7, .55); | |
| 224 | + float2 de = q - event; | |
| 225 | + q = event + rot(de, c.hit * 3.4 * exp(-dot(de, de) * 7)); | |
| 226 | + float boost = 1 + c.hit * 2.5 * exp(-dot(p - event, p - event) * 6); | |
| 227 | + float haze = fbm2(q * 1.3 + float2(0, -t * .04), 4); | |
| 228 | + float3 color = deep(.1 + h * .1, f) * .35 + paint(.3 + haze * .3, f) * haze * haze * (.06 + .28 * h); | |
| 229 | + for (int k = 0; k < 4; ++k) { | |
| 230 | + float fk = float(k); | |
| 231 | + float x0 = ((fk + .5) / 4 * 2 - 1) * ext.x * .82 + .12 * sin(t * .05 + fk * 2); | |
| 232 | + float sway = (.03 + .25 * h * h) * sin(q.y * 2.1 - t * .35 + fk * 1.9) + .1 * h * sin(q.y * 4.3 - t * .6 + fk); | |
| 233 | + float dx = q.x - x0 - sway; | |
| 234 | + float level = c.b[k]; | |
| 235 | + float width = (.012 + .11 * h * h) * (1 + c.b.x * 1.4); | |
| 236 | + float twist = q.y * 5 - t * .8 + fk * 1.7; | |
| 237 | + float strands = 0; | |
| 238 | + for (int i = 0; i < 3; ++i) strands += glow(dx - width * sin(twist + float(i) * 2.094), .0035 + .012 * h); | |
| 239 | + float sheet = exp(-dx * dx / (width * width * 1.2 + 1e-4)); | |
| 240 | + float fade = 1 - .7 * smoothstep(.6f, 1.f, h); | |
| 241 | + float3 tint = paint(.2 + fk * .17 + h * .35, f); | |
| 242 | + color += tint * (strands * .32 + sheet * .25) * fade * (.45 + level * 1.9) * boost; | |
| 243 | + } | |
| 244 | + return color; | |
| 245 | + } | |
| 246 | + NATIVE_EFFECT(incenseDrift) | |
| 247 | + | |
| 248 | + // ---------------------------------------------------------------- 344 Shibori Bloom | |
| 249 | + // Resist-dyed cloth: indigo ground with arashi pleats, kumo blooms of feathered rings and | |
| 250 | + // radial creases, dye bleeding outward over time. Each bloom bleeds with its band; attacks | |
| 251 | + // blot a fresh ring through the picked blooms. | |
| 252 | + float3 shiboriBloom(Ctx c, constant NativeFrame &f) { | |
| 253 | + float2 p = c.uv / c.size; | |
| 254 | + float t = c.t; | |
| 255 | + float2 cloth = p + float2(c.travel * .04, t * .004); | |
| 256 | + float2 d = rot(cloth, .55); | |
| 257 | + float pleat = d.y * 6.5 + .45 * sin(d.x * 1.7 + t * .06) + .5 * fbm2(d * float2(.6, 3.5), 3); | |
| 258 | + float fold = abs(fract(pleat) - .5) * 2; | |
| 259 | + float3 indigo = deep(0, f) * .45 + paint(0, f) * .07; | |
| 260 | + float3 color = mix(paint(.55, f) * .4, indigo, smoothstep(.04f, .3f, fold + .15 * noise2(d * float2(2, 14)))); | |
| 261 | + // Kumo blooms. | |
| 262 | + float2 bq = cloth * .8; | |
| 263 | + float4 v = voronoi(bq, .75, 0); | |
| 264 | + float2 seed = hash22(v.zw); | |
| 265 | + float2 site = v.zw + .5 + .375 * sin(seed * TAU); | |
| 266 | + float2 local = (bq - site) / .8; | |
| 267 | + float r = length(local); | |
| 268 | + float level = c.b[int(seed.x * 3.99)]; | |
| 269 | + float pick = mat_pick(seed.y, c); | |
| 270 | + float radius = (.36 + .14 * seed.y) * (1 + level * .25); | |
| 271 | + float2 direction = local / max(r, 1e-4f); | |
| 272 | + float wobble = noise2(direction * 2.2 + seed * 13) - .5; | |
| 273 | + float rr = r * (1 + .2 * wobble) / radius; | |
| 274 | + float ringPhase = rr * 5 - t * .1 * (1 + seed.x) - level * .8; | |
| 275 | + float ring = .5 + .5 * cos(ringPhase * TAU) + .3 * (noise2(local * 11 + seed * 7) - .5); | |
| 276 | + float bleed = .08 + level * .4 + rr * .15; | |
| 277 | + float resist = smoothstep(.62 - bleed, .62 + bleed * .4, ring); | |
| 278 | + float a = atan2(local.y, local.x); | |
| 279 | + float spokes = 10 + floor(seed.y * 6); | |
| 280 | + float crease = smoothstep(.55f, 1.f, abs(cos(a * spokes * .5))) * smoothstep(.05f, .3f, rr); | |
| 281 | + resist *= 1 - .75 * crease; | |
| 282 | + resist = max(resist, smoothstep(.2f, .08f, rr)); | |
| 283 | + float3 dye = paint(.3 + seed.x * .45, f) * (.6 + level * .6); | |
| 284 | + float3 bloom = mix(indigo, dye, smoothstep(.3f, .7f, sin(ringPhase * PI * .5 + seed.y * 4) * .5 + .5) * .8); | |
| 285 | + bloom = mix(bloom, paint(.9, f) * .72, resist); | |
| 286 | + float blot = c.hit * (.35 + pick) * exp(-pow((rr - (1.05 - c.hit * .8)) * 7, 2.f)); | |
| 287 | + bloom += paint(.85, f) * blot * 1.1; | |
| 288 | + float inside = 1 - smoothstep(.85f, 1.05f, rr); | |
| 289 | + float edgeHalo = exp(-pow((rr - 1) * 5, 2.f)) * (.2 + level * .5); | |
| 290 | + color = mix(color, bloom, inside); | |
| 291 | + color = mix(color, paint(.5, f) * .5, edgeHalo * (1 - inside * .5)); | |
| 292 | + float weave = 1 + .06 * sin(cloth.x * 260) * sin(cloth.y * 260) * smoothstep(.01f, .004f, c.px / c.size); | |
| 293 | + return color * weave; | |
| 294 | + } | |
| 295 | + NATIVE_EFFECT(shiboriBloom) | |
| 296 | + | |
| 297 | + // ---------------------------------------------------------------- 345 Heat Haze | |
| 298 | + // A false-colour thermal view of a convection tank: rolls turn across the frame, hot plumes | |
| 299 | + // rise where they meet and carry mushroom thermals upward through shimmering isotherms. | |
| 300 | + // Bass heats every plume, each plume also follows its own band, highs add shimmer; attacks | |
| 301 | + // release a hot bubble at the plume roots. | |
| 302 | + float3 heatHaze(Ctx c, constant NativeFrame &f) { | |
| 303 | + float2 p = c.uv / c.size; | |
| 304 | + float2 ext = c.extent / c.size; | |
| 305 | + float t = c.t; | |
| 306 | + float h = p.y / ext.y * .5 + .5; | |
| 307 | + float hc = clamp(h, 0.f, 1.f); | |
| 308 | + float2 shimmer = float2(fbm2(p * 2.4 + float2(0, -t * .3), 3), fbm2(p * 2.4 + float2(5.1, -t * .26), 3)) - .5; | |
| 309 | + float2 q = p + shimmer * (.08 + c.b.w * .28); | |
| 310 | + const float span = .8; | |
| 311 | + float xr = q.x / span + t * .01; | |
| 312 | + float T = .42 - .42 * hc; | |
| 313 | + // Counter-rotating convection rolls wrap warm streaks into spirals between the plumes. | |
| 314 | + float roll = floor(xr * .5); | |
| 315 | + float2 rl = float2((xr * .5 - roll - .5) * 2, q.y / ext.y * 1.1); | |
| 316 | + float rr = length(rl); | |
| 317 | + float turn = (int(roll) & 1) == 0 ? 1. : -1.; | |
| 318 | + float spiral = sin(atan2(rl.y, rl.x) + rr * 9 * turn - t * .7 * turn); | |
| 319 | + T += (.12 + c.b.y * .14) * spiral * smoothstep(1.05f, .25f, rr) * smoothstep(0.f, .2f, rr); | |
| 320 | + T += .1 * cos(PI * xr) * sin(PI * hc); | |
| 321 | + // Plumes rise where neighbouring rolls meet. | |
| 322 | + float plume = floor(xr * .5 + .5); | |
| 323 | + float dxr = (xr * .5 - plume) * 2 * span; | |
| 324 | + float seed = hash11(plume * 1.7 + .3); | |
| 325 | + float level = c.b[int(abs(plume)) % 4]; | |
| 326 | + float sway = .08 * hc * sin(q.y * 2.3 - t * .4 + seed * 6) + .05 * hc * sin(q.y * 5 - t * .7 + seed * 3); | |
| 327 | + float dx = dxr - sway; | |
| 328 | + float wide = .05 + .1 * hc; | |
| 329 | + float strength = .28 + .18 * seed + c.b.x * .45 + level * .35; | |
| 330 | + T += strength * exp(-dx * dx / (wide * wide)) * (1 - .45 * hc); | |
| 331 | + for (int j = 0; j < 2; ++j) { | |
| 332 | + float life = fract(t * .05 + seed + float(j) * .5); | |
| 333 | + float y = mix(-1.3, 1.3, life) * ext.y; | |
| 334 | + float2 head = float2(dx, q.y - y); | |
| 335 | + float capWidth = .12 + .14 * life; | |
| 336 | + float cap = exp(-head.x * head.x / (capWidth * capWidth) - head.y * head.y / .014); | |
| 337 | + float curl = exp(-pow(abs(head.x) - capWidth * .95, 2.f) / .005 - pow(head.y + .06, 2.f) / .008); | |
| 338 | + T += (cap * .42 + curl * .3) * strength; | |
| 339 | + } | |
| 340 | + float pick = mat_pick(seed, c); | |
| 341 | + float bubbleY = -ext.y * .72 + (1 - c.hit) * .45; | |
| 342 | + T += c.hit * (.55 + pick * 1.4) * exp(-(dx * dx + pow(q.y - bubbleY, 2.f)) / .03); | |
| 343 | + T += .06 * (fbm2(q * 3 + float2(0, -t * .2), 3) - .5); | |
| 344 | + float temp = clamp(T, 0.f, 1.3f); | |
| 345 | + float3 color = paint(.02 + temp * .9, f) * (.025 + .95 * smoothstep(.08f, .7f, temp) + .35 * max(temp - .8f, 0.f)); | |
| 346 | + float iso = fract(T * 10); | |
| 347 | + float isoLine = 1 - smoothstep(.02f, .1f, min(iso, 1 - iso)); | |
| 348 | + color *= 1 - .4 * isoLine; | |
| 349 | + color += paint(.85, f) * isoLine * .1 * temp * temp; | |
| 350 | + return color; | |
| 351 | + } | |
| 352 | + NATIVE_EFFECT(heatHaze) | |
| 353 | + | |
| 354 | + // ---------------------------------------------------------------- 346 Gel Overlap | |
| 355 | + // Translucent colour gels lie on a light table; where they overlap their colours multiply. | |
| 356 | + // Each gel drifts and thickens with its band, the cut edges catch the light, and the music | |
| 357 | + // clock slides a long strip over the stack; attacks shove it and flash its edges. | |
| 358 | + float gel_sdf(float2 p, int k, float3 seed, float2 ext) { | |
| 359 | + if (k == 1 || k == 4) return length(p) - (.42 + .22 * seed.x); | |
| 360 | + if (k == 2) return sdBox2(p, float2(2.2 * max(ext.x, ext.y), .17 + .05 * seed.y)) - .02; | |
| 361 | + return sdBox2(p, float2(.48 + .3 * seed.y, .34 + .2 * seed.z)) - .06; | |
| 362 | + } | |
| 363 | + float3 gelOverlap(Ctx c, constant NativeFrame &f) { | |
| 364 | + float2 p = c.uv / c.size; | |
| 365 | + float2 ext = c.extent / c.size; | |
| 366 | + float t = c.t; | |
| 367 | + float px = c.px / c.size * 1.5; | |
| 368 | + float glowField = .18 + 1.05 * exp(-dot(p / ext, p / ext) * 1.3); | |
| 369 | + float3 table = (paint(0, f) + paint(.25, f) + paint(.5, f) + paint(.75, f)) * .25; | |
| 370 | + float3 filter = float3(1); | |
| 371 | + float cover = 0, shade = 1; | |
| 372 | + float3 edges = 0; | |
| 373 | + for (int k = 0; k < 7; ++k) { | |
| 374 | + float fk = float(k); | |
| 375 | + float3 seed = hash33(float3(fk, 2.7, 9.1)); | |
| 376 | + float level = k < 6 ? c.b[k % 4] : 0.; | |
| 377 | + float2 center; | |
| 378 | + float angle; | |
| 379 | + int shape = k; | |
| 380 | + if (k < 6) { | |
| 381 | + float2 home = (seed.xy - .5) * ext * 1.3; | |
| 382 | + float2 drift = float2(sin(t * (.04 + seed.z * .03) + fk * 1.7), cos(t * (.035 + seed.x * .03) + fk * 2.3)) * ext * .35; | |
| 383 | + float2 push = float2(cos(fk * 2.4), sin(fk * 2.4)) * level * .55; | |
| 384 | + center = home + drift + push; | |
| 385 | + angle = t * .03 * (seed.z - .5) + fk; | |
| 386 | + } else { | |
| 387 | + // The slider: a long strip carried across by the music clock. | |
| 388 | + center = float2((fract(c.m * .3 + .5) * 2 - 1) * (ext.x + 1.4) + c.hit * .35, 0); | |
| 389 | + angle = 1.35; | |
| 390 | + shape = 2; | |
| 391 | + } | |
| 392 | + float2 local = rot(p - center, angle); | |
| 393 | + float d = gel_sdf(local, shape, seed, ext); | |
| 394 | + float shadow = 1 - smoothstep(-.02f, .09f, gel_sdf(rot(p - center - float2(.05, -.06), angle), shape, seed, ext)); | |
| 395 | + float mask = fill(d, px); | |
| 396 | + float3 tint = paint(fk * .19 + .08 + .05 * sin(t * .02 + fk), f); | |
| 397 | + tint = pow(tint / max(max(tint.r, tint.g), max(tint.b, 1e-3f)), float3(2.6)); | |
| 398 | + float density = .86 + level * .14; | |
| 399 | + filter *= mix(float3(1), tint, mask * density); | |
| 400 | + cover += mask; | |
| 401 | + shade *= 1 - .35 * shadow * (1 - mask); | |
| 402 | + float rim = line(d, .006, px) + glow(d, .01) * .3; | |
| 403 | + float sheen = mask * smoothstep(.2f, 1.f, sin(dot(local, float2(1.3, .8)) * 2 + t * .1 + fk)) * .1; | |
| 404 | + edges += (table * .35 + paint(.9, f) * .1) * (rim * (.3 + level * 1.2 + (k == 6 ? c.hit * 3 : 0.)) + sheen); | |
| 405 | + } | |
| 406 | + float covered = min(cover, 1.f); | |
| 407 | + float3 color = mix(table * .42, filter * (.8 + .25 * min(cover - 1, 1.f)), covered) * glowField * shade; | |
| 408 | + return color + edges; | |
| 409 | + } | |
| 410 | + NATIVE_EFFECT(gelOverlap) | |
| 411 | + | |
| 412 | + // ---------------------------------------------------------------- 347 Holo Foil | |
| 413 | + // A sheet of crumpled holographic foil fills the frame: sharp creases split it into tilted | |
| 414 | + // facets whose diffraction rainbow slides as the sheet flexes. Bass deepens the creases, | |
| 415 | + // low-mids bend the sheet, high-mids widen the rainbow, highs sparkle glitter flakes; | |
| 416 | + // attacks sweep a highlight across the foil. | |
| 417 | + float holo_height(float2 p) { | |
| 418 | + float h = 0, amplitude = .5; | |
| 419 | + for (int i = 0; i < 3; ++i) { | |
| 420 | + float n = noise2(p + float2(float(i) * 7.1, float(i) * 3.3)); | |
| 421 | + h += amplitude * (1 - abs(n * 2 - 1)); | |
| 422 | + p = rot(p, .7) * 2.2; | |
| 423 | + amplitude *= .45; | |
| 424 | + } | |
| 425 | + return h; | |
| 426 | + } | |
| 427 | + float3 holoFoil(Ctx c, constant NativeFrame &f) { | |
| 428 | + float2 p = c.uv / c.size; | |
| 429 | + float2 ext = c.extent / c.size; | |
| 430 | + float t = c.t; | |
| 431 | + float2 fp = rot(p, .45) * float2(.75, 1.5) + float2(c.travel * .05 + t * .006, 0); | |
| 432 | + const float e = .01; | |
| 433 | + float h0 = holo_height(fp), hx = holo_height(fp + float2(e, 0)), hy = holo_height(fp + float2(0, e)); | |
| 434 | + float flex = .75 + .25 * sin(t * .23 + p.x * .6) + c.b.x * 1.2; | |
| 435 | + float2 grad = float2(hx - h0, hy - h0) / e * flex; | |
| 436 | + float4 facet = voronoi(fp * 1.8, .9, 0); | |
| 437 | + grad += (hash22(facet.zw) - .5) * (1.1 + c.b.x * 1.2); | |
| 438 | + float bend = .45 + c.b.y * 1.1; | |
| 439 | + grad += bend * float2(cos(p.x * 1.3 + t * .11) * sin(p.y * .9 - t * .07), .7 * sin(p.x * 1.3 + t * .11) * cos(p.y * .9 - t * .07)); | |
| 440 | + float3 n = normalize(float3(-grad * .4, 1)); | |
| 441 | + float3 light = normalize(float3(cos(t * .09) * .7, sin(t * .07) * .6, 1)); | |
| 442 | + float3 r = reflect(float3(0, 0, -1), n); | |
| 443 | + float facing = max(dot(r, light), 0.f); | |
| 444 | + float spread = 3 + c.b.z * 2.4; | |
| 445 | + float phase = (n.x * .8 + n.y * .5) * spread + facing * .9 + dot(p, float2(.55, .85)) * .9 + t * .03; | |
| 446 | + float3 color = filmColor(phase, f) * (.3 + .8 * pow(facing, 3.f)); | |
| 447 | + color += paint(.9, f) * pow(facing, 30.f) * .7; | |
| 448 | + float4 g = voronoi(p * 20, .9, 0); | |
| 449 | + float2 gs = hash22(g.zw); | |
| 450 | + float twinkle = pow(max(0.f, sin(t * (1.5 + gs.x * 2) + gs.y * TAU)), 16.f); | |
| 451 | + color += paint(.85 + .1 * gs.x, f) * (1 - smoothstep(.03f, .1f, g.x)) * twinkle * (.12 + c.b.w * 2.6); | |
| 452 | + float sweepAngle = c.m * 1.3 + .6; | |
| 453 | + float2 axis = float2(cos(sweepAngle), sin(sweepAngle)); | |
| 454 | + float reach = length(ext); | |
| 455 | + float sweep = exp(-pow(dot(p, axis) - ((1 - c.hit) * 2.2 - 1.1) * reach, 2.f) * 9) * c.hit; | |
| 456 | + color += paint(.88, f) * sweep * (.8 + 1.2 * facing * facing) * 1.6; | |
| 457 | + return color; | |
| 458 | + } | |
| 459 | + NATIVE_EFFECT(holoFoil) | |
| 460 | + | |
| 461 | + // ---------------------------------------------------------------- 348 Opal Fire | |
| 462 | + // A black opal's play of colour: harlequin patches of spectral fire at two depths, each | |
| 463 | + // with a rolling flash that slides through it as the stone tilts, plus pinfire sparks. | |
| 464 | + // Each patch follows a band; attacks ignite a burst of fire that spreads through the patches. | |
| 465 | + float3 opalFire(Ctx c, constant NativeFrame &f) { | |
| 466 | + float2 p = c.uv / c.size; | |
| 467 | + float t = c.t; | |
| 468 | + float2 tilt = float2(sin(t * .11), cos(t * .087)) * .9; | |
| 469 | + float2 event = mat_eventPoint(c, 2.9, .6); | |
| 470 | + float near = exp(-dot(p - event, p - event) * 3); | |
| 471 | + // Black potch with a faint milky depth. | |
| 472 | + float3 color = deep(.05, f) * .04 + deep(.35, f) * .05 * fbm2(p * 1.5 + t * .01, 2); | |
| 473 | + // Harlequin patches of fire. | |
| 474 | + float2 q = rot(p * 3.4 + float2(c.travel * .2, 0), .5) * float2(1, 1.4); | |
| 475 | + q += (float2(noise2(q * .6), noise2(q * .6 + 5.3)) - .5) * .9; | |
| 476 | + float4 v = voronoi(q, .95, t * .04); | |
| 477 | + float3 seed = hash33(float3(v.zw, 1.7)); | |
| 478 | + float level = c.b[int(seed.z * 3.99)]; | |
| 479 | + float2 grating = float2(cos(seed.x * PI), sin(seed.x * PI)); | |
| 480 | + float2 across = float2(-grating.y, grating.x); | |
| 481 | + float2 view = tilt + p * .35; | |
| 482 | + // Rolling flash: a band of colour slides through each patch as the stone tilts. | |
| 483 | + float roll = dot(view, grating) * 2.4 + dot(q, grating) * .8 + seed.y * 6 + t * .03; | |
| 484 | + float flash = pow(.5 + .5 * cos(roll), 9.f); | |
| 485 | + float ignite = c.hit * (near * 2.2 + mat_pick(seed.x, c) * .7); | |
| 486 | + // Streaky flame texture runs along each patch's grating. | |
| 487 | + float2 sq = float2(dot(q, grating) * 1.2, dot(q, across) * 5) + seed.xy * 20 + float2(t * .03, 0); | |
| 488 | + float flame = .12 + .88 * pow(smoothstep(.25f, .8f, fbm2(sq, 3)), 1.5f); | |
| 489 | + float edge = .75 + .25 * smoothstep(0.f, .05f, v.y - v.x); | |
| 490 | + float bright = (.05 + flash * (2.2 + level * 3) + ignite * 1.6) * flame * edge; | |
| 491 | + float hue = seed.y * 1.2 + dot(view, grating) * .35 + level * .3 + ignite * .2; | |
| 492 | + color += mix(paint(hue, f), filmColor(hue * 1.3 + .2, f), .6) * bright; | |
| 493 | + // Pinfire: tiny points of colour deeper in the stone. | |
| 494 | + float4 pin = voronoi(p * 13 + 3.3, .9, 0); | |
| 495 | + float2 ps = hash22(pin.zw); | |
| 496 | + float twinkle = pow(.5 + .5 * sin(dot(view, float2(cos(ps.x * TAU), sin(ps.x * TAU))) * 5 + ps.y * TAU), 8.f); | |
| 497 | + float dotMask = (1 - smoothstep(.03f, .1f, pin.x)) * step(.6f, ps.x); | |
| 498 | + color += paint(ps.y + .3, f) * dotMask * twinkle * (.3 + c.b.w * 2.6); | |
| 499 | + // Polished dome: a soft window reflection drifting over the stone. | |
| 500 | + float2 g = p - float2(-.5, .45) - .25 * float2(sin(t * .05), cos(t * .04)); | |
| 501 | + color += paint(.95, f) * exp(-dot(g * float2(1, 2.5), g * float2(1, 2.5)) * 3) * .1; | |
| 502 | + return color; | |
| 503 | + } | |
| 504 | + NATIVE_EFFECT(opalFire) | |
| 505 | + | |
| 506 | + // ---------------------------------------------------------------- 349 Raku Crackle | |
| 507 | + // Raku glaze straight from the kiln: a crackle network splits the dark glossy glaze into | |
| 508 | + // tiles, its seams still glowing; copper lustre flashes across the tiles as their tilted | |
| 509 | + // gloss catches a moving light. Bands grow new cracks in their own regions, bass heats the | |
| 510 | + // seams, high-mids flash the copper; attacks shatter a local patch. | |
| 511 | + float3 rakuCrackle(Ctx c, constant NativeFrame &f) { | |
| 512 | + float2 p = c.uv / c.size; | |
| 513 | + float2 ext = c.extent / c.size; | |
| 514 | + float t = c.t; | |
| 515 | + float px = c.px / c.size; | |
| 516 | + float2 g = p + float2(c.travel * .04 + t * .004, 0); | |
| 517 | + g += (float2(noise2(g * 1.7), noise2(g * 1.7 + 4.2)) - .5) * .18; | |
| 518 | + float4 big = voronoi(g * 1.7, .85, 0); | |
| 519 | + float edgeBig = (big.y - big.x) / 1.7; | |
| 520 | + float4 fine = voronoi(g * 4.6 + 3.1, .9, 0); | |
| 521 | + float edgeFine = (fine.y - fine.x) / 4.6; | |
| 522 | + float2 tilt = (hash22(big.zw) - .5) * .6 + (hash22(fine.zw) - .5) * .14; | |
| 523 | + float3 n = normalize(float3(tilt, 1)); | |
| 524 | + // A moving soft light reflected in the gloss; every tile tilts it differently. | |
| 525 | + float2 mirror = p + n.xy * 2.4; | |
| 526 | + float2 lamp = float2(sin(t * .05) * ext.x * .8, cos(t * .037) * ext.y * .6); | |
| 527 | + float2 box = abs(mirror - lamp) - float2(.65, .3); | |
| 528 | + float softbox = 1 - smoothstep(-.1f, .3f, max(box.x, box.y)); | |
| 529 | + float lustre = smoothstep(.44f, .62f, fbm2(g * 1.1 + float2(t * .01, 0), 3)); | |
| 530 | + float thickness = fbm2(g * 2.2 - t * .02, 2) * 1.8 + dot(n.xy, float2(3, 2)); | |
| 531 | + float flash = .5 + c.b.z * 1.5; | |
| 532 | + float3 glaze = mix(deep(.2, f) * .07 + paint(.05, f) * .03, filmColor(thickness, f) * .5 * flash, lustre); | |
| 533 | + glaze += mix(paint(.85, f) * .3, filmColor(thickness + .3, f) * 1.1, lustre) * softbox; | |
| 534 | + // Band regions decide where new cracks grow. | |
| 535 | + float growth = 0; | |
| 536 | + for (int k = 0; k < 4; ++k) { | |
| 537 | + float angle = float(k) * 1.5708 + .4 + t * .02; | |
| 538 | + float2 at = float2(cos(angle), sin(angle)) * ext * .55; | |
| 539 | + growth += c.b[k] * exp(-dot(p - at, p - at) * .9); | |
| 540 | + } | |
| 541 | + float crackBig = 1 - smoothstep(.007f, .007f + px * 1.5, edgeBig); | |
| 542 | + float grow = smoothstep(-.06f, .06f, .3 + growth * 1.3 - noise2(g * 2.6)); | |
| 543 | + float crackFine = (1 - smoothstep(.0035f, .0035f + px * 1.5, edgeFine)) * grow; | |
| 544 | + float2 event = mat_eventPoint(c, 4.1, .6); | |
| 545 | + float shatter = c.hit * exp(-dot(p - event, p - event) * 4.5); | |
| 546 | + float4 micro = voronoi(g * 12 + 7.7, .9, 0); | |
| 547 | + float edgeMicro = (micro.y - micro.x) / 12; | |
| 548 | + float crackMicro = (1 - smoothstep(.002f, .002f + px * 1.5, edgeMicro)) * smoothstep(.04f, .25f, shatter); | |
| 549 | + float heat = .4 + .6 * noise2(g * 2 + float2(0, t * .08)) + c.b.x * 1.1; | |
| 550 | + float3 color = glaze * (1 - .9 * max(crackBig, max(crackFine, crackMicro))); | |
| 551 | + float seam = exp(-edgeBig * 140) * .8 + exp(-edgeFine * 220) * .5 * grow + exp(-edgeMicro * 300) * shatter * 2.5; | |
| 552 | + color += paint(.55 + .35 * min(heat, 1.f), f) * seam * heat * (.55 + shatter * 2); | |
| 553 | + return color; | |
| 554 | + } | |
| 555 | + NATIVE_EFFECT(rakuCrackle) |
Sources/PulseCanvas/Resources/NativeExpansionMaterialII.metal added
| 1 | + // Second versions of designs whose original and final review clips were both red-tagged. | |
| 2 | + // Original PulseCanvas designs 340–349. Full-frame materials in motion: liquids, films and crafts with vivid color, in the spirit of the kept Flow designs (Silk Cascade, Ink Bloom, Oil Marble, Chrome Metaballs) but with new materials. | |
| 3 | + // Every design is Form scale: the material itself moves with procedural time and the music; | |
| 4 | + // audio terms are zero at zero Chaos. | |
| 5 | + | |
| 6 | + // ---------------------------------------------------------------- shared helpers | |
| 7 | + // A wandering point for attack events: a smooth path of the music clock, so each attack | |
| 8 | + // lands somewhere new without anything jumping between frames. | |
| 9 | + float2 mat_eventPoint(Ctx c, float seed, float reach) { | |
| 10 | + return float2(sin(c.m * 2.3 + seed * 4.1), sin(c.m * 1.7 + seed * 2.7 + 1.3)) * c.extent / c.size * reach; | |
| 11 | + } | |
| 12 | + // Picks a changing subset of elements for each attack; continuous in the music clock. | |
| 13 | + float mat_pick(float seed, Ctx c) { | |
| 14 | + float s = .5 + .5 * sin(c.m * 3.7 + seed * TAU); | |
| 15 | + return s * s * s; | |
| 16 | + } | |
| 17 | + | |
| 18 | + // ---------------------------------------------------------------- 340 Acrylic Cells | |
| 19 | + // A poured acrylic skin: opaque streams of saturated paint and dark ground run across the | |
| 20 | + // canvas, cells open in the cell-forming streams (a bright core, a coloured ring and a dark | |
| 21 | + // wall) and fine lacing webs the light layers. Bass opens the cells, low-mids push the pour, | |
| 22 | + // high-mids thicken the lacing, highs freckle micro-cells; attacks open a bloom of fresh cells. | |
| 23 | + float3 acr_layer(float index, constant NativeFrame &f) { | |
| 24 | + float kind = hash11(index * 2.71 + 8.3); | |
| 25 | + // Each paint is one tube colour: a palette stop, never a muddy in-between. | |
| 26 | + float hue = floor(hash11(index * 1.37 + 2.9) * 4.99) * .25; | |
| 27 | + if (kind < .3) return deep(hue + .5, f) * .07; | |
| 28 | + return paint(hue, f) * (.6 + .3 * kind); | |
| 29 | + } | |
| 30 | + float3 acrylicCellsII(Ctx c, constant NativeFrame &f) { | |
| 31 | + float2 p = c.uv / c.size; | |
| 32 | + float t = c.t; | |
| 33 | + float2 base = p * .8 + float2(t * .03 + c.travel * .06, -t * .012); | |
| 34 | + float2 warp = float2(fbm2(base * .9 + float2(0, t * .02), 3), fbm2(base * .9 + float2(4.3, 1.7 - t * .018), 3)); | |
| 35 | + float2 q = base + (warp - .5) * (1.45 + c.b.y * 1.5); | |
| 36 | + // Stacked pour layers of varying width run along the flow. | |
| 37 | + float s = q.y * 1.1 + q.x * .42 + .3 * sin(q.x * 1.2 + t * .04); | |
| 38 | + float layer = s * 2.7 + .3 * sin(s * 1.9 + 1.3); | |
| 39 | + float index = floor(layer), fr = fract(layer); | |
| 40 | + // Layer edges stay a constant few pixels wide however far the pour stretches them. | |
| 41 | + float aa = clamp(fwidth(layer) * 1.2, 1e-4f, .3f); | |
| 42 | + float3 color = mix(acr_layer(index, f), acr_layer(index + 1, f), smoothstep(1 - aa, 1.f, fr)); | |
| 43 | + color *= .82 + .25 * sin(fr * PI); | |
| 44 | + // Cells: voronoi stretched along the flow, open only in the cell-forming streams. | |
| 45 | + float2 along = normalize(float2(1.1, -.42)); | |
| 46 | + // Cells ride the pour but stay round, only a little stretched along it. | |
| 47 | + float2 cp = base + (warp - .5) * (.5 + c.b.y * .5); | |
| 48 | + float2 cq = float2(dot(cp, along) * 2.6, dot(cp, float2(-along.y, along.x)) * 3.4); | |
| 49 | + float4 v = voronoi(cq, .85, t * .12); | |
| 50 | + float2 seed = hash22(v.zw); | |
| 51 | + float region = smoothstep(.3f, .55f, noise2(cp * .9 + 11.3)); | |
| 52 | + float2 event = mat_eventPoint(c, .3, .6); | |
| 53 | + float near = exp(-dot(p - event, p - event) * 2.4); | |
| 54 | + float pick = mat_pick(seed.x, c); | |
| 55 | + float radius = (.1 + .24 * seed.y) * region * (.65 + c.b.x * 1.3); | |
| 56 | + radius += (.14 + .14 * seed.y) * c.hit * (pick * .5 + near * 1.8); | |
| 57 | + radius = min(radius, .46f); | |
| 58 | + float present = smoothstep(0.f, .04f, radius); | |
| 59 | + float aac = c.px / c.size * 4 * 1.5; | |
| 60 | + float3 core = paint(floor(seed.x * 4.99) * .25, f) * 1.05; | |
| 61 | + float3 ring = paint(floor(seed.y * 4.99) * .25 + .5, f) * .8; | |
| 62 | + float3 wall = deep(seed.x, f) * .05; | |
| 63 | + float u = v.x; | |
| 64 | + float3 cell = mix(core, ring, smoothstep(radius * .5 - aac, radius * .5 + aac, u)); | |
| 65 | + cell = mix(cell, wall, smoothstep(radius * .8 - aac, radius * .8 + aac, u)); | |
| 66 | + float2 local = cq - v.zw - .5 - .425 * sin(t * .12 + seed * TAU); | |
| 67 | + float2 lit = local + float2(.32, -.32) * radius; | |
| 68 | + cell += paint(.5, f) * (1 - smoothstep(radius * .1 - aac, radius * .1 + aac, length(lit))) * .45; | |
| 69 | + float inside = (1 - smoothstep(radius - aac, radius + aac, u)) * present; | |
| 70 | + float rim = exp(-abs(u - radius) / .02) * present * (1 - inside); | |
| 71 | + color = mix(color, cell, inside); | |
| 72 | + color += paint(.5, f) * rim * (.25 + c.hit * (pick + near) * 1.4); | |
| 73 | + // Lacing and micro-cells on a finer web. | |
| 74 | + float4 web = voronoi(cq * 2.3 + 5.1, .85, t * .1); | |
| 75 | + float lace = 1 - smoothstep(.01f, .035f + c.b.z * .06f, web.y - web.x); | |
| 76 | + float laceRegion = smoothstep(.45f, .7f, noise2(q * 1.1 + 4.7)) * (1 - inside); | |
| 77 | + color = mix(color, paint(.5, f) * 1.1, lace * laceRegion * (.35 + c.b.z * 1.1)); | |
| 78 | + float freckle = 1 - smoothstep(.04 + .12 * c.b.w, .07 + .12 * c.b.w, web.x); | |
| 79 | + color = mix(color, paint(hash21(web.zw), f) * .9, freckle * step(.6f, hash21(web.zw + 3.7)) * smoothstep(.02f, .1f, c.b.w) * (1 - inside) * region); | |
| 80 | + // Wet gloss: a slow window reflection across the pour. | |
| 81 | + float gloss = exp(-pow(dot(p, float2(.6, .8)) - 1.3 * sin(t * .045), 2.f) * 4); | |
| 82 | + color += paint(.5, f) * gloss * .07; | |
| 83 | + return color * .72; | |
| 84 | + } | |
| 85 | + NATIVE_EFFECT(acrylicCellsII) | |
| 86 | + | |
| 87 | + // ---------------------------------------------------------------- 341 Molten Glass | |
| 88 | + // Thick canes of molten glass are pulled across a dark furnace. Each cane has an | |
| 89 | + // incandescent core, a cooling glossy skin and twisted threads inside. Bass stretches the | |
| 90 | + // canes and necks them thin, low-mids sway them, high-mids light the threads, highs glint | |
| 91 | + // trapped seeds; attacks fold a kink into the canes and flare it white-hot. | |
| 92 | + float3 moltenGlassII(Ctx c, constant NativeFrame &f) { | |
| 93 | + float2 p = c.uv / c.size; | |
| 94 | + float2 ext = c.extent / c.size; | |
| 95 | + float t = c.t; | |
| 96 | + float stretch = 1 + c.b.x * .9; | |
| 97 | + float3 color = deep(.03, f) * .04 + paint(.03, f) * .06 * fbm2(p * 1.4 + float2(t * .02, -t * .05), 3); | |
| 98 | + float2 event = mat_eventPoint(c, 1.7, .7); | |
| 99 | + const int count = 5; | |
| 100 | + for (int k = 0; k < count; ++k) { | |
| 101 | + float fk = float(k); | |
| 102 | + float seed = hash11(fk * 3.71 + .37); | |
| 103 | + float side = (k & 1) == 0 ? 1. : -1.; | |
| 104 | + float angle = side * (.12 + .3 * seed) + .1 * sin(t * .04 + fk * 1.3); | |
| 105 | + float2 center = float2(.25 * sin(fk * 2.1), (fk - 2) / 2 * ext.y * .78); | |
| 106 | + float2 q = rot(p - center, -angle); | |
| 107 | + float2 eq = rot(event - center, -angle); | |
| 108 | + float pick = mat_pick(seed, c); | |
| 109 | + float level = c.b[k % 4]; | |
| 110 | + float x = q.x / stretch; | |
| 111 | + float amp = .08 + .06 * seed + c.b.y * .16; | |
| 112 | + float frequency = 1.1 + .9 * seed; | |
| 113 | + float phase = t * (.16 + .08 * seed) + seed * 9; | |
| 114 | + float yc = amp * sin(x * frequency + phase) + .05 * sin(x * 2.7 - phase * 1.3); | |
| 115 | + float slope = (amp * frequency * cos(x * frequency + phase) + .135 * cos(x * 2.7 - phase * 1.3)) / stretch; | |
| 116 | + float kink = exp(-pow((q.x - eq.x) / .4, 2.f)) * c.hit * (.45 + pick); | |
| 117 | + yc += kink * .35 * sin((q.x - eq.x) * 5); | |
| 118 | + float neckAt = sin(t * .05 + seed * 6) * ext.x * .6; | |
| 119 | + float neck = exp(-pow((q.x - neckAt) / (.55 * stretch), 2.f)) * (.15 + c.b.x * .5); | |
| 120 | + float width = (.13 + .07 * seed) * (1 - neck); | |
| 121 | + float u = (q.y - yc) / sqrt(1 + slope * slope) / width; | |
| 122 | + float aa = c.px / c.size / width * 1.5; | |
| 123 | + float body = 1 - smoothstep(1 - aa, 1 + aa, abs(u)); | |
| 124 | + float uc = clamp(u, -1.f, 1.f); | |
| 125 | + float nz = sqrt(max(0.f, 1 - uc * uc)); | |
| 126 | + float heat = (.6 + .3 * sin(x * .8 - t * .1 + seed * 7) + .35 * level) * (1 - neck * .6) + kink * 2.2; | |
| 127 | + // Glowing glass: emission peaks inside the cane, so there is no dark side. | |
| 128 | + float emission = heat * (.3 + .7 * nz * nz); | |
| 129 | + float twist = asin(uc) * 2 + x * (7 + 4 * seed) * side - t * (.35 + seed * .3); | |
| 130 | + float strand = smoothstep(.35f, .75f, sin(twist)) * nz; | |
| 131 | + float3 glass = paint(.12 + .72 * min(emission, 1.2f), f) * min(emission, 1.3f) * 1.05; | |
| 132 | + glass += paint(.88, f) * strand * (.08 + c.b.z * .9) * heat; | |
| 133 | + float3 n = float3(0, uc, nz); | |
| 134 | + float specular = pow(max(0.f, dot(n, normalize(float3(0, .58, .81)))), 220.f); | |
| 135 | + glass += paint(.95, f) * specular * 1.3; | |
| 136 | + glass += paint(.35, f) * pow(1 - nz, 8.f) * .35 * heat; | |
| 137 | + // Trapped seeds (tiny bubbles) glint with the highs. | |
| 138 | + float segment = floor(x * 2.5 + seed * 17); | |
| 139 | + float2 bubbleSeed = hash22(float2(segment, fk)); | |
| 140 | + float2 bubble = float2((fract(x * 2.5 + seed * 17) - .2 - .6 * bubbleSeed.x) * .4 * stretch, (u - (bubbleSeed.y - .5) * 1.2) * width); | |
| 141 | + glass += paint(.95, f) * glow(length(bubble) - .01, .005) * (.04 + c.b.w * 2.4) * nz * sin(PI * fract(x * 2.5 + seed * 17)); | |
| 142 | + // Translucent: canes behind still glow through, dimmed by the glass in front. | |
| 143 | + float outside = max(abs(u) - 1, 0.f) * width; | |
| 144 | + color += paint(.2 + .3 * min(heat, 1.f), f) * exp(-outside * 10) * .14 * heat * (1 - body); | |
| 145 | + color = color * (1 - .6 * body) + glass * body; | |
| 146 | + } | |
| 147 | + return color * .9; | |
| 148 | + } | |
| 149 | + NATIVE_EFFECT(moltenGlassII) | |
| 150 | + | |
| 151 | + // ---------------------------------------------------------------- 342 Liquid Crystal | |
| 152 | + // A nematic film between crossed polarisers: interference colours set by the film's | |
| 153 | + // retardation, dark brushes radiating from drifting defects. Each band twists the director | |
| 154 | + // in its own region; attacks tear a defect pair out of the uniform field. | |
| 155 | + float lc_pair(float2 p, float2 center, float2 offset) { | |
| 156 | + // +1/2 at center + offset and -1/2 at center - offset. Exactly zero when the offset is | |
| 157 | + // zero, so pairs can be born and annihilate continuously. | |
| 158 | + float2 a = p - center - offset, b = p - center + offset; | |
| 159 | + return .5 * atan2(a.y * b.x - a.x * b.y, a.x * b.x + a.y * b.y); | |
| 160 | + } | |
| 161 | + float3 liquidCrystalII(Ctx c, constant NativeFrame &f) { | |
| 162 | + float2 p = c.uv / c.size; | |
| 163 | + float2 ext = c.extent / c.size; | |
| 164 | + float t = c.t; | |
| 165 | + float theta = 1.3 * fbm2(p * .8 + float2(t * .02, -t * .015), 3) + .3 * sin(p.x * .8 + t * .06) + .25 * cos(p.y * 1.1 - t * .05); | |
| 166 | + theta += .22 * noise2(p * 4 + float2(t * .05, 0)); | |
| 167 | + bool wide = ext.x >= ext.y; | |
| 168 | + int columns = wide ? 4 : 2, rows = wide ? 2 : 4; | |
| 169 | + for (int i = 0; i < 8; ++i) { | |
| 170 | + float fi = float(i); | |
| 171 | + int column = i % columns, row = i / columns; | |
| 172 | + float2 seed = hash22(float2(fi, 3.1)); | |
| 173 | + float2 cell = float2((float(column) + .5) / float(columns), (float(row) + .5) / float(rows)) * 2 - 1; | |
| 174 | + float2 at = cell * ext * .85 + (seed - .5) * .5 + float2(sin(t * (.08 + seed.x * .05) + fi * 2.1), cos(t * (.07 + seed.y * .05) + fi * 1.3)) * .34; | |
| 175 | + float charge = ((column + row) & 1) == 0 ? .5 : -.5; | |
| 176 | + if (i == 1) charge = 1; | |
| 177 | + if (i == 6) charge = -1; | |
| 178 | + theta += charge * atan2(p.y - at.y, p.x - at.x); | |
| 179 | + } | |
| 180 | + for (int k = 0; k < 4; ++k) { | |
| 181 | + float angle = float(k) * 1.5708 + .7 + t * .03; | |
| 182 | + float2 at = float2(cos(angle), sin(angle)) * ext * .55; | |
| 183 | + theta += c.b[k] * .85 * exp(-dot(p - at, p - at) * 1.4); | |
| 184 | + } | |
| 185 | + float flare = 0; | |
| 186 | + for (int j = 0; j < 3; ++j) { | |
| 187 | + float fj = float(j); | |
| 188 | + float pick = mat_pick(fj * .31 + .1, c); | |
| 189 | + float2 at = mat_eventPoint(c, fj * 2.3, .6); | |
| 190 | + float separation = (c.hit * .35 + c.e * .08) * (.3 + pick); | |
| 191 | + float2 direction = float2(cos(fj * 2.1 + t * .1), sin(fj * 2.1 + t * .1)); | |
| 192 | + theta += lc_pair(p, at, direction * separation); | |
| 193 | + flare += c.hit * (.3 + pick) * exp(-dot(p - at, p - at) * 4); | |
| 194 | + } | |
| 195 | + float polarizer = t * .065; | |
| 196 | + float brush = sin(2 * (theta - polarizer)); | |
| 197 | + float intensity = brush * brush; | |
| 198 | + float retardation = 1 + 5.5 * fbm2(p * .6 + float2(t * .015, 3.7), 3) + .5 * length(p) + .12 * sin(t * .07); | |
| 199 | + float3 color = filmColor(retardation, f) * (.02 + .9 * pow(intensity, 1.3f)); | |
| 200 | + color += paint(.9, f) * pow(intensity, 12.f) * .1; | |
| 201 | + color += paint(.85, f) * flare * intensity * .9; | |
| 202 | + return color * .88; | |
| 203 | + } | |
| 204 | + NATIVE_EFFECT(liquidCrystalII) | |
| 205 | + | |
| 206 | + // ---------------------------------------------------------------- 343 Incense Drift | |
| 207 | + // Ribbons of incense smoke rise from below the frame, twist as thin lit sheets and curl | |
| 208 | + // into loops on rising eddies before melting into a lit haze. Each plume follows its band, | |
| 209 | + // bass thickens them all, low-mids spin the eddies; attacks curl a new loop. | |
| 210 | + float3 incenseDriftII(Ctx c, constant NativeFrame &f) { | |
| 211 | + float2 p = c.uv / c.size; | |
| 212 | + float2 ext = c.extent / c.size; | |
| 213 | + float t = c.t; | |
| 214 | + float h = clamp(p.y / ext.y * .5 + .5, 0.f, 1.f); | |
| 215 | + float2 q = p + curl2(p * 1.1 + float2(0, -t * .12)) * (.015 + .09 * h * h); | |
| 216 | + for (int j = 0; j < 4; ++j) { | |
| 217 | + float fj = float(j); | |
| 218 | + float cycle = t * .022 + fj * .25; | |
| 219 | + float life = fract(cycle); | |
| 220 | + float2 seed = hash22(float2(floor(cycle), fj)); | |
| 221 | + float2 at = float2((seed.x - .5) * 1.7 * ext.x, mix(-.4, 1.1, life) * ext.y); | |
| 222 | + float spin = (1.6 + c.b.y * 1.6) * sin(PI * life) * (seed.y < .5 ? -1. : 1.); | |
| 223 | + float2 d = q - at; | |
| 224 | + q = at + rot(d, spin * exp(-dot(d, d) * 5)); | |
| 225 | + } | |
| 226 | + float2 event = mat_eventPoint(c, .7, .55); | |
| 227 | + float2 de = q - event; | |
| 228 | + q = event + rot(de, c.hit * 3.4 * exp(-dot(de, de) * 7)); | |
| 229 | + float boost = 1 + c.hit * 2.5 * exp(-dot(p - event, p - event) * 6); | |
| 230 | + float haze = fbm2(q * 1.3 + float2(0, -t * .04), 4); | |
| 231 | + // A dark room: a little light pools low where the sticks burn, and the haze above | |
| 232 | + // holds a soft glow, so the lit ribbons stand out against depth rather than a flat wash. | |
| 233 | + float pool = exp(-pow(h + .1f, 2.f) * 4) * (.6 + .4 * sin(p.x * 1.3 + t * .03)); | |
| 234 | + float3 color = deep(.08 + h * .1, f) * (.1 + .12 * pool) + paint(.25 + haze * .35, f) * haze * haze * (.05 + .32 * h); | |
| 235 | + for (int k = 0; k < 4; ++k) { | |
| 236 | + float fk = float(k); | |
| 237 | + float x0 = ((fk + .5) / 4 * 2 - 1) * ext.x * .82 + .12 * sin(t * .05 + fk * 2); | |
| 238 | + float sway = (.03 + .25 * h * h) * sin(q.y * 2.1 - t * .35 + fk * 1.9) + .1 * h * sin(q.y * 4.3 - t * .6 + fk); | |
| 239 | + float dx = q.x - x0 - sway; | |
| 240 | + float level = c.b[k]; | |
| 241 | + float width = (.012 + .11 * h * h) * (1 + c.b.x * 1.4); | |
| 242 | + float twist = q.y * 5 - t * .8 + fk * 1.7; | |
| 243 | + float strands = 0; | |
| 244 | + for (int i = 0; i < 3; ++i) strands += glow(dx - width * sin(twist + float(i) * 2.094), .0035 + .012 * h); | |
| 245 | + float sheet = exp(-dx * dx / (width * width * 1.2 + 1e-4)); | |
| 246 | + float fade = 1 - .7 * smoothstep(.6f, 1.f, h); | |
| 247 | + float3 tint = paint(.2 + fk * .17 + h * .35, f); | |
| 248 | + color += tint * (strands * .42 + sheet * .3) * fade * (.5 + level * 1.9) * boost; | |
| 249 | + color += paint(.95, f) * strands * strands * .05 * fade * (.5 + level) * boost; | |
| 250 | + } | |
| 251 | + return color; | |
| 252 | + } | |
| 253 | + NATIVE_EFFECT(incenseDriftII) | |
| 254 | + | |
| 255 | + | |
| 256 | + // ---------------------------------------------------------------- 345 Heat Haze | |
| 257 | + // A false-colour thermal view of a convection tank: rolls turn across the frame, hot plumes | |
| 258 | + // rise where they meet and carry mushroom thermals upward through shimmering isotherms. | |
| 259 | + // Bass heats every plume, each plume also follows its own band, highs add shimmer; attacks | |
| 260 | + // release a hot bubble at the plume roots. | |
| 261 | + float3 heatHazeII(Ctx c, constant NativeFrame &f) { | |
| 262 | + float2 p = c.uv / c.size; | |
| 263 | + float2 ext = c.extent / c.size; | |
| 264 | + float t = c.t; | |
| 265 | + float h = p.y / ext.y * .5 + .5; | |
| 266 | + float hc = clamp(h, 0.f, 1.f); | |
| 267 | + float2 shimmer = float2(fbm2(p * 2.4 + float2(0, -t * .3), 3), fbm2(p * 2.4 + float2(5.1, -t * .26), 3)) - .5; | |
| 268 | + float2 q = p + shimmer * (.07 + c.b.w * .28); | |
| 269 | + const float span = .6; | |
| 270 | + float xr = q.x / span + t * .01; | |
| 271 | + float T = .36 - .38 * hc; | |
| 272 | + // Counter-rotating convection rolls wrap warm streaks into spirals between the plumes. | |
| 273 | + float roll = floor(xr * .5); | |
| 274 | + float2 rl = float2((xr * .5 - roll - .5) * 2, (q.y / ext.y - .1 * sin(roll * 2.3)) * 1.4); | |
| 275 | + float rr = length(rl); | |
| 276 | + float turn = (int(roll) & 1) == 0 ? 1. : -1.; | |
| 277 | + float spiral = sin(atan2(rl.y, rl.x) + rr * 8 * turn - t * .7 * turn); | |
| 278 | + T += (.13 + c.b.y * .16) * spiral * smoothstep(1.05f, .25f, rr) * smoothstep(0.f, .2f, rr); | |
| 279 | + // Plumes rise where neighbouring rolls meet. | |
| 280 | + float plume = floor(xr * .5 + .5); | |
| 281 | + float dxr = (xr * .5 - plume) * 2 * span; | |
| 282 | + float seed = hash11(plume * 1.7 + .3); | |
| 283 | + float level = c.b[int(abs(plume)) % 4]; | |
| 284 | + float sway = .07 * hc * sin(q.y * 2.3 - t * .4 + seed * 6) + .04 * hc * sin(q.y * 5 - t * .7 + seed * 3); | |
| 285 | + float dx = dxr - sway; | |
| 286 | + float wide = .035 + .07 * hc; | |
| 287 | + float strength = .32 + .2 * seed + c.b.x * .5 + level * .4; | |
| 288 | + T += strength * exp(-dx * dx / (wide * wide)) * (1.1 - .55 * hc); | |
| 289 | + // Mushroom thermals climb each plume. | |
| 290 | + for (int j = 0; j < 3; ++j) { | |
| 291 | + float life = fract(t * .045 + seed + float(j) / 3); | |
| 292 | + float y = mix(-1.25, 1.25, life) * ext.y; | |
| 293 | + float2 head = float2(dx, q.y - y); | |
| 294 | + float capWidth = .08 + .12 * life; | |
| 295 | + float cap = exp(-head.x * head.x / (capWidth * capWidth) - head.y * head.y / .01); | |
| 296 | + float curl = exp(-pow(abs(head.x) - capWidth, 2.f) / .003 - pow(head.y + .05, 2.f) / .006); | |
| 297 | + float stem = exp(-dx * dx / (wide * wide * .5)) * smoothstep(.0f, -.25f, head.y) * smoothstep(-.6f, -.2f, head.y); | |
| 298 | + T += (cap * .5 + curl * .38 + stem * .15) * strength * (1 - .3 * life); | |
| 299 | + } | |
| 300 | + float pick = mat_pick(seed, c); | |
| 301 | + float bubbleY = -ext.y * .72 + (1 - c.hit) * .45; | |
| 302 | + T += c.hit * (.6 + pick * 1.4) * exp(-(dx * dx + pow(q.y - bubbleY, 2.f)) / .025); | |
| 303 | + T += .05 * (fbm2(q * 3 + float2(0, -t * .2), 3) - .5); | |
| 304 | + float temp = clamp(T, 0.f, 1.5f); | |
| 305 | + // False colour: cool is dark red, warm a saturated orange, and only the hottest cores | |
| 306 | + // climb through gold to white, so mid temperatures never wash out to khaki. | |
| 307 | + float3 warm = paint(.02 + .44 * smoothstep(0.f, .85f, temp), f); | |
| 308 | + float3 color = mix(warm, paint(.98, f), smoothstep(1.f, 1.4f, temp)) * (.06 + 1.1 * smoothstep(.0f, .45f, temp) + .4 * max(temp - .8f, 0.f)); | |
| 309 | + // Isotherms: thin, evenly wide contour lines however steep the temperature gradient. | |
| 310 | + float contour = T * 10; | |
| 311 | + float iso = fract(contour); | |
| 312 | + float isoWidth = clamp(fwidth(contour), 1e-3f, .45f); | |
| 313 | + // Where contours crowd together they fade out instead of greying the hot cores. | |
| 314 | + float isoLine = (1 - smoothstep(isoWidth * .6f, isoWidth * 1.6f, min(iso, 1 - iso))) * (1 - smoothstep(.12f, .3f, isoWidth)); | |
| 315 | + color *= 1 - .3 * isoLine * smoothstep(.05f, .2f, temp) * (1 - smoothstep(.55f, .85f, temp)); | |
| 316 | + color += paint(.9, f) * isoLine * .1 * temp * temp; | |
| 317 | + return color; | |
| 318 | + } | |
| 319 | + NATIVE_EFFECT(heatHazeII) | |
| 320 | + | |
| 321 | + // ---------------------------------------------------------------- 346 Gel Overlap | |
| 322 | + // Translucent colour gels lie on a light table; where they overlap their colours multiply. | |
| 323 | + // Each gel drifts and thickens with its band, the cut edges catch the light, and the music | |
| 324 | + // clock slides a long strip over the stack; attacks shove it and flash its edges. | |
| 325 | + float gel_sdf(float2 p, int k, float3 seed, float2 ext) { | |
| 326 | + if (k == 1 || k == 4 || k == 7) return length(p) - (.48 + .25 * seed.x); | |
| 327 | + if (k == 2) return sdBox2(p, float2(2.2 * max(ext.x, ext.y), .17 + .05 * seed.y)) - .02; | |
| 328 | + return sdBox2(p, float2(.55 + .35 * seed.y, .38 + .22 * seed.z)) - .06; | |
| 329 | + } | |
| 330 | + float3 gelOverlapII(Ctx c, constant NativeFrame &f) { | |
| 331 | + float2 p = c.uv / c.size; | |
| 332 | + float2 ext = c.extent / c.size; | |
| 333 | + float t = c.t; | |
| 334 | + float px = c.px / c.size * 1.5; | |
| 335 | + float glowField = .18 + 1.05 * exp(-dot(p / ext, p / ext) * 1.3); | |
| 336 | + float3 table = (paint(.5, f) + paint(.75, f) + paint(.95, f)) / 3; | |
| 337 | + float3 filter = float3(1); | |
| 338 | + float cover = 0, shade = 1; | |
| 339 | + float3 edges = 0; | |
| 340 | + for (int k = 0; k < 9; ++k) { | |
| 341 | + float fk = float(k); | |
| 342 | + float3 seed = hash33(float3(fk, 2.7, 9.1)); | |
| 343 | + float level = k < 8 ? c.b[k % 4] : 0.; | |
| 344 | + float2 center; | |
| 345 | + float angle; | |
| 346 | + int shape = k; | |
| 347 | + if (k < 8) { | |
| 348 | + float2 home = (seed.xy - .5) * ext * 1.4; | |
| 349 | + float2 drift = float2(sin(t * (.04 + seed.z * .03) + fk * 1.7), cos(t * (.035 + seed.x * .03) + fk * 2.3)) * ext * .35; | |
| 350 | + float2 push = float2(cos(fk * 2.4), sin(fk * 2.4)) * level * .55; | |
| 351 | + center = home + drift + push; | |
| 352 | + angle = t * .03 * (seed.z - .5) + fk; | |
| 353 | + } else { | |
| 354 | + // The slider: a long strip glides back and forth on the music clock; attacks shove it. | |
| 355 | + center = float2(sin(c.m * .9 + 1.2) * ext.x * .75 + c.hit * .35, 0); | |
| 356 | + angle = 1.35; | |
| 357 | + shape = 2; | |
| 358 | + } | |
| 359 | + float2 local = rot(p - center, angle); | |
| 360 | + float d = gel_sdf(local, shape, seed, ext); | |
| 361 | + float shadow = 1 - smoothstep(-.02f, .09f, gel_sdf(rot(p - center - float2(.05, -.06), angle), shape, seed, ext)); | |
| 362 | + float mask = fill(d, px); | |
| 363 | + float3 tint = paint(fk * .19 + .08 + .05 * sin(t * .02 + fk), f); | |
| 364 | + tint = pow(tint / max(max(tint.r, tint.g), max(tint.b, 1e-3f)), float3(2.6)); | |
| 365 | + float density = .86 + level * .14; | |
| 366 | + filter *= mix(float3(1), tint, mask * density); | |
| 367 | + cover += mask; | |
| 368 | + shade *= 1 - .35 * shadow * (1 - mask); | |
| 369 | + float rim = line(d, .006, px) + glow(d, .01) * .3; | |
| 370 | + float sheen = mask * smoothstep(.2f, 1.f, sin(dot(local, float2(1.3, .8)) * 2 + t * .1 + fk)) * .1; | |
| 371 | + edges += (table * .35 + paint(.9, f) * .1) * (rim * (.16 + level * .9 + (k == 8 ? c.hit * 3 : 0.)) + sheen); | |
| 372 | + } | |
| 373 | + float covered = min(cover, 1.f); | |
| 374 | + float3 color = mix(table * .42, filter * (.8 + .25 * min(cover - 1, 1.f)), covered) * glowField * shade; | |
| 375 | + return (color + edges) * .82; | |
| 376 | + } | |
| 377 | + NATIVE_EFFECT(gelOverlapII) | |
| 378 | + | |
| 379 | + // ---------------------------------------------------------------- 347 Holo Foil | |
| 380 | + // A sheet of crumpled holographic foil fills the frame: long straight folds, each dying out | |
| 381 | + // somewhere in the sheet, split it into flat tilted facets whose diffraction rainbow slides | |
| 382 | + // as the sheet flexes and the light moves. Bass deepens the folds, low-mids bend the sheet, | |
| 383 | + // high-mids widen the rainbow, highs sparkle glitter flakes; attacks sweep a highlight. | |
| 384 | + // Fold table: direction and grid jitter, then span, depth, mountain or valley and wobble phase. | |
| 385 | + constant float4 holo_foldShape[24] = { | |
| 386 | + float4(0.4533, 0.8914, -0.0091, 0.1166), | |
| 387 | + float4(0.2087, 0.9780, -0.1367, -0.1458), | |
| 388 | + float4(0.9119, 0.4104, 0.0050, 0.0492), | |
| 389 | + float4(0.2996, 0.9541, 0.0715, 0.0295), | |
| 390 | + float4(0.8019, 0.5974, -0.0777, -0.1257), | |
| 391 | + float4(-0.6798, 0.7334, -0.0917, 0.0197), | |
| 392 | + float4(-0.0593, 0.9982, 0.0406, 0.0902), | |
| 393 | + float4(-0.8872, 0.4614, -0.0146, -0.0004), | |
| 394 | + float4(0.4170, 0.9089, 0.0212, 0.1031), | |
| 395 | + float4(-0.1742, 0.9847, 0.0669, -0.0178), | |
| 396 | + float4(-0.9864, 0.1642, 0.0219, 0.0611), | |
| 397 | + float4(0.8761, 0.4822, 0.0427, 0.0389), | |
| 398 | + float4(0.6464, 0.7630, 0.0395, -0.0383), | |
| 399 | + float4(0.5342, 0.8453, 0.1277, 0.0684), | |
| 400 | + float4(0.5890, 0.8081, -0.0807, 0.0293), | |
| 401 | + float4(0.0414, 0.9991, 0.0256, 0.1012), | |
| 402 | + float4(0.0004, 1.0000, 0.0486, -0.0559), | |
| 403 | + float4(-0.9361, 0.3517, 0.1184, -0.0745), | |
| 404 | + float4(-0.7139, 0.7002, 0.0971, 0.1212), | |
| 405 | + float4(0.7026, 0.7116, 0.0102, 0.0302), | |
| 406 | + float4(-0.6574, 0.7536, -0.1123, -0.0067), | |
| 407 | + float4(0.8592, 0.5117, 0.0133, -0.0957), | |
| 408 | + float4(0.7588, 0.6513, -0.0803, 0.1024), | |
| 409 | + float4(0.4562, 0.8899, 0.0113, 0.0796)}; | |
| 410 | + constant float4 holo_foldSize[24] = { | |
| 411 | + float4(1.0441, 0.5081, -1, 1.6482), | |
| 412 | + float4(1.4087, 0.5376, 1, 1.4102), | |
| 413 | + float4(1.2331, 0.4800, 1, 3.4016), | |
| 414 | + float4(0.8896, 0.4174, -1, 3.5601), | |
| 415 | + float4(1.2544, 0.5569, 1, 6.1110), | |
| 416 | + float4(0.4967, 0.3116, -1, 2.6663), | |
| 417 | + float4(0.4868, 0.5107, 1, 0.4695), | |
| 418 | + float4(1.5919, 0.3574, -1, 2.0644), | |
| 419 | + float4(1.5637, 0.5998, 1, 5.3051), | |
| 420 | + float4(1.3944, 0.4082, 1, 3.5323), | |
| 421 | + float4(0.5207, 0.3344, -1, 2.8307), | |
| 422 | + float4(0.7279, 0.5184, 1, 2.2901), | |
| 423 | + float4(0.4754, 0.3622, 1, 4.7969), | |
| 424 | + float4(1.3931, 0.3884, 1, 0.1466), | |
| 425 | + float4(0.7807, 0.3595, -1, 3.0191), | |
| 426 | + float4(0.5903, 0.4323, 1, 0.5335), | |
| 427 | + float4(1.1370, 0.3664, 1, 3.5982), | |
| 428 | + float4(0.8365, 0.5818, 1, 0.0843), | |
| 429 | + float4(1.2090, 0.3913, -1, 6.0840), | |
| 430 | + float4(1.4923, 0.4483, 1, 5.4160), | |
| 431 | + float4(1.3985, 0.3428, 1, 5.3823), | |
| 432 | + float4(1.2818, 0.2636, 1, 4.8497), | |
| 433 | + float4(0.9903, 0.3780, 1, 2.6605), | |
| 434 | + float4(1.3489, 0.4933, 1, 0.8857)}; | |
| 435 | + float3 holoFoilII(Ctx c, constant NativeFrame &f) { | |
| 436 | + float2 p = c.uv / c.size; | |
| 437 | + float2 ext = c.extent / c.size; | |
| 438 | + float t = c.t; | |
| 439 | + float px = c.px / c.size; | |
| 440 | + float2 sp = rot(p * 1.5, .08 * sin(t * .031)) + float2(c.travel * .05 + t * .004, -t * .002); | |
| 441 | + float reachAll = length(ext) * 1.5; | |
| 442 | + float flex = .6 + .25 * sin(t * .17) + c.b.x * .75; | |
| 443 | + float2 grad = 0; | |
| 444 | + float ridge = 0, valley = 0; | |
| 445 | + // Folds are spread over a jittered grid so every part of the canvas is crumpled. | |
| 446 | + bool wide = ext.x >= ext.y; | |
| 447 | + int columns = wide ? 6 : 4; | |
| 448 | + float2 drift = float2(c.travel * .05 + t * .004, -t * .002); | |
| 449 | + float soft = px * px * 4.5f, lineWidth = px * 2.4 + .003; | |
| 450 | + for (int k = 0; k < 24; ++k) { | |
| 451 | + float4 shape = holo_foldShape[k], size = holo_foldSize[k]; | |
| 452 | + float2 cell = float2(float(k % columns) + .5, float(k / columns) + .5) / float2(float(columns), float(24 / columns)); | |
| 453 | + float2 center = (cell * 2 - 1 + shape.zw) * ext * 1.5 + drift; | |
| 454 | + float2 n = normalize(shape.xy + float2(.03 * sin(t * .041 + size.w), 0)); | |
| 455 | + float2 rel = sp - center; | |
| 456 | + // Each fold runs only part way across the sheet before it relaxes. | |
| 457 | + float a = dot(rel, float2(-n.y, n.x)) / size.x; | |
| 458 | + if (a * a > 6) continue; | |
| 459 | + float d = dot(rel, n); | |
| 460 | + float reach = exp(-a * a); | |
| 461 | + float side = d / sqrt(d * d + soft); | |
| 462 | + grad += size.y * flex * reach * side * size.z * n; | |
| 463 | + float creaseLine = exp(-abs(d) / lineWidth) * reach; | |
| 464 | + if (size.z > 0) ridge += creaseLine; else valley += creaseLine; | |
| 465 | + } | |
| 466 | + float bend = .1 + c.b.y * .45; | |
| 467 | + grad += bend * float2(cos(p.x * 1.3 + t * .11) * sin(p.y * .9 - t * .07), .7 * sin(p.x * 1.3 + t * .11) * cos(p.y * .9 - t * .07)); | |
| 468 | + float3 n = normalize(float3(-grad * .9, 1)); | |
| 469 | + float3 light = normalize(float3(cos(t * .09) * .6, sin(t * .07) * .5, 1)); | |
| 470 | + float3 r = reflect(float3(0, 0, -1), n); | |
| 471 | + float facing = max(dot(r, light), 0.f); | |
| 472 | + // Diffraction: the rainbow order depends on the facet's tilt against the light. | |
| 473 | + float spread = 3.2 + c.b.z * 2.4; | |
| 474 | + float phase = dot(n.xy - light.xy * .4, float2(.85, .55)) * spread + dot(p, float2(.18, .12)) + t * .02; | |
| 475 | + float3 color = filmColor(phase, f) * (.13 + 1.05 * facing * facing); | |
| 476 | + color += paint(.9, f) * pow(facing, 24.f) * .45; | |
| 477 | + color += paint(.92, f) * min(ridge, 1.f) * (.2 + .35 * facing); | |
| 478 | + color *= 1 - .6 * min(valley, 1.f); | |
| 479 | + // Glitter flakes in the foil twinkle with the highs. | |
| 480 | + float2 gp = p * 22, gcell = floor(gp); | |
| 481 | + float2 gs = hash22(gcell); | |
| 482 | + float2 gl = fract(gp) - .5 - (gs.yx - .5) * .5; | |
| 483 | + float twinkle = pow(max(0.f, sin(t * (1.5 + gs.x * 2) + gs.y * TAU)), 16.f); | |
| 484 | + color += paint(.85 + .1 * gs.x, f) * (1 - smoothstep(.05f, .12f, length(gl))) * twinkle * (.03 + c.b.w * 2.2) * (.25 + facing); | |
| 485 | + // Attacks sweep a bright band across the foil, strongest on facets facing the light. | |
| 486 | + float sweepAngle = c.m * 1.3 + .6; | |
| 487 | + float2 axis = float2(cos(sweepAngle), sin(sweepAngle)); | |
| 488 | + float sweep = exp(-pow(dot(p, axis) - ((1 - c.hit) * 2.2 - 1.1) * reachAll, 2.f) * 9) * c.hit; | |
| 489 | + color += filmColor(phase + .3, f) * sweep * (.6 + 1.4 * facing) * 1.4; | |
| 490 | + return color * .9; | |
| 491 | + } | |
| 492 | + NATIVE_EFFECT(holoFoilII) | |
| 493 | + | |
| 494 | + // ---------------------------------------------------------------- 348 Opal Fire | |
| 495 | + // A black opal's play of colour: harlequin patches of spectral fire at two depths, each | |
| 496 | + // with a rolling flash that slides through it as the stone tilts, plus pinfire sparks. | |
| 497 | + // Each patch follows a band; attacks ignite a burst of fire that spreads through the patches. | |
| 498 | + float3 opalFireII(Ctx c, constant NativeFrame &f) { | |
| 499 | + float2 p = c.uv / c.size; | |
| 500 | + float2 ext = c.extent / c.size; | |
| 501 | + float t = c.t; | |
| 502 | + float2 tilt = float2(sin(t * .11), cos(t * .087)) * .9; | |
| 503 | + float2 view = tilt + p * .4; | |
| 504 | + float2 event = mat_eventPoint(c, 2.9, .6); | |
| 505 | + float near = exp(-dot(p - event, p - event) * 3); | |
| 506 | + // Black potch with a deep coloured glow from fire further inside the stone. | |
| 507 | + float body = fbm2(p * 1.2 + float2(t * .01, 0), 3); | |
| 508 | + float3 color = deep(.05, f) * .04 + filmColor(body * 2.2 + dot(view, float2(.4, .3)), f) * .07 * body; | |
| 509 | + // Harlequin mosaic: patches, each a diffraction grating with its own angle. | |
| 510 | + float2 q = rot(p * 4.4 + float2(c.travel * .2, 0), .35) * float2(1, 1.3); | |
| 511 | + q += (float2(noise2(q * .45), noise2(q * .45 + 5.3)) - .5) * .5; | |
| 512 | + float4 v = voronoi(q, .85, t * .03); | |
| 513 | + float3 seed = hash33(float3(v.zw, 1.7)); | |
| 514 | + float level = c.b[int(seed.z * 3.99)]; | |
| 515 | + float2 grating = float2(cos(seed.x * TAU), sin(seed.x * TAU)); | |
| 516 | + float facing = dot(view, grating) + (seed.y - .5) * 1.2; | |
| 517 | + float flash = pow(max(0.f, cos(facing * 2.2 + t * .02)), 4.f); | |
| 518 | + float ignite = c.hit * (near * 2.4 + mat_pick(seed.x, c) * .35); | |
| 519 | + // Each patch is a small diffraction grating: a spectrum runs across it and slides | |
| 520 | + // through it as the viewing angle changes. That sliding spectrum is the play of colour. | |
| 521 | + float2 local = q - v.zw - .5; | |
| 522 | + float across = dot(local, grating); | |
| 523 | + float spectrum = seed.y * 2 + across * .8 - facing * 1.1 + level * .35 + ignite * .25; | |
| 524 | + float band = .4 + .6 * pow(.5 + .5 * cos(across * 3 - facing * 5 + seed.z * 6), 2.f); | |
| 525 | + float grain = .7 + .3 * noise2(q * 9 + seed.xy * 40 + grating * t * .1); | |
| 526 | + float seam = .08 + .92 * smoothstep(0.f, c.px / c.size * 10, v.y - v.x); | |
| 527 | + float bright = (.04 + flash * (1.5 + level * 2.8) + ignite * 1.6) * band * grain * seam; | |
| 528 | + color += mix(paint(spectrum, f), filmColor(spectrum * 1.1, f), .7) * bright; | |
| 529 | + // Pinfire: tiny points of colour deeper in the stone. | |
| 530 | + float4 pin = voronoi(p * 15 + 3.3, .9, 0); | |
| 531 | + float2 ps = hash22(pin.zw); | |
| 532 | + float twinkle = pow(.5 + .5 * sin(dot(view, float2(cos(ps.x * TAU), sin(ps.x * TAU))) * 6 + ps.y * TAU), 10.f); | |
| 533 | + float dotMask = (1 - smoothstep(.03f, .09f, pin.x)) * step(.55f, ps.x); | |
| 534 | + color += filmColor(ps.y + .3, f) * dotMask * twinkle * (.35 + c.b.w * 2.6); | |
| 535 | + // Polished cabochon: a soft window reflection drifting over the stone. | |
| 536 | + float2 g = p - float2(-.45, .4) * ext - .25 * float2(sin(t * .05), cos(t * .04)); | |
| 537 | + color += paint(.95, f) * exp(-dot(g * float2(1, 2.2), g * float2(1, 2.2)) * 2.5) * .12; | |
| 538 | + return color; | |
| 539 | + } | |
| 540 | + NATIVE_EFFECT(opalFireII) | |
| 541 | + | |
| 542 | + // ---------------------------------------------------------------- 349 Raku Crackle | |
| 543 | + // Raku glaze straight from the kiln: smoky black glaze with pools of copper lustre whose | |
| 544 | + // iridescence flows like oil, split by a crackle network whose seams still glow with | |
| 545 | + // kiln heat. A broad gloss sweep rakes across the tiles; every tile is tilted a little, | |
| 546 | + // so the copper flash breaks at each crack. Bands grow new crazing in their own regions, | |
| 547 | + // bass heats the seams, low-mids shift the lustre colours, high-mids flash the copper, | |
| 548 | + // highs glint metal flecks; attacks shatter a local patch with a radiating star fracture. | |
| 549 | + float raku_edge(float4 v, float scale) { return (v.y - v.x) / scale; } | |
| 550 | + float3 rakuCrackleII(Ctx c, constant NativeFrame &f) { | |
| 551 | + float2 p = c.uv / c.size; | |
| 552 | + float2 ext = c.extent / c.size; | |
| 553 | + float t = c.t; | |
| 554 | + float px = c.px / c.size; | |
| 555 | + float2 g = p + float2(c.travel * .04 + t * .004, t * .0015); | |
| 556 | + // Crack paths wander a little instead of running dead straight. | |
| 557 | + float2 gc = g + (float2(noise2(g * 1.3), noise2(g * 1.3 + 4.2)) - .5) * .3 | |
| 558 | + + (float2(noise2(g * 6.1 + 2.3), noise2(g * 6.1 + 9.4)) - .5) * .05; | |
| 559 | + float4 big = voronoi(gc * 1.45, .9, 0); | |
| 560 | + float edgeBig = raku_edge(big, 1.45); | |
| 561 | + float4 fine = voronoi(gc * 4.4 + 3.1, .9, 0); | |
| 562 | + float edgeFine = raku_edge(fine, 4.4); | |
| 563 | + float2 tileSeed = hash22(big.zw); | |
| 564 | + // Crazed tiles lift slightly at their edges, so each one is a shallow dome with its own tilt. | |
| 565 | + float2 dome = (gc * 1.45 - big.zw - .5 - .45 * sin(tileSeed * TAU)) / 1.45; | |
| 566 | + float2 tilt = (tileSeed - .5) * .3 + (hash22(fine.zw) - .5) * .05 + dome * .9; | |
| 567 | + // Copper lustre pools on smoky black glaze. | |
| 568 | + float pool = fbm2(g * .85 + float2(2.3 - t * .006, t * .004), 3) + (tileSeed.x - .5) * .2; | |
| 569 | + float lustre = smoothstep(.4f, .54f, pool); | |
| 570 | + float thickness = fbm2(g * 1.5 + float2(t * .014, -t * .01), 3) * 2.4 + dot(tilt, float2(1.7, 1.2)) + c.b.y * .7; | |
| 571 | + // A broad gloss sweep: each tile's tilt shifts it, so the flash breaks at every crack. | |
| 572 | + float sweepAngle = .65 + .35 * sin(t * .019); | |
| 573 | + float2 sweepAxis = float2(cos(sweepAngle), sin(sweepAngle)); | |
| 574 | + float sweepAt = sin(t * .047) * length(ext) * .75; | |
| 575 | + float s = dot(p + tilt * 1.8, sweepAxis) - sweepAt; | |
| 576 | + float sheen = exp(-s * s * 3.5); | |
| 577 | + // The reflected window: a crisp stripe that steps sideways at every crack. | |
| 578 | + float window = 1 - smoothstep(.12f, .16f, abs(s + .05 * sin(dot(p, sweepAxis.yx) * 2.3))); | |
| 579 | + float flash = .6 + sheen * (.6 + c.b.z * 1.8) + window * (.7 + c.b.z); | |
| 580 | + // Lustre bands run through the film; their hue follows their brightness like hot metal, | |
| 581 | + // dim bands red, bright ones gold, so the glaze never turns brown. | |
| 582 | + float band = flash * (.3 + .7 * smoothstep(-.35f, .75f, sin(thickness * 3.2))); | |
| 583 | + float3 film = mix(paint(.03 + .42 * min(band * band, 1.5f), f), filmColor(thickness, f), .15) * band; | |
| 584 | + float3 smoke = deep(.1 + .1 * tileSeed.y, f) * .05 + paint(0, f) * .05 * fbm2(g * 3 + 1.7, 2); | |
| 585 | + float3 color = mix(smoke + paint(.15, f) * .14 * sheen + paint(.42, f) * .3 * window, film, lustre); | |
| 586 | + color += paint(.8, f) * window * .1 * lustre; | |
| 587 | + // Metal flecks in the lustre glint with the highs. | |
| 588 | + float4 micro = voronoi(g * 13 + 7.7, .9, 0); | |
| 589 | + float fleck = (1 - smoothstep(.03f, .08f, micro.x)) * step(.72f, hash21(micro.zw)); | |
| 590 | + color += paint(.9, f) * fleck * lustre * (.06 + .3 * sheen + c.b.w * 1.6); | |
| 591 | + // Bands grow new crazing in their own regions; the network also spreads slowly on its own. | |
| 592 | + float growth = 0; | |
| 593 | + for (int k = 0; k < 4; ++k) { | |
| 594 | + float angle = float(k) * 1.5708 + .4 + t * .02; | |
| 595 | + float2 at = float2(cos(angle), sin(angle)) * ext * .55; | |
| 596 | + growth += c.b[k] * exp(-dot(p - at, p - at) * 1.1); | |
| 597 | + } | |
| 598 | + float spread = .2 + .2 * sin(dot(g, float2(1.3, .9)) - t * .05) + growth * .9; | |
| 599 | + float front = noise2(gc * 2.3 + 6.1) * .85 + noise2(gc * 7.3 + 1.9) * .3; | |
| 600 | + float reveal = smoothstep(front - .06f, front + .06f, spread); | |
| 601 | + // Smoke stains the glaze along every crack; the seams themselves still glow. | |
| 602 | + float heat = .5 + .5 * noise2(gc * 2.2 + float2(0, t * .09)) + c.b.x * 1.2; | |
| 603 | + float3 seamColor = paint(.4 + .38 * min(heat, 1.f), f); | |
| 604 | + float3 haloColor = paint(.25 + .25 * min(heat, 1.f), f); | |
| 605 | + float wBig = max(.0045f, px * 1.1), wFine = max(.0025f, px * .8); | |
| 606 | + float crackBig = 1 - smoothstep(wBig * .4, wBig + px, edgeBig); | |
| 607 | + float crackFine = 1 - smoothstep(wFine * .4, wFine + px, edgeFine); | |
| 608 | + color *= 1 - .85 * exp(-edgeBig / .03) - .5 * exp(-edgeFine / .012) * (.3 + .7 * reveal); | |
| 609 | + color += seamColor * crackBig * (.45 + heat); | |
| 610 | + color += haloColor * exp(-edgeBig / (.01 + .018 * min(heat, 1.5f))) * .45 * heat; | |
| 611 | + color += seamColor * crackFine * reveal * (.1 + growth * 1.2 + .12 * heat); | |
| 612 | + // Attacks shatter a local patch: a star fracture and fine crazing radiate from the strike. | |
| 613 | + float2 strike = mat_eventPoint(c, 4.1, .55); | |
| 614 | + float2 d = p - strike; | |
| 615 | + float r = length(d); | |
| 616 | + float reach = .1 + (1 - c.hit) * .5; | |
| 617 | + float zone = c.hit * smoothstep(reach + .06f, reach - .12f, r); | |
| 618 | + float spokes = 9; | |
| 619 | + float a = atan2(d.y, d.x) + .15 * sin(r * 14 + strike.x * 5); | |
| 620 | + float spokeDistance = abs(fract(a / TAU * spokes + .5 * noise2(float2(r * 3, strike.y))) - .5) * TAU / spokes * r; | |
| 621 | + float star = 1 - smoothstep(wBig * .4, wBig + px, spokeDistance); | |
| 622 | + float crazing = 1 - smoothstep(.0015f, .0015f + px, raku_edge(micro, 13)); | |
| 623 | + color *= 1 - .5 * zone; | |
| 624 | + color += paint(.9, f) * (star + crazing * .8) * zone * 1.6; | |
| 625 | + color += paint(.8, f) * exp(-pow((r - reach) / .045, 2.f)) * c.hit * .9; | |
| 626 | + return color; | |
| 627 | + } | |
| 628 | + NATIVE_EFFECT(rakuCrackleII) |
Sources/PulseCanvas/Resources/NativeExpansionPassage.metal added
| 1 | + // Original PulseCanvas tunnel surfaces and independently choreographed depth stacks. | |
| 2 | + // Periodic cell sites keep the cylinder seam continuous, including cell colors. | |
| 3 | + float4 passageCells(float2 p,float width,float jitter,float phase){ | |
| 4 | + float2 cell=floor(p),f=fract(p);float first=8,second=8;float2 winner=0; | |
| 5 | + for(int y=-1;y<=1;++y)for(int x=-1;x<=1;++x){ | |
| 6 | + float2 g=float2(x,y),id=cell+g;id.x-=width*floor(id.x/width); | |
| 7 | + float2 seed=hash22(id),site=g+.5+jitter*.5*sin(phase+seed*TAU); | |
| 8 | + float d=length(site-f); | |
| 9 | + if(d<first){second=first;first=d;winner=id;}else second=min(second,d); | |
| 10 | + }return float4(first,second,winner); | |
| 11 | + } | |
| 12 | + | |
| 13 | + struct Passage { float a; float z; float r; float aa; }; | |
| 14 | + Passage passage(Ctx c,float pitch,float sway) { | |
| 15 | + float2 p=c.uv/c.size+float2(sin(c.t*.19),cos(c.t*.17))*sway; | |
| 16 | + Passage w;w.r=max(length(p),.04f);w.z=pitch/w.r+c.travel*2; | |
| 17 | + w.a=atan2(p.y,p.x)+c.t*.08; | |
| 18 | + w.aa=min(.35f,c.px*(1+pitch/(w.r*w.r))); | |
| 19 | + return w; | |
| 20 | + } | |
| 21 | + float3 passageFinish(float3 color,Passage w,constant NativeFrame &f){ | |
| 22 | + return color*smoothstep(.03f,.17f,w.r)+deep(.6,f)*.1; | |
| 23 | + } | |
| 24 | + | |
| 25 | + float3 saffronSpindle(Ctx c, constant NativeFrame &f) { | |
| 26 | + | |
| 27 | + Passage w=passage(c,2.4,.12); float tooth=cos(w.a*18+w.z*.35+c.t*.25); | |
| 28 | + float spoke=glow(sin(w.a*9+w.z*.15),.055), rib=line(sin(w.z*3+tooth*.3),.08,w.aa); | |
| 29 | + float lathe=.5+.5*cos(w.z*1.7+tooth*(1+c.b.y)); | |
| 30 | + return passageFinish(paint((.5+.3*sin(w.a))+w.z*.015,f)*(.22+lathe*.45+rib*.9+spoke*.8),w,f); | |
| 31 | + } | |
| 32 | + NATIVE_EFFECT(saffronSpindle) | |
| 33 | + | |
| 34 | + float3 opalineIris(Ctx c, constant NativeFrame &f) { | |
| 35 | + | |
| 36 | + Passage w=passage(c,1.8,.08); float sector=w.a*7+w.z*.28+c.t*.18; | |
| 37 | + float leaf=.5+.5*cos(sector), shutter=sin(w.z*2.7+leaf*3+c.b.x*sin(sector*2)); | |
| 38 | + float vein=line(sin(sector*5-w.z),.06,w.aa), lip=glow(shutter,.095); | |
| 39 | + float3 col=paint(leaf*.3+w.z*.022,f)*(.2+leaf*.55+vein*.25+lip); | |
| 40 | + col+=paint(.85,f)*pow(max(0.f,cos(w.z*2.7+leaf*3)),14.f)*.6; | |
| 41 | + return passageFinish(col,w,f); | |
| 42 | + } | |
| 43 | + NATIVE_EFFECT(opalineIris) | |
| 44 | + | |
| 45 | + float3 electricHelicoid(Ctx c, constant NativeFrame &f) { | |
| 46 | + | |
| 47 | + Passage w=passage(c,2.8,.1); float helical=w.a*2+w.z*.65+c.t*.2; | |
| 48 | + float sail=pow(.5+.5*cos(helical+c.b.y*sin(w.z)*.8),4.f); | |
| 49 | + float seam=line(sin(w.z*5+helical*2),.08,w.aa)*sail; | |
| 50 | + float counter=glow(sin(w.a*5-w.z*.45),.065); | |
| 51 | + return passageFinish(paint((.5+.3*sin(helical))+w.z*.008,f)*(.16+sail*.95+seam*.6)+paint(.75,f)*counter*.9,w,f); | |
| 52 | + } | |
| 53 | + NATIVE_EFFECT(electricHelicoid) | |
| 54 | + | |
| 55 | + float3 ultramarineArcade(Ctx c, constant NativeFrame &f) { | |
| 56 | + | |
| 57 | + Passage w=passage(c,2.2,.07); float2 q=float2(w.a*5/PI,w.z*.7), l=fract(q)-.5; | |
| 58 | + float arch=length(float2(l.x,l.y*.7+max(0.f,l.y)*.6))-.38; | |
| 59 | + float arcade=line(arch,.055,w.aa), pillar=glow(abs(l.x)-.42,.045); | |
| 60 | + float window=fill(arch-.06,w.aa)*(.3+.3*cos(q.y+c.t*.4+c.b.x)); | |
| 61 | + return passageFinish(paint(q.y*.04+.3*sin(floor(q.x)*TAU/10),f)*(.2+arcade+pillar*.4+window),w,f); | |
| 62 | + } | |
| 63 | + NATIVE_EFFECT(ultramarineArcade) | |
| 64 | + | |
| 65 | + float3 fuchsiaFurnace(Ctx c, constant NativeFrame &f) { | |
| 66 | + | |
| 67 | + Passage w=passage(c,2.5,.15); float ring=sin(w.z*2+sin(w.a*12)*.6); | |
| 68 | + float tooth=pow(.5+.5*cos(w.a*24+c.t*.4+w.z*.18),5.f); | |
| 69 | + float rim=line(ring,.1+c.b.z*.05,w.aa), sparks=pow(.5+.5*sin(w.z*5-w.a*11),12.f); | |
| 70 | + return passageFinish(paint((.5+.3*sin(w.a))+w.z*.015,f)*(.17+tooth*.55+rim*1.25+sparks*.4),w,f); | |
| 71 | + } | |
| 72 | + NATIVE_EFFECT(fuchsiaFurnace) | |
| 73 | + | |
| 74 | + float3 amberAperture(Ctx c, constant NativeFrame &f) { | |
| 75 | + | |
| 76 | + float3 col=deep(.5,f)*.16; | |
| 77 | + for(int k=0;k<8;++k){float2 s=layerSlot(k,8,c.travel*.14);float sc=layerScale(s.x,3.4)/c.size; | |
| 78 | + float2 p=rot(c.uv*sc,c.t*.12+s.y*.21);float corner=.22+.05*sin(s.y+c.t*.4); | |
| 79 | + float d=sdBox2(p,float2(1.1, .85))-corner;float rim=glow(d,.055+c.b[int(s.y-4*floor(s.y/4))]*.06); | |
| 80 | + float bevel=glow(d-.14,.04), wall=exp(-abs(d)*5)*.35; | |
| 81 | + col+=paint(s.y*.12,f)*(rim+bevel*.6+wall)*layerFade(s.x); | |
| 82 | + }return col; | |
| 83 | + } | |
| 84 | + NATIVE_EFFECT(amberAperture) | |
| 85 | + | |
| 86 | + float3 auroraCorkscrew(Ctx c, constant NativeFrame &f) { | |
| 87 | + | |
| 88 | + Passage w=passage(c,2.1,.14);float liquid=w.a*3+w.z*.85+sin(w.a*5-w.z*.3)*1.4; | |
| 89 | + liquid+=c.b.y*sin(w.a*13+w.z)*.7;float fold=.5+.5*sin(liquid); | |
| 90 | + float crest=pow(max(0.f,cos(liquid)),12.f), ripple=line(sin(liquid*5+w.z),.055,w.aa); | |
| 91 | + return passageFinish(paint(liquid*.05+w.z*.012,f)*(.18+fold*.6+ripple*.35)+paint(.85,f)*crest*.9,w,f); | |
| 92 | + } | |
| 93 | + NATIVE_EFFECT(auroraCorkscrew) | |
| 94 | + | |
| 95 | + float3 prismPortals(Ctx c, constant NativeFrame &f) { | |
| 96 | + | |
| 97 | + float3 col=paint(.5,f)*.12; | |
| 98 | + for(int k=0;k<9;++k){float2 s=layerSlot(k,9,c.travel*.15);float sc=layerScale(s.x,3.2)/c.size; | |
| 99 | + float2 p=rot(c.uv*sc-float2(sin(s.y*.7),cos(s.y*.4))*.2,s.y*.31+c.t*.14); | |
| 100 | + float a=atan2(p.y,p.x), polygon=length(p)*cos(fmod(a+TAU,TAU/3)-PI/3)-.78; | |
| 101 | + float edge=glow(polygon,.045+.03*c.b[int(s.y-4*floor(s.y/4))]), facet=glow(polygon-.15,.08)*.3; | |
| 102 | + col+=paint(s.y*.17+sin(a)*.2,f)*(edge*1.3+facet)*layerFade(s.x); | |
| 103 | + }return col; | |
| 104 | + } | |
| 105 | + NATIVE_EFFECT(prismPortals) | |
| 106 | + | |
| 107 | + float3 magentaConduit(Ctx c, constant NativeFrame &f) { | |
| 108 | + | |
| 109 | + Passage w=passage(c,2.3,.07);float2 q=float2(w.a*10/PI,w.z*1.1),l=fract(q)-.5,id=floor(q); | |
| 110 | + float direction=fmod(abs(id.x+id.y),2.f), trace=min(abs(l.x),abs(l.y-(direction-.5)*.45)); | |
| 111 | + float wire=line(trace,.055,w.aa), node=glow(length(l-float2(0,(direction-.5)*.45)),.14); | |
| 112 | + float charge=.45+.55*pow(.5+.5*sin(q.y*2-id.x+c.t*.6),4.f); | |
| 113 | + return passageFinish(paint(id.y*.04+.3*sin(id.x*TAU/20),f)*(.16+wire*charge+node*(.5+c.b.w)),w,f); | |
| 114 | + } | |
| 115 | + NATIVE_EFFECT(magentaConduit) | |
| 116 | + | |
| 117 | + float3 verdantSpiral(Ctx c, constant NativeFrame &f) { | |
| 118 | + | |
| 119 | + Passage w=passage(c,2.6,.11);float spine=sin(w.a*5+w.z*.65), frond=sin(w.a*20+w.z*1.8); | |
| 120 | + float stalk=glow(spine,.06), leaf=pow(.5+.5*cos(frond+spine*3+c.b.y*sin(w.z)),4.f)*exp(-abs(spine)*1.5); | |
| 121 | + float veins=line(sin(w.z*7+w.a*30),.06,w.aa)*leaf; | |
| 122 | + return passageFinish(paint((.5+.3*sin(w.a))+w.z*.014,f)*(.15+leaf*.8+veins*.35)+paint(.7,f)*stalk*.9,w,f); | |
| 123 | + } | |
| 124 | + NATIVE_EFFECT(verdantSpiral) | |
| 125 | + | |
| 126 | + float3 sapphireCascade(Ctx c, constant NativeFrame &f) { | |
| 127 | + | |
| 128 | + Passage w=passage(c,2.8,.07);float falls=sin(w.a*18+sin(w.z*.4)*.7+c.t*.2); | |
| 129 | + float water=.5+.5*sin(w.z*3+falls*2+c.b.x*sin(w.a*9)); | |
| 130 | + float film=pow(max(0.f,cos(w.z*3+falls*2)),10.f), droplets=pow(.5+.5*cos(w.a*36-w.z*5),12.f); | |
| 131 | + return passageFinish(paint(.55+falls*.08+w.z*.015,f)*(.2+water*.6+droplets*.4)+paint(.9,f)*film*.9,w,f); | |
| 132 | + } | |
| 133 | + NATIVE_EFFECT(sapphireCascade) | |
| 134 | + | |
| 135 | + float3 garnetGallery(Ctx c, constant NativeFrame &f) { | |
| 136 | + | |
| 137 | + float3 col=deep(.6,f)*.16; | |
| 138 | + for(int k=0;k<8;++k){float2 s=layerSlot(k,8,c.travel*.12);float sc=layerScale(s.x,3.3)/c.size; | |
| 139 | + float2 p=rot(c.uv*sc,s.y*.3+c.t*.13);float diamond=abs(p.x)+abs(p.y)-(1.3+c.b[int(s.y-4*floor(s.y/4))]*.12); | |
| 140 | + float face=exp(-abs(diamond)*5), edge=glow(diamond,.05), corners=glow(min(abs(p.x),abs(p.y)),.1)*face; | |
| 141 | + col+=paint(s.y*.13+p.x*.03,f)*(face*.4+edge+corners*.5)*layerFade(s.x); | |
| 142 | + }return col; | |
| 143 | + } | |
| 144 | + NATIVE_EFFECT(garnetGallery) | |
| 145 | + | |
| 146 | + float3 luminousNautilus(Ctx c, constant NativeFrame &f) { | |
| 147 | + | |
| 148 | + Passage w=passage(c,2.1,.06);float spiral=w.a*3+w.z*.55+c.t*.13; | |
| 149 | + float chamber=sin(spiral)+.4*sin(w.z*3.8+cos(spiral)*2); | |
| 150 | + float ribs=line(chamber,.08+c.b.z*.05,w.aa), pearl=pow(.5+.5*cos(spiral),4.f); | |
| 151 | + float3 col=paint(sin(spiral)*.24+w.z*.02,f)*(.18+pearl*.6+ribs*.8); | |
| 152 | + col+=paint(.85,f)*pow(max(0.f,cos(chamber*4)),14.f)*.5; | |
| 153 | + return passageFinish(col,w,f); | |
| 154 | + } | |
| 155 | + NATIVE_EFFECT(luminousNautilus) | |
| 156 | + | |
| 157 | + float3 indigoInfinity(Ctx c, constant NativeFrame &f) { | |
| 158 | + | |
| 159 | + float3 col=paint(.5,f)*.12; | |
| 160 | + for(int k=0;k<7;++k){float2 s=layerSlot(k,7,c.travel*.13);float sc=layerScale(s.x,3)/c.size; | |
| 161 | + float2 p=rot(c.uv*sc,s.y*.27+c.t*.12);float r2=dot(p,p); | |
| 162 | + float curve=abs(r2*r2-2*(p.x*p.x-p.y*p.y))- (.14+.07*c.b[int(s.y-4*floor(s.y/4))]); | |
| 163 | + float hoop=glow(curve/max(.3f,r2),.055), mist=glow(curve/max(.3f,r2),.3)*.18; | |
| 164 | + col+=paint(s.y*.16+p.x*.04,f)*(hoop+mist)*layerFade(s.x); | |
| 165 | + }return col; | |
| 166 | + } | |
| 167 | + NATIVE_EFFECT(indigoInfinity) | |
| 168 | + | |
| 169 | + float3 goldenGyre(Ctx c, constant NativeFrame &f) { | |
| 170 | + | |
| 171 | + Passage w=passage(c,2.7,.1);float fan=w.a*11+w.z*.45; | |
| 172 | + float shade=.5+.5*cos(fan+sin(w.z)*c.b.y), slat=line(sin(fan),.065,w.aa); | |
| 173 | + float arc=line(sin(w.z*3+sin(fan)*.5),.07,w.aa), sun=pow(.5+.5*cos(fan-w.z*.8),8.f); | |
| 174 | + return passageFinish(paint((.5+.3*sin(w.a))+w.z*.01,f)*(.2+shade*.45+slat*.6+arc*.7+sun*.5),w,f); | |
| 175 | + } | |
| 176 | + NATIVE_EFFECT(goldenGyre) | |
| 177 | + | |
| 178 | + float3 liquidLabyrinth(Ctx c, constant NativeFrame &f) { | |
| 179 | + | |
| 180 | + Passage w=passage(c,2.1,.05);float2 q=float2(w.a*5/PI,w.z*.9); | |
| 181 | + q+=float2(sin(q.y*.8+c.t*.4),cos(w.a*3+c.t*.3))*(.3+c.b.x*.35); | |
| 182 | + float4 v=passageCells(q,10,.6,c.t*.7);float seam=glow(v.y-v.x,.065), pool=exp(-v.x*v.x*4); | |
| 183 | + float chrome=pow(max(0.f,1-v.x*1.5),12.f); | |
| 184 | + return passageFinish(paint(v.z*.13+v.w*.11,f)*(.18+pool*.45+seam*.8)+paint(.85,f)*chrome*.5,w,f); | |
| 185 | + } | |
| 186 | + NATIVE_EFFECT(liquidLabyrinth) | |
| 187 | + | |
| 188 | + float3 photonPetals(Ctx c, constant NativeFrame &f) { | |
| 189 | + | |
| 190 | + float3 col=paint(.4,f)*.12; | |
| 191 | + for(int k=0;k<8;++k){float2 s=layerSlot(k,8,c.travel*.14);float sc=layerScale(s.x,3)/c.size; | |
| 192 | + float2 p=rot(c.uv*sc,s.y*.34+c.t*.14);float a=atan2(p.y,p.x),r=length(p); | |
| 193 | + float edge=r-(1.2+.25*cos(a*6)+.1*c.b[int(s.y-4*floor(s.y/4))]*sin(a*12)); | |
| 194 | + float lip=glow(edge,.05), petal=glow(edge-.18,.13)*(.5+.5*cos(a*6)); | |
| 195 | + col+=paint(s.y*.15+(.5+.3*sin(a)),f)*(lip*1.2+petal*.5)*layerFade(s.x); | |
| 196 | + }return col; | |
| 197 | + } | |
| 198 | + NATIVE_EFFECT(photonPetals) | |
| 199 | + | |
| 200 | + | |
| 201 | + float3 celestialCoil(Ctx c, constant NativeFrame &f) { | |
| 202 | + | |
| 203 | + Passage w=passage(c,2.3,.09);float spring=w.z*4+w.a*2+c.t*.17; | |
| 204 | + float wire=glow(sin(spring),.075), rail=glow(sin(w.a*5+w.z*.08),.05); | |
| 205 | + float bead=pow(.5+.5*cos(w.a*20-w.z),8.f)*wire; | |
| 206 | + float sheen=.5+.5*cos(spring+c.b.y*sin(w.a*9)*.8); | |
| 207 | + return passageFinish(paint(w.z*.016+(.5+.3*sin(w.a)),f)*(.18+sheen*.35+wire*.8+rail*.6+bead*.8),w,f); | |
| 208 | + } | |
| 209 | + NATIVE_EFFECT(celestialCoil) | |
| 210 | + | |
| 211 | + float3 chromeComet(Ctx c, constant NativeFrame &f) { | |
| 212 | + | |
| 213 | + Passage w=passage(c,2.4,.08);float metal=sin(w.a*4+w.z*.6)+.45*sin(w.a*9-w.z*.35); | |
| 214 | + metal+=c.b.x*sin(w.a*16+w.z)*.5;float crease=.5+.5*sin(metal*4+w.z*.4); | |
| 215 | + float spec=pow(max(0.f,cos(metal*4+w.z*.4)),16.f), tails=line(sin(w.a*24+w.z*.2),.07,w.aa); | |
| 216 | + return passageFinish(paint(metal*.08+w.z*.01,f)*(.16+crease*.6+tails*.25)+paint(.9,f)*spec*1.2,w,f); | |
| 217 | + } | |
| 218 | + NATIVE_EFFECT(chromeComet) | |
| 219 | + | |
| 220 | + float3 candyCathedral(Ctx c, constant NativeFrame &f) { | |
| 221 | + | |
| 222 | + Passage w=passage(c,2.2,.1);float arch=sin(w.z*2.1+cos(w.a*3)*1.4); | |
| 223 | + float rose=pow(.5+.5*cos(w.a*12+w.z*.1),4.f), mullion=line(sin(w.a*24),.07,w.aa); | |
| 224 | + float ribs=line(arch,.09+c.b.z*.06,w.aa), glass=.5+.5*sin(w.z*3.7+w.a*7); | |
| 225 | + return passageFinish(paint((.5+.3*sin(w.a))+w.z*.025,f)*(.16+glass*rose*.65+mullion*.35+ribs),w,f); | |
| 226 | + } | |
| 227 | + NATIVE_EFFECT(candyCathedral) | |
| 228 | + | |
| 229 | + float3 scarletSiphon(Ctx c, constant NativeFrame &f) { | |
| 230 | + | |
| 231 | + Passage w=passage(c,2.6,.14);float stream=w.z*.8+w.a*4+sin(w.z*.5-w.a*2)*1.5; | |
| 232 | + float tear=pow(.5+.5*cos(stream+c.b.y*sin(w.z)*.9),3.f), small=line(sin(stream*7+w.a*5),.07,w.aa); | |
| 233 | + float shine=pow(max(0.f,sin(stream)),12.f); | |
| 234 | + return passageFinish(paint(sin(stream)*.24+w.z*.01,f)*(.18+tear*.65+small*.25)+paint(.85,f)*shine*.8,w,f); | |
| 235 | + } | |
| 236 | + NATIVE_EFFECT(scarletSiphon) | |
| 237 | + | |
| 238 | + float3 emeraldEcho(Ctx c, constant NativeFrame &f) { | |
| 239 | + | |
| 240 | + float3 col=paint(.5,f)*.12; | |
| 241 | + for(int k=0;k<9;++k){float2 s=layerSlot(k,9,c.travel*.15);float sc=layerScale(s.x,3.5)/c.size; | |
| 242 | + float2 p=rot(c.uv*sc,s.y*.2+c.t*.14);float a=atan2(p.y,p.x); | |
| 243 | + float d=length(p)*cos(fmod(a+TAU,TAU/8)-PI/8)-1.1; | |
| 244 | + float rim=glow(d,.045+.03*c.b[int(s.y-4*floor(s.y/4))]), brace=glow(d-.18,.035)*(.5+.5*cos(a*16)); | |
| 245 | + col+=paint(s.y*.14+sin(a)*.2,f)*(rim*1.3+brace*.6)*layerFade(s.x); | |
| 246 | + }return col; | |
| 247 | + } | |
| 248 | + NATIVE_EFFECT(emeraldEcho) | |
| 249 | + | |
| 250 | + float3 arcticRaceway(Ctx c, constant NativeFrame &f) { | |
| 251 | + | |
| 252 | + Passage w=passage(c,2.8,.09);float2 q=float2(w.a*7/PI,w.z*.85),l=fract(q)-.5; | |
| 253 | + float shard=abs(l.x)+abs(l.y)*1.3-.5, cuts=min(abs(l.x-l.y),abs(l.x+l.y)); | |
| 254 | + float ridge=line(shard,.06,w.aa), glint=glow(cuts,.04)*fill(shard,w.aa); | |
| 255 | + float shade=.5+.5*cos(q.y*2+floor(q.x)+c.b.x*sin(q.x)); | |
| 256 | + return passageFinish(paint(.3*sin(floor(q.x)*TAU/14)+floor(q.y)*.06,f)*(.18+shade*.4+ridge*.8+glint*.7),w,f); | |
| 257 | + } | |
| 258 | + NATIVE_EFFECT(arcticRaceway) | |
| 259 | + | |
| 260 | + float3 plasmaPassage(Ctx c, constant NativeFrame &f) { | |
| 261 | + | |
| 262 | + Passage w=passage(c,2.4,.12);float plasma=sin(w.a*5+w.z*.8+sin(w.a*3-w.z*.4)*1.2); | |
| 263 | + plasma+=.6*cos(w.a*11-w.z*1.6+c.t*.4+c.b.y*sin(w.z)); | |
| 264 | + float skin=glow(plasma,.1), body=.5+.5*sin(plasma*3), hot=pow(max(0.f,cos(plasma*3)),12.f); | |
| 265 | + return passageFinish(paint(plasma*.12+w.z*.017,f)*(.2+body*.5+skin*.7)+paint(.85,f)*hot*.65,w,f); | |
| 266 | + } | |
| 267 | + NATIVE_EFFECT(plasmaPassage) | |
| 268 | + | |
| 269 | + float3 violetVelocity(Ctx c, constant NativeFrame &f) { | |
| 270 | + | |
| 271 | + Passage w=passage(c,3.3,.07);float a=w.a+w.z*.05; | |
| 272 | + float slats=pow(.5+.5*cos(a*22),7.f), streak=.5+.5*sin(w.z*1.2+floor(a*12)*1.3); | |
| 273 | + float lips=line(sin(w.z*3.6+a*2),.07+c.b.w*.05,w.aa); | |
| 274 | + float cross=pow(.5+.5*cos(a*5-w.z*.6+c.t*.2),4.f); | |
| 275 | + return passageFinish(paint((.5+.3*sin(a))+w.z*.011,f)*(.18+slats*(.5+streak*.7)+lips*.9+cross*.3),w,f); | |
| 276 | + } | |
| 277 | + NATIVE_EFFECT(violetVelocity) | |
| 278 | + | |
| 279 | + float3 tangerineTurbine(Ctx c, constant NativeFrame &f) { | |
| 280 | + | |
| 281 | + float3 col=deep(.6,f)*.18; | |
| 282 | + for(int k=0;k<7;++k){float2 s=layerSlot(k,7,c.travel*.13);float sc=layerScale(s.x,3.1)/c.size; | |
| 283 | + float2 p=c.uv*sc;float a=atan2(p.y,p.x)+s.y*.45+c.t*.3,r=length(p); | |
| 284 | + float blade=pow(.5+.5*cos(a*8+r*.7+sin(a*8)*c.b[int(s.y-4*floor(s.y/4))]*.5),5.f); | |
| 285 | + float rim=glow(r-1.4,.055), fan=blade*exp(-abs(r-1.3)*2.5); | |
| 286 | + col+=paint(s.y*.15+(.5+.3*sin(a)),f)*(fan*.85+rim*.7)*layerFade(s.x); | |
| 287 | + }return col; | |
| 288 | + } | |
| 289 | + NATIVE_EFFECT(tangerineTurbine) | |
| 290 | + | |
| 291 | + float3 ceruleanShell(Ctx c, constant NativeFrame &f) { | |
| 292 | + | |
| 293 | + Passage w=passage(c,2.4,.08);float scallop=cos(w.a*10+w.z*.18); | |
| 294 | + float shell=sin(w.z*2.7+scallop*.7+c.b.x*sin(w.a*20)*.35), growth=line(shell,.08,w.aa); | |
| 295 | + float pearl=pow(.5+.5*cos(w.z*2.7+scallop*.7),5.f), hair=line(sin(w.a*40+w.z*.15),.05,w.aa); | |
| 296 | + return passageFinish(paint((.5+.3*sin(w.a))+w.z*.014,f)*(.22+pearl*.5+growth*.8+hair*.2),w,f); | |
| 297 | + } | |
| 298 | + NATIVE_EFFECT(ceruleanShell) | |
| 299 | + | |
| 300 | + float3 discoHelix(Ctx c, constant NativeFrame &f) { | |
| 301 | + | |
| 302 | + Passage w=passage(c,2.6,.11);float2 q=float2(w.a*8/PI+w.z*.16,w.z*.85); | |
| 303 | + float4 cell=hexCell(q);float r=length(cell.xy), rim=line(sdHex(cell.xy,.47),.045,w.aa); | |
| 304 | + float local=.5+.5*sin(sin(cell.z*TAU/16)*2+cell.w*1.7+c.t*.8), band=c.b[int(cell.z+cell.w-4*floor((cell.z+cell.w)/4))]; | |
| 305 | + float jewel=pow(max(0.f,1-r*1.6),2.f), facets=.5+.5*cos(atan2(cell.y,cell.x)*6); | |
| 306 | + return passageFinish(paint(.3*sin(cell.z*TAU/16)+cell.w*.07,f)*(.14+rim*.8+jewel*(.5+facets*.4+band*.5)*local),w,f); | |
| 307 | + } | |
| 308 | + NATIVE_EFFECT(discoHelix) | |
| 309 | + | |
| 310 | + float3 iridescentDescent(Ctx c, constant NativeFrame &f) { | |
| 311 | + | |
| 312 | + Passage w=passage(c,2.9,.1);float terrace=w.z*2+sin(w.a*4)*.8; | |
| 313 | + float rounded=floor(terrace)+smoothstep(.35f,.65f,fract(terrace)), contour=line(sin(terrace*PI),.06,w.aa); | |
| 314 | + float gleam=pow(.5+.5*cos(w.a*7+rounded+c.b.y*sin(w.a*13)),8.f); | |
| 315 | + return passageFinish(paint(rounded*.065+(.5+.3*sin(w.a)),f)*(.2+.25*fract(terrace)+contour*.85+gleam*.6),w,f); | |
| 316 | + } | |
| 317 | + NATIVE_EFFECT(iridescentDescent) | |
| 318 | + | |
| 319 | + float3 solarSerpent(Ctx c, constant NativeFrame &f) { | |
| 320 | + | |
| 321 | + Passage w=passage(c,2.3,.1);float3 col=deep(.5,f)*.18; | |
| 322 | + for(int k=0;k<4;++k){float phase=w.a+float(k)*PI*.5+w.z*.4+c.t*.16; | |
| 323 | + float center=sin(phase)+.25*sin(w.z*1.2+float(k)+c.b[k]*sin(w.a*5)); | |
| 324 | + float ribbon=glow(center,.17), scales=line(sin(w.z*7+phase*6),.07,w.aa); | |
| 325 | + col+=paint(float(k)*.22+w.z*.014,f)*ribbon*(.6+scales*.6); | |
| 326 | + }return passageFinish(col,w,f); | |
| 327 | + } | |
| 328 | + NATIVE_EFFECT(solarSerpent) | |
| 329 | + | |
| 330 | + float3 rainbowReactor(Ctx c, constant NativeFrame &f) { | |
| 331 | + | |
| 332 | + Passage w=passage(c,2.7,.08);float2 q=float2(w.a*7/PI,w.z*.8);float4 cell=hexCell(q); | |
| 333 | + float edge=line(sdHex(cell.xy,.43),.06,w.aa), core=glow(length(cell.xy),.2+c.b.x*.08); | |
| 334 | + float bolt=line(sin(w.a*21+w.z*.7),.05,w.aa), energy=.4+.6*pow(.5+.5*cos(w.z*3+c.t*.4),4.f); | |
| 335 | + return passageFinish(paint(.3*sin(cell.z*TAU/14)+cell.w*.08,f)*(.16+edge*.6+core*energy+bolt*.35),w,f); | |
| 336 | + } | |
| 337 | + NATIVE_EFFECT(rainbowReactor) | |
| 338 | + | |
| 339 | + | |
| 340 | + float3 crystalCarousel(Ctx c, constant NativeFrame &f) { | |
| 341 | + | |
| 342 | + Passage w=passage(c,2.5,.1);float2 q=float2(w.a*8/PI+w.z*.1,w.z*.8),l=fract(q)-.5; | |
| 343 | + float square=max(abs(l.x),abs(l.y)), diamond=abs(l.x)+abs(l.y); | |
| 344 | + float edges=line(square-.42,.05,w.aa)+line(diamond-.45,.035,w.aa); | |
| 345 | + float bevel=pow(min(abs(l.x),abs(l.y))/max(.03f,square),6.f)*fill(square-.4,w.aa); | |
| 346 | + float pulse=.4+.6*pow(.5+.5*cos(floor(q.x)+floor(q.y)*.7+c.t*.5),3.f); | |
| 347 | + return passageFinish(paint(.3*sin(floor(q.x)*TAU/16)+floor(q.y)*.06,f)*(.2+edges*.65+bevel*(.6+c.b.z)*pulse),w,f); | |
| 348 | + } | |
| 349 | + NATIVE_EFFECT(crystalCarousel) | |
| 350 | + | |
| 351 | + float3 neonMaelstrom(Ctx c, constant NativeFrame &f) { | |
| 352 | + | |
| 353 | + Passage w=passage(c,2.8,.16);float twist=w.a*6+w.z*.85+c.t*.2; | |
| 354 | + float eddy=sin(twist)+.45*sin(twist*2-w.z*.6+c.b.y*sin(w.a*11)); | |
| 355 | + float flow=.5+.5*cos(eddy*4+w.z*.7), curl=line(sin(twist*4+w.z*2),.065,w.aa); | |
| 356 | + float foam=pow(max(0.f,sin(eddy*4+w.z*.7)),14.f); | |
| 357 | + return passageFinish(paint(sin(twist)*.24+w.z*.011,f)*(.16+flow*.6+curl*.4)+paint(.9,f)*foam*.85,w,f); | |
| 358 | + } | |
| 359 | + NATIVE_EFFECT(neonMaelstrom) | |
| 360 | + | |
| 361 | + // Coaster versions: the same designs riding the roller-coaster course. | |
| 362 | + NATIVE_COASTER(saffronSpindle, 245, false) | |
| 363 | + NATIVE_COASTER(opalineIris, 246, false) | |
| 364 | + NATIVE_COASTER(electricHelicoid, 247, false) | |
| 365 | + NATIVE_COASTER(ultramarineArcade, 248, false) | |
| 366 | + NATIVE_COASTER(fuchsiaFurnace, 249, false) | |
| 367 | + NATIVE_COASTER(auroraCorkscrew, 251, false) | |
| 368 | + NATIVE_COASTER(magentaConduit, 253, false) | |
| 369 | + NATIVE_COASTER(sapphireCascade, 255, false) | |
| 370 | + NATIVE_COASTER(luminousNautilus, 257, false) | |
| 371 | + NATIVE_COASTER(goldenGyre, 259, false) | |
| 372 | + NATIVE_COASTER(liquidLabyrinth, 260, false) | |
| 373 | + NATIVE_COASTER(celestialCoil, 263, false) | |
| 374 | + NATIVE_COASTER(chromeComet, 264, false) | |
| 375 | + NATIVE_COASTER(candyCathedral, 265, false) | |
| 376 | + NATIVE_COASTER(scarletSiphon, 266, false) | |
| 377 | + NATIVE_COASTER(arcticRaceway, 268, false) | |
| 378 | + NATIVE_COASTER(plasmaPassage, 269, false) | |
| 379 | + NATIVE_COASTER(violetVelocity, 270, false) | |
| 380 | + NATIVE_COASTER(ceruleanShell, 272, false) | |
| 381 | + NATIVE_COASTER(discoHelix, 273, false) | |
| 382 | + NATIVE_COASTER(iridescentDescent, 274, false) | |
| 383 | + NATIVE_COASTER(solarSerpent, 275, false) | |
| 384 | + NATIVE_COASTER(rainbowReactor, 276, false) | |
| 385 | + NATIVE_COASTER(crystalCarousel, 278, false) | |
| 386 | + NATIVE_COASTER(neonMaelstrom, 279, false) |
Sources/PulseCanvas/Resources/NativeExpansionPortal.metal added
| 1 | + // Original PulseCanvas designs 310–319: portal tunnels. Each is a perspective tube or portal | |
| 2 | + // stack whose walls carry one strong surface material (chainmail, feathers, tartan, | |
| 3 | + // herringbone, quilting, lace, zippers, cable knit, basketry, louvres). Cross-sections and | |
| 4 | + // cameras vary: a billowing bent bore, a pointed vault, a twisting rounded square, a | |
| 5 | + // rectangular hall, an off-axis pipe, a lace stack, a helical seam, a padded bent tube, | |
| 6 | + // an elliptic burrow seen from low down and an octagon. Original procedural code; every | |
| 7 | + // audio term is zero at zero Chaos. | |
| 8 | + | |
| 9 | + // ---------------------------------------------------------------- shared portal helpers | |
| 10 | + // Smooth wandering offset for a vanishing point. | |
| 11 | + float2 ptlDrift(float t, float2 amount) { | |
| 12 | + return float2(sin(t * .21 + .6) + .5 * sin(t * .34 + 2.3), cos(t * .17 + 1.1) + .5 * sin(t * .29 + .2)) / 1.5 * amount; | |
| 13 | + } | |
| 14 | + // Bent view: far depths converge on the drifting vanishing point while the near walls stay | |
| 15 | + // put. One-to-one for |vanish| < .9. | |
| 16 | + float2 ptlBend(float2 uv, float2 vanish) { return uv - vanish * exp(-dot(uv, uv) * 1.6); } | |
| 17 | + float ptlFog(float depth, Ctx c, float base) { return exp(-depth * (base + c.fog * .12)); } | |
| 18 | + float ptlAttack(Ctx c) { return smoothstep(.03f, .65f, c.hit); } | |
| 19 | + // Attack front: a band of depth that starts near the camera and runs away as the attack | |
| 20 | + // decays, so every hit sends a local event down the tunnel. | |
| 21 | + float ptlFront(Ctx c, float depth, float near, float far, float width) { | |
| 22 | + float x = (depth - near - (1 - ptlAttack(c)) * far) / width; | |
| 23 | + return c.hit * exp(-x * x); | |
| 24 | + } | |
| 25 | + float ptlWrap(float x, float period) { return x - period * floor(x / period); } | |
| 26 | + float ptlBand(Ctx c, float id) { return c.b[min(3, int(ptlWrap(id, 4.f)))]; } | |
| 27 | + | |
| 28 | + // ---------------------------------------------------------------- 310 Chainmail Bore | |
| 29 | + // A bent bore lined with interlocking 4-in-1 chainmail. Two staggered ring families tilt | |
| 30 | + // opposite ways, so every crossing alternates over and under. Bass billows the mesh in | |
| 31 | + // rolling folds and lights their crests, low-mids roll light behind the mesh, high-mids | |
| 32 | + // tint the staggered ring family, highs spin bright glints around the rings and attacks run | |
| 33 | + // a bright ripple through whole linked rings. | |
| 34 | + struct PtlRing { float cover; float height; float across; float2 dir; float2 centre; float family; }; | |
| 35 | + | |
| 36 | + PtlRing ptlNoRing() { | |
| 37 | + PtlRing ring; | |
| 38 | + ring.cover = 0; ring.height = -9; ring.across = 0; ring.dir = float2(0, 1); ring.centre = 0; ring.family = 0; | |
| 39 | + return ring; | |
| 40 | + } | |
| 41 | + PtlRing ptlMailRing(float2 p, float2 centre, float family, float aa) { | |
| 42 | + const float radius = .4, wire = .088; | |
| 43 | + PtlRing ring; | |
| 44 | + float2 l = p - centre; | |
| 45 | + float dist = length(l); | |
| 46 | + ring.dir = l / max(dist, 1e-4f); | |
| 47 | + ring.across = clamp((dist - radius) / wire, -1.f, 1.f); | |
| 48 | + ring.cover = 1 - smoothstep(wire - aa, wire + aa, abs(dist - radius)); | |
| 49 | + // Opposite tilts for the two families make every crossing alternate over and under. | |
| 50 | + ring.height = (family > .5 ? -l.y : l.y) / radius; | |
| 51 | + ring.centre = centre; | |
| 52 | + ring.family = family; | |
| 53 | + return ring; | |
| 54 | + } | |
| 55 | + float3 ptlMailShade(PtlRing ring, Ctx c, constant NativeFrame &f, float unit, float travel, float crest) { | |
| 56 | + float seed = hash21(float2(ptlWrap(ring.centre.x, 20.f), ring.centre.y) + ring.family * 41); | |
| 57 | + float s = ring.across; | |
| 58 | + float3 n = normalize(float3(ring.dir * s, sqrt(max(0.f, 1 - s * s)) + .2)); | |
| 59 | + // Each ring has its own light that circles it: the glint spins around the wire. | |
| 60 | + float spin = seed * TAU + c.t * (.5 + seed) * (seed > .5 ? 1 : -1); | |
| 61 | + float3 light = normalize(float3(cos(spin), sin(spin), 1.1)); | |
| 62 | + float diffuse = max(0.f, dot(n, light)); | |
| 63 | + float spec = pow(max(0.f, dot(n, normalize(light + float3(0, 0, 1)))), 28.f); | |
| 64 | + float ripple = ptlFront(c, ring.centre.y * unit - travel, .5, 6, .45); | |
| 65 | + float twinkle = step(.5f, seed) * pow(.5 + .5 * sin(c.t * 4.3 + seed * 60), 6.f); | |
| 66 | + float3 base = paint(.04 + seed * .24 + ring.family * (.3 + c.b.z * .2), f); | |
| 67 | + float3 color = base * (.04 + .5 * diffuse) * (1 + ring.family * c.b.z * 2.6 + crest * 2.6); | |
| 68 | + color += paint(.95, f) * spec * (.5 + c.b.w * 6 * (.25 + twinkle)); | |
| 69 | + color += paint(.85 + seed * .1, f) * ripple * (1 + 2.5 * spec + diffuse); | |
| 70 | + return color; | |
| 71 | + } | |
| 72 | + | |
| 73 | + float3 chainmailBore(Ctx c, constant NativeFrame &f) { | |
| 74 | + const float N = 20, unit = TAU / N; | |
| 75 | + float2 vanish = ptlDrift(c.t * .6, float2(.3, .2)); | |
| 76 | + float2 q = ptlBend(c.uv / c.size, vanish); | |
| 77 | + float r = max(length(q), 1e-3f), a = atan2(q.y, q.x); | |
| 78 | + float travel = c.travel * 2.2, d0 = 1 / r; | |
| 79 | + // The mesh hangs in soft folds that roll toward the camera; bass deepens them. | |
| 80 | + float fold = .6 * sin(a * 3 + (d0 + travel) * .8 - c.t * .7) + .4 * sin(a * 2 - (d0 + travel) * .5 + c.t * .45); | |
| 81 | + float depth = d0 * (1 + (.05 + .22 * c.b.x) * fold); | |
| 82 | + float zw = depth + travel; | |
| 83 | + float2 p = float2(a, zw) / unit; | |
| 84 | + float fw = c.px / c.size * max(1.f, depth) / r / unit; | |
| 85 | + float aa = clamp(fw * .75f, .004f, .3f); | |
| 86 | + PtlRing best = ptlNoRing(), under = ptlNoRing(); | |
| 87 | + float2 baseA = floor(p), baseB = floor(p - .5) + .5; | |
| 88 | + for (int k = 0; k < 8; ++k) { | |
| 89 | + float2 o = float2(float(k & 1), float((k >> 1) & 1)); | |
| 90 | + PtlRing ring = ptlMailRing(p, (k < 4 ? baseA : baseB) + o, k < 4 ? 0.f : 1.f, aa); | |
| 91 | + if (ring.cover > .001) { | |
| 92 | + if (ring.height > best.height) { under = best; best = ring; } | |
| 93 | + else if (ring.height > under.height) under = ring; | |
| 94 | + } | |
| 95 | + } | |
| 96 | + float crest = max(0.f, fold) * c.b.x; | |
| 97 | + float behind = .5 + .5 * sin(zw * .7 - c.t * .8 + sin(a * 2 + c.t * .1) * 1.2); | |
| 98 | + float3 back = deep(.5, f) * .03 + paint(.45 + .15 * sin(a + zw * .05), f) * behind * behind * (.02 + .6 * c.b.y); | |
| 99 | + back += paint(.85, f) * ptlFront(c, depth, .5, 6, .6) * .4; | |
| 100 | + float3 color = back; | |
| 101 | + if (under.cover > 0) color = mix(color, ptlMailShade(under, c, f, unit, travel, crest) * .45, under.cover); | |
| 102 | + if (best.cover > 0) color = mix(color, ptlMailShade(best, c, f, unit, travel, crest), best.cover); | |
| 103 | + float3 average = back * .6 + paint(.2, f) * (.09 + crest * .2); | |
| 104 | + color = mix(average, color, smoothstep(.24f, .07f, fw)); | |
| 105 | + float3 core = paint(.55, f) * .12 + paint(.9, f) * exp(-r * 7) * .8; | |
| 106 | + return mix(core, color, ptlFog(depth, c, .045)); | |
| 107 | + } | |
| 108 | + NATIVE_EFFECT(chainmailBore) | |
| 109 | + | |
| 110 | + // ---------------------------------------------------------------- 311 Feather Vault | |
| 111 | + // A pointed vault lined with long overlapping iridescent feathers whose tips flow toward the | |
| 112 | + // viewer. Farther rows lie on top, like scales, and the feathers lean so the rows spiral. | |
| 113 | + // Bass lifts waves of feathers (they reach out, catch light and throw shadows), low-mids | |
| 114 | + // light the shafts, high-mids the vane rims, highs shimmer the barbs and attacks ruffle a | |
| 115 | + // wave of feathers down the vault. | |
| 116 | + float ptlVaultRadius(float a) { | |
| 117 | + float s = sin(a), co = cos(a); | |
| 118 | + // Pointed arch above (two circular arcs meeting at the apex), a flatter oval below. | |
| 119 | + if (s > 0) return sqrt(1.55f * 1.55f - .3025f * s * s) - .55f * abs(co); | |
| 120 | + return rsqrt(co * co + s * s / .8f); | |
| 121 | + } | |
| 122 | + struct PtlFeather { float alpha; float shadow; float3 color; }; | |
| 123 | + | |
| 124 | + PtlFeather ptlFeather(float2 p, float row, float column, Ctx c, constant NativeFrame &f, float aa, float resolve, float rowDepth, float N) { | |
| 125 | + PtlFeather fe; | |
| 126 | + float seed = hash21(float2(ptlWrap(column, N), row)); | |
| 127 | + float sway = .5 + .5 * sin(row * .7 + column * 1.3 - c.t * 1.2); | |
| 128 | + float ruffle = ptlFront(c, rowDepth, .45, 6, .6); | |
| 129 | + float lift = c.b.x * (.2 + .8 * sway * sway) * 1.5 + ruffle * 1.4; | |
| 130 | + float y = p.y - row + lift * .2; | |
| 131 | + float t = (y + 1.6) / 2.1; // 0 at the tip, 1 at the base | |
| 132 | + // Feathers lean and their tips curl, so the rows read as a flowing helix. | |
| 133 | + float x = p.x - column + t * .95 - .12 * (1 - t) * (1 - t) - .04 * sin(c.t * .7 + seed * 6); | |
| 134 | + float halfWidth = .5 * pow(saturate(t * 2.2), .6f) * (1 + lift * .08); | |
| 135 | + float edge = abs(x) - halfWidth; | |
| 136 | + float body = smoothstep(-.01f, .03f, t) * (1 - smoothstep(.9f, 1.f, t)); | |
| 137 | + // Barbs sweep from the shaft back toward the base; some vanes split apart. | |
| 138 | + float barbCoord = y + abs(x) * 1.6; | |
| 139 | + float split = smoothstep(.04f, .015f, abs(fract(barbCoord * .8 + seed * 3) - .5)) * step(.08f, abs(x)) * step(.35f, seed); | |
| 140 | + fe.alpha = (1 - smoothstep(-aa, aa, edge)) * body * (1 - split * resolve * .9); | |
| 141 | + float st = (y + 1.8 + .2 * lift) / 2.1; | |
| 142 | + fe.shadow = (1 - smoothstep(-.1f, .12f, abs(x) - .55f * pow(saturate(st * 2.2), .6f))) * smoothstep(0.f, .1f, st) * (.45 + .55 * saturate(lift)); | |
| 143 | + float across = saturate(abs(x) / max(halfWidth, 1e-3f)); | |
| 144 | + float barbs = pow(.5 + .5 * cos(barbCoord * 14 * TAU), 2.f); | |
| 145 | + float shimmer = c.b.w * sin(barbCoord * 7 + c.t * 3 + seed * 9); | |
| 146 | + float3 film = filmColor(seed * .5 + across * .45 + t * .4 + shimmer * .3 + c.t * .02, f); | |
| 147 | + float tuck = mix(1.f, .12f, smoothstep(.22f, .55f, t)); | |
| 148 | + float barbLight = mix(.55f, .3f + .8f * barbs * (1 + 2.5 * c.b.w), resolve); | |
| 149 | + float3 color = film * (.07 + .3 * (1 - across * .6)) * barbLight * tuck; | |
| 150 | + color += film * lift * .45 * pow(1 - across * .7, 2.f) * tuck; | |
| 151 | + float shaft = line(x, .028 * (1.3 - t * .6), aa) * smoothstep(.02f, .08f, t); | |
| 152 | + color += paint(.9, f) * shaft * (.12 + 2.6 * c.b.y) * tuck; | |
| 153 | + float rim = smoothstep(-.1f, -.01f, edge); | |
| 154 | + color += paint(.72 + seed * .12, f) * rim * (.06 + 2.2 * c.b.z) * tuck; | |
| 155 | + color += paint(.92, f) * ruffle * (.4 + barbs) * tuck; | |
| 156 | + fe.color = color; | |
| 157 | + return fe; | |
| 158 | + } | |
| 159 | + | |
| 160 | + float3 featherVault(Ctx c, constant NativeFrame &f) { | |
| 161 | + const float N = 22, rowLength = .34; | |
| 162 | + float2 vanish = ptlDrift(c.t * .5, float2(.16, .1)) + float2(0, .14); | |
| 163 | + float2 q = ptlBend(c.uv / c.size, vanish); | |
| 164 | + float r = max(length(q), 1e-3f), a = atan2(q.y, q.x); | |
| 165 | + float depth = ptlVaultRadius(a) / r; | |
| 166 | + float travel = c.travel * 2.1, zw = depth + travel; | |
| 167 | + float2 p = float2(a * N / TAU, zw / rowLength); | |
| 168 | + float fw = c.px / c.size / r * max(N / TAU, depth / rowLength); | |
| 169 | + float aa = clamp(fw, .004f, .3f); | |
| 170 | + float resolve = smoothstep(.1f, .035f, fw); | |
| 171 | + float3 color = 0; | |
| 172 | + float transmit = 1, shade = 1; | |
| 173 | + float baseRow = floor(p.y); | |
| 174 | + for (int k = 2; k >= 0; --k) { | |
| 175 | + float row = baseRow + float(k); | |
| 176 | + float offset = ptlWrap(row, 2.f) * .5; | |
| 177 | + float lean = saturate((p.y - row + 1.6) / 2.1) * .95; | |
| 178 | + float column = floor(p.x + lean - offset + .5) + offset; | |
| 179 | + float other = column + (p.x + lean > column ? 1 : -1); | |
| 180 | + float rowDepth = row * rowLength - travel; | |
| 181 | + for (int j = 0; j < 2; ++j) { | |
| 182 | + PtlFeather fe = ptlFeather(p, row, j == 0 ? column : other, c, f, aa, resolve, rowDepth, N); | |
| 183 | + color += transmit * shade * fe.alpha * fe.color; | |
| 184 | + transmit *= 1 - fe.alpha; | |
| 185 | + shade *= 1 - .65 * fe.shadow; | |
| 186 | + } | |
| 187 | + } | |
| 188 | + color += transmit * shade * deep(.35, f) * .05; | |
| 189 | + // The apex rib of the pointed vault. | |
| 190 | + float rib = exp(-abs(a - PI * .5) * r * 60) * step(0.f, q.y); | |
| 191 | + color += paint(.8, f) * rib * (.12 + .5 * c.b.z); | |
| 192 | + float3 core = paint(.65, f) * .25 + paint(.92, f) * exp(-r * 6) * 1.1; | |
| 193 | + return mix(core, color, ptlFog(depth, c, .05)); | |
| 194 | + } | |
| 195 | + NATIVE_EFFECT(featherVault) | |
| 196 | + | |
| 197 | + // ---------------------------------------------------------------- 312 Tartan Tube | |
| 198 | + // A twisting rounded-square tube wrapped in tartan: a symmetric sett of crossing thread | |
| 199 | + // stripes woven as a 2/2 twill, so the diagonal weave shows in every check. Each of the four | |
| 200 | + // thread colours belongs to one band and brightens with it; attacks send a bright stripe | |
| 201 | + // along the weft, lighting only the weft floats so the twill flashes. | |
| 202 | + float ptlSett(float s) { | |
| 203 | + float x = abs(fract(s) - .5) * 2; | |
| 204 | + return x < .07 ? 3 : x < .36 ? 0 : x < .44 ? 2 : x < .64 ? 1 : x < .7 ? 3 : x < .84 ? 2 : 0; | |
| 205 | + } | |
| 206 | + float3 ptlThread(float slot, Ctx c, constant NativeFrame &f) { | |
| 207 | + float3 hue = slot < .5 ? paint(.97, f) : slot < 1.5 ? paint(.04, f) : slot < 2.5 ? paint(.74, f) : paint(.5, f); | |
| 208 | + float gain = slot < .5 ? .14 : slot < 2.5 ? .22 : .4; | |
| 209 | + return hue * (gain + 1.4 * c.b[min(3, int(slot))]); | |
| 210 | + } | |
| 211 | + | |
| 212 | + float3 tartanTube(Ctx c, constant NativeFrame &f) { | |
| 213 | + const float T = 36, setts = 10, settLength = .75; | |
| 214 | + float2 vanish = ptlDrift(c.t * .5, float2(.22, .15)); | |
| 215 | + float2 q = ptlBend(c.uv / c.size, vanish); | |
| 216 | + float r = max(length(q), 1e-3f); | |
| 217 | + float travel = c.travel * 2.1; | |
| 218 | + // The section twists along the tube, so flying forward slowly rolls the view. | |
| 219 | + float twist = (1 / r + travel) * .07 + c.t * .04; | |
| 220 | + float a = atan2(q.y, q.x) - twist; | |
| 221 | + float ca = cos(a) * cos(a), sa = sin(a) * sin(a); | |
| 222 | + float depth = rsqrt(sqrt(ca * ca + sa * sa)) / r; | |
| 223 | + float zw = depth + travel; | |
| 224 | + float2 yarnPos = float2(a / TAU * setts, zw / settLength) * T; | |
| 225 | + float2 cell = floor(yarnPos), local = fract(yarnPos); | |
| 226 | + float warpSlot = ptlSett((cell.x + .5) / T), weftSlot = ptlSett((cell.y + .5) / T); | |
| 227 | + float twill = ptlWrap(cell.x + cell.y, 4.f); | |
| 228 | + bool warpUp = twill < 2; | |
| 229 | + float3 warpColor = ptlThread(warpSlot, c, f), weftColor = ptlThread(weftSlot, c, f); | |
| 230 | + // Each float is a rounded thread that dips at the ends where it passes under. | |
| 231 | + float along = warpUp ? (twill + local.y) * .5 : (twill - 2 + local.x) * .5; | |
| 232 | + float dip = .65 + .35 * sin(PI * along); | |
| 233 | + float3 woven = (warpUp ? warpColor * (.35 + .65 * sin(PI * local.x)) : weftColor * (.35 + .65 * sin(PI * local.y))) * dip; | |
| 234 | + float fw = c.px / c.size / r * max(T * setts / TAU, depth * T / settLength); | |
| 235 | + float3 cloth = mix((warpColor + weftColor) * .33, woven, smoothstep(.55f, .2f, fw)); | |
| 236 | + // Soft drapes in the cloth. | |
| 237 | + float drape = .7 + .3 * sin(a * 8 + zw * .6 + sin(zw * .3 + c.t * .2) * 2); | |
| 238 | + cloth *= drape; | |
| 239 | + float stripe = ptlFront(c, depth, .4, 5, .35); | |
| 240 | + float head = pow(.5 + .5 * cos(a - (1 - ptlAttack(c)) * 9), 6.f); | |
| 241 | + cloth += paint(.9, f) * stripe * (warpUp ? .25 : 1.3) * (1 + 2 * head); | |
| 242 | + float3 core = deep(.25, f) * .12 + paint(.9, f) * exp(-r * 9) * .6; | |
| 243 | + return mix(core, cloth, ptlFog(depth, c, .05)); | |
| 244 | + } | |
| 245 | + NATIVE_EFFECT(tartanTube) | |
| 246 | + | |
| 247 | + // ---------------------------------------------------------------- 313 Herringbone Hall | |
| 248 | + // A rectangular hall paved on every surface with 2:1 herringbone tiles and glowing grout; | |
| 249 | + // the pattern folds continuously around the corners. Bass tilts and lights tiles in chevron | |
| 250 | + // waves that roll down the hall, low-mids glow the vertical tiles, high-mids sheen the | |
| 251 | + // horizontal ones, highs light the grout and attacks flash a whole herringbone row. | |
| 252 | + struct PtlBrick { float2 local; float2 id; float2 centre; float vertical; float edge; }; | |
| 253 | + | |
| 254 | + // Herringbone of 2x1 bricks in brick units: a staircase of horizontal/vertical pairs | |
| 255 | + // repeating along (1,1) and (0,4). | |
| 256 | + PtlBrick ptlHerringbone(float2 p) { | |
| 257 | + PtlBrick b; | |
| 258 | + float m = floor(p.x), lx = p.x - m; | |
| 259 | + float yp = p.y - m + 3, n = floor(yp / 4), yl = yp - 4 * n; | |
| 260 | + if (yl < 2) { | |
| 261 | + b.local = float2(yl, lx); b.id = float2(m - 2, n); b.vertical = 1; | |
| 262 | + b.centre = float2(m + .5, m - 2 + 4 * n); | |
| 263 | + } else if (yl < 3) { | |
| 264 | + b.local = float2(lx + 1, yl - 2); b.id = float2(m - 1, n); b.vertical = 0; | |
| 265 | + b.centre = float2(m, m - .5 + 4 * n); | |
| 266 | + } else { | |
| 267 | + b.local = float2(lx, yl - 3); b.id = float2(m, n); b.vertical = 0; | |
| 268 | + b.centre = float2(m + 1, m + .5 + 4 * n); | |
| 269 | + } | |
| 270 | + b.edge = min(min(b.local.x, 2 - b.local.x), min(b.local.y, 1 - b.local.y)); | |
| 271 | + return b; | |
| 272 | + } | |
| 273 | + | |
| 274 | + float3 herringboneHall(Ctx c, constant NativeFrame &f) { | |
| 275 | + const float W = 1.3, H = .82, unit = .15; | |
| 276 | + float2 vanish = ptlDrift(c.t * .5, float2(.16, .1)); | |
| 277 | + float2 q = ptlBend(c.uv / c.size, vanish); | |
| 278 | + float ax = abs(q.x) / W, ay = abs(q.y) / H; | |
| 279 | + bool wall = ax > ay; | |
| 280 | + float depth = 1 / max(max(ax, ay), 1e-3f); | |
| 281 | + float travel = c.travel * 2.4, zw = depth + travel; | |
| 282 | + float2 hit = q * depth; | |
| 283 | + // Perimeter coordinate, continuous around the corners; mid = centre of this surface. | |
| 284 | + float across, mid; | |
| 285 | + if (wall) { | |
| 286 | + if (q.x > 0) { across = 2 * W + H + hit.y; mid = 2 * W + H; } | |
| 287 | + else { across = 4 * W + 3 * H - hit.y; mid = 4 * W + 3 * H; } | |
| 288 | + } else { | |
| 289 | + if (q.y < 0) { across = W + hit.x; mid = W; } | |
| 290 | + else { across = 3 * W + 2 * H - hit.x; mid = 3 * W + 2 * H; } | |
| 291 | + } | |
| 292 | + float2 p = rot(float2(across, zw), PI * .25) / unit; | |
| 293 | + PtlBrick b = ptlHerringbone(p); | |
| 294 | + float2 cs = rot(b.centre * unit, -PI * .25); | |
| 295 | + float rel = cs.y - travel; | |
| 296 | + float seed = hash21(b.id + b.vertical * 19); | |
| 297 | + float fw = c.px / c.size * depth * max(1.f, depth / (wall ? W : H)) / unit; | |
| 298 | + float aa = clamp(fw, .01f, .5f); | |
| 299 | + // Chevron waves roll down the hall; bass tilts and lights the tiles they cross. | |
| 300 | + float wave = pow(.5 + .5 * sin(rel * 1.6 - abs(cs.x - mid) * 1.4 - c.t * 1.2), 4.f); | |
| 301 | + float lit = wave * (.12 + c.b.x); // a small baseline keeps the corridor moving at zero zoom | |
| 302 | + float tilt = (b.local.x - 1) * (.22 + 1.2 * lit) * (seed > .5 ? 1 : -1); | |
| 303 | + float3 tile = paint(.02 + seed * .2 + b.vertical * .3, f) * (.05 + .08 * seed); | |
| 304 | + float twinkle = .5 + .5 * sin(seed * 23 + c.t * .8); | |
| 305 | + tile *= (1 + (b.vertical > .5 ? c.b.y : c.b.z) * 2.6 * twinkle) * (.85 + tilt); | |
| 306 | + float bevel = smoothstep(.03f, .16f, b.edge); | |
| 307 | + tile *= .55 + .45 * bevel; | |
| 308 | + tile += paint(.7 + seed * .12, f) * lit * 1.3 * bevel; | |
| 309 | + tile += paint(.92, f) * ptlFront(c, rel, .5, 6, .55) * 1.6; | |
| 310 | + float grout = line(b.edge, .045, aa); | |
| 311 | + float3 groutColor = paint(.72, f) * (.22 + 2.4 * c.b.w); | |
| 312 | + float3 color = mix(tile, groutColor, grout) + groutColor * glow(b.edge, .1) * .1; | |
| 313 | + float3 average = paint(.2, f) * .1 + groutColor * .1; | |
| 314 | + color = mix(average, color, smoothstep(.35f, .1f, fw)); | |
| 315 | + // Dark creases where the surfaces meet. | |
| 316 | + color *= 1 - .7 * exp(-abs(ax - ay) * depth * 26); | |
| 317 | + float3 core = paint(.8, f) * .3 + paint(.95, f) * exp(-max(ax, ay) * 12) * 1.1; | |
| 318 | + return mix(core, color, ptlFog(depth, c, .045)); | |
| 319 | + } | |
| 320 | + NATIVE_EFFECT(herringboneHall) | |
| 321 | + | |
| 322 | + | |
| 323 | + // ---------------------------------------------------------------- 315 Lace Funnel | |
| 324 | + // A funnel of layered lace rings drifting toward the viewer against a hot core of light. | |
| 325 | + // The lace is laid out on conformal log-polar tiles, so every motif keeps its shape at | |
| 326 | + // every radius: rows of rimmed eyelets in cloth stitch, five-petal flowers over net and | |
| 327 | + // spotted net, with a picot inner edge and a scalloped border. Alternate layers turn against | |
| 328 | + // each other. Each layer's eyelets glow with its own band, highs light the cords and attacks | |
| 329 | + // bloom light through the openwork of one layer as it passes. | |
| 330 | + float4 ptlLace(float2 g, float yIn, float yOut, float aa) { | |
| 331 | + float y = g.y - yIn, row = floor(y); | |
| 332 | + float shift = ptlWrap(row, 2.f) * .5; | |
| 333 | + float2 l = float2(fract(g.x + shift) - .5, y - row - .5); | |
| 334 | + float type = ptlWrap(row, 3.f); | |
| 335 | + float e = length(l); | |
| 336 | + float cord = 0, cloth = 0, net = 0, hole = 0; | |
| 337 | + if (type < .5) { | |
| 338 | + // Eyelet band: cloth stitch pierced by a rimmed eyelet, small holes at the corners. | |
| 339 | + float corner = length(abs(l) - .5); | |
| 340 | + hole = max(fill(e - .13, aa), fill(corner - .08, aa)); | |
| 341 | + cord = max(line(e - .17, .045, aa), line(corner - .11, .03, aa)); | |
| 342 | + cloth = 1; | |
| 343 | + } else if (type < 1.5) { | |
| 344 | + // Five-petal flower in cloth stitch over net, with a pierced centre. | |
| 345 | + float ang = atan2(l.y, l.x); | |
| 346 | + float petal = e - (.14 + .28 * pow(abs(cos(ang * 2.5)), .7f)); | |
| 347 | + cloth = fill(petal, aa); | |
| 348 | + cord = max(line(petal, .03, aa), line(e - .075, .025, aa)); | |
| 349 | + hole = fill(e - .055, aa); | |
| 350 | + net = 1; | |
| 351 | + } else { | |
| 352 | + // Spotted net with a ring motif. | |
| 353 | + cloth = fill(e - .08, aa); | |
| 354 | + cord = line(e - .24, .03, aa); | |
| 355 | + net = 1; | |
| 356 | + } | |
| 357 | + float4 h = hexCell(g * 5); | |
| 358 | + float hexEdge = .5 - max(abs(h.x), max(abs(.5 * h.x + .866 * h.y), abs(.5 * h.x - .866 * h.y))); | |
| 359 | + float netThread = mix(.3f, line(hexEdge, .09, aa * 5), smoothstep(.12f, .05f, aa)); | |
| 360 | + float clothTex = mix(.6f, .5f + .5f * sin((l.x + l.y) * 50) * sin((l.x - l.y) * 50), smoothstep(.05f, .02f, aa)); | |
| 361 | + // Picot inner edge and scalloped outer border. | |
| 362 | + float sx = fract(g.x) - .5; | |
| 363 | + float border = yOut - .35 + .35 * sqrt(max(0.f, 1 - 4 * sx * sx)); | |
| 364 | + float inside = fill(g.y - border, aa) * fill(yIn - g.y, aa); | |
| 365 | + float edges = line(g.y - border, .05, aa) + line(g.y - yIn, .05, aa); | |
| 366 | + edges += line(length(float2(sx, g.y - yIn + .13)) - .1, .028, aa) * step(g.y, yIn); | |
| 367 | + float lace = max(cloth * .85, net * netThread * .7); | |
| 368 | + float opacity = max(inside * max(lace, cord), edges) * (1 - hole * inside); | |
| 369 | + float glowLight = inside * ((1 - hole) * (cloth * .32 * clothTex + net * (1 - cloth) * netThread * .55)); | |
| 370 | + return float4(saturate(opacity), glowLight, inside * hole, saturate(inside * cord + edges)); | |
| 371 | + } | |
| 372 | + | |
| 373 | + float3 laceFunnel(Ctx c, constant NativeFrame &f) { | |
| 374 | + const float M = 16; | |
| 375 | + float2 uv = c.uv / c.size; | |
| 376 | + float ru = length(uv), au = atan2(uv.y, uv.x); | |
| 377 | + float rays = .6 + .4 * sin(au * 7 + c.t * .2) * sin(au * 4 - c.t * .13); | |
| 378 | + float3 color = deep(.3, f) * .1 + paint(.4, f) * glow(ru, .9) * .25 * rays + paint(.9, f) * glow(ru, .2) * 1.4; | |
| 379 | + const float yIn = -2.4, yOut = 2.6; | |
| 380 | + const int layers = 6; | |
| 381 | + for (int k = 0; k < layers; ++k) { | |
| 382 | + float2 s = layerSlot(k, layers, c.travel * .14); | |
| 383 | + float id = s.y; | |
| 384 | + float sc = layerScale(s.x, 3.6); | |
| 385 | + float turn = ptlWrap(id, 2.f) < 1 ? 1 : -1; | |
| 386 | + float2 off = float2(sin(id * .9 + c.t * .21), cos(id * .7 + c.t * .17)) * .1 * (1 - s.x); | |
| 387 | + float2 p = rot(uv * sc - off, turn * c.t * .1 + id * .6); | |
| 388 | + float rr = max(length(p), 1e-3f); | |
| 389 | + float2 g = float2(atan2(p.y, p.x), log(rr)) * M / TAU; | |
| 390 | + float aa = c.px / c.size * sc / rr * M / TAU; | |
| 391 | + float4 lace = ptlLace(g, yIn, yOut, aa); | |
| 392 | + float fade = layerFade(s.x); | |
| 393 | + float dim = .4 + .6 * s.x; | |
| 394 | + float band = ptlBand(c, id); | |
| 395 | + float bloom = ptlFront(c, 1 - s.x, .15, .65, .13); | |
| 396 | + float3 threadColor = paint(.55 + .15 * sin(id * 1.3), f); | |
| 397 | + float3 emit = threadColor * lace.y * .4 * dim + paint(.9, f) * lace.w * (.22 + 1.4 * c.b.w) * dim; | |
| 398 | + float3 eyelets = paint(.95, f) * lace.z * (.03 + 2.8 * band + 3 * bloom); | |
| 399 | + color = color * (1 - lace.x * fade * .88) + (emit + eyelets + paint(.95, f) * bloom * lace.y * 2) * fade; | |
| 400 | + } | |
| 401 | + return color; | |
| 402 | + } | |
| 403 | + NATIVE_EFFECT(laceFunnel) | |
| 404 | + | |
| 405 | + // ---------------------------------------------------------------- 316 Zipper Run | |
| 406 | + // A tube sewn from one continuous helical zipper: the seam spirals down the walls and its | |
| 407 | + // sliders run along it, opening lens-shaped sections that reveal hot light behind the teeth | |
| 408 | + // and closing them again. Bass widens the openings, low-mids light the tape stitching, | |
| 409 | + // high-mids the piping between turns, highs glint the metal teeth and attacks unzip a | |
| 410 | + // section that runs away down the tube. | |
| 411 | + float3 zipperRun(Ctx c, constant NativeFrame &f) { | |
| 412 | + const float pitch = .85, P = .13, tw = .05; | |
| 413 | + float2 vanish = ptlDrift(c.t * .55, float2(.24, .16)); | |
| 414 | + float2 q = ptlBend(c.uv / c.size, vanish); | |
| 415 | + float r = max(length(q), 1e-3f); | |
| 416 | + float a = atan2(q.y, q.x) + c.t * .04; | |
| 417 | + float depth = 1 / r; | |
| 418 | + float travel = c.travel * 2.3, zw = depth + travel; | |
| 419 | + // One continuous helical seam: `across` runs along the tube, `along` follows the helix. | |
| 420 | + float turns = a / TAU; | |
| 421 | + float w = zw - turns * pitch; | |
| 422 | + float k = floor(w / pitch + .5); | |
| 423 | + float across = w - k * pitch; | |
| 424 | + float along = (turns + k) * TAU; | |
| 425 | + float aa = clamp(c.px / c.size / r * max(1.f, depth), .002f, .2f); | |
| 426 | + // Sliders run along the helix, opening lens-shaped sections and closing them again. | |
| 427 | + float lens = .6 * sin(along * .32 - c.t * .9) + .4 * sin(along * .11 + c.t * .35); | |
| 428 | + float open = max(0.f, lens - .2) * (.2 + .6 * c.b.x); | |
| 429 | + float unzip = ptlFront(c, depth, .4, 5, .6); | |
| 430 | + open += unzip * .3 * (.6 + .4 * sin(along * .5)); | |
| 431 | + float sl = across + open * .5, sr = across - open * .5; | |
| 432 | + float nl = floor(along / P + .5), nr = floor(along / P) + .5; | |
| 433 | + float2 tl = float2(sl + .8 * tw, along - nl * P), tr = float2(sr - .8 * tw, along - nr * P); | |
| 434 | + float2 toothSize = float2(tw * 1.1, P * .24); | |
| 435 | + float toothL = sdBox2(tl, toothSize) - P * .05, toothR = sdBox2(tr, toothSize) - P * .05; | |
| 436 | + float teeth = fill(min(toothL, toothR), aa); | |
| 437 | + bool leftTooth = toothL < toothR; | |
| 438 | + float2 tooth = leftTooth ? tl : tr; | |
| 439 | + float toothId = leftTooth ? nl : nr + 5000; | |
| 440 | + float tape = max(fill(sl + 1.45 * tw, aa), fill(1.45 * tw - sr, aa)); | |
| 441 | + // Hot light behind the chain. | |
| 442 | + float3 lightColor = paint(.04 + .08 * sin(along * .07 + c.t * .2), f) * (1.3 + 3 * unzip); | |
| 443 | + float3 color = lightColor; | |
| 444 | + // Fabric tapes: fine ribbing, colour drifting along the helix, two stitch lines each. | |
| 445 | + float edgeDist = abs(across) - open * .5 - 1.45 * tw; | |
| 446 | + float rib = .8 + .2 * sin(abs(across) * 150); | |
| 447 | + float fold = smoothstep(pitch * .5f, 0.f, abs(across)); | |
| 448 | + float3 fabric = paint(.62 + .14 * sin(along * .05 + k), f) * (.05 + .17 * fold) * rib; | |
| 449 | + float seams = (line(edgeDist - .03, .006, aa) + line(edgeDist - .06, .006, aa)) * smoothstep(.3f, .55f, fract(along * 16)); | |
| 450 | + fabric += paint(.35, f) * seams * (.12 + 2.6 * c.b.y); | |
| 451 | + color = mix(color, fabric, tape); | |
| 452 | + // Metal teeth: rounded crowns with glints on highs. | |
| 453 | + float seed = hash21(float2(toothId, k)); | |
| 454 | + float crown = saturate(1 - abs(tooth.y) / (P * .29)); | |
| 455 | + float3 metal = paint(.45, f) * (.1 + .7 * crown * crown) + paint(.9, f) * pow(crown, 8.f) * .4; | |
| 456 | + metal += paint(.95, f) * pow(seed, 5.f) * c.b.w * 5 * crown; | |
| 457 | + color = mix(color, metal, teeth); | |
| 458 | + // Light spills over the open edges. | |
| 459 | + color += lightColor * glow(abs(across) - open * .5, .02 + open * .3) * .35 * saturate(open * 6); | |
| 460 | + // Piping cord where neighbouring turns of the helix are sewn together. | |
| 461 | + float pipe = pitch * .5 - abs(across); | |
| 462 | + float cord = fill(pipe - .035, aa); | |
| 463 | + float3 piping = paint(.8, f) * (.06 + .25 * smoothstep(0.f, .035f, pipe)) * (1 + 3.5 * c.b.z); | |
| 464 | + color = mix(color, piping, cord) + paint(.78, f) * glow(pipe, .03) * c.b.z * .5; | |
| 465 | + float3 core = paint(.1, f) * .3 + paint(.95, f) * exp(-r * 8) * 1.1; | |
| 466 | + return mix(core, color, ptlFog(depth, c, .05)); | |
| 467 | + } | |
| 468 | + NATIVE_EFFECT(zipperRun) | |
| 469 | + | |
| 470 | + // ---------------------------------------------------------------- 317 Cable Knit Tube | |
| 471 | + // A strongly bending tube of chunky cable knit. Seven padded cables run down the walls, each | |
| 472 | + // two braided strands of plied V stitches crossing over and under, with purl ridges between | |
| 473 | + // and a soft fibre fuzz, lit by two coloured lights. Bass twists the cables further, each | |
| 474 | + // cable's stitches brighten with its own band and attacks pull a ripple through the knit. | |
| 475 | + float3 cableKnitTube(Ctx c, constant NativeFrame &f) { | |
| 476 | + const float N = 7, rowsPerColumn = 9, sw = .14; | |
| 477 | + float2 vanish = ptlDrift(c.t * .75, float2(.42, .3)); | |
| 478 | + float2 q = ptlBend(c.uv / c.size, vanish); | |
| 479 | + float r = max(length(q), 1e-3f), a = atan2(q.y, q.x) + c.t * .025; | |
| 480 | + float u = a * N / TAU; | |
| 481 | + float column = floor(u + .5), x = u - column; | |
| 482 | + float depth = (1 - .07 * cos(x * TAU)) / r; | |
| 483 | + float travel = c.travel * 1.9, zw = depth + travel; | |
| 484 | + float colId = ptlWrap(column, N); | |
| 485 | + float band = ptlBand(c, colId); | |
| 486 | + float pull = ptlFront(c, depth, .4, 5, .55); | |
| 487 | + float v = zw * N / TAU + pull * .3; | |
| 488 | + float fw = c.px / c.size / r * max(1.f, depth) * N / TAU; | |
| 489 | + float resolve = smoothstep(.06f, .02f, fw); | |
| 490 | + // Two strands braid around each other; bass twists them further. | |
| 491 | + float twist = c.b.x * 2.8 * (.55 + .45 * sin(colId * 1.9 + c.t * .5)); | |
| 492 | + float phase = v * 2.2 + twist + colId * 1.3; | |
| 493 | + float A = sw * (1 + .25 * c.b.x); | |
| 494 | + float x1 = A * cos(phase); | |
| 495 | + bool firstOver = ptlWrap(floor(phase / PI), 2.f) < 1; | |
| 496 | + float d1 = abs(x - x1), d2 = abs(x + x1); | |
| 497 | + float aaX = clamp(fw, .002f, .1f); | |
| 498 | + float c1 = fill(d1 - sw, aaX), c2 = fill(d2 - sw, aaX); | |
| 499 | + bool useFirst = (c1 > .5 && c2 > .5) ? firstOver : d1 < d2; | |
| 500 | + float strand = useFirst ? c1 : c2; | |
| 501 | + float centre = useFirst ? x1 : -x1; | |
| 502 | + // Plied V stitches: two stitch columns per strand, each stitch two leaning yarn legs. | |
| 503 | + float vc = (x - centre) / sw + 1; | |
| 504 | + float2 sp = float2(fract(vc) - .5, v * rowsPerColumn); | |
| 505 | + float rowBase = floor(sp.y); | |
| 506 | + float best = 9, along = 0, legSide = 1; | |
| 507 | + float2 away = float2(0, 1); | |
| 508 | + for (int i = 0; i < 2; ++i) { | |
| 509 | + float ry = rowBase + (i == 0 ? 0.f : (fract(sp.y) < .5 ? -1.f : 1.f)); | |
| 510 | + for (int j = 0; j < 2; ++j) { | |
| 511 | + float side = j == 0 ? -1 : 1; | |
| 512 | + float2 a0 = float2(side * .4, ry + .95), a1 = float2(side * .06, ry); | |
| 513 | + float2 pa = sp - a0, ba = a1 - a0; | |
| 514 | + float h = saturate(dot(pa, ba) / dot(ba, ba)); | |
| 515 | + float2 dv = pa - ba * h; | |
| 516 | + float d = length(dv); | |
| 517 | + if (d < best) { best = d; along = h; away = dv / max(d, 1e-4f); legSide = side; } | |
| 518 | + } | |
| 519 | + } | |
| 520 | + const float yarn = .21; | |
| 521 | + float across = saturate(best / yarn); | |
| 522 | + float bump = sqrt(saturate(1 - across * across)); | |
| 523 | + float legMask = 1 - smoothstep(.85f, 1.05f, best / yarn); | |
| 524 | + float ply = .75 + .25 * sin(along * 18 + legSide * across * 3); | |
| 525 | + float3 n = normalize(float3(away * across, bump + .05)); | |
| 526 | + float3 lightA = normalize(float3(-.7, .5, .55)), lightB = normalize(float3(.75, -.35, .55)); | |
| 527 | + float hue = colId * .09 + (useFirst ? 0 : .12); | |
| 528 | + float3 knit = paint(.05 + hue, f) * (.02 + .1 * bump); | |
| 529 | + knit += (paint(.12 + hue * .5, f) * max(0.f, dot(n, lightA)) + paint(.7, f) * max(0.f, dot(n, lightB))) * .28 * ply; | |
| 530 | + knit *= legMask; | |
| 531 | + knit = mix(paint(.3 + hue, f) * .1, knit, resolve); | |
| 532 | + // Strands are rounded: their edges fall into shadow, and the strand on top shades the other. | |
| 533 | + float strandEdge = sw - abs(x - centre); | |
| 534 | + float otherEdge = abs(x - (useFirst ? -x1 : x1)) - sw; | |
| 535 | + knit *= smoothstep(-.01f, .05f, strandEdge) * .6 + .4; | |
| 536 | + knit *= 1 - .7 * ((useFirst != firstOver) ? smoothstep(.07f, 0.f, otherEdge) : 0.f); | |
| 537 | + knit *= 1 + band * 2.8; | |
| 538 | + // Purl ridges between the cables. | |
| 539 | + float2 pp = float2(x * 18 + .5 * floor(v * rowsPerColumn), v * rowsPerColumn); | |
| 540 | + float2 pl = fract(pp) - .5; | |
| 541 | + float purlBump = saturate(1 - length(pl * float2(1.1, 1.9)) * 1.5); | |
| 542 | + float3 purl = paint(.55 + colId * .05, f) * (.015 + .1 * mix(.4f, purlBump, resolve)) * (1 + band); | |
| 543 | + float3 color = mix(purl, knit, strand); | |
| 544 | + // Fibre fuzz: a soft halo of stray fibres along the strand edges. | |
| 545 | + float fuzz = noise2(float2(u * 50, v * 50)) * glow(min(d1, d2) - sw, .03) * resolve; | |
| 546 | + color += paint(.75, f) * fuzz * (.08 + band * .5); | |
| 547 | + color += paint(.92, f) * pull * (.3 + bump) * strand * 1.3; | |
| 548 | + float3 core = paint(.6, f) * .15 + paint(.9, f) * exp(-r * 8) * .8; | |
| 549 | + return mix(core, color, ptlFog(depth, c, .05)); | |
| 550 | + } | |
| 551 | + NATIVE_EFFECT(cableKnitTube) | |
| 552 | + | |
| 553 | + // ---------------------------------------------------------------- 318 Basket Weave Burrow | |
| 554 | + // An elliptic burrow seen from low down, woven from two families of wide helical strips that | |
| 555 | + // pass over and under each other, with light leaking through the gaps. Bass lifts and shifts | |
| 556 | + // the strips (opening the gaps), low-mids and high-mids each light one strip family, highs | |
| 557 | + // brighten the gap light and attacks tighten a weave ring that squeezes down the burrow. | |
| 558 | + float3 basketWeaveBurrow(Ctx c, constant NativeFrame &f) { | |
| 559 | + const float ea = 1.3, eb = .85, h = .3, N = 14; | |
| 560 | + float2 vanish = ptlDrift(c.t * .5, float2(.15, .08)); | |
| 561 | + float2 q = ptlBend(c.uv / c.size, vanish); | |
| 562 | + float r = max(length(q), 1e-3f); | |
| 563 | + float2 dir = q / r; | |
| 564 | + float A = dir.x * dir.x / (ea * ea) + dir.y * dir.y / (eb * eb); | |
| 565 | + float B = dir.y * h / (eb * eb), C = h * h / (eb * eb) - 1; | |
| 566 | + float R = (B + sqrt(max(0.f, B * B - A * C))) / A; | |
| 567 | + float2 P = dir * R; | |
| 568 | + float travel = c.travel * 2.0; | |
| 569 | + float squeeze = ptlFront(c, R / r, .4, 5, .5); | |
| 570 | + float depth = R / r * (1 + .12 * squeeze); | |
| 571 | + float zw = depth + travel; | |
| 572 | + float phi = atan2((P.y - h) / eb, P.x / ea); | |
| 573 | + float2 g = float2(phi * N / TAU, zw * N / 6.8); | |
| 574 | + float lift = c.b.x * (.5 + .5 * sin(g.y * .5 - c.t * .9 + phi * 2)); | |
| 575 | + float2 s = float2(g.x + g.y, g.x - g.y) + lift * .25 * float2(1, -1); | |
| 576 | + float2 cell = floor(s), l = fract(s) - .5; | |
| 577 | + float fw = c.px / c.size / r * max(N / TAU, depth * N / 6.8) * 1.5; | |
| 578 | + float aa = clamp(fw, .01f, .5f); | |
| 579 | + float halfWidth = .41 - .12 * lift + .06 * squeeze; | |
| 580 | + float coverA = fill(abs(l.x) - halfWidth, aa), coverB = fill(abs(l.y) - halfWidth, aa); | |
| 581 | + float hA = cos(PI * (s.y - .5 + cell.x)), hB = -cos(PI * (s.x - .5 + cell.y)); | |
| 582 | + float topA = smoothstep(-.15f, .15f, hA - hB); | |
| 583 | + float3 stripA = paint(.06 + .08 * sin(cell.x * 1.7), f) * (.03 + .22 * (.5 + .5 * hA)) * (1 + 3 * c.b.y); | |
| 584 | + float3 stripB = paint(.42 + .08 * sin(cell.y * 1.3), f) * (.03 + .2 * (.5 + .5 * hB)) * (1 + 3 * c.b.z); | |
| 585 | + stripA *= 1 - .45 * (l.x / halfWidth) * (l.x / halfWidth); | |
| 586 | + stripB *= 1 - .45 * (l.y / halfWidth) * (l.y / halfWidth); | |
| 587 | + // A soft sheen on each strip where it crests over its neighbour. | |
| 588 | + stripA += paint(.75, f) * pow(saturate(hA), 6.f) * .14 * saturate(1 - abs(l.x) / halfWidth); | |
| 589 | + stripB += paint(.75, f) * pow(saturate(hB), 6.f) * .14 * saturate(1 - abs(l.y) / halfWidth); | |
| 590 | + // Grain lines along each strip. | |
| 591 | + float grain = smoothstep(.4f, .15f, fw); | |
| 592 | + stripA *= 1 - grain * .2 * (.5 + .5 * sin(s.y * 40 + cell.x * 3)); | |
| 593 | + stripB *= 1 - grain * .2 * (.5 + .5 * sin(s.x * 40 + cell.y * 3)); | |
| 594 | + float3 gap = paint(.8 + .08 * sin(zw * .3), f) * (.5 + 3.5 * c.b.w); | |
| 595 | + float3 color = gap; | |
| 596 | + color = mix(color, stripB, coverB * (1 - coverA * topA)); | |
| 597 | + color = mix(color, stripA, coverA * (coverB > 0 ? topA : 1)); | |
| 598 | + color += gap * glow(min(abs(l.x), abs(l.y)) - halfWidth, .04) * (1 - coverA * coverB) * .2; | |
| 599 | + color += paint(.92, f) * squeeze * (.6 + .5 * max(hA, hB)); | |
| 600 | + float3 average = paint(.3, f) * .12 + gap * .05; | |
| 601 | + color = mix(average, color, smoothstep(.45f, .15f, fw)); | |
| 602 | + float3 core = paint(.8, f) * .3 + paint(.95, f) * exp(-r * 8) * 1.1; | |
| 603 | + return mix(core, color, ptlFog(depth, c, .05)); | |
| 604 | + } | |
| 605 | + NATIVE_EFFECT(basketWeaveBurrow) | |
| 606 | + | |
| 607 | + // ---------------------------------------------------------------- 319 Louvre Tunnel | |
| 608 | + // A slowly rolling octagonal tunnel whose faces are banks of angled louvre slats with | |
| 609 | + // coloured light behind them. Slats open and close in waves; bass opens groups of slat rows, | |
| 610 | + // low-mids and high-mids brighten the light behind alternate faces, highs glint the | |
| 611 | + // mullions and attacks snap a ring of slats open so light floods through locally. | |
| 612 | + float3 louvreTunnel(Ctx c, constant NativeFrame &f) { | |
| 613 | + const float rin = .9, P = .14; | |
| 614 | + float2 vanish = ptlDrift(c.t * .5, float2(.2, .14)); | |
| 615 | + float2 q = ptlBend(c.uv / c.size, vanish); | |
| 616 | + float r = max(length(q), 1e-3f); | |
| 617 | + float a = atan2(q.y, q.x) - c.t * .03; | |
| 618 | + float sector = floor(a / (TAU / 8) + .5); | |
| 619 | + float local = a - sector * TAU / 8; | |
| 620 | + float face = ptlWrap(sector, 8.f); | |
| 621 | + float depth = rin / (r * cos(local)); | |
| 622 | + float across = rin * tan(local); | |
| 623 | + float travel = c.travel * 2.2, zw = depth + travel; | |
| 624 | + float row = floor(zw / P), zl = zw / P - row; | |
| 625 | + float rowDepth = (row + .5) * P - travel; | |
| 626 | + float fz = clamp(fwidth(zw) / P, .002f, .5f); | |
| 627 | + float wave = .5 + .5 * sin(row * .3 - c.t * 1.3 + face * .7); | |
| 628 | + float bassRows = pow(.5 + .5 * sin(row * .8 + face * 1.1 - c.t * .2), 3.f); | |
| 629 | + float snap = ptlFront(c, rowDepth, .4, 5, .45); | |
| 630 | + float open = clamp(.06 + .36 * wave * wave + 1.4 * c.b.x * bassRows + 1.6 * snap, 0.f, .85f); | |
| 631 | + float cover = 1 - open; | |
| 632 | + float slat = fill(zl - cover, fz); | |
| 633 | + float t01 = saturate(zl / max(cover, .05f)); | |
| 634 | + bool even = ptlWrap(face, 2.f) < 1; | |
| 635 | + float lamp = .45 + .55 * cos(across / (rin * .41421356) * 1.3); | |
| 636 | + float3 light = paint(even ? .05 + .05 * sin(row * .13) : .78 + .05 * sin(row * .11), f) * (.35 + .6 * open) * lamp * (1 + 2.4 * (even ? c.b.y : c.b.z)); | |
| 637 | + light += paint(.95, f) * snap * 1.5; | |
| 638 | + // Slat face: tilted, so it shades from its hinge to the lip that catches the light. | |
| 639 | + float sideShade = 1 - .5 * pow(abs(across) / (rin * .41421356), 4.f); | |
| 640 | + float3 slatColor = paint(.98, f) * (.025 + .14 * t01 * t01) * sideShade; | |
| 641 | + slatColor += light * pow(t01, 10.f) * (.15 + .5 * open); | |
| 642 | + float3 color = mix(light, slatColor, slat); | |
| 643 | + // Light floods over the slats around open gaps. | |
| 644 | + color += light * glow(zl - cover, .04 + open * .3) * open * .25 * slat; | |
| 645 | + // Mullions between faces. | |
| 646 | + float edge = rin * .41421356 - abs(across); | |
| 647 | + float mullion = fill(edge - .04, max(fz * P, .003f)); | |
| 648 | + float glint = pow(.5 + .5 * sin(zw * 9 - c.t * 2 + face * 2), 12.f); | |
| 649 | + float3 frame = deep(.2, f) * .03 + paint(.5, f) * glint * smoothstep(.01f, .04f, edge) * c.b.w * 3; | |
| 650 | + color = mix(color, frame, mullion); | |
| 651 | + float3 average = mix(light, slatColor, .6); | |
| 652 | + color = mix(average, color, smoothstep(.45f, .15f, fz)); | |
| 653 | + float3 core = paint(.8, f) * .35 + paint(.95, f) * exp(-r * 8) * 1.0; | |
| 654 | + return mix(core, color, ptlFog(depth, c, .05)); | |
| 655 | + } | |
| 656 | + NATIVE_EFFECT(louvreTunnel) | |
| 657 | + | |
| 658 | + // Coaster versions: the same designs riding the roller-coaster course. | |
| 659 | + NATIVE_COASTER(chainmailBore, 310, false) | |
| 660 | + NATIVE_COASTER(featherVault, 311, false) | |
| 661 | + NATIVE_COASTER(tartanTube, 312, false) | |
| 662 | + NATIVE_COASTER(herringboneHall, 313, false) | |
| 663 | + NATIVE_COASTER(laceFunnel, 315, false) | |
| 664 | + NATIVE_COASTER(zipperRun, 316, false) | |
| 665 | + NATIVE_COASTER(cableKnitTube, 317, false) | |
| 666 | + NATIVE_COASTER(basketWeaveBurrow, 318, false) | |
| 667 | + NATIVE_COASTER(louvreTunnel, 319, false) |
Sources/PulseCanvas/Resources/NativeExpansionPortalII.metal added
| 1 | + // Final version of 314 Quilted Pipe (its v2 review clip was red-tagged). | |
| 2 | + // Original PulseCanvas designs 310–319: portal tunnels. Each is a perspective tube or portal | |
| 3 | + // stack whose walls carry one strong surface material (chainmail, feathers, tartan, | |
| 4 | + // herringbone, quilting, lace, zippers, cable knit, basketry, louvres). Cross-sections and | |
| 5 | + // cameras vary: a billowing bent bore, a pointed vault, a twisting rounded square, a | |
| 6 | + // rectangular hall, an off-axis pipe, a lace stack, a helical seam, a padded bent tube, | |
| 7 | + // an elliptic burrow seen from low down and an octagon. Original procedural code; every | |
| 8 | + // audio term is zero at zero Chaos. | |
| 9 | + | |
| 10 | + // ---------------------------------------------------------------- shared portal helpers | |
| 11 | + // Smooth wandering offset for a vanishing point. | |
| 12 | + float2 ptlDrift(float t, float2 amount) { | |
| 13 | + return float2(sin(t * .21 + .6) + .5 * sin(t * .34 + 2.3), cos(t * .17 + 1.1) + .5 * sin(t * .29 + .2)) / 1.5 * amount; | |
| 14 | + } | |
| 15 | + // Bent view: far depths converge on the drifting vanishing point while the near walls stay | |
| 16 | + // put. One-to-one for |vanish| < .9. | |
| 17 | + float2 ptlBend(float2 uv, float2 vanish) { return uv - vanish * exp(-dot(uv, uv) * 1.6); } | |
| 18 | + float ptlFog(float depth, Ctx c, float base) { return exp(-depth * (base + c.fog * .12)); } | |
| 19 | + float ptlAttack(Ctx c) { return smoothstep(.03f, .65f, c.hit); } | |
| 20 | + // Attack front: a band of depth that starts near the camera and runs away as the attack | |
| 21 | + // decays, so every hit sends a local event down the tunnel. | |
| 22 | + float ptlFront(Ctx c, float depth, float near, float far, float width) { | |
| 23 | + float x = (depth - near - (1 - ptlAttack(c)) * far) / width; | |
| 24 | + return c.hit * exp(-x * x); | |
| 25 | + } | |
| 26 | + float ptlWrap(float x, float period) { return x - period * floor(x / period); } | |
| 27 | + float ptlBand(Ctx c, float id) { return c.b[min(3, int(ptlWrap(id, 4.f)))]; } | |
| 28 | + // Travelling pulse used to spread a band's response down the tunnel as moving bands of | |
| 29 | + // light rather than a uniform brightness change. | |
| 30 | + float ptlSurge(float x) { float s = .5 + .5 * sin(x); return s * s * s; } | |
| 31 | + | |
| 32 | + // ---------------------------------------------------------------- 310 Chainmail Bore | |
| 33 | + // A bent bore lined with interlocking 4-in-1 chainmail. Two staggered ring families tilt | |
| 34 | + // opposite ways, so every crossing alternates over and under. Bass billows the mesh in | |
| 35 | + // rolling folds and lights their crests, low-mids roll light behind the mesh, high-mids | |
| 36 | + // tint the staggered ring family, highs spin bright glints around the rings and attacks run | |
| 37 | + // a bright ripple through whole linked rings. | |
| 38 | + struct PtlRing { float cover; float height; float across; float2 dir; float2 centre; float family; }; | |
| 39 | + | |
| 40 | + PtlRing ptlNoRing() { | |
| 41 | + PtlRing ring; | |
| 42 | + ring.cover = 0; ring.height = -9; ring.across = 0; ring.dir = float2(0, 1); ring.centre = 0; ring.family = 0; | |
| 43 | + return ring; | |
| 44 | + } | |
| 45 | + PtlRing ptlMailRing(float2 p, float2 centre, float family, float aa) { | |
| 46 | + const float radius = .4, wire = .088; | |
| 47 | + PtlRing ring; | |
| 48 | + float2 l = p - centre; | |
| 49 | + float dist = length(l); | |
| 50 | + ring.dir = l / max(dist, 1e-4f); | |
| 51 | + ring.across = clamp((dist - radius) / wire, -1.f, 1.f); | |
| 52 | + ring.cover = 1 - smoothstep(wire - aa, wire + aa, abs(dist - radius)); | |
| 53 | + // Opposite tilts for the two families make every crossing alternate over and under. | |
| 54 | + ring.height = (family > .5 ? -l.y : l.y) / radius; | |
| 55 | + ring.centre = centre; | |
| 56 | + ring.family = family; | |
| 57 | + return ring; | |
| 58 | + } | |
| 59 | + float3 ptlMailShade(PtlRing ring, Ctx c, constant NativeFrame &f, float unit, float travel, float crest) { | |
| 60 | + float seed = hash21(float2(ptlWrap(ring.centre.x, 20.f), ring.centre.y) + ring.family * 41); | |
| 61 | + float s = ring.across; | |
| 62 | + float3 n = normalize(float3(ring.dir * s, sqrt(max(0.f, 1 - s * s)) + .2)); | |
| 63 | + // Each ring has its own light that circles it: the glint spins around the wire. | |
| 64 | + float spin = seed * TAU + c.t * (.5 + seed) * (seed > .5 ? 1 : -1); | |
| 65 | + float3 light = normalize(float3(cos(spin), sin(spin), 1.1)); | |
| 66 | + float diffuse = max(0.f, dot(n, light)); | |
| 67 | + float spec = pow(max(0.f, dot(n, normalize(light + float3(0, 0, 1)))), 28.f); | |
| 68 | + float ripple = ptlFront(c, ring.centre.y * unit - travel, 1.1, 6, .3); | |
| 69 | + float twinkle = step(.5f, seed) * pow(.5 + .5 * sin(c.t * 4.3 + seed * 60), 6.f); | |
| 70 | + float3 base = paint(.04 + seed * .24 + ring.family * (.3 + c.b.z * .2), f); | |
| 71 | + float surge = ptlSurge(ring.centre.y * .7 - c.t * 2.2 + 2 * sin(ring.centre.x * TAU / 10)); | |
| 72 | + float3 color = base * (.04 + .5 * diffuse) * (1 + ring.family * c.b.z * 7 * surge + crest * 2.6); | |
| 73 | + color += paint(.95, f) * spec * (.5 + c.b.w * 6 * (.25 + twinkle)); | |
| 74 | + color += paint(.85 + seed * .1, f) * ripple * (1 + 2.5 * spec + diffuse); | |
| 75 | + return color; | |
| 76 | + } | |
| 77 | + | |
| 78 | + | |
| 79 | + // ---------------------------------------------------------------- 311 Feather Vault | |
| 80 | + // A pointed vault lined with long overlapping iridescent feathers whose tips flow toward the | |
| 81 | + // viewer. Farther rows lie on top, like scales, and the feathers lean so the rows spiral. | |
| 82 | + // Bass lifts waves of feathers (they reach out, catch light and throw shadows), low-mids | |
| 83 | + // light the shafts, high-mids the vane rims, highs shimmer the barbs and attacks ruffle a | |
| 84 | + // wave of feathers down the vault. | |
| 85 | + float ptlVaultRadius(float a) { | |
| 86 | + float s = sin(a), co = cos(a); | |
| 87 | + // Pointed arch above (two circular arcs meeting at the apex), a flatter oval below. | |
| 88 | + if (s > 0) return sqrt(1.55f * 1.55f - .3025f * s * s) - .55f * abs(co); | |
| 89 | + return rsqrt(co * co + s * s / .8f); | |
| 90 | + } | |
| 91 | + struct PtlFeather { float alpha; float shadow; float3 color; }; | |
| 92 | + | |
| 93 | + PtlFeather ptlFeather(float2 p, float row, float column, Ctx c, constant NativeFrame &f, float aa, float resolve, float rowDepth, float N) { | |
| 94 | + PtlFeather fe; | |
| 95 | + float seed = hash21(float2(ptlWrap(column, N), row)); | |
| 96 | + float sway = .5 + .5 * sin(row * .7 + column * 1.3 - c.t * 1.2); | |
| 97 | + float ruffle = ptlFront(c, rowDepth, 1.1, 6, .35); | |
| 98 | + float lift = c.b.x * (.2 + .8 * sway * sway) * 1.5 + ruffle * 1.4; | |
| 99 | + float y = p.y - row + lift * .2; | |
| 100 | + float t = (y + 1.6) / 2.1; // 0 at the tip, 1 at the base | |
| 101 | + // Feathers lean and their tips curl, so the rows read as a flowing helix. | |
| 102 | + float x = p.x - column + t * .95 - .12 * (1 - t) * (1 - t) - .04 * sin(c.t * .7 + seed * 6); | |
| 103 | + float halfWidth = .5 * pow(saturate(t * 2.2), .6f) * (1 + lift * .08); | |
| 104 | + float edge = abs(x) - halfWidth; | |
| 105 | + float body = smoothstep(-.01f, .03f, t) * (1 - smoothstep(.9f, 1.f, t)); | |
| 106 | + // Barbs sweep from the shaft back toward the base; some vanes split apart. | |
| 107 | + float barbCoord = y + abs(x) * 1.6; | |
| 108 | + float split = smoothstep(.04f, .015f, abs(fract(barbCoord * .8 + seed * 3) - .5)) * step(.08f, abs(x)) * step(.35f, seed); | |
| 109 | + fe.alpha = (1 - smoothstep(-aa, aa, edge)) * body * (1 - split * resolve * .9); | |
| 110 | + float st = (y + 1.8 + .2 * lift) / 2.1; | |
| 111 | + fe.shadow = (1 - smoothstep(-.1f, .12f, abs(x) - .55f * pow(saturate(st * 2.2), .6f))) * smoothstep(0.f, .1f, st) * (.45 + .55 * saturate(lift)); | |
| 112 | + float across = saturate(abs(x) / max(halfWidth, 1e-3f)); | |
| 113 | + float barbs = pow(.5 + .5 * cos(barbCoord * 14 * TAU), 2.f); | |
| 114 | + float shimmer = c.b.w * sin(barbCoord * 7 + c.t * 3 + seed * 9); | |
| 115 | + float3 film = filmColor(seed * .5 + across * .45 + t * .4 + shimmer * .3 + c.t * .02, f); | |
| 116 | + float tuck = mix(1.f, .12f, smoothstep(.22f, .55f, t)); | |
| 117 | + float surge = ptlSurge(row * .8 - c.t * 3 + 2 * sin(column * TAU / N * 3)); | |
| 118 | + float barbLight = mix(.55f, .3f + .8f * barbs * (1 + 6 * c.b.w * surge), resolve); | |
| 119 | + float3 color = film * (.09 + .34 * (1 - across * .6)) * barbLight * tuck; | |
| 120 | + color += film * lift * .45 * pow(1 - across * .7, 2.f) * tuck; | |
| 121 | + float shaft = line(x, .028 * (1.3 - t * .6), aa) * smoothstep(.02f, .08f, t); | |
| 122 | + color += paint(.9, f) * shaft * (.12 + 2.6 * c.b.y) * tuck; | |
| 123 | + float rim = smoothstep(-.1f, -.01f, edge); | |
| 124 | + color += paint(.72 + seed * .12, f) * rim * (.06 + 2.2 * c.b.z) * tuck; | |
| 125 | + color += paint(.92, f) * ruffle * (.4 + barbs) * tuck; | |
| 126 | + fe.color = color; | |
| 127 | + return fe; | |
| 128 | + } | |
| 129 | + | |
| 130 | + | |
| 131 | + // ---------------------------------------------------------------- 312 Tartan Tube | |
| 132 | + // A twisting rounded-square tube wrapped in tartan: a symmetric sett of crossing thread | |
| 133 | + // stripes woven as a 2/2 twill, so the diagonal weave shows in every check. Each of the four | |
| 134 | + // thread colours belongs to one band and brightens with it; attacks send a bright stripe | |
| 135 | + // along the weft, lighting only the weft floats so the twill flashes. | |
| 136 | + float ptlSett(float s) { | |
| 137 | + float x = abs(fract(s) - .5) * 2; | |
| 138 | + return x < .07 ? 3 : x < .36 ? 0 : x < .44 ? 2 : x < .64 ? 1 : x < .7 ? 3 : x < .84 ? 2 : 0; | |
| 139 | + } | |
| 140 | + float3 ptlThread(float slot, float phase, Ctx c, constant NativeFrame &f) { | |
| 141 | + float3 hue = slot < .5 ? paint(.97, f) : slot < 1.5 ? paint(.04, f) : slot < 2.5 ? paint(.74, f) : paint(.5, f); | |
| 142 | + float gain = slot < .5 ? .26 : slot < 2.5 ? .36 : .55; | |
| 143 | + return hue * (gain + 3 * c.b[min(3, int(slot))] * ptlSurge(phase + slot * 1.9)); | |
| 144 | + } | |
| 145 | + | |
| 146 | + | |
| 147 | + // ---------------------------------------------------------------- 313 Herringbone Hall | |
| 148 | + // A rectangular hall paved on every surface with 2:1 herringbone tiles and glowing grout; | |
| 149 | + // the pattern folds continuously around the corners. Bass tilts and lights tiles in chevron | |
| 150 | + // waves that roll down the hall, low-mids glow the vertical tiles, high-mids sheen the | |
| 151 | + // horizontal ones, highs light the grout and attacks flash a whole herringbone row. | |
| 152 | + struct PtlBrick { float2 local; float2 id; float2 centre; float vertical; float edge; }; | |
| 153 | + | |
| 154 | + // Herringbone of 2x1 bricks in brick units: a staircase of horizontal/vertical pairs | |
| 155 | + // repeating along (1,1) and (0,4). | |
| 156 | + PtlBrick ptlHerringbone(float2 p) { | |
| 157 | + PtlBrick b; | |
| 158 | + float m = floor(p.x), lx = p.x - m; | |
| 159 | + float yp = p.y - m + 3, n = floor(yp / 4), yl = yp - 4 * n; | |
| 160 | + if (yl < 2) { | |
| 161 | + b.local = float2(yl, lx); b.id = float2(m - 2, n); b.vertical = 1; | |
| 162 | + b.centre = float2(m + .5, m - 2 + 4 * n); | |
| 163 | + } else if (yl < 3) { | |
| 164 | + b.local = float2(lx + 1, yl - 2); b.id = float2(m - 1, n); b.vertical = 0; | |
| 165 | + b.centre = float2(m, m - .5 + 4 * n); | |
| 166 | + } else { | |
| 167 | + b.local = float2(lx, yl - 3); b.id = float2(m, n); b.vertical = 0; | |
| 168 | + b.centre = float2(m + 1, m + .5 + 4 * n); | |
| 169 | + } | |
| 170 | + b.edge = min(min(b.local.x, 2 - b.local.x), min(b.local.y, 1 - b.local.y)); | |
| 171 | + return b; | |
| 172 | + } | |
| 173 | + | |
| 174 | + | |
| 175 | + // ---------------------------------------------------------------- 314 Quilted Pipe | |
| 176 | + // An off-axis view down a round pipe upholstered in puffy quilted diamonds: the camera rides | |
| 177 | + // close to one wall and slowly orbits the axis, so near diamonds loom large on one side. | |
| 178 | + // Bass inflates diamonds in rolling groups, low-mids brighten alternate diamonds, high-mids | |
| 179 | + // light the tufted buttons, highs glow the running stitches and attacks press a dimple | |
| 180 | + // wave through the quilt. | |
| 181 | + float3 quiltedPipe(Ctx c, constant NativeFrame &f) { | |
| 182 | + const float N = 11; | |
| 183 | + float orbit = c.t * .05; | |
| 184 | + float2 eye = float2(cos(orbit), sin(orbit)) * .5; | |
| 185 | + float3 forward = normalize(float3(-eye * .3, 1)); | |
| 186 | + float3 ray = cameraRay(c.uv / c.size, forward, float3(0, 1, 0), 1.15); | |
| 187 | + float2 dxy = ray.xy; | |
| 188 | + float bq = dot(eye, dxy), aq = max(dot(dxy, dxy), 1e-7f); | |
| 189 | + float tq = (-bq + sqrt(max(0.f, bq * bq - aq * (dot(eye, eye) - 1)))) / aq; | |
| 190 | + float2 hit = eye + dxy * tq; | |
| 191 | + float depth = min(tq * ray.z, 200.f); | |
| 192 | + float a = atan2(hit.y, hit.x); | |
| 193 | + float travel = c.travel * 1.2, zw = depth + travel; | |
| 194 | + float2 grid = float2(a, zw) * N / TAU; | |
| 195 | + float2 dia = float2(grid.x + grid.y, grid.x - grid.y); | |
| 196 | + float2 cell = floor(dia), l = fract(dia) - .5; | |
| 197 | + float fw = max(length(fwidth(hit)), fwidth(zw)) * N / TAU * 1.4; | |
| 198 | + float aa = clamp(fw, .01f, .5f); | |
| 199 | + float parity = ptlWrap(cell.x + cell.y, 2.f); | |
| 200 | + float seed = hash21(float2(cell.x - cell.y, ptlWrap(cell.x + cell.y, 2 * N))); | |
| 201 | + float cellDepth = (cell.x - cell.y) * .5 * TAU / N - travel; | |
| 202 | + float group = .5 + .5 * sin(cellDepth * .9 - c.t * 1.1 + parity * 2.2 + a); | |
| 203 | + float press = ptlFront(c, cellDepth, 1.1, 5, .35); | |
| 204 | + float inflate = .6 + .2 * sin(seed * 6 + c.t * .6) + 1.7 * c.b.x * group * group - 2.4 * press; | |
| 205 | + float2 cl = cos(PI * l), sl = sin(PI * l); | |
| 206 | + float2 grad = -PI * float2(sl.x * cl.y, cl.x * sl.y) * inflate; | |
| 207 | + float3 n = normalize(float3(-grad * .45, 1)); | |
| 208 | + float spin = c.t * .15; | |
| 209 | + float3 light = normalize(float3(cos(spin) * .8, sin(spin) * .8 + .3, .8)); | |
| 210 | + float diffuse = .55 * n.z * n.z + .45 * max(0.f, dot(n, light)); | |
| 211 | + float spec = pow(max(0.f, dot(n, normalize(light + float3(0, 0, 1)))), 22.f); | |
| 212 | + float edge = .5 - max(abs(l.x), abs(l.y)); | |
| 213 | + float crease = smoothstep(0.f, .2f, edge); | |
| 214 | + float3 satin = paint(.06 + parity * .36 + seed * .12, f) * (.02 + .42 * pow(diffuse, 3.f)) * (.25 + .75 * crease); | |
| 215 | + satin *= 1 + parity * 7 * c.b.y * ptlSurge(cellDepth * 1.3 - c.t * 2.2 + sin(a * 2)); | |
| 216 | + satin += paint(.88, f) * spec * (.25 + .4 * saturate(inflate)) * crease; | |
| 217 | + // Running stitches just inside every seam. | |
| 218 | + float seamAlong = abs(l.x) > abs(l.y) ? dia.y : dia.x; | |
| 219 | + float dash = smoothstep(.12f, .2f, abs(fract(seamAlong * 5) - .5)); | |
| 220 | + float stitch = line(edge - .075, .018, aa) * dash; | |
| 221 | + float3 stitchColor = paint(.95, f) * (.25 + 3 * c.b.w); | |
| 222 | + float3 color = mix(satin, stitchColor, stitch * smoothstep(.3f, .1f, fw)); | |
| 223 | + // Tufted buttons where the seams cross. | |
| 224 | + float button = length(.5 - abs(l)); | |
| 225 | + color = mix(color, paint(.75, f) * (.25 + 3 * c.b.z), fill(button - .075, aa)); | |
| 226 | + color += paint(.75, f) * glow(button, .06) * c.b.z * .6; | |
| 227 | + color += paint(.92, f) * press * (crease * .6 + glow(edge, .06) * 1.5); | |
| 228 | + float3 average = paint(.2, f) * .14; | |
| 229 | + color = mix(average, color, smoothstep(.4f, .12f, fw)); | |
| 230 | + float3 core = deep(.6, f) * .1 + paint(.85, f) * exp(-length(dxy) * 9) * 1.0; | |
| 231 | + return mix(core, color, ptlFog(depth, c, .045)); | |
| 232 | + } | |
| 233 | + NATIVE_EFFECT(quiltedPipe) | |
| 234 | + | |
| 235 | + // ---------------------------------------------------------------- 315 Lace Funnel | |
| 236 | + // A funnel of layered lace rings drifting toward the viewer against a hot core of light. | |
| 237 | + // The lace is laid out on conformal log-polar tiles, so every motif keeps its shape at | |
| 238 | + // every radius: rows of rimmed eyelets in cloth stitch, five-petal flowers over net and | |
| 239 | + // spotted net, with a picot inner edge and a scalloped border. Alternate layers turn against | |
| 240 | + // each other. Each layer's eyelets glow with its own band, highs light the cords and attacks | |
| 241 | + // bloom light through the openwork of one layer as it passes. | |
| 242 | + float4 ptlLace(float2 g, float yIn, float yOut, float aa) { | |
| 243 | + float y = g.y - yIn, row = floor(y); | |
| 244 | + float shift = ptlWrap(row, 2.f) * .5; | |
| 245 | + float2 l = float2(fract(g.x + shift) - .5, y - row - .5); | |
| 246 | + float type = ptlWrap(row, 3.f); | |
| 247 | + // A ring cord runs along every row boundary. | |
| 248 | + float cord = line(abs(l.y) - .5, .05, aa), cloth = 0, hole = 0, rim = 0; | |
| 249 | + if (type < .5) { | |
| 250 | + // Eyelet row: a band of cloth stitch pierced by rimmed eyelets. | |
| 251 | + float e = length(l * float2(1, 1.15)); | |
| 252 | + hole = fill(e - .16, aa); | |
| 253 | + rim = line(e - .2, .04, aa); | |
| 254 | + cloth = fill(abs(l.y) - .3, aa); | |
| 255 | + } else if (type < 1.5) { | |
| 256 | + // Scallop row: cloth arches, each pierced by an eyelet, open net between them. | |
| 257 | + float2 m = float2(l.x, l.y + .5); | |
| 258 | + float arch = length(m) - .46; | |
| 259 | + float eye = length(m - float2(0, .22)) - .08; | |
| 260 | + cloth = fill(arch, aa); | |
| 261 | + hole = fill(eye, aa); | |
| 262 | + rim = max(line(arch, .045, aa), line(eye - .035, .028, aa)); | |
| 263 | + } else { | |
| 264 | + // Bar row: open net crossed by slanted twisted bars joining the cords. | |
| 265 | + rim = line(abs(l.x - l.y * .6) - .02, .035, aa) * (.75 + .25 * sin(l.y * 40)); | |
| 266 | + } | |
| 267 | + cord = max(cord, rim); | |
| 268 | + float4 h = hexCell(g * 5); | |
| 269 | + float hexEdge = .5 - max(abs(h.x), max(abs(.5 * h.x + .866 * h.y), abs(.5 * h.x - .866 * h.y))); | |
| 270 | + float netThread = mix(.3f, line(hexEdge, .09, aa * 5), smoothstep(.12f, .05f, aa)); | |
| 271 | + float clothTex = mix(.6f, .5f + .5f * sin((l.x + l.y) * 50) * sin((l.x - l.y) * 50), smoothstep(.05f, .02f, aa)); | |
| 272 | + // Picot inner edge and scalloped outer border. | |
| 273 | + float sx = fract(g.x) - .5; | |
| 274 | + float border = yOut - .35 + .35 * sqrt(max(0.f, 1 - 4 * sx * sx)); | |
| 275 | + float inside = fill(g.y - border, aa) * fill(yIn - g.y, aa); | |
| 276 | + float edges = line(g.y - border, .08, aa) + line(g.y - yIn, .07, aa); | |
| 277 | + edges += line(length(float2(sx, g.y - yIn + .13)) - .1, .028, aa) * step(g.y, yIn); | |
| 278 | + float lace = max(cloth * .85, (1 - cloth) * netThread * .22); | |
| 279 | + float opacity = max(inside * max(lace, cord), edges) * (1 - hole * inside); | |
| 280 | + float glowLight = inside * (1 - hole) * (cloth * .5 * clothTex + (1 - cloth) * netThread * .12); | |
| 281 | + float holeGlow = inside * hole * (1 - smoothstep(0.f, .16f, length(l)) * .6); | |
| 282 | + return float4(saturate(opacity), glowLight, holeGlow, saturate(inside * cord + edges)); | |
| 283 | + } | |
| 284 | + | |
| 285 | + // Coaster versions: the same designs riding the roller-coaster course. | |
| 286 | + NATIVE_COASTER(quiltedPipe, 314, false) |
Sources/PulseCanvas/Resources/NativeFlow.metal added
| 1 | + // Liquid, molten and wave designs. Original PulseCanvas procedural code. | |
| 2 | + // Every effect receives Ctx from NativeCommon.metal; audio terms are zero at zero Chaos. | |
| 3 | + | |
| 4 | + // ------------------------------------------------------------------ 31 Silk Cascade | |
| 5 | + // Layered satin drapes hang at different depths and drift toward the viewer. Pleats run | |
| 6 | + // down each drape; bass deepens them, attacks send a gust across the cloth, and highs | |
| 7 | + // tighten the satin highlight. | |
| 8 | + float silkHeight(float2 p, float id, Ctx c) { | |
| 9 | + float drift = c.t * .3 + c.m * .5 + id * 1.7; | |
| 10 | + float gust = c.b.x * .6 + c.hit * .5; | |
| 11 | + float sway = sin(p.y * .9 + drift) * (.9 + gust * .8) + sin(p.y * 2.3 - drift * 1.3 + id) * .25; | |
| 12 | + float pleats = sin(p.x * 5.5 + sway * 1.6 + id * 3.1); | |
| 13 | + pleats = sign(pleats) * pow(abs(pleats), .7f); | |
| 14 | + float secondary = sin(p.x * 13 + sway * 3 - p.y * .6) * .18; | |
| 15 | + float cascade = sin(p.y * 3.4 - drift * 2.2 + p.x * .8) * (.08 + gust * .14); | |
| 16 | + return pleats * .5 + secondary + cascade; | |
| 17 | + } | |
| 18 | + float3 silkCascade(Ctx c, constant NativeFrame &f) { | |
| 19 | + float3 color = deep(.15 + c.uv.y * .06, f) * .05; | |
| 20 | + const int count = 5; | |
| 21 | + for (int k = 0; k < count; ++k) { | |
| 22 | + float2 slot = layerSlot(k, count, c.travel * 0.1); | |
| 23 | + float phase = slot.x, id = slot.y, fade = layerFade(phase); | |
| 24 | + float scale = layerScale(phase, 2.2) * .7 / c.size; | |
| 25 | + float2 p = rot(c.uv, .12 * sin(id * 1.9)) * scale + float2(hash11(id) * 17, id * 5.3); | |
| 26 | + float coordinate = p.x * .23 + .12 * sin(p.y * .6 + c.t * .15 + id); | |
| 27 | + float gap = abs(fract(coordinate) - .5) * 2; | |
| 28 | + float width = .8 + .1 * sin(id * 2.3); | |
| 29 | + float edge = c.px * scale * 3; | |
| 30 | + float mask = (1 - smoothstep(width - edge, width + edge, gap)) * fade; | |
| 31 | + float shadow = (1 - smoothstep(width, width + .25, gap)) * fade; | |
| 32 | + float h = silkHeight(p, id, c), e = .006; | |
| 33 | + float2 slope = float2(silkHeight(p + float2(e, 0), id, c) - h, silkHeight(p + float2(0, e), id, c) - h) / e; | |
| 34 | + float3 n = normalize(float3(-slope * .16, 1)); | |
| 35 | + float3 light = normalize(float3(-.65, .35, .65)); | |
| 36 | + float diffuse = max(dot(n, light), 0.f); | |
| 37 | + float3 halfway = normalize(light + float3(0, 0, 1)); | |
| 38 | + float sheen = pow(max(dot(n, halfway), 0.f), 40 + c.b.w * 80 + c.detail * 40); | |
| 39 | + float rim = pow(1 - n.z, 2.f); | |
| 40 | + float3 cloth = paint(.2 + hash11(id + 3) * .45 + h * .08, f); | |
| 41 | + float3 shaded = cloth * (.04 + diffuse * diffuse * .9 + rim * .2) + paint(.92, f) * sheen * (1.1 + c.detail); | |
| 42 | + shaded *= .75 + .25 * smoothstep(width, width * .6, gap); | |
| 43 | + float depthTone = mix(.3, 1., phase) * (1 - c.fog * .4 * (1 - phase)); | |
| 44 | + color *= 1 - shadow * .7; | |
| 45 | + color = mix(color, shaded * depthTone, mask); | |
| 46 | + } | |
| 47 | + return color; | |
| 48 | + } | |
| 49 | + | |
| 50 | + // ------------------------------------------------------------------ 33 Ribbon Foundry | |
| 51 | + // Broad forged ribbons twist through depth. Each shows a chrome face and a hot face; the | |
| 52 | + // twist reveals one, then the glowing edge, then the other. Music speeds individual | |
| 53 | + // twists, bass curls the ribbons and highs heat their edges. | |
| 54 | + float3 ribbonFoundry(Ctx c, constant NativeFrame &f) { | |
| 55 | + float3 color = deep(.08 + c.screen.y * .1, f) * .05; | |
| 56 | + color += paint(.9, f) * pow(noise2(c.uv * 3 + c.t * .1), 6.f) * .05; | |
| 57 | + const int count = 9; | |
| 58 | + for (int k = 0; k < count; ++k) { | |
| 59 | + float2 slot = layerSlot(k, count, c.travel * 0.09); | |
| 60 | + float phase = slot.x, id = slot.y, fade = layerFade(phase); | |
| 61 | + float scale = layerScale(phase, 2.6) * .6; | |
| 62 | + float angle = (hash11(id * 7.1) - .5) * 1.2; | |
| 63 | + float2 p = rot(c.uv, angle) * scale + float2(id * 2.3, (hash11(id) - .5) * 1.4); | |
| 64 | + float band = hash11(id * 3.3); | |
| 65 | + float curl = .38 + c.b.x * .3 * (band < .5 ? 1. : .6); | |
| 66 | + float center = curl * sin(p.x * 1.1 + c.t * .4 + id) + .18 * sin(p.x * 2.6 - c.t * .3 + id * 2); | |
| 67 | + center += c.hit * .12 * sin(p.x * 5 - c.m * 6 + id); | |
| 68 | + float twist = p.x * (1.4 + band) + c.t * (.6 + band * .5) + c.m * (.8 + band) + id; | |
| 69 | + float facing = cos(twist); | |
| 70 | + float halfWidth = .2 * c.size * max(abs(facing), .045); | |
| 71 | + float across = (p.y - center) / halfWidth; | |
| 72 | + float pixel = c.px * scale / halfWidth; | |
| 73 | + float body = (1 - smoothstep(1 - pixel, 1 + pixel, abs(across))) * fade; | |
| 74 | + float bevel = sqrt(max(0.f, 1 - across * across)); | |
| 75 | + float3 n = normalize(float3(0, sin(twist) + across * .45 * facing, abs(facing) * (.5 + .5 * bevel))); | |
| 76 | + float3 light = normalize(float3(.3, .6, .75)); | |
| 77 | + float specular = pow(max(dot(reflect(-light, n), float3(0, 0, 1)), 0.f), 24.f); | |
| 78 | + float3 chrome = paint(.3 + band * .4 + n.y * .2, f) * (.15 + .5 * max(dot(n, light), 0.f)) + paint(.95, f) * specular * 1.4; | |
| 79 | + float3 molten = paint(.75 + n.y * .15, f) * (.65 + .35 * bevel) * 1.4; | |
| 80 | + float3 face = facing > 0 ? chrome : molten; | |
| 81 | + float edge = pow(abs(across), 8.f) * (1 - abs(facing)) * (1.2 + c.b.w * 2); | |
| 82 | + face += paint(.9, f) * edge; | |
| 83 | + float depthTone = mix(.3, 1., phase); | |
| 84 | + color = mix(color * (1 - .4 * fade * exp(-abs(across) * .5) * step(1.f, abs(across))), face * depthTone, body); | |
| 85 | + color += paint(.85, f) * exp(-max(abs(across) - 1, 0.f) * 6) * .04 * fade * (1 - body); | |
| 86 | + } | |
| 87 | + return color; | |
| 88 | + } | |
| 89 | + | |
| 90 | + // ------------------------------------------------------------------ 40 Lava Estuary | |
| 91 | + // An oblique flight over a molten delta: cooled crust plates drift on glowing rivers. | |
| 92 | + // Bass opens the cracks where surges pass, attacks flare the seams, highs lift embers. | |
| 93 | + | |
| 94 | + | |
| 95 | + // ------------------------------------------------------------------ 78 Ferrofluid Crown | |
| 96 | + // One continuous liquid height field: smooth magnetic crowns and travelling capillary | |
| 97 | + // waves. Analytic slopes keep reflections joined across the triangular lattice. | |
| 98 | + | |
| 99 | + | |
| 100 | + // ------------------------------------------------------------------ 79 Windowpane Drizzle | |
| 101 | + // Rain running down a window in front of soft city lights. Every drop is a lens that | |
| 102 | + // shows a sharp, inverted view of the lights. Bands brighten individual lights; the | |
| 103 | + // music clock speeds the running drops. | |
| 104 | + float3 bokehLights(float2 p, float blur, Ctx c, constant NativeFrame &f) { | |
| 105 | + float3 color = deep(.12 + p.y * .05, f) * .22 + paint(.3, f) * .05 * (1 + p.y); | |
| 106 | + for (int layer = 0; layer < 3; ++layer) { | |
| 107 | + float fl = float(layer); | |
| 108 | + float2 q = p * (1.4 + fl * .9) + float2(fl * 7.3, c.t * .025 * (fl + 1)); | |
| 109 | + float2 base = floor(q); | |
| 110 | + for (int y = -1; y <= 1; ++y) for (int x = -1; x <= 1; ++x) { | |
| 111 | + float2 cell = base + float2(x, y); | |
| 112 | + float seed = hash21(cell + fl * 31); | |
| 113 | + if (seed < .3) continue; | |
| 114 | + float2 center = cell + .5 + (hash22(cell + fl * 17) - .5) * .8; | |
| 115 | + float band = c.b[int(fract(seed * 7.3) * 3.99)]; | |
| 116 | + float radius = (.32 + fract(seed * 13.1) * .3) * (1 + band * .3); | |
| 117 | + float d = length(q - center); | |
| 118 | + float soft = blur * (1.4 + fl); | |
| 119 | + float disc = 1 - smoothstep(radius - soft, radius + soft, d); | |
| 120 | + float ring = exp(-pow((d - radius) / (soft + .03), 2.f)) * .3; | |
| 121 | + float shimmer = .65 + .35 * sin(c.t * (.4 + seed) + seed * 40) + c.hit * step(.6, fract(seed * 3.7)) * 1.2; | |
| 122 | + color += paint(seed * 1.6 + fl * .25, f) * (disc * .35 + ring * .5) * shimmer * (1 + band * 1.6) / (1 + fl * .6); | |
| 123 | + } | |
| 124 | + } | |
| 125 | + return color; | |
| 126 | + } | |
| 127 | + float3 windowpaneDrizzle(Ctx c, constant NativeFrame &f) { | |
| 128 | + float2 view = c.uv * (1 - .08 * sin(c.travel * .2)) + float2(0, c.travel * .05); | |
| 129 | + float2 refraction = 0.f; | |
| 130 | + float drop = 0; | |
| 131 | + // Static beads. | |
| 132 | + float2 grid = c.uv * 9 / c.size; | |
| 133 | + float2 cell = floor(grid), local = fract(grid) - .5; | |
| 134 | + float2 seed = hash22(cell); | |
| 135 | + float2 bead = local - (seed - .5) * .6; | |
| 136 | + float beadRadius = .08 + seed.x * .14; | |
| 137 | + float beadMask = 1 - smoothstep(beadRadius * .85, beadRadius, length(bead)); | |
| 138 | + beadMask *= step(.35, seed.y); | |
| 139 | + refraction += bead / beadRadius * beadMask; | |
| 140 | + drop = max(drop, beadMask); | |
| 141 | + // Running drops with trails. | |
| 142 | + float columns = 5 / c.size; | |
| 143 | + float x = c.uv.x * columns; | |
| 144 | + float column = floor(x); | |
| 145 | + float lane = hash11(column * 3.7); | |
| 146 | + float speed = .25 + lane * .35; | |
| 147 | + float fall = c.t * speed + c.m * .4 * (lane + .3) + lane * 9; | |
| 148 | + float y = c.uv.y * columns * .6 + fall; | |
| 149 | + float segment = floor(y); | |
| 150 | + float local1 = fract(y); | |
| 151 | + float wiggle = sin(c.uv.y * 9 + lane * 20) * .08; | |
| 152 | + float2 runner = float2(fract(x) - .5 - wiggle - (hash11(segment + column) - .5) * .4, (local1 - .25) * 1.6); | |
| 153 | + float runnerRadius = .2 + hash11(column + segment * 1.7) * .1; | |
| 154 | + float runnerMask = (1 - smoothstep(runnerRadius * .8, runnerRadius, length(runner * float2(1, .7)))) * step(.3, hash11(segment * 2.1 + column)); | |
| 155 | + float trail = (1 - smoothstep(.03f, .07f, abs(runner.x))) * smoothstep(.0f, .8f, local1 - .3) * .6 * step(.3, hash11(segment * 2.1 + column)); | |
| 156 | + refraction += runner / runnerRadius * runnerMask * 1.4; | |
| 157 | + drop = max(drop, runnerMask); | |
| 158 | + float3 behind = bokehLights(view, .08, c, f); | |
| 159 | + float3 through = bokehLights(view * float2(-1, -1) * .6 + refraction * .3 + 2, .015, c, f); | |
| 160 | + float3 color = mix(behind * (1 - trail * .3), through * 1.3, drop); | |
| 161 | + float3 n = normalize(float3(refraction, 1)); | |
| 162 | + color += paint(.95, f) * pow(max(dot(n, normalize(float3(-.5, .7, .6))), 0.f), 30.f) * drop * (1 + c.b.w); | |
| 163 | + color += paint(.9, f) * trail * .05; | |
| 164 | + return color; | |
| 165 | + } | |
| 166 | + | |
| 167 | + // ------------------------------------------------------------------ 80 Ink Bloom | |
| 168 | + // Palette inks billow downward through clear water over a pale ground. Bass makes the | |
| 169 | + // plumes billow, attacks release fresh puffs, highs add fine filaments. | |
| 170 | + float3 inkBloom(Ctx c, constant NativeFrame &f) { | |
| 171 | + float3 paper = mix(paint(.8, f), paint(1, f), .5) * 1.6; | |
| 172 | + float3 color = paper * (.9 + .1 * fbm2(c.uv * 3, 3)); | |
| 173 | + for (int ink = 0; ink < 3; ++ink) { | |
| 174 | + float fi = float(ink); | |
| 175 | + float2 p = c.uv * (.9 + fi * .25) / c.size + float2(fi * 3.7, 0); | |
| 176 | + p.y += c.t * (.12 + fi * .03) + c.travel * .12; | |
| 177 | + float billow = .8 + c.b.x * .5 + c.e * .3; | |
| 178 | + float2 warp = float2(fbm2(p * 1.3 + float2(0, c.t * .1) + fi, 4), fbm2(p * 1.3 + float2(5.2, -c.t * .08) + fi, 4)); | |
| 179 | + float2 q = p + (warp - .5) * 1.6 * billow; | |
| 180 | + q += curl2(q * 1.4 + c.m * .3) * (.08 + c.b.x * .08 + c.hit * .1); | |
| 181 | + float plume = fbm2(q * 1.6, 5); | |
| 182 | + float columns = .5 + .5 * sin(q.x * 2.3 + fi * 2); | |
| 183 | + float density = smoothstep(.45, .75, plume * (.75 + .45 * columns)); | |
| 184 | + float filaments = pow(max(0.f, 1 - abs(fbm2(q * 6 + fi, 3) - .5) * 6), 3.f) * (.25 + c.detail * .4 + c.b.w * .8); | |
| 185 | + density = clamp(density + filaments * smoothstep(.3, .6, plume), 0.f, 1.f); | |
| 186 | + float3 inkColor = paint(.1 + fi * .32, f); | |
| 187 | + color = mix(color, color * inkColor * 1.1, density * .85); | |
| 188 | + } | |
| 189 | + return color; | |
| 190 | + } | |
| 191 | + | |
| 192 | + // ------------------------------------------------------------------ 81 Oil Marble | |
| 193 | + // Combed marbling with thin-film colors. Slow vortices fold the bands; the music clock | |
| 194 | + // spins them, bass pulls the comb, attacks drop new rings of ink. | |
| 195 | + float2 marbleWarp(float2 p, Ctx c) { | |
| 196 | + for (int i = 0; i < 4; ++i) { | |
| 197 | + float fi = float(i); | |
| 198 | + float2 center = float2(sin(c.t * .07 + fi * 2.3), cos(c.t * .06 + fi * 1.7)) * 1.6; | |
| 199 | + float2 d = p - center; | |
| 200 | + float r = length(d); | |
| 201 | + float spin = (.9 + c.b.y * .8) * exp(-r * r * .6) * sin(c.t * .11 + c.m * .4 + fi * 2.1); | |
| 202 | + p = center + rot(d, spin); | |
| 203 | + } | |
| 204 | + p.x += sin(p.y * 3.1 + c.t * .2) * (.12 + c.b.x * .18); | |
| 205 | + p.y += sin(p.x * 1.7 - c.t * .15) * .18; | |
| 206 | + return p; | |
| 207 | + } | |
| 208 | + float3 oilMarblePattern(float2 p, Ctx c, constant NativeFrame &f) { | |
| 209 | + float2 q = marbleWarp(p, c); | |
| 210 | + float drop = 0; | |
| 211 | + for (int i = 0; i < 3; ++i) { | |
| 212 | + float beat = floor(c.m * .5 + float(i) / 3); | |
| 213 | + float age = fract(c.m * .5 + float(i) / 3); | |
| 214 | + float2 center = (hash22(float2(beat, float(i))) - .5) * 3; | |
| 215 | + drop += sin(length(q - center) * 14 - age * 6) * exp(-length(q - center) * 1.5) * (1 - age) * smoothstep(0.f, .1f, age); | |
| 216 | + } | |
| 217 | + float bands = q.y * 2.2 + fbm2(q * 1.5, 4) * 1.4 + drop * (.35 + c.hit * .5); | |
| 218 | + float thickness = fract(bands); | |
| 219 | + float3 film = filmColor(bands * .35 + c.t * .01, f); | |
| 220 | + float vein = exp(-abs(thickness - .5) * 16) * .6; | |
| 221 | + return film * (.55 + .45 * smoothstep(.1f, .5f, thickness)) + paint(.95, f) * vein * (.5 + c.hit * .8); | |
| 222 | + } | |
| 223 | + float3 oilMarble(Ctx c, constant NativeFrame &f) { | |
| 224 | + float3 color = 0.f; | |
| 225 | + for (int octave = 0; octave < 2; ++octave) { | |
| 226 | + float2 z = octaveZoom(c.travel * .12, octave); | |
| 227 | + color += oilMarblePattern(c.uv * z.x * .9 / c.size + float2(0, float(octave) * 0), c, f) * z.y; | |
| 228 | + } | |
| 229 | + float2 n = curl2(c.uv * 3 + c.t * .05) * .1; | |
| 230 | + color += paint(.9, f) * pow(max(0.f, n.x + n.y), 2.f) * .3 * (1 + c.b.w); | |
| 231 | + return color; | |
| 232 | + } | |
| 233 | + | |
| 234 | + // ------------------------------------------------------------------ 82 Chladni Sand | |
| 235 | + // Sand piles into the nodal lines of a vibrating brass plate. The mode drifts slowly; | |
| 236 | + // bass shakes grains off the lines and attacks scatter them, so loud passages blur the | |
| 237 | + // figure and quiet ones let bold ridges form again. | |
| 238 | + | |
| 239 | + | |
| 240 | + // ------------------------------------------------------------------ 83 Ripple Tank | |
| 241 | + // An oblique view across a wide ripple tank. Drifting sources interfere; the curvature of | |
| 242 | + // the surface focuses light into caustic lines on the floor. Each source follows its own | |
| 243 | + // band; attacks drop a ring at a new point. | |
| 244 | + float tankHeight(float2 p, Ctx c) { | |
| 245 | + float h = 0; | |
| 246 | + float2 cell = floor(p / 2.5); | |
| 247 | + for (int y = -1; y <= 1; ++y) for (int x = -1; x <= 1; ++x) { | |
| 248 | + float2 id = cell + float2(x, y); | |
| 249 | + float2 seed = hash22(id); | |
| 250 | + float2 source = (id + .5 + (seed - .5) * .5) * 2.5 + float2(sin(c.t * .2 + seed.x * 6), cos(c.t * .17 + seed.y * 6)) * .35; | |
| 251 | + float r = length(p - source); | |
| 252 | + float band = c.b[int(seed.x * 3.99)]; | |
| 253 | + float amplitude = (.35 + band * .8 + c.hit * .5 * step(.5, seed.y)) / (1 + r * .6) * smoothstep(2.5f, 1.2f, r); | |
| 254 | + h += amplitude * sin(r * (8 + seed.y * 3) - c.t * 2.2 - c.m * 2 + seed.x * 6); | |
| 255 | + } | |
| 256 | + float drop = floor(c.m * .7), age = fract(c.m * .7); | |
| 257 | + float2 at = (hash22(float2(drop, 3)) - .5) * 6 + float2(0, c.travel * 1.2 + 6); | |
| 258 | + float r = length(p - at); | |
| 259 | + h += exp(-abs(r - age * 6) * 3) * sin(r * 9 - age * 20) * (1 - age) * smoothstep(0.f, .08f, age) * (.8 + c.hit * 1.6); | |
| 260 | + return h * .12; | |
| 261 | + } | |
| 262 | + float3 rippleTank(Ctx c, constant NativeFrame &f) { | |
| 263 | + // Seen from directly above, drifting across an endless tank. | |
| 264 | + float3 g = float3(c.uv, 0); | |
| 265 | + float2 p = rot(c.uv, .3) * 3.2 / c.size + float2(c.t * .05, c.travel * 1.2); | |
| 266 | + float e = .025; | |
| 267 | + float h = tankHeight(p, c); | |
| 268 | + float hx = tankHeight(p + float2(e, 0), c), hy = tankHeight(p + float2(0, e), c); | |
| 269 | + float hx2 = tankHeight(p - float2(e, 0), c), hy2 = tankHeight(p - float2(0, e), c); | |
| 270 | + float laplacian = (hx + hx2 + hy + hy2 - 4 * h) / (e * e); | |
| 271 | + float2 slope = float2(hx - hx2, hy - hy2) / (2 * e); | |
| 272 | + float2 floorUV = p + slope * .6; | |
| 273 | + float2 tile = abs(fract(floorUV * .5) - .5); | |
| 274 | + float grout = 1 - smoothstep(.0f, .04f, min(tile.x, tile.y)); | |
| 275 | + float caustic = clamp(1 - laplacian * .35, 0.f, 5.f); | |
| 276 | + caustic = pow(caustic, 3.f) * .6; | |
| 277 | + float3 floorColor = deep(.3 + floorUV.x * .02, f) * (.25 - grout * .15); | |
| 278 | + float3 color = floorColor * (.4 + caustic * .9) + paint(.85 + h, f) * pow(max(caustic - 1, 0.f), 1.5f) * .5; | |
| 279 | + float3 n = normalize(float3(-slope * .5, 1)); | |
| 280 | + color += paint(.95, f) * pow(max(dot(reflect(float3(0, 0, -1), n), normalize(float3(.3, .4, .85))), 0.f), 60.f) * .6; | |
| 281 | + float vignette = 1 - .35 * dot(g.xy, g.xy) / dot(c.extent, c.extent); | |
| 282 | + return color * vignette; | |
| 283 | + } | |
| 284 | + | |
| 285 | + // ------------------------------------------------------------------ 84 Chrome Metaballs | |
| 286 | + // A drifting field of liquid-chrome droplets that merge and part as the camera glides | |
| 287 | + // through them. Each droplet swells with its own band; attacks ripple their skins. | |
| 288 | + float metaField(float3 p, Ctx c) { | |
| 289 | + float3 cell = floor(p / 3), base = cell * 3; | |
| 290 | + float3 local = p - base - 1.5; | |
| 291 | + float3 octant = sign(local); | |
| 292 | + float d = 9; | |
| 293 | + for (int i = 0; i < 8; ++i) { | |
| 294 | + float3 o = float3(i & 1, (i >> 1) & 1, (i >> 2) & 1) * octant; | |
| 295 | + float3 id = cell + o; | |
| 296 | + float3 seed = hash33(id); | |
| 297 | + float band = c.b[int(seed.x * 3.99)]; | |
| 298 | + float3 center = (id + .5) * 3 + sin(c.t * (.3 + seed * .4) + seed * TAU) * .9; | |
| 299 | + float radius = (.75 + seed.y * .45) * c.size * .9 * (1 + band * .35); | |
| 300 | + d = smin(d, length(p - center) - radius, .9); | |
| 301 | + } | |
| 302 | + d += c.hit * .03 * sin(p.x * 9 + c.m * 5) * sin(p.y * 9) * sin(p.z * 9 - c.m * 4); | |
| 303 | + float2 path = float2(sin(c.t * .11) * .8, cos(c.t * .09) * .6); | |
| 304 | + return max(d, .9 - length(p.xy - path)); | |
| 305 | + } | |
| 306 | + float3 chromeMetaballs(Ctx c, constant NativeFrame &f) { | |
| 307 | + float3 ro = float3(sin(c.t * .11) * .8, cos(c.t * .09) * .6, c.travel * 1.6); | |
| 308 | + float3 rd = normalize(float3(c.uv, 1.4)); | |
| 309 | + rd.xy = rot(rd.xy, c.t * .04); | |
| 310 | + float travel = 0, glow = 0; | |
| 311 | + bool hit = false; | |
| 312 | + for (int i = 0; i < 44; ++i) { | |
| 313 | + float d = metaField(ro + rd * travel, c); | |
| 314 | + glow += exp(-max(d, 0.f) * 4) * .012; | |
| 315 | + if (d < .002 * (1 + travel * .4)) { hit = true; break; } | |
| 316 | + travel += d; | |
| 317 | + if (travel > 26) break; | |
| 318 | + } | |
| 319 | + float3 background = deep(.2 + rd.y * .2, f) * .12 + paint(.6, f) * glow * .4; | |
| 320 | + if (!hit) return background; | |
| 321 | + float3 p = ro + rd * travel; | |
| 322 | + float2 e = float2(.004, 0); | |
| 323 | + float3 n = normalize(float3(metaField(p + e.xyy, c) - metaField(p - e.xyy, c), metaField(p + e.yxy, c) - metaField(p - e.yxy, c), metaField(p + e.yyx, c) - metaField(p - e.yyx, c))); | |
| 324 | + float3 r = reflect(rd, n); | |
| 325 | + float3 environment = mix(deep(.1, f) * .25, paint(.3 + r.y * .3, f) * .8, smoothstep(-.02f, .02f, r.y)); | |
| 326 | + float2 box = abs(float2(atan2(r.x, r.z) - c.t * .05, r.y - .55)); | |
| 327 | + box.x = abs(fract(box.x / 1.6 + .5) - .5) * 1.6; | |
| 328 | + environment += paint(.95, f) * (1 - smoothstep(.0f, .03f, max(box.x - .3, box.y - .12))) * 2.2; | |
| 329 | + environment += paint(.75, f) * exp(-abs(r.y) * 30) * .8; | |
| 330 | + environment += deep(.4, f) * .2 * step(r.y, 0.f) * smoothstep(.9f, 1.f, abs(sin(r.x / max(-r.y, .05f) * 3))); | |
| 331 | + float fresnel = .4 + .6 * pow(1 - max(dot(-rd, n), 0.f), 3.f); | |
| 332 | + float3 color = environment * fresnel; | |
| 333 | + float fog = exp(-travel * (.035 + c.fog * .05)); | |
| 334 | + return mix(background, color, fog); | |
| 335 | + } | |
| 336 | + | |
| 337 | + // ------------------------------------------------------------------ 85 Ocean Swell | |
| 338 | + // Rolling open-ocean swells under a palette dusk. Bass lifts wave groups as they pass, | |
| 339 | + // highs add chop and glitter, and the camera skims forward with Zoom speed. | |
| 340 | + float swellHeight(float2 p, Ctx c, int octaves) { | |
| 341 | + float h = 0, amplitude = .55 * (1 + c.b.x * .5), frequency = .32; | |
| 342 | + float2 direction = normalize(float2(.3, 1)); | |
| 343 | + for (int i = 0; i < octaves; ++i) { | |
| 344 | + float fi = float(i); | |
| 345 | + float2 d = rot(direction, fi * 1.37 - .6); | |
| 346 | + float phase = dot(p, d) * frequency + c.t * (.7 + fi * .21) + c.m * .25 * fi; | |
| 347 | + float wave = 1 - abs(sin(phase)); | |
| 348 | + h += (wave * wave - .4) * amplitude; | |
| 349 | + amplitude *= .52 + c.b.w * .05; frequency *= 1.85; | |
| 350 | + } | |
| 351 | + return h; | |
| 352 | + } | |
| 353 | + float3 oceanSwell(Ctx c, constant NativeFrame &f) { | |
| 354 | + // The glide over the swell speeds up with the music clock. | |
| 355 | + float3 ro = float3(0, 1.6, c.travel * 2.5 + c.m * .8); | |
| 356 | + float3 rd = cameraRay(c.uv, float3(0, -.12, 1), float3(0, 1, 0), 1.5); | |
| 357 | + float3 sunDirection = normalize(float3(.25, .18, 1)); | |
| 358 | + float3 sky = mix(paint(.85, f) * .9, deep(.25, f) * .35, smoothstep(-.05f, .5f, rd.y)); | |
| 359 | + sky += paint(.98, f) * pow(max(dot(rd, sunDirection), 0.f), 400.f) * 4 + paint(.9, f) * pow(max(dot(rd, sunDirection), 0.f), 8.f) * .4; | |
| 360 | + float clouds = fbm2(rd.xz / max(rd.y, .05f) * .6 + c.t * .02, 4); | |
| 361 | + sky = mix(sky, paint(.6, f) * .6, smoothstep(.5f, .8f, clouds) * smoothstep(0.f, .2f, rd.y) * .6); | |
| 362 | + if (rd.y > 0) return sky; | |
| 363 | + float travel = (ro.y + .3) / -rd.y * .5, lastGap = 1; | |
| 364 | + for (int i = 0; i < 60; ++i) { | |
| 365 | + float3 p = ro + rd * travel; | |
| 366 | + float gap = p.y - swellHeight(p.xz, c, 4); | |
| 367 | + if (gap < .01) break; | |
| 368 | + travel += gap * .7; | |
| 369 | + lastGap = gap; | |
| 370 | + if (travel > 60) break; | |
| 371 | + } | |
| 372 | + float3 p = ro + rd * travel; | |
| 373 | + float e = .03; | |
| 374 | + float h = swellHeight(p.xz, c, 7); | |
| 375 | + float3 n = normalize(float3(h - swellHeight(p.xz + float2(e, 0), c, 7), e, h - swellHeight(p.xz + float2(0, e), c, 7))); | |
| 376 | + float3 r = reflect(rd, n); | |
| 377 | + r.y = abs(r.y); | |
| 378 | + float fresnel = .04 + .96 * pow(1 - max(dot(-rd, n), 0.f), 5.f); | |
| 379 | + float3 reflected = mix(paint(.85, f) * .9, deep(.25, f) * .35, smoothstep(-.05f, .5f, r.y)) + paint(.98, f) * pow(max(dot(r, sunDirection), 0.f), 120.f) * (3 + c.b.w * 4 + c.hit * 5); | |
| 380 | + // Crests glow from within on the low-mids, in bands that roll toward the viewer on the clock. | |
| 381 | + float roll = .5 + .5 * sin(p.z * .35 - c.m * 1.8 + p.x * .1); | |
| 382 | + float3 water = deep(.3, f) * .12 * (.6 + .4 * max(n.y, 0.f)) + paint(.45 + c.b.z * .15, f) * (.08 + c.b.y * .35 * roll) * smoothstep(-.2f, .6f, h); | |
| 383 | + float foam = smoothstep(.45f - c.hit * .12, .75f, h + .1 * fbm2(p.xz * 3, 3)) * (.6 + c.b.x * .5); | |
| 384 | + float3 color = mix(water, reflected, fresnel) + paint(.95, f) * foam * .5; | |
| 385 | + float distanceFog = 1 - exp(-travel * (.02 + c.fog * .03)); | |
| 386 | + return mix(color, sky, distanceFog); | |
| 387 | + } | |
| 388 | + | |
| 389 | + #define FLOW_EFFECTS(X) X(silkCascade) X(ribbonFoundry) X(windowpaneDrizzle) X(inkBloom) X(oilMarble) X(rippleTank) X(chromeMetaballs) X(oceanSwell) | |
| 390 | + FLOW_EFFECTS(NATIVE_EFFECT) |
Sources/PulseCanvas/Resources/NativeNature.metal added
| 1 | + // Organic, landscape and volumetric designs. Original PulseCanvas procedural code. | |
| 2 | + // Every effect receives Ctx from NativeCommon.metal; audio terms are zero at zero Chaos. | |
| 3 | + | |
| 4 | + float3 natureNormal(float d0, float dx, float dy, float dz) { return normalize(float3(dx - d0, dy - d0, dz - d0) + 1e-6); } | |
| 5 | + | |
| 6 | + // Folding fractal tree in local coordinates; returns distance to the nearest branch and | |
| 7 | + // the depth of that branch. | |
| 8 | + | |
| 9 | + | |
| 10 | + // ------------------------------------------------------------------ 34 Electric Orchard | |
| 11 | + // Rows of luminous fractal trees recede across a dark orchard. Current climbs every tree | |
| 12 | + // in pulses; each tree pulses on its band and attacks flash the whole canopy. | |
| 13 | + | |
| 14 | + | |
| 15 | + // ------------------------------------------------------------------ 36 Graviton Petals | |
| 16 | + // A flight through a weightless garden of huge flowers that open and close. Each bloom | |
| 17 | + // opens on its band; attacks shiver the petals. | |
| 18 | + | |
| 19 | + | |
| 20 | + // ------------------------------------------------------------------ 42 Sonic Topography | |
| 21 | + // A living contour map seen from above. Glowing isolines wrap hills that rise and fall; | |
| 22 | + // each region's hills lift with their band, attacks ripple through the contours, and the | |
| 23 | + // map glides and slowly turns with Zoom speed. | |
| 24 | + float topographyHeight(float2 p, Ctx c) { | |
| 25 | + float h = fbm2(p * .35, 5) * 2.2; | |
| 26 | + float2 cell = floor(p * .25); | |
| 27 | + float band = c.b[int(hash21(cell) * 3.99)]; | |
| 28 | + h += band * .6 * smoothstep(.2f, 1.f, fbm2(p * .5 + 3, 2)); | |
| 29 | + h += c.hit * .08 * sin(length(p - float2(sin(c.m) * 3, c.travel * 1.5)) * 3 - c.m * 6); | |
| 30 | + return h + .15 * sin(p.x * .4 + c.t * .1) * sin(p.y * .3 - c.t * .08); | |
| 31 | + } | |
| 32 | + float3 sonicTopography(Ctx c, constant NativeFrame &f) { | |
| 33 | + float2 xz = rot(c.uv, c.t * .01) * 3.2 / c.size + float2(sin(c.t * .05) * 2, c.travel * 1.5); | |
| 34 | + float e = .02, h = topographyHeight(xz, c); | |
| 35 | + float2 slope = float2(topographyHeight(xz + float2(e, 0), c) - h, topographyHeight(xz + float2(0, e), c) - h) / e; | |
| 36 | + float3 n = normalize(float3(-slope, 1.2)); | |
| 37 | + float shade = .2 + .8 * max(dot(n, normalize(float3(-.5, .5, .7))), 0.f); | |
| 38 | + float levels = h * 10; | |
| 39 | + float w = fwidth(levels); | |
| 40 | + float toLevel = .5 - abs(fract(levels) - .5); | |
| 41 | + float contour = 1 - smoothstep(.015f, .015f + max(w * 1.5, .02f), toLevel); | |
| 42 | + float toMajor = .5 - abs(fract(h * 2) - .5); | |
| 43 | + float major = 1 - smoothstep(.01f, .01f + max(fwidth(h * 2) * 1.5, .015f), toMajor); | |
| 44 | + float2 gridLines = abs(fract(xz * .5) - .5); | |
| 45 | + float grid = (1 - smoothstep(.0f, .015f, min(gridLines.x, gridLines.y))) * .12; | |
| 46 | + float water = smoothstep(.75f, .7f, h); | |
| 47 | + float3 land = deep(.25 + h * .1, f) * .1 * shade + paint(.15 + h * .3, f) * .08 * shade; | |
| 48 | + float3 sea = deep(.6, f) * .08 + paint(.5, f) * .05 * (1 + sin(h * 40 - c.t)); | |
| 49 | + float3 color = mix(land, sea, water * .8); | |
| 50 | + color += paint(.25 + h * .25, f) * contour * .8 * (.5 + shade) + paint(.9, f) * major * 1.1 + paint(.6, f) * grid; | |
| 51 | + return color; | |
| 52 | + } | |
| 53 | + | |
| 54 | + // ------------------------------------------------------------------ 43 Prismatic Dunes | |
| 55 | + // A low flight over wind-rippled dunes at golden hour. Ridges split the light into | |
| 56 | + // prismatic sheen; bass lifts dune crests as gusts pass and highs blow sand off them. | |
| 57 | + float duneHeight(float2 p, Ctx c) { | |
| 58 | + float ridges = 0; | |
| 59 | + float2 q = p * .25; | |
| 60 | + ridges += (1 - abs(sin(q.x * 1.3 + sin(q.y * .7) * 1.5 + q.y * .3))) * 1.2; | |
| 61 | + ridges += (1 - abs(sin(q.x * 2.7 - q.y * .9 + 2))) * .4; | |
| 62 | + ridges += fbm2(q * 1.5, 3) * .5; | |
| 63 | + float gust = (c.b.x * 1.1 + c.hit * .8) * pow(.5 + .5 * sin(q.y * 1.4 - c.m * 2), 3.f); | |
| 64 | + float ripples = sin(p.x * 2.2 + p.y * .6 + fbm2(p * .4, 2) * 3) * .03; | |
| 65 | + return ridges * (1 + gust) + ripples; | |
| 66 | + } | |
| 67 | + float3 prismaticDunes(Ctx c, constant NativeFrame &f) { | |
| 68 | + c.travel += c.m * f.camera.w * .7; | |
| 69 | + float3 ro = float3(c.t * .2, 4.0, c.travel * 2.2); | |
| 70 | + float3 rd = cameraRay(c.uv, float3(.2, -.18, 1), float3(0, 1, 0), 1.5); | |
| 71 | + float3 sun = normalize(float3(-.6, .22, 1)); | |
| 72 | + float3 sky = mix(paint(.65, f) * 1.1, deep(.3, f) * .25, smoothstep(-.05f, .55f, rd.y)); | |
| 73 | + sky += paint(.82, f) * pow(max(dot(rd, sun), 0.f), 200.f) * 3 + paint(.85, f) * pow(max(dot(rd, sun), 0.f), 6.f) * .4; | |
| 74 | + float travel = 0; | |
| 75 | + bool hit = false; | |
| 76 | + for (int i = 0; i < 90; ++i) { | |
| 77 | + float3 p = ro + rd * travel; | |
| 78 | + float gap = p.y - duneHeight(p.xz / c.size, c); | |
| 79 | + if (gap < .006) { hit = true; break; } | |
| 80 | + travel += max(gap * .45, .015f); | |
| 81 | + if (travel > 60) break; | |
| 82 | + } | |
| 83 | + if (!hit) return sky; | |
| 84 | + float3 p = ro + rd * travel; | |
| 85 | + float2 xz = p.xz / c.size; | |
| 86 | + float e = .015, h = duneHeight(xz, c); | |
| 87 | + float3 n = normalize(float3(h - duneHeight(xz + float2(e, 0), c), e, h - duneHeight(xz + float2(0, e), c))); | |
| 88 | + float diffuse = max(dot(n, sun), 0.f); | |
| 89 | + float shadowSide = smoothstep(.0f, .25f, diffuse); | |
| 90 | + float prism = pow(1 - abs(dot(n, normalize(rd + sun))), 6.f); | |
| 91 | + float3 sand = mix(deep(.35, f) * .2, paint(.55 + h * .1, f), shadowSide) * (.25 + diffuse * .9); | |
| 92 | + sand += paint(.55 + .12 * sin(dot(n.xz, float2(1, .5)) * 2 + h), f) * prism * .45; | |
| 93 | + float drift = pow(fbm2(xz * 3 + float2(c.t * .8, 0), 3), 4.f) * smoothstep(.8f, 1.4f, h) * (.3 + c.b.w * 2 + c.hit * 3); | |
| 94 | + sand += paint(.95, f) * drift; | |
| 95 | + float ripples = .5 + .5 * sin(xz.x * 2.5 + xz.y * 1.5 - c.t - c.m * 3); | |
| 96 | + sand += paint(.48 + n.x * .16, f) * ripples * (c.b.y * .65 + c.hit * .7); | |
| 97 | + return mix(sky, sand, exp(-travel * (.012 + c.fog * .03))); | |
| 98 | + } | |
| 99 | + | |
| 100 | + // ------------------------------------------------------------------ 44 Honeycomb Tide | |
| 101 | + // A flight low over golden comb. Honey in every cell rises and falls like a tide; cells | |
| 102 | + // fill on their own band and attacks make the honey surfaces shimmer. | |
| 103 | + | |
| 104 | + | |
| 105 | + // ------------------------------------------------------------------ 45 Nebula Nursery | |
| 106 | + // A slow flight into an emission nebula where new stars ignite. Bands light their own | |
| 107 | + // layers of gas; attacks flare the young stars' diffraction spikes. | |
| 108 | + | |
| 109 | + | |
| 110 | + // ------------------------------------------------------------------ 46 Crystal Orchard | |
| 111 | + // A glide across a plain of quartz clusters. Hexagonal crystals catch the light and glow | |
| 112 | + // from within; each cluster grows on its band and attacks spark across the facets. | |
| 113 | + float crystalField(float3 p, Ctx c, thread float &glowOut) { | |
| 114 | + // Only the two nearest cells on each axis can hold the closest crystal. | |
| 115 | + float spacing = 2.4; | |
| 116 | + float2 cellPosition = p.xz / spacing; | |
| 117 | + float2 base = floor(cellPosition - .5); | |
| 118 | + float d = p.y; | |
| 119 | + glowOut = 0; | |
| 120 | + for (int y = 0; y <= 1; ++y) for (int x = 0; x <= 1; ++x) { | |
| 121 | + float2 g = base + float2(x, y); | |
| 122 | + float3 seed = hash33(float3(g, 3)); | |
| 123 | + float band = c.b[int(seed.x * 3.99)]; | |
| 124 | + for (int k = 0; k < 2; ++k) { | |
| 125 | + float3 s2 = hash33(float3(g, float(k) + 7)); | |
| 126 | + float2 center = float2((g.x + .5 + (s2.x - .5) * .5) * spacing, (g.y + .5 + (s2.y - .5) * .5) * spacing); | |
| 127 | + // A crystal (radius ≤ .32, ≤ 3.3 tall, leaning ≤ .35 rad) lies within 1.5 of its base axis, | |
| 128 | + // so one farther away than the current nearest cannot be the nearest surface. | |
| 129 | + if (length(p.xz - center) - 1.5 > d) continue; | |
| 130 | + float3 q = p - float3(center.x, 0, center.y); | |
| 131 | + q.xy = rot(q.xy, (s2.z - .5) * .7); | |
| 132 | + float height = min((.6 + s2.z * 1.1) * (1 + band * .45) * (.85 + .15 * sin(c.t * .3 + seed.y * 9)), 2.6f); | |
| 133 | + float radius = .2 + s2.y * .12; | |
| 134 | + float prism = max(sdHex(q.xz, radius), max(-q.y, q.y - height - radius * 1.8 + length(q.xz) * 1.8)); | |
| 135 | + if (prism < d) { d = prism; glowOut = seed.z; } | |
| 136 | + } | |
| 137 | + } | |
| 138 | + return d; | |
| 139 | + } | |
| 140 | + float3 crystalOrchard(Ctx c, constant NativeFrame &f) { | |
| 141 | + // The glide over the orchard speeds up with the music clock. | |
| 142 | + float3 ro = float3(sin(c.t * .06) * 1.5, 3.4, c.travel * 1.6 + c.m * .5); | |
| 143 | + float3 rd = cameraRay(c.uv, float3(0, -.45, 1), float3(0, 1, 0), 1.35); | |
| 144 | + float travel = 0, glow = 0; | |
| 145 | + bool hit = false; | |
| 146 | + for (int i = 0; i < 64; ++i) { | |
| 147 | + float3 p = ro + rd * travel; | |
| 148 | + float d = crystalField(p, c, glow); | |
| 149 | + if (d < .002 * (1 + travel * .3)) { hit = true; break; } | |
| 150 | + // Above the tallest crystal the field is exact, so take long steps. | |
| 151 | + travel += min(d * .75, p.y > 3.1 ? 1.5f : .6f); | |
| 152 | + if (travel > 35) break; | |
| 153 | + } | |
| 154 | + float3 sky = mix(paint(.75, f) * .3, deep(.4, f) * .08, smoothstep(-.1f, .5f, rd.y)); | |
| 155 | + if (!hit) return sky; | |
| 156 | + float3 p = ro + rd * travel; | |
| 157 | + float e = .002, g2; | |
| 158 | + float d0 = crystalField(p, c, g2); | |
| 159 | + float3 n = natureNormal(d0, crystalField(p + float3(e, 0, 0), c, g2), crystalField(p + float3(0, e, 0), c, g2), crystalField(p + float3(0, 0, e), c, g2)); | |
| 160 | + float3 light = normalize(float3(.4, .7, -.3)); | |
| 161 | + float diffuse = max(dot(n, light), 0.f); | |
| 162 | + float fresnel = pow(1 - max(dot(-rd, n), 0.f), 3.f); | |
| 163 | + float3 color; | |
| 164 | + if (p.y < .01) { | |
| 165 | + float3 reflected = mix(paint(.75, f) * .3, deep(.4, f) * .08, smoothstep(-.1f, .5f, reflect(rd, n).y)); | |
| 166 | + // The floor catches the light of nearby crystals as they glow on their bands. | |
| 167 | + float floorBand = c.b[int(hash21(floor(p.xz * .5)) * 3.99)]; | |
| 168 | + color = deep(.3, f) * .08 * (.6 + .4 * fbm2(p.xz * 3, 3)) + reflected * .3 + paint(.6, f) * floorBand * .12; | |
| 169 | + } else { | |
| 170 | + // Each crystal cluster glows from within on its own band. | |
| 171 | + float crystalBand = c.b[int(hash21(floor(p.xz * .5)) * 3.99)]; | |
| 172 | + float inner = (.5 + .5 * sin(p.y * 6 - c.t - c.m * 2 + glow * 20)) * (1 + c.hit * 1.4 * step(.4, glow)) * (1 + crystalBand * 2.2); | |
| 173 | + color = paint(.3 + glow * .5, f) * (.12 + diffuse * .4 + inner * .45) + paint(.95, f) * (fresnel * .8 + pow(max(dot(reflect(rd, n), light), 0.f), 40.f) * (1 + c.hit * 2)); | |
| 174 | + } | |
| 175 | + return mix(sky, color, exp(-travel * (.035 + c.fog * .05))); | |
| 176 | + } | |
| 177 | + | |
| 178 | + // ------------------------------------------------------------------ 48 Velvet Nebula | |
| 179 | + // Towering dust pillars stand against a glowing nebula, their rims lit from behind. | |
| 180 | + // Layers drift past; bands brighten the emission behind each pillar and attacks light | |
| 181 | + // the tips where stars are being born. | |
| 182 | + float3 velvetNebula(Ctx c, constant NativeFrame &f) { | |
| 183 | + float3 color = 0.f; | |
| 184 | + float2 glowCenter = float2(c.extent.x * .4, c.extent.y * .6); | |
| 185 | + float2 flow = float2(fbm2(c.uv * .8 + c.t * .03, 3), fbm2(c.uv * .8 - c.t * .025 + 4, 3)) - .5; | |
| 186 | + float3 emission = mix(paint(.3, f), paint(.85, f), exp(-length(c.uv - glowCenter) * .9)) * (.4 + .6 * fbm2(c.uv * 1.5 + flow * 1.2 + c.t * .04, 5)); | |
| 187 | + emission *= 1 + c.b.y * .8; | |
| 188 | + color = emission; | |
| 189 | + color += paint(.95, f) * pow(hash21(floor(c.uv * 120)), 60.f); | |
| 190 | + const int count = 4; | |
| 191 | + for (int k = 0; k < count; ++k) { | |
| 192 | + float2 slot = layerSlot(k, count, c.travel * 0.06); | |
| 193 | + float phase = slot.x, id = slot.y, fade = layerFade(phase); | |
| 194 | + float scale = layerScale(phase, 1.6) * .9 / c.size; | |
| 195 | + float2 p = c.uv * scale + float2(id * 2.7 + c.t * .03 * (1 + phase), 0); | |
| 196 | + float column = floor(p.x / 1.4 + .5); | |
| 197 | + float local = p.x - column * 1.4; | |
| 198 | + float seed = hash21(float2(column, id)); | |
| 199 | + float top = -.2 + seed * 1.1 + .15 * sin(c.t * .05 + seed * 9); | |
| 200 | + float wobble = fbm2(float2(p.y * 2 - c.t * .05, column * 3 + id), 4) - .5 + .06 * sin(c.t * .3 + column + p.y * 2); | |
| 201 | + float width = (.28 + seed * .2) * (1 - smoothstep(top - .6, top + .1, p.y) * .6); | |
| 202 | + float pillar = abs(local + wobble * .35) - width; | |
| 203 | + pillar = max(pillar, p.y - top - fbm2(float2(local * 4, id), 3) * .3); | |
| 204 | + float edge = c.px * scale * 2; | |
| 205 | + float body = (1 - smoothstep(-edge, edge, pillar)) * fade; | |
| 206 | + float rim = exp(-abs(pillar) * 25) * smoothstep(.1f, -.3f, p.y - top) * 0 + exp(-abs(pillar) * 30); | |
| 207 | + float band = c.b[int(seed * 3.99)]; | |
| 208 | + float tip = exp(-length(float2(local, p.y - top)) * 6) * (.4 + c.hit * 2 + band); | |
| 209 | + float3 dust = deep(.15 + seed * .1, f) * .05 * (.6 + fbm2(p * 6, 4)); | |
| 210 | + color = mix(color, dust, body * mix(.7, 1., phase)); | |
| 211 | + color += paint(.8, f) * rim * .5 * fade + paint(.95, f) * tip * .4 * fade; | |
| 212 | + } | |
| 213 | + return color; | |
| 214 | + } | |
| 215 | + | |
| 216 | + // ------------------------------------------------------------------ 49 Arc Foundry | |
| 217 | + // A dark steel foundry floor lit by welding arcs. Showers of sparks fly, fall and bounce; | |
| 218 | + // each arc flickers on its band and attacks throw bigger showers. | |
| 219 | + | |
| 220 | + | |
| 221 | + // ------------------------------------------------------------------ 51 Paper Cascades | |
| 222 | + // Layered paper-cut hills drift toward the viewer, each casting a soft shadow on the | |
| 223 | + // one behind. Ridges carry tiny cut-out trees; bands lift their own hills and attacks | |
| 224 | + // flutter the paper edges. | |
| 225 | + | |
| 226 | + | |
| 227 | + // ------------------------------------------------------------------ 53 Fractal Canopy | |
| 228 | + // Looking up through a forest canopy: fractal branches against a bright sky, clusters of | |
| 229 | + // leaves and sun rays through the gaps. Bass sends gusts through the branches; bands | |
| 230 | + // rustle their own trees and attacks flash the sun through the leaves. | |
| 231 | + | |
| 232 | + | |
| 233 | + // ------------------------------------------------------------------ 58 Kelp Cathedral | |
| 234 | + // A kelp forest: tall swaying stalks carrying long rippled blades in deep layers, god | |
| 235 | + // rays from the surface and drifting marine snow. Bands sway their own stalks; attacks | |
| 236 | + // shimmer the light shafts. | |
| 237 | + | |
| 238 | + | |
| 239 | + // ------------------------------------------------------------------ 59 Solar Filigree | |
| 240 | + // The curved limb of a star fills the lower canvas: boiling granulation, a glowing | |
| 241 | + // chromosphere and loops of plasma arching into black space, threaded with flowing | |
| 242 | + // filaments. Each loop brightens on its band, attacks flare them higher, and Zoom speed | |
| 243 | + // turns the star beneath the viewer. | |
| 244 | + | |
| 245 | + | |
| 246 | + // ------------------------------------------------------------------ 77 Zen Rake | |
| 247 | + // A raked gravel garden seen from above. Grooves flow around moss-ringed stones; the | |
| 248 | + // rake slowly redraws them. Bass sends ripples outward from each stone; highs glint on | |
| 249 | + // the gravel. | |
| 250 | + | |
| 251 | + | |
| 252 | + // ------------------------------------------------------------------ 93 Mitosis Garden | |
| 253 | + // A living culture under phase-contrast light: membranes, nuclei and organelles drift | |
| 254 | + // in two focal planes, and cells pinch apart as they divide. Each cell swells on its | |
| 255 | + // band; attacks quicken the cytoplasm. | |
| 256 | + | |
| 257 | + | |
| 258 | + // ------------------------------------------------------------------ 94 Neural Bloom | |
| 259 | + // Large neurons glow in shallow focus: bright somas with nuclei, tapering dendrites and | |
| 260 | + // a few long axons. Action potentials race along the axons; each neuron fires at a rate | |
| 261 | + // set by its band and attacks trigger cascades. The far layer is soft, like microscopy. | |
| 262 | + | |
| 263 | + | |
| 264 | + // ------------------------------------------------------------------ 95 Jellyfish Abyss | |
| 265 | + // Bioluminescent jellyfish drift through the deep in layers. Bells contract and trail | |
| 266 | + // rippling tentacles; each jelly pulses on its band and attacks make them contract. | |
| 267 | + | |
| 268 | + | |
| 269 | + // ------------------------------------------------------------------ 96 Glacier Rift | |
| 270 | + // A flight down a crevasse of translucent glacier ice: banded walls, glowing fractures | |
| 271 | + // and blowing snow. Bands light their own fracture families; attacks shimmer the ice. | |
| 272 | + | |
| 273 | + | |
| 274 | + // ------------------------------------------------------------------ 97 Firefly Meadow | |
| 275 | + // A moonlit meadow. Layers of tall grass sway toward the viewer while fireflies blink | |
| 276 | + // and drift; each firefly blinks on its band and attacks send a wave of light through | |
| 277 | + // the swarm. | |
| 278 | + | |
| 279 | + | |
| 280 | + #define NATURE_EFFECTS(X) X(sonicTopography) X(prismaticDunes) X(crystalOrchard) X(velvetNebula) | |
| 281 | + NATURE_EFFECTS(NATIVE_EFFECT) |
Sources/PulseCanvas/Resources/NativeRave.metal added
| 1 | + // PulseCanvas native designs. Original procedural code; see NativeCommon.metal. | |
| 2 | + | |
| 3 | + // Shared helpers for this file. | |
| 4 | + // Smooth per-element weight that drifts with the music clock (selects who reacts to an | |
| 5 | + // attack without ever switching abruptly). | |
| 6 | + float raveWeight(float m, float id, float sharpness) { | |
| 7 | + return pow(.5f + .5f * cos(m * .9f + id * 2.39f), sharpness); | |
| 8 | + } | |
| 9 | + // The attack envelope rides on a steady swell; this keeps only the punchy part. | |
| 10 | + float raveKick(float hit) { return smoothstep(.12f, .7f, hit); } | |
| 11 | + // Distance from p to the ellipse center + a cos(phi) + b sin(phi) (the projection of a | |
| 12 | + // tilted circle). An affine angle estimate is refined with damped Newton steps; phi | |
| 13 | + // returns the angle of the closest point. | |
| 14 | + float raveEllipse(float2 p, float2 center, float2 a, float2 b, thread float &phi) { | |
| 15 | + float det = a.x * b.y - a.y * b.x; | |
| 16 | + det = abs(det) < 1e-5 ? 1e-5 : det; | |
| 17 | + float2 d = p - center; | |
| 18 | + float2 w = float2(d.x * b.y - d.y * b.x, -d.x * a.y + d.y * a.x) / det; | |
| 19 | + phi = atan2(w.y, w.x); | |
| 20 | + for (int i = 0; i < 3; ++i) { | |
| 21 | + float cs = cos(phi), sn = sin(phi); | |
| 22 | + float2 s = a * cs + b * sn, ds = b * cs - a * sn; | |
| 23 | + float2 e = s - d; | |
| 24 | + float g = dot(e, ds), gg = dot(ds, ds) - dot(e, s); | |
| 25 | + phi -= clamp(g / max(abs(gg), 1e-5f), -.4f, .4f); | |
| 26 | + } | |
| 27 | + return length(d - a * cos(phi) - b * sin(phi)); | |
| 28 | + } | |
| 29 | + // Orthonormal basis (e1, e2) of the plane with normal n. | |
| 30 | + void raveBasis(float3 n, thread float3 &e1, thread float3 &e2) { | |
| 31 | + float3 helper = abs(n.y) < .9 ? float3(0, 1, 0) : float3(1, 0, 0); | |
| 32 | + e1 = normalize(cross(helper, n)); | |
| 33 | + e2 = cross(n, e1); | |
| 34 | + } | |
| 35 | + | |
| 36 | + // ---------------------------------------------------------------- Smoke Rings | |
| 37 | + // Vortex rings of luminous smoke drift through coloured beams in a dark room. Rings are | |
| 38 | + // launched on a staggered schedule from different directions, swell, wobble and slowly | |
| 39 | + // dissipate; their smoke rolls around the core. Zoom speed carries the camera through the | |
| 40 | + // dust in the beams. Bass thickens and brightens the rings, attacks launch a fast extra | |
| 41 | + // ring and highs glitter in the smoke. | |
| 42 | + constant float smokeFocal = 1.4; | |
| 43 | + float3 smokeRing(float2 uv, float3 start, float3 end, float age, float alpha, float id, float hue, float beam, float band, Ctx c, constant NativeFrame &f) { | |
| 44 | + if (alpha <= .002) return 0; | |
| 45 | + float travel = 1 - pow(1 - age, 1.7f); | |
| 46 | + float3 center = mix(start, end, travel); | |
| 47 | + float3 heading = normalize(end - start); | |
| 48 | + float3 axis = normalize(float3(heading.xy * .7 + float2(.25 * sin(c.t * .9 + id), .2 * cos(c.t * .7 + id * 1.3)), -1)); | |
| 49 | + float3 e1, e2; | |
| 50 | + raveBasis(axis, e1, e2); | |
| 51 | + float radius = (.55 + .35 * hash11(id * 3.7)) * (1 + 1.1 * age) * c.size; | |
| 52 | + float s = smokeFocal / max(center.z, .3f); | |
| 53 | + float2 c2 = center.xy * s; | |
| 54 | + float wobble = 1 + .05 * sin(c.t * 2.1 + id); | |
| 55 | + float2 a2 = e1.xy * radius * s * wobble, b2 = e2.xy * radius * s / wobble; | |
| 56 | + float thick = radius * (.2 + .12 * age) * (1 + c.b.x * .7 + band * .5) * s; | |
| 57 | + if (length(uv - c2) > (radius * s) * 1.3 + thick * 4) return 0; | |
| 58 | + float phi; | |
| 59 | + float d = raveEllipse(uv, c2, a2, b2, phi); | |
| 60 | + if (d > thick * 4) return 0; | |
| 61 | + float2 onRing = c2 + a2 * cos(phi) + b2 * sin(phi); | |
| 62 | + float inner = length(uv - c2) < length(onRing - c2) ? -1.f : 1.f; | |
| 63 | + float across = inner * d / thick; | |
| 64 | + float roll = fbm3(float3(cos(phi) * 1.7, sin(phi) * 1.7, across * .8 - c.t * 1.3 - c.m * 1.4 + id * 7.1), 3); | |
| 65 | + float core = exp(-across * across * 1.5); | |
| 66 | + float density = core * (.35 + 1.2 * roll * roll * 1.6) + exp(-abs(across) * 1.4) * .05; | |
| 67 | + float3 tint = paint(hue + band * .3, f); | |
| 68 | + float facing = .75 + .35 * dot(normalize(uv - c2 + 1e-4), float2(.35, .9)); | |
| 69 | + float depthFade = exp(-max(center.z - 2.f, 0.f) * (.06 + c.fog * .08)); | |
| 70 | + float3 color = tint * density * (.45 + .7 * beam) * facing + paint(.95, f) * pow(core * roll, 3.f) * .4; | |
| 71 | + float glitter = step(.982f, hash21(floor(uv * 230) + floor(c.t * 12))) * core * c.b.w * 3; | |
| 72 | + color += paint(.97, f) * glitter; | |
| 73 | + return color * alpha * depthFade * (1 + c.b.x * .4 + band * 1.6); | |
| 74 | + } | |
| 75 | + float3 smokeRings(Ctx c, constant NativeFrame &f) { | |
| 76 | + float2 drift = float2(sin(c.travel * .13) * .45, sin(c.travel * .09 + 1) * .2); | |
| 77 | + float2 uv = c.uv + drift; | |
| 78 | + // dark room, sweeping coloured beams and haze | |
| 79 | + float haze = fbm2(uv * 1.2 + float2(c.t * .05, c.t * .02), 4); | |
| 80 | + float3 color = deep(.55, f) * .06 + paint(.2, f) * .03; | |
| 81 | + float beamSum = 0; | |
| 82 | + float3 beamLight = 0; | |
| 83 | + for (int b = 0; b < 3; ++b) { | |
| 84 | + float fb = float(b); | |
| 85 | + float2 origin = float2((fb - 1) * c.extent.x * .8, c.extent.y + .3); | |
| 86 | + float2 d = uv - origin; | |
| 87 | + float ang = atan2(d.x, -d.y) - (.35 * sin(c.t * (.13 + fb * .04) + c.m * .25 + fb * 2.1) - (fb - 1) * .25); | |
| 88 | + float cone = exp(-ang * ang * 30) * smoothstep(5.f, .4f, length(d)); | |
| 89 | + beamSum += cone; | |
| 90 | + beamLight += paint(.15 + fb * .33, f) * cone * (1 + c.b[b + 1] * 1.6); | |
| 91 | + } | |
| 92 | + color += beamLight * (.1 + .16 * haze); | |
| 93 | + color += paint(.6, f) * .05 * haze; | |
| 94 | + // dust motes drifting toward the camera | |
| 95 | + for (int k = 0; k < 3; ++k) { | |
| 96 | + float2 slot = layerSlot(k, 3, c.travel * .12); | |
| 97 | + float phase = slot.x, id = slot.y; | |
| 98 | + float scale = layerScale(phase, 2) * 6; | |
| 99 | + float2 p = uv * scale + float2(id * 5.3, id * 2.9 + c.t * .1); | |
| 100 | + float2 cell = floor(p), local = fract(p) - .5; | |
| 101 | + float2 o = (hash22(cell + id) - .5) * .7; | |
| 102 | + float mote = exp(-length(local - o) * scale * 9 / (1 + phase * 3)); | |
| 103 | + color += paint(.9, f) * mote * layerFade(phase) * beamSum * .9 * (1 + c.b.w * 4) * step(.75f, hash21(cell + id * 3)); | |
| 104 | + } | |
| 105 | + // the rings: six staggered launches plus an attack ring | |
| 106 | + const int count = 8; | |
| 107 | + for (int k = 0; k < count; ++k) { | |
| 108 | + float clock = c.t * .07 + c.m * .05 + float(k) / float(count); | |
| 109 | + float age = fract(clock); | |
| 110 | + float id = floor(clock) * 7 + float(k) * 13; | |
| 111 | + float3 h = hash33(float3(id, 1.7, 3.1)); | |
| 112 | + float side = h.x < .5 ? -1.f : 1.f; | |
| 113 | + float z0 = 7 + h.y * 3, z1 = 2.1 + h.x * 1.8; | |
| 114 | + float2 from = float2(side * c.extent.x * (.5 + .4 * h.z), (h.z - .5) * 1.4 * c.extent.y); | |
| 115 | + float2 to = float2(-side * c.extent.x * (.1 + .75 * h.y), (h.x - .5) * 1.7 * c.extent.y); | |
| 116 | + float3 start = float3(from * z0 / smokeFocal, z0); | |
| 117 | + float3 end = float3(to * z1 / smokeFocal, z1); | |
| 118 | + float alpha = smoothstep(0.f, .1f, age) * (1 - smoothstep(.55f, 1.f, age)); | |
| 119 | + color += smokeRing(uv, start, end, age, alpha, id, h.z * 1.8, beamSum, c.b[k % 4], c, f); | |
| 120 | + } | |
| 121 | + float kick = raveKick(c.hit); | |
| 122 | + float3 launch = float3(sin(c.m * .7) * 3, -2 + .5 * cos(c.m * .5), 8); | |
| 123 | + float3 target = float3(-sin(c.m * .7) * .9, .5, 2.6); | |
| 124 | + color += smokeRing(uv, launch, target, (1 - kick) * .7, kick, 97, .95, beamSum, c.b.x, c, f) * 1.3; | |
| 125 | + return color; | |
| 126 | + } | |
| 127 | + | |
| 128 | + // ---------------------------------------------------------------- Wand Orbs | |
| 129 | + // Long-exposure light painting: wireframe globes are traced arc by arc by spinning LED | |
| 130 | + // wands, each meridian a dashed, slightly jittery stroke with a colour gradient along it, | |
| 131 | + // then the globe hangs, glows and dissolves while the next one is painted. Orbs stand at | |
| 132 | + // two depths over a dark mirror floor and Zoom speed dollies past them. Bands tint the | |
| 133 | + // wand gradients, attacks flash a bright equator arc and highs sparkle along the arcs. | |
| 134 | + constant float orbFocal = 1.3; | |
| 135 | + float3 wandOrb(float2 uv, float2 center, float radius, float scale, float cell, float layer, Ctx c, constant NativeFrame &f) { | |
| 136 | + float rs = radius * scale; | |
| 137 | + if (length(uv - center) > rs * 1.35 + .15) return 0; | |
| 138 | + float seed = hash11(cell * 1.31 + layer * 7.7); | |
| 139 | + float clock = c.t * .1 + c.m * .07 + seed * 5; | |
| 140 | + float band = c.b[int(fmod(abs(cell + layer * 2), 4.f))]; | |
| 141 | + float age = fract(clock); | |
| 142 | + float cycle = floor(clock); | |
| 143 | + float hueBase = hash11(cycle + cell * 3.1) * 1.6 + (c.b.y - c.b.z) * .35 + c.b.x * .2; | |
| 144 | + float build = smoothstep(0.f, .55f, age); | |
| 145 | + float dissolve = smoothstep(.78f, 1.f, age); | |
| 146 | + float fadeIn = smoothstep(0.f, .03f, age); | |
| 147 | + float yaw = c.t * .25 + c.m * .35 + seed * 6; | |
| 148 | + float roll = .3 * sin(seed * 9 + c.t * .1); | |
| 149 | + float2 axisX = rot(float2(1, 0), roll), axisY = rot(float2(0, 1), roll); | |
| 150 | + float pixel = c.px * 1.2; | |
| 151 | + float width = .006 * c.size * scale * (1 + c.b.x * .8 + band * .6); | |
| 152 | + const int arcs = 9; | |
| 153 | + float3 color = 0; | |
| 154 | + float swell = 1 + .1 * dissolve; | |
| 155 | + for (int k = 0; k < arcs; ++k) { | |
| 156 | + float fk = float(k); | |
| 157 | + float progress = clamp(build * float(arcs) - fk, 0.f, 1.f); | |
| 158 | + if (progress <= 0) break; | |
| 159 | + float theta = fk * PI / float(arcs) + yaw; | |
| 160 | + float2 a = axisX * rs * cos(theta) * swell, b = axisY * rs * swell; | |
| 161 | + float phi; | |
| 162 | + float d = raveEllipse(uv, center, a, b, phi); | |
| 163 | + if (d > .12) continue; | |
| 164 | + float q = fract((phi + PI * .5) / TAU); | |
| 165 | + float drawn = smoothstep(progress + .004f, progress - .004f, q); | |
| 166 | + float jitter = 1 + .25 * sin(q * 47 + fk * 3.1 + cycle); | |
| 167 | + float dash = .55 + .45 * smoothstep(.12f, .3f, fract(q * 40 + fk * .37)); | |
| 168 | + float front = .55 + .45 * cos(phi) * sin(theta) + .45; | |
| 169 | + float headGlow = progress < 1 ? exp(-abs(q - progress) * 60) * 2.5 : 0.f; | |
| 170 | + float3 tint = paint(hueBase + q * .7 + fk * .03, f); | |
| 171 | + float stroke = (line(d, width * jitter, pixel) * 1.3 + exp(-d / (.018 * scale * (1 + band * 1.5))) * .28) * (1 + band * 2.4); | |
| 172 | + float sparkle = pow(hash11(floor(q * 140) + fk * 17 + cycle), 18.f) * c.b.w * 3; | |
| 173 | + color += tint * stroke * drawn * dash * front * (1 + headGlow) + paint(.97, f) * sparkle * drawn * exp(-d / .01); | |
| 174 | + } | |
| 175 | + // attack: a bright equator arc | |
| 176 | + float flash = raveKick(c.hit) * raveWeight(c.m, cell + layer * 3, 2); | |
| 177 | + if (flash > .01) { | |
| 178 | + float phi; | |
| 179 | + float d = raveEllipse(uv, center, axisX * rs * 1.08, axisY * rs * .28, phi); | |
| 180 | + color += paint(.95, f) * (line(d, width * 1.6, pixel) * 1.5 + exp(-d / .03) * .5) * flash; | |
| 181 | + } | |
| 182 | + return color * fadeIn * (1 - dissolve); | |
| 183 | + } | |
| 184 | + float3 wandOrbs(Ctx c, constant NativeFrame &f) { | |
| 185 | + float tall = clamp((c.extent.y / c.extent.x - 1) / .78f, 0.f, 1.f); | |
| 186 | + float2 uv = (c.uv - float2(0, .3 * tall)) / (1 + .3 * tall); | |
| 187 | + float camX = c.travel * .35 + sin(c.t * .05) * .4; | |
| 188 | + float camY = .15; | |
| 189 | + float horizon = -.05; | |
| 190 | + float3 color = deep(.7, f) * .1 + paint(.2, f) * .05 * (1 + fbm2(uv * 1.5 + c.t * .03, 3)) + paint(.6, f) * .045; | |
| 191 | + color += paint(.85, f) * .05 * exp(-abs(uv.x + .4 * sin(c.t * .07)) * 1.5) * smoothstep(horizon, horizon + 2.f, uv.y); | |
| 192 | + color += paint(.6, f) * .06 * exp(-abs(uv.y - horizon) * 3); | |
| 193 | + if (uv.y < horizon) { | |
| 194 | + float depth = 1 / max(horizon - uv.y, .02f); | |
| 195 | + float sheen = exp(-abs(fract((uv.x * depth + camX) * .5) - .5) * 30) * .03 * exp(-(horizon - uv.y) * 2); | |
| 196 | + color = deep(.6, f) * .07 + paint(.6, f) * .04 + paint(.5, f) * sheen + paint(.6, f) * .05 * exp(-(horizon - uv.y) * 6); | |
| 197 | + } | |
| 198 | + for (int layer = 2; layer >= 0; --layer) { | |
| 199 | + float fl = float(layer); | |
| 200 | + float z = 2.3 + fl * 1.7 + fl * fl * .3; | |
| 201 | + float s = orbFocal / z; | |
| 202 | + float spacing = 2.5 - fl * .4; | |
| 203 | + float xw = uv.x / s + camX * (1 - fl * .3); | |
| 204 | + float cell = round(xw / spacing); | |
| 205 | + float seed = hash11(cell * 1.7 + fl * 5.1); | |
| 206 | + float radius = (.6 + .2 * seed) * c.size; | |
| 207 | + float floorY = -1.1 - camY; | |
| 208 | + float centerY = floorY + radius + .25 + fl * (.7 + .5 * seed) + .1 * sin(c.t * .4 + cell); | |
| 209 | + float2 center = float2((cell * spacing + (seed - .5) * .5 - camX * (1 - fl * .3)) * s, centerY * s); | |
| 210 | + float contact = floorY * s; | |
| 211 | + float depthFade = exp(-fl * (.3 + c.fog * .4)); | |
| 212 | + if (uv.y >= contact) { | |
| 213 | + color += wandOrb(uv, center, radius, s, cell, fl, c, f) * depthFade; | |
| 214 | + } else { | |
| 215 | + float2 mirrored = float2(uv.x + .004 * sin(uv.y * 90 + c.t), 2 * contact - uv.y); | |
| 216 | + color += wandOrb(mirrored, center, radius, s, cell, fl, c, f) * depthFade * .35 * exp(-(contact - uv.y) * 2.5); | |
| 217 | + } | |
| 218 | + } | |
| 219 | + return color; | |
| 220 | + } | |
| 221 | + | |
| 222 | + // ---------------------------------------------------------------- Faraday Dish | |
| 223 | + // Macro view straight down into a shallow dish of liquid vibrated from below: Faraday | |
| 224 | + // standing waves form square, hexagonal and quasicrystal lattices of crests that morph | |
| 225 | + // into each other, mirroring coloured studio lights, with light focused onto the dish | |
| 226 | + // floor under every crest and droplets bouncing on the surface. Zoom speed drifts and | |
| 227 | + // zooms across the dish. Bass raises the waves, the band balance shifts the lattice scale, | |
| 228 | + // attacks spray droplets and highs glitter on the crests. | |
| 229 | + | |
| 230 | + | |
| 231 | + // ---------------------------------------------------------------- String Resonance | |
| 232 | + // A giant light harp: long glowing strings cross the frame at slight angles and depths, | |
| 233 | + // held by bright bridge pins, and every span rings in standing-wave modes, drawn as a | |
| 234 | + // long-exposure envelope (bright at the turning points) around the moving string. Spans | |
| 235 | + // are plucked on a staggered schedule; Zoom speed slides the camera along the strings. | |
| 236 | + // Each band keeps its own string group ringing, attacks pluck a cluster hard and highs | |
| 237 | + // shimmer along the strings. | |
| 238 | + float3 stringResonance(Ctx c, constant NativeFrame &f) { | |
| 239 | + float2 uv = c.uv; | |
| 240 | + float haze = fbm2(uv * 1.1 + float2(c.t * .03, -c.t * .015), 4); | |
| 241 | + float3 color = deep(.25, f) * (.05 + .05 * haze) + paint(.1, f) * .025; | |
| 242 | + float3 glowSum = 0; | |
| 243 | + const int strings = 12; | |
| 244 | + float kick = raveKick(c.hit); | |
| 245 | + for (int i = 0; i < strings; ++i) { | |
| 246 | + float fi = float(i); | |
| 247 | + float3 h = hash33(float3(fi, 4.1, 9.3)); | |
| 248 | + float z = 1 + h.z * 1.6; | |
| 249 | + float scale = 1 / z; | |
| 250 | + float angle = (h.x - .5) * .32; | |
| 251 | + float y0 = ((fi + .5) / float(strings) * 2 - 1) * c.extent.y * .95 + (h.y - .5) * .12; | |
| 252 | + float2 local = rot(uv - float2(0, y0), -angle); | |
| 253 | + float maxAmp = .2 * scale + .05; | |
| 254 | + if (abs(local.y) > maxAmp + .25) continue; | |
| 255 | + float spanLength = 2.4 + h.x; | |
| 256 | + float xs = local.x * z + c.travel * .45 + h.y * 9; | |
| 257 | + float span = floor(xs / spanLength); | |
| 258 | + float s = xs / spanLength - span; | |
| 259 | + float3 hs = hash33(float3(span, fi, 2.7)); | |
| 260 | + float rate = .18 + hs.x * .2; | |
| 261 | + float clock = c.t * rate + c.m * rate * .9 + hs.y; | |
| 262 | + float age = fract(clock) / rate; | |
| 263 | + float pluck = smoothstep(0.f, .03f, age) * exp(-age * (.55 + hs.z * .4)); | |
| 264 | + int group = i % 4; | |
| 265 | + float drive = c.b[group] * .9 + kick * raveWeight(c.m, fi * .6, 3) * 1.4; | |
| 266 | + float strength = (pluck * .8 + drive) * scale; | |
| 267 | + float pluckAt = .15 + .3 * hs.z; | |
| 268 | + float a1 = .1 * strength * sin(PI * pluckAt); | |
| 269 | + float a2 = .05 * strength * sin(2 * PI * pluckAt); | |
| 270 | + float a3 = .03 * strength * sin(3 * PI * pluckAt); | |
| 271 | + float w = 9 + hs.x * 4; | |
| 272 | + float m1 = sin(PI * s), m2 = sin(2 * PI * s), m3 = sin(3 * PI * s); | |
| 273 | + float envelope = abs(a1 * m1) + abs(a2 * m2) + abs(a3 * m3); | |
| 274 | + float tv = c.t + c.m * .4; | |
| 275 | + float y = a1 * m1 * cos(w * tv) + a2 * m2 * cos(2 * w * tv + 1) + a3 * m3 * cos(3 * w * tv + 2); | |
| 276 | + float pixel = c.px * 1.2; | |
| 277 | + float width = .004 * c.size * scale + pixel * .4; | |
| 278 | + float ly = local.y; | |
| 279 | + // long-exposure envelope: dwell is longest at the turning points | |
| 280 | + float inside = smoothstep(envelope + pixel * 2, envelope - pixel, abs(ly)); | |
| 281 | + float dwell = envelope / sqrt(max(envelope * envelope - ly * ly, envelope * envelope * .02f) + 1e-6f); | |
| 282 | + float band = inside * clamp(dwell * .12f, 0.f, .9f) * smoothstep(0.f, .004f, envelope); | |
| 283 | + float3 tint = paint(.08 + fi / float(strings) * .85 + hs.z * .05, f); | |
| 284 | + float core = line(ly - y, width, pixel); | |
| 285 | + float bloom = exp(-abs(ly - y) / (.025 * scale + .01)) * .3 + exp(-max(abs(ly) - envelope, 0.f) / (.08 * scale)) * .08; | |
| 286 | + float shimmer = pow(hash21(float2(floor(xs * 60), floor(c.t * 14) + fi)), 24.f) * c.b.w * 3 * exp(-abs(ly - y) / .01); | |
| 287 | + float depthFade = exp(-(z - 1) * (.35 + c.fog * .4)); | |
| 288 | + float lit = .45 + 2.6 * strength; | |
| 289 | + color += (tint * (core * 1.1 + band * .55 + bloom * .8) * lit + paint(.97, f) * shimmer) * depthFade; | |
| 290 | + glowSum += tint * exp(-abs(ly) / .3) * .02 * lit * depthFade; | |
| 291 | + // bridge pins at the ends of every span | |
| 292 | + float pinX = (round(xs / spanLength) * spanLength - c.travel * .45 - h.y * 9) / z; | |
| 293 | + float pin = length(float2(local.x - pinX, ly) / float2(1, 2.5)); | |
| 294 | + color += paint(.9, f) * (exp(-pin / (.012 * scale)) * .9 + exp(-pin / (.06 * scale)) * .15) * depthFade; | |
| 295 | + } | |
| 296 | + return color + glowSum * (.6 + haze); | |
| 297 | + } | |
| 298 | + | |
| 299 | + // ---------------------------------------------------------------- Light Bars | |
| 300 | + // Kinetic light installation: four depth rows of hanging LED bars on fine wires rise, | |
| 301 | + // fall and tilt in travelling waves, each bar glowing along its length with a chasing | |
| 302 | + // gradient inside a lit haze. Zoom speed pans the camera along the rows (parallax). Each | |
| 303 | + // band lifts and tilts its own bar group, attacks flare a moving cluster of bars. | |
| 304 | + float3 lightBars(Ctx c, constant NativeFrame &f) { | |
| 305 | + float tall = clamp((c.extent.y / c.extent.x - 1) / .78f, 0.f, 1.f); | |
| 306 | + float camX = c.travel * .3 + sin(c.t * .05) * .5; | |
| 307 | + float camY = sin(c.t * .09) * .1; | |
| 308 | + float floorY = -.78 - .45 * tall; | |
| 309 | + float2 uv = c.uv; | |
| 310 | + bool mirror = uv.y < floorY; | |
| 311 | + float depthBelow = max(floorY - uv.y, 0.f); | |
| 312 | + if (mirror) uv = float2(uv.x + sin(depthBelow * 40 / (depthBelow + .1) + c.t) * .004, 2 * floorY - uv.y); | |
| 313 | + float haze = fbm2(uv * 1.3 + float2(c.t * .04, -c.t * .02), 3); | |
| 314 | + float3 color = deep(.35 + uv.y * .08, f) * (.1 + .08 * haze) + paint(.15, f) * .04; | |
| 315 | + float3 hazeLight = 0; | |
| 316 | + const int layers = 3; | |
| 317 | + const float eye = -.12; | |
| 318 | + for (int layer = layers - 1; layer >= 0; --layer) { | |
| 319 | + float fl = float(layer); | |
| 320 | + float z = 1 + fl * .75 + fl * fl * .25; | |
| 321 | + float2 p = float2(uv.x * z + camX * (1 + fl * .2), (uv.y - eye) * z + eye + camY); | |
| 322 | + float spacing = .26; | |
| 323 | + float id0 = round(p.x / spacing); | |
| 324 | + float pixel = c.px * z; | |
| 325 | + float depthFade = exp(-fl * (.25 + c.fog * .45)); | |
| 326 | + float width = .02 * c.size; | |
| 327 | + for (int k = -1; k <= 1; ++k) { | |
| 328 | + float id = id0 + float(k); | |
| 329 | + float x = id * spacing; | |
| 330 | + int group = int(fmod(abs(id + fl), 4.f)); | |
| 331 | + float band = c.b[group]; | |
| 332 | + float lift = .4 * sin(x * .85 - c.t * 1.15 - c.m * .9 + fl * 1.1) + .12 * sin(x * .3 + c.t * .5 + fl) + band * .45 * (group % 2 == 0 ? 1.f : -1.f); | |
| 333 | + float tilt = .13 * sin(x * .6 - c.t * .8 + fl * 1.3) + band * .2 * sin(float(group) * 1.7 + c.t * .8); | |
| 334 | + float length2 = .3 + .18 * tall; | |
| 335 | + float tier = (fmod(abs(id), 2.f) < .5 ? .42f : -.42f) * (1 + .7 * tall); | |
| 336 | + float2 center = float2(x, eye + .05 + tier + lift * .75); | |
| 337 | + float2 local = rot(p - center, -tilt); | |
| 338 | + float d = length(max(abs(local) - float2(0, length2), 0.f)) - width; | |
| 339 | + float along = local.y / length2; | |
| 340 | + float flare = c.hit * raveWeight(c.m, id * .7 + fl * 1.9, 4); | |
| 341 | + float chase = .5 + .5 * sin(along * 6 - c.t * 4 - c.m * 3 + id * 1.3); | |
| 342 | + float3 led = paint(.25 + along * .22 + fl * .13 + sin(id * .4 + c.t * .2) * .2, f); | |
| 343 | + float core = fill(d, pixel * 1.5); | |
| 344 | + float brightness = (.45 + .55 * chase + band * .6) * (1 + flare * 3.5); | |
| 345 | + color += led * (core * .9 + exp(-max(d, 0.f) / (.025 * c.size)) * .22) * brightness * depthFade; | |
| 346 | + hazeLight += led * exp(-max(d, 0.f) / .35) * .035 * brightness * depthFade; | |
| 347 | + float2 top = center + rot(float2(0, length2), tilt); | |
| 348 | + float wire = sdSegment(p, top, float2(top.x, top.y + 8)); | |
| 349 | + color += paint(.6, f) * exp(-wire / (pixel * 1.1)) * .1 * depthFade; | |
| 350 | + } | |
| 351 | + } | |
| 352 | + color += hazeLight * (.4 + 1.2 * haze); | |
| 353 | + if (mirror) color = color * .55 * exp(-depthBelow * 1.1) + deep(.4, f) * .06 + paint(.7, f) * .15 * exp(-depthBelow / .01); | |
| 354 | + return color; | |
| 355 | + } | |
| 356 | + | |
| 357 | + // ---------------------------------------------------------------- Sequin Curtain | |
| 358 | + // A wall of thousands of two-sided flip sequins in offset rows. Travelling flip waves | |
| 359 | + // (sweeps, spirals and rings that crossfade) turn each disc over, edge-on discs darken | |
| 360 | + // and catch sharp glints as the fronts pass, and a slow cloth ripple rolls through the | |
| 361 | + // whole curtain. Zoom speed pans and slightly zooms along it. Each band drives its own | |
| 362 | + // wave front, attacks flip a ring outward from a point and highs add glints. | |
| 363 | + float sequinFlip(float2 p, Ctx c) { | |
| 364 | + float tc = c.t * .05; | |
| 365 | + float3 w = pow(.5f + .5f * cos(tc * TAU + float3(0, 2.094, 4.189)), float3(2.f)) + float3(c.b.x, c.b.y, c.b.z) * 1.2; | |
| 366 | + float2 ctr = float2(sin(c.t * .11) * 1.2, cos(c.t * .09) * .6); | |
| 367 | + float2 d = p - ctr; | |
| 368 | + float sweep = sin(dot(p, normalize(float2(1, .35))) * 1.5 - c.t * 1.2); | |
| 369 | + float spiral = sin(atan2(d.y, d.x) * 2 + length(d) * 2.6 - c.t * 1.4); | |
| 370 | + float rings = sin(length(p - float2(-ctr.x, ctr.y * .5)) * 3.4 - c.t * 1.7 - c.m * .6); | |
| 371 | + float s = (w.x * sweep + w.y * spiral + w.z * rings) / (w.x + w.y + w.z); | |
| 372 | + s += c.b.w * .35 * sin(p.x * 5 + p.y * 3 - c.t * 3); | |
| 373 | + float flip = smoothstep(-.4f, .4f, s); | |
| 374 | + float kick = raveKick(c.hit); | |
| 375 | + float2 origin = float2(sin(c.m * .7) * 1.1, cos(c.m * .5) * .5); | |
| 376 | + float front = (1 - kick) * 2.4; | |
| 377 | + float ring = exp(-pow((length(p - origin) - front) / .22, 2.f)) * kick; | |
| 378 | + return mix(flip, 1 - flip, ring); | |
| 379 | + } | |
| 380 | + float3 sequinCurtain(Ctx c, constant NativeFrame &f) { | |
| 381 | + float zoom = 1 + .08 * sin(c.travel * .1); | |
| 382 | + float2 p = c.uv * zoom + float2(c.travel * .18, .1 * sin(c.travel * .07)); | |
| 383 | + float pitch = .075 * c.size; | |
| 384 | + float fold = sin(p.x * 2.1 + 1.4 * sin(p.y * 1.2 + c.t * .35) + c.t * .5); | |
| 385 | + p += float2(0, .015 * fold); | |
| 386 | + float4 cell = hexCell(p / pitch); | |
| 387 | + float2 q = cell.xy; | |
| 388 | + float2 centerP = cell.zw * float2(1, 1.7320508) * pitch; | |
| 389 | + float flip = sequinFlip(centerP, c); | |
| 390 | + float theta = flip * PI; | |
| 391 | + float ct = cos(theta), st = sin(theta); | |
| 392 | + float squash = max(abs(ct), .06f); | |
| 393 | + float2 sq = float2(q.x, q.y / squash); | |
| 394 | + float r = length(sq); | |
| 395 | + float pixel = c.px / pitch * 1.4; | |
| 396 | + float disc = fill(r - .47, pixel / squash); | |
| 397 | + float3 fabric = deep(.3, f) * .05 + paint(.7, f) * .02 * (1 + fold); | |
| 398 | + // cupped disc tilted about its horizontal axis | |
| 399 | + float3 n = normalize(float3(sq * .35 * float2(1, sign(ct)), 1)); | |
| 400 | + n = normalize(float3(n.x, n.y * ct + n.z * st, -n.y * st + n.z * ct)); | |
| 401 | + if (ct < 0) n = float3(n.x, -n.y, -n.z); | |
| 402 | + n.z = abs(n.z); | |
| 403 | + float2 jitter = hash22(cell.zw * 1.7) - .5; | |
| 404 | + n = normalize(n + float3(jitter * .22, 0)); | |
| 405 | + float3 key = normalize(float3(-.35 + .2 * sin(c.t * .13), .55, .75)); | |
| 406 | + float3 rim = normalize(float3(.6, -.3, .55)); | |
| 407 | + float3 refl = float3(2 * n.z * n.x, 2 * n.z * n.y, 2 * n.z * n.z - 1); | |
| 408 | + float spec = pow(max(dot(refl, key), 0.f), 40.f); | |
| 409 | + float spec2 = pow(max(dot(refl, rim), 0.f), 40.f); | |
| 410 | + float diffuse = max(dot(n, key), 0.f); | |
| 411 | + float hueA = .08 + .12 * sin(centerP.x * .4 + centerP.y * .3), hueB = .62 + .1 * sin(centerP.y * .5 - c.t * .1); | |
| 412 | + float3 side = ct > 0 ? paint(hueA, f) : paint(hueB, f); | |
| 413 | + float edgeOn = 1 - smoothstep(.05f, .45f, abs(ct)); | |
| 414 | + float glitter = 1 + c.b.w * 3 * step(.6f, hash21(cell.zw + floor(c.t * 4))); | |
| 415 | + float3 sequin = side * (.08 + .42 * diffuse) * (.8 + .25 * fold) * (1 - .6 * edgeOn) + side * side * .12; | |
| 416 | + sequin += (paint(.97, f) * spec * 2.4 + side * spec * 1.2) * glitter + paint(hueB + .3, f) * spec2 * .7; | |
| 417 | + sequin *= .9 + .2 * fill(r - .36, pixel) - .1; | |
| 418 | + float shadow = 1 - .5 * exp(-pow(length(q - float2(.06, -.08)) - .45, 2.f) * 40) * (1 - disc); | |
| 419 | + return mix(fabric * shadow, sequin, disc); | |
| 420 | + } | |
| 421 | + | |
| 422 | + // ---------------------------------------------------------------- Torsion Wave | |
| 423 | + // Wave-machine sculptures: hundreds of thin polished rods mounted crosswise on long spines | |
| 424 | + // that recede diagonally into the dark. Torsion waves and their reflections travel along | |
| 425 | + // each spine, twisting the rods, whose glowing tips leave short light trails. Three | |
| 426 | + // machines sit at different depths and Zoom speed moves the camera along the spines. | |
| 427 | + // Bass deepens the twist, bands add their own wave groups, attacks launch a pulse from | |
| 428 | + // the near end and highs sparkle the tips. | |
| 429 | + constant float torsionFocal = 1.3; | |
| 430 | + | |
| 431 | + | |
| 432 | + // ---------------------------------------------------------------- Spin Paint | |
| 433 | + // Spin art in motion: each pour lands on a spinning disc and flings outward as a fan of | |
| 434 | + // thin glossy streaks curving along logarithmic spirals, thinning toward the rim and | |
| 435 | + // ending in droplets, while a ring of colour smears around the landing radius. Pours | |
| 436 | + // layer up and fade so the canvas never saturates; overlapping discs spin at their own | |
| 437 | + // speeds and Zoom speed zooms seamlessly into the canvas. Bands pick the colour that | |
| 438 | + // pours, attacks fling an extra burst of streaks and highs add fine speckles. | |
| 439 | + | |
| 440 | + | |
| 441 | + // ---------------------------------------------------------------- Stadium Wave | |
| 442 | + // A vast perspective field of glowing balls (a crowd of lights) rises and falls in | |
| 443 | + // travelling waves: a stadium wave sweeping sideways, a diagonal swell and a circular | |
| 444 | + // ripple interfere, and colour follows height. Zoom speed flies the camera over the | |
| 445 | + // field. Bass raises the waves, each attack launches a ring wave from a drifting point. | |
| 446 | + float stadiumHeight(float2 g, float camZ, Ctx c) { | |
| 447 | + float sweep = pow(.5f + .5f * cos(g.x * .13 - c.t * 1.1 - c.m * .9 + g.y * .02), 12.f) * 1.4; | |
| 448 | + float swell = pow(.5f + .5f * cos(g.x * .06 + g.y * .11 - c.t * .7), 6.f); | |
| 449 | + float2 center = float2(sin(c.t * .13) * 6, camZ + 16); | |
| 450 | + float ripple = .5 + .5 * sin(length(g - center) * .55 - c.t * 2.2 - c.m * 1.6); | |
| 451 | + float h = (sweep * .9 + swell * .4 + ripple * .2) * (1 + c.b.x * 1.2); | |
| 452 | + float kick = raveKick(c.hit); | |
| 453 | + float2 origin = float2(sin(c.m * .7) * 7, camZ + 12 + 4 * cos(c.m * .5)); | |
| 454 | + float ring = (1 - kick) * 22 + 1; | |
| 455 | + h += kick * 1.1 * exp(-pow(length(g - origin) - ring, 2.f) * .35); | |
| 456 | + return h; | |
| 457 | + } | |
| 458 | + float3 stadiumWave(Ctx c, constant NativeFrame &f) { | |
| 459 | + const float focal = 1.25, camH = 4.6, maxLift = 2.2; | |
| 460 | + float horizon = c.extent.y * .62 + .3; | |
| 461 | + float camZ = c.travel * 1.6; | |
| 462 | + float camX = sin(c.t * .05) * 3; | |
| 463 | + float2 uv = c.uv; | |
| 464 | + float hz = horizon - uv.y; | |
| 465 | + // night sky with stadium floodlight glow | |
| 466 | + float3 color = deep(.7, f) * .08 + paint(.65, f) * .16 * exp(-abs(uv.y - horizon) * 4); | |
| 467 | + for (int k = 0; k < 4; ++k) { | |
| 468 | + float lx = (float(k) - 1.5) * c.extent.x * .6; | |
| 469 | + color += paint(.9, f) * .3 * exp(-length((uv - float2(lx, horizon + .1)) * float2(1, 2.5)) * 9); | |
| 470 | + } | |
| 471 | + if (hz <= 0) return color; | |
| 472 | + float zGround = camH * focal / hz; | |
| 473 | + float zNear = (camH - maxLift) * focal / hz; | |
| 474 | + float zCut = camH * focal / (horizon + c.extent.y + .3) * .8; | |
| 475 | + float3 ground = deep(.6, f) * .05 + paint(.6, f) * .03 * exp(-zGround * .03); | |
| 476 | + const float lattice = .62; | |
| 477 | + float radius = .17 * c.size; | |
| 478 | + float transmit = 1; | |
| 479 | + float3 accum = 0; | |
| 480 | + float j0 = ceil((max(zNear, zCut * .7f) + camZ - radius) / lattice), j1 = (zGround + camZ + radius) / lattice; | |
| 481 | + float pix = c.px * 1.2; | |
| 482 | + for (int k = 0; k < 30; ++k) { | |
| 483 | + float row = j0 + float(k); | |
| 484 | + if (row > j1) break; | |
| 485 | + float zr = row * lattice - camZ; | |
| 486 | + float nearFade = smoothstep(zCut * .7f, zCut, zr); | |
| 487 | + if (nearFade <= 0) continue; | |
| 488 | + float colX = round((uv.x * zr / focal + camX) / lattice) * lattice; | |
| 489 | + float2 g = float2(colX, row * lattice); | |
| 490 | + float h = stadiumHeight(g, camZ, c); | |
| 491 | + float y = .3 + h; | |
| 492 | + float s = focal / zr; | |
| 493 | + float2 center = float2((colX - camX) * s, horizon - (camH - y) * s); | |
| 494 | + float footY = horizon - camH * s; | |
| 495 | + float rs = radius * s; | |
| 496 | + float2 q = (uv - center) / rs; | |
| 497 | + float d = length(q); | |
| 498 | + float fade = exp(-zr * (.02 + c.fog * .035)) * nearFade; | |
| 499 | + float3 tint = paint(.06 + h * .36, f); | |
| 500 | + float stem = abs(uv.x - center.x) / rs; | |
| 501 | + float onStem = step(footY, uv.y) * step(uv.y, center.y); | |
| 502 | + accum += transmit * tint * exp(-stem * 8) * onStem * .16 * fade * min(rs / pix, 1.f); | |
| 503 | + float2 foot = (uv - float2(center.x, footY)) / (rs * float2(1.6, .5)); | |
| 504 | + accum += transmit * tint * exp(-dot(foot, foot) * 1.5) * .2 * (.3 + h) * fade; | |
| 505 | + accum += transmit * tint * exp(-max(d - 1, 0.f) * 3.5) * .08 * (.3 + h) * fade * min(rs / pix, 1.f); | |
| 506 | + float cover = (1 - smoothstep(1 - pix / rs, 1 + pix / rs, d)) * nearFade; | |
| 507 | + if (cover > 0) { | |
| 508 | + float2 qn = q / max(d, 1.f); | |
| 509 | + float nz = sqrt(max(1 - dot(qn, qn), 0.f)); | |
| 510 | + float3 ball = tint * (.25 + .5 * nz) * (.55 + .55 * h) + paint(.97, f) * pow(max(dot(float3(qn, nz), normalize(float3(-.4, .6, .7))), 0.f), 22.f) * .4; | |
| 511 | + ball = mix(color * .4 + paint(.6, f) * .05, ball, fade); | |
| 512 | + accum += transmit * cover * ball; | |
| 513 | + transmit *= 1 - cover; | |
| 514 | + if (transmit < .03) break; | |
| 515 | + } | |
| 516 | + } | |
| 517 | + float fieldFog = 1 - exp(-zGround * (.02 + c.fog * .03)); | |
| 518 | + ground = mix(ground, paint(.6, f) * .1, fieldFog); | |
| 519 | + return accum + transmit * ground; | |
| 520 | + } | |
| 521 | + | |
| 522 | + // ---------------------------------------------------------------- Liquid Floor | |
| 523 | + // A glossy black liquid dance floor seen at an angle, mirroring the club ceiling (LED | |
| 524 | + // strips, fixtures and roaming light pools). Unseen dancers' steps send rings across the | |
| 525 | + // surface in choreographed phrases (walks, turns and side steps) that interfere and bend | |
| 526 | + // the reflections. Zoom speed glides the camera across the floor. Bass strengthens the | |
| 527 | + // ripples, attacks add a hard stomp ring and highs sparkle in the reflections. | |
| 528 | + float2 liquidStepPos(float i, float n) { | |
| 529 | + float t = n / 1.6; | |
| 530 | + float2 center = float2(1.2 * sin(t * .23 + i * 2.1), 1.5 + i * 1.1 + .5 * cos(t * .17 + i)); | |
| 531 | + float2 heading = normalize(float2(1.1 * .23 * cos(t * .23 + i * 2.1), -.5 * .17 * sin(t * .17 + i)) + 1e-4); | |
| 532 | + float2 side = float2(-heading.y, heading.x); | |
| 533 | + float foot = fmod(n, 2.f) < .5 ? -1.f : 1.f; | |
| 534 | + float phrase = floor(hash11(floor(n / 8) + i * 7.3) * 3); | |
| 535 | + if (phrase < .5) return center + side * foot * .12; | |
| 536 | + if (phrase < 1.5) return center + .26 * float2(cos(n * .9), sin(n * .9)); | |
| 537 | + return center + side * foot * .28 + heading * .05 * sin(n); | |
| 538 | + } | |
| 539 | + float3 liquidCeiling(float3 origin, float3 dir, float camZ, Ctx c, constant NativeFrame &f) { | |
| 540 | + // LED wall far ahead: vertical colour bars that chase | |
| 541 | + float wallX = origin.x + dir.x / max(dir.z, .05f) * 12; | |
| 542 | + float bars = .5 + .5 * sin(wallX * 2.2 - c.t * 1.5); | |
| 543 | + float3 wall = paint(.1 + .8 * fract(floor(wallX * .7) * .37), f) * (.25 + .9 * pow(bars, 3.f)) * smoothstep(.0f, .12f, dir.y + .02f) * smoothstep(.45f, .05f, dir.y); | |
| 544 | + if (dir.y <= .02) return paint(.55, f) * .12 + wall * .6; | |
| 545 | + float t = (3.2 - origin.y) / dir.y; | |
| 546 | + float2 q = origin.xz + dir.xz * t; | |
| 547 | + float fade = exp(-t * .045); | |
| 548 | + float3 color = paint(.3 + .25 * sin(q.x * .3 + q.y * .2 + c.t * .1), f) * .12; | |
| 549 | + // rows of chasing LED strips across the room and dimmer strips along it | |
| 550 | + float stripD = abs(fract(q.y / 1.1) - .5) * 1.1; | |
| 551 | + float stripId = floor(q.y / 1.1); | |
| 552 | + float chase = .5 + .5 * sin(q.x * 2.2 - c.t * 3 - c.m * 2.5 + stripId * 1.7); | |
| 553 | + float stripBand = c.b[int(fmod(abs(stripId), 4.f))]; | |
| 554 | + color += paint(.1 + fract(stripId * .37) * .85, f) * (fill(stripD - .06, .015) * 1.5 + exp(-stripD / .15) * .4) * (.45 + .8 * chase) * (1 + stripBand * 2.2); | |
| 555 | + float laneD = abs(fract(q.x / 2.2) - .5) * 2.2; | |
| 556 | + float laneId = floor(q.x / 2.2); | |
| 557 | + color += paint(.55 + fract(laneId * .29) * .4, f) * (fill(laneD - .04, .015) * .8 + exp(-laneD / .12) * .2) * (.6 + .4 * sin(q.y * 1.5 + c.t * 2 + c.m * 1.5 + laneId)) * (1 + c.b[int(fmod(abs(laneId) + 2, 4.f))] * 1.8); | |
| 558 | + // fixtures | |
| 559 | + float2 cell = floor(q / 1.1), local = fract(q / 1.1) - .5; | |
| 560 | + float lamp = length(local); | |
| 561 | + float fixture = (fill(lamp - .07, .015) * 2 + exp(-lamp / .12) * .5) * step(.4f, hash21(cell)); | |
| 562 | + color += paint(.75 + .25 * hash21(cell + 2), f) * fixture * (.7 + .3 * sin(c.t * 2.3 + cell.x * 1.3 + cell.y)) * (1 + c.b[int(hash21(cell + 5) * 3.99)] * 2.4); | |
| 563 | + // sweeping beams and roaming pools of light | |
| 564 | + for (int k = 0; k < 3; ++k) { | |
| 565 | + float fk = float(k); | |
| 566 | + float2 pivot = float2((fk - 1) * 3, camZ + 6 + fk * 1.5); | |
| 567 | + float beamAngle = c.t * (.21 + fk * .05) + c.m * .3 + fk * 2.1; | |
| 568 | + float2 dirB = float2(cos(beamAngle), sin(beamAngle)); | |
| 569 | + float beamD = abs(dot(q - pivot, float2(-dirB.y, dirB.x))); | |
| 570 | + color += paint(.2 + fk * .3, f) * exp(-beamD / .3) * .45 * (1 + c.b[k + 1] * 2.2); | |
| 571 | + float2 pool = float2(sin(c.t * (.2 + fk * .07) + fk * 2) * 2.5, camZ + 5 + fk * 2.5 + 1.5 * cos(c.t * .15 + fk)); | |
| 572 | + color += paint(.25 + fk * .3, f) * .4 * exp(-length(q - pool) * 1.2); | |
| 573 | + } | |
| 574 | + return color * fade + paint(.5, f) * .12 * (1 - fade) + wall; | |
| 575 | + } | |
| 576 | + float3 liquidFloor(Ctx c, constant NativeFrame &f) { | |
| 577 | + const float focal = 1.3, height = 1.25; | |
| 578 | + float tall = clamp((c.extent.y / c.extent.x - 1) / .78f, 0.f, 1.f); | |
| 579 | + float horizon = c.extent.y * .78 + .1 - .2 * tall; | |
| 580 | + float2 uv = c.uv; | |
| 581 | + float camZ = c.travel * .8; | |
| 582 | + float camX = sin(c.travel * .05) * 1.5; | |
| 583 | + float3 color = paint(.5, f) * .12 * exp(-abs(uv.y - horizon) * 2) + deep(.6, f) * .04; | |
| 584 | + if (uv.y >= horizon) return color; | |
| 585 | + float z = height * focal / (horizon - uv.y); | |
| 586 | + float2 g = float2(uv.x * z / focal, z); | |
| 587 | + float3 eye = float3(camX, height, camZ); | |
| 588 | + float3 hit = float3(g.x + camX, 0, g.y + camZ); | |
| 589 | + float3 view = normalize(hit - eye); | |
| 590 | + // ripple field from the dancers' recent steps | |
| 591 | + float2 grad = 0; | |
| 592 | + float scale = 1 / c.size; | |
| 593 | + for (int i = 0; i < 3; ++i) { | |
| 594 | + float fi = float(i); | |
| 595 | + float clock = c.t * 1.6 + c.m * 1.0 + fi * .37; | |
| 596 | + float now = floor(clock); | |
| 597 | + for (int k = 0; k < 3; ++k) { | |
| 598 | + float n = now - float(k); | |
| 599 | + float tau = (clock - n) / 1.6; | |
| 600 | + float2 source = liquidStepPos(fi, n); | |
| 601 | + float2 d = g - source; | |
| 602 | + float dist = length(d) * scale; | |
| 603 | + float radius = tau * .6; | |
| 604 | + float amp = (.5 + c.b.x * 1.3) * exp(-tau * 1.1) / (1 + radius * 2.5) * smoothstep(0.f, .05f, tau); | |
| 605 | + float x = dist - radius; | |
| 606 | + float env = exp(-x * x / .03); | |
| 607 | + float slope = amp * (28 * cos(x * 28) - 2 * x / .03 * sin(x * 28)) * env; | |
| 608 | + grad += slope * d / max(length(d), 1e-3f); | |
| 609 | + } | |
| 610 | + } | |
| 611 | + float kick = raveKick(c.hit); | |
| 612 | + if (kick > .01) { | |
| 613 | + float2 d = g - float2(sin(c.m * .6) * .8, 2.6); | |
| 614 | + float x = length(d) * scale - (1 - kick) * 1.4; | |
| 615 | + float env = exp(-x * x / .05); | |
| 616 | + grad += kick * 1.6 * (24 * cos(x * 24) - 2 * x / .05 * sin(x * 24)) * env * d / max(length(d), 1e-3f); | |
| 617 | + } | |
| 618 | + float3 n = normalize(float3(-grad.x * .02, 1, -grad.y * .02)); | |
| 619 | + float3 r = reflect(view, n); | |
| 620 | + float fresnel = .05 + .95 * pow(1 - max(dot(-view, n), 0.f), 4.f); | |
| 621 | + float3 env = liquidCeiling(hit, r, camZ, c, f); | |
| 622 | + float3 surface = deep(.6, f) * .05 + env * (.34 + .5 * fresnel); | |
| 623 | + // light pools gliding over the surface | |
| 624 | + for (int k = 0; k < 2; ++k) { | |
| 625 | + float fk = float(k); | |
| 626 | + float2 pool = float2(sin(c.t * (.17 + fk * .06) + fk * 3) * 1.5, 2.5 + fk * 1.5 + cos(c.t * .13 + fk) * 1.2); | |
| 627 | + surface += paint(.2 + fk * .5, f) * .08 * exp(-length(g - pool) * 1.6); | |
| 628 | + } | |
| 629 | + float glint = step(.97f, hash21(floor(uv * 180) + floor(c.t * 12))) * c.b.w * smoothstep(.3f, 1.2f, dot(env, float3(.33))); | |
| 630 | + surface += paint(.97, f) * glint * 2; | |
| 631 | + float haze = 1 - exp(-z * (.03 + c.fog * .03)); | |
| 632 | + return mix(surface, color + paint(.5, f) * .06, haze); | |
| 633 | + } | |
| 634 | + | |
| 635 | + // ---------------------------------------------------------------- Confetti Storm | |
| 636 | + // Party confetti: layers of paper flakes and curly streamers flutter down through a | |
| 637 | + // bright stage glow, every flake spinning and tumbling so it flashes as it catches the | |
| 638 | + // light; Zoom speed carries the camera through the layers. Confetti cannons in the | |
| 639 | + // bottom corners fire on their own; bass launches extra bursts and attacks fire both. | |
| 640 | + | |
| 641 | + | |
| 642 | + // ---------------------------------------------------------------- Bokeh Club | |
| 643 | + // A nightclub seen through a fast lens wide open: layers of club lights and LED strips | |
| 644 | + // dissolve into large hexagonal bokeh with onion-ring texture and colour fringes at the | |
| 645 | + // rims, drifting and swirling in haze while the focus slowly racks through the layers. | |
| 646 | + // Zoom speed drifts the lens forward through them. Each band brightens its own group of | |
| 647 | + // lights, attacks flare a cluster and highs add tiny sharp sparkles. | |
| 648 | + | |
| 649 | + | |
| 650 | + // ---------------------------------------------------------------- Persistence Fans | |
| 651 | + // Holographic LED fans float in a dark room at different depths and angles; their | |
| 652 | + // spinning blades paint luminous shapes by persistence of vision (mandalas, a band-driven | |
| 653 | + // waveform ring, outward rings and starbursts that morph into each other), with faint | |
| 654 | + // blade sweeps, LED scanlines and flicker bands. Zoom speed dollies between the fans. | |
| 655 | + // The waveform ring follows the bands, attacks pop a starburst and highs sparkle LEDs. | |
| 656 | + | |
| 657 | + | |
| 658 | + // ---------------------------------------------------------------- Domino Run | |
| 659 | + // Glossy coloured dominoes stand in a long meandering line on a dark mirror floor; a | |
| 660 | + // toppling wave runs along it, each domino tipping onto the next with a glint, and every | |
| 661 | + // so often the chain forks into a side line that topples in step. The camera follows the | |
| 662 | + // falling front (Zoom speed sets how fast). The music clock pushes the wave, bands light | |
| 663 | + // the falling dominoes, attacks race a bright wave down the side line and highs glint. | |
| 664 | + constant float dominoSpacing = .3, dominoFork = 15; | |
| 665 | + float dominoPath(float z) { return 1.2 * sin(z * .19) + .5 * sin(z * .43 + 1.3); } | |
| 666 | + float dominoSlope(float z) { return 1.2 * .19 * cos(z * .19) + .5 * .43 * cos(z * .43 + 1.3); } | |
| 667 | + float dominoBranch(float z, thread float &side, thread float &along) { | |
| 668 | + float k = floor((z - 6) / dominoFork); | |
| 669 | + along = z - (k * dominoFork + 6); | |
| 670 | + side = hash11(k * 3.7) < .5 ? -1.f : 1.f; | |
| 671 | + if (along < .6 || along > 11) return 1e3; | |
| 672 | + return dominoPath(z) + side * (1 - cos(min(along, 7.f) / 7 * PI)) * .72; | |
| 673 | + } | |
| 674 | + float dominoBox(float3 p, float x, float zi, float slope, float fallFront, float size) { | |
| 675 | + float3 base = float3(x, 0, zi); | |
| 676 | + float2 tangent = normalize(float2(slope, 1)); | |
| 677 | + float2 normal = float2(tangent.y, -tangent.x); | |
| 678 | + float3 d = p - base; | |
| 679 | + float3 q = float3(dot(d.xz, normal), d.y, dot(d.xz, tangent)); | |
| 680 | + float thick = .035 * size, tall = .24 * size, wide = .11 * size; | |
| 681 | + float angle = clamp((fallFront - zi) / .45f, 0.f, 1.f) * 1.32; | |
| 682 | + float qy = q.y, qz = q.z - thick; | |
| 683 | + float ly = qy * cos(angle) + qz * sin(angle); | |
| 684 | + float lz = -qy * sin(angle) + qz * cos(angle); | |
| 685 | + return sdBox(float3(q.x, ly - tall, lz + thick), float3(wide, tall, thick)) - .006 * size; | |
| 686 | + } | |
| 687 | + constant float dominoLineGap = 3.4; | |
| 688 | + float dominoMap(float3 p, float front, float size, thread float &which, thread float &index) { | |
| 689 | + float lane = round((p.x - dominoPath(p.z)) / dominoLineGap); | |
| 690 | + float shift = lane * 7.3; | |
| 691 | + float offset = lane * dominoLineGap; | |
| 692 | + float lineFront = front - abs(lane) * 1.7; | |
| 693 | + float3 lp = float3(p.x - offset, p.y, p.z); | |
| 694 | + float i0 = round(lp.z / dominoSpacing); | |
| 695 | + float best = 1e3; | |
| 696 | + for (int k = 0; k < 2; ++k) { | |
| 697 | + float i = i0 - float(k); | |
| 698 | + float zi = i * dominoSpacing; | |
| 699 | + float d = dominoBox(lp, dominoPath(zi), zi, dominoSlope(zi), lineFront, size); | |
| 700 | + if (d < best) { best = d; which = lane * 2; index = i; } | |
| 701 | + float side, along; | |
| 702 | + float bx = dominoBranch(zi + shift, side, along); | |
| 703 | + bx += dominoPath(zi) - dominoPath(zi + shift); | |
| 704 | + if (bx < 100) { | |
| 705 | + float slope = dominoSlope(zi) + side * sin(min(along, 7.f) / 7 * PI) * PI / 7 * .72 * step(along, 7.f); | |
| 706 | + float db = dominoBox(lp, bx, zi, slope, lineFront, size); | |
| 707 | + if (db < best) { best = db; which = lane * 2 + 1; index = i; } | |
| 708 | + } | |
| 709 | + } | |
| 710 | + return best; | |
| 711 | + } | |
| 712 | + float3 dominoRun(Ctx c, constant NativeFrame &f) { | |
| 713 | + float size = c.size; | |
| 714 | + float front = c.t * 1.9 + c.travel * 1.5 + c.m * 1.1; | |
| 715 | + float camZ = front - 3.2; | |
| 716 | + float tall = clamp((c.extent.y / c.extent.x - 1) / .78f, 0.f, 1.f); | |
| 717 | + float3 eye = float3(dominoPath(camZ) * .6 + .9, 1.7 + 1.1 * tall, camZ); | |
| 718 | + float3 target = float3(dominoPath(camZ + 5) * .8, 0, camZ + 5.5); | |
| 719 | + float3 rd = cameraRay(c.uv, target - eye, float3(0, 1, 0), 1.5); | |
| 720 | + float3 sky = deep(.7, f) * .08 + paint(.6, f) * .14 * exp(-abs(rd.y + .04) * 7); | |
| 721 | + if (rd.y >= -.005) return sky; | |
| 722 | + float tFloor = eye.y / -rd.y; | |
| 723 | + float tStart = (eye.y - .62 * size) / -rd.y; | |
| 724 | + float t = max(tStart, 0.f); | |
| 725 | + float which = 0, index = 0; | |
| 726 | + bool hit = false; | |
| 727 | + for (int s = 0; s < 44; ++s) { | |
| 728 | + float3 p = eye + rd * t; | |
| 729 | + float d = dominoMap(p, front, size, which, index); | |
| 730 | + if (d < .002) { hit = true; break; } | |
| 731 | + t += max(d * .9, .004f); | |
| 732 | + if (t > tFloor) break; | |
| 733 | + } | |
| 734 | + float3 light = normalize(float3(-.5, .8, .35)); | |
| 735 | + float fog = exp(-max(min(t, tFloor) - 2, 0.f) * (.06 + c.fog * .06)); | |
| 736 | + if (hit) { | |
| 737 | + float3 p = eye + rd * t; | |
| 738 | + const float2 e = float2(.003, -.003); | |
| 739 | + float dummyA, dummyB; | |
| 740 | + float3 n = normalize(e.xyy * dominoMap(p + e.xyy, front, size, dummyA, dummyB) + e.yyx * dominoMap(p + e.yyx, front, size, dummyA, dummyB) | |
| 741 | + + e.yxy * dominoMap(p + e.yxy, front, size, dummyA, dummyB) + e.xxx * dominoMap(p + e.xxx, front, size, dummyA, dummyB)); | |
| 742 | + float lane = round(which * .5 - .25); | |
| 743 | + float zi = index * dominoSpacing; | |
| 744 | + float falling = clamp((front - abs(lane) * 1.7 - zi) / .45f, 0.f, 1.f); | |
| 745 | + float moving = falling * (1 - falling) * 4; | |
| 746 | + float band = c.b[int(fmod(abs(index), 4.f))]; | |
| 747 | + float hue = fract(index * .061 + which * .37) * 1.8; | |
| 748 | + float3 tint = paint(hue, f); | |
| 749 | + float diffuse = max(dot(n, light), 0.f); | |
| 750 | + float spec = pow(max(dot(reflect(rd, n), light), 0.f), 40.f); | |
| 751 | + float rim = pow(1 - max(dot(-rd, n), 0.f), 3.f); | |
| 752 | + float side, along; | |
| 753 | + dominoBranch(index * dominoSpacing + lane * 7.3, side, along); | |
| 754 | + float kick = raveKick(c.hit); | |
| 755 | + float race = fmod(abs(which), 2.f) > .5 ? kick * exp(-pow(along - (1 - kick) * 11, 2.f) * .8) : 0.f; | |
| 756 | + float glint = 1 + c.b.w * 3 * step(.8f, hash11(index * 1.7 + floor(c.t * 8))); | |
| 757 | + float3 color = tint * (.12 + .7 * diffuse) * (1 + band * (1.2 + 1.6 * moving) + falling * .15) + paint(.97, f) * spec * 1.3 * glint + tint * rim * .35 * (1 + band * 2); | |
| 758 | + color += paint(.95, f) * race * 1.5 + tint * moving * .35; | |
| 759 | + return mix(sky, color, fog); | |
| 760 | + } | |
| 761 | + // mirror floor: soft reflections and contact shadows from the nearest dominoes | |
| 762 | + float3 p = eye + rd * tFloor; | |
| 763 | + float3 color = deep(.6, f) * .07 + paint(.6, f) * .03; | |
| 764 | + float near = dominoMap(p + float3(0, .12 * size, 0), front, size, which, index); | |
| 765 | + float zi = index * dominoSpacing; | |
| 766 | + float3 tint = paint(fract(index * .061 + which * .37) * 1.8, f); | |
| 767 | + float floorBand = c.b[int(fmod(abs(index), 4.f))]; | |
| 768 | + color += tint * (exp(-max(near, 0.f) * 9) * .45 + exp(-max(near, 0.f) * 2.5) * .06) * (1 + floorBand * 2.5); | |
| 769 | + color *= .55 + .45 * smoothstep(0.f, .12f, dominoMap(p + light * .08, front, size, which, index)); | |
| 770 | + float2 g = p.xz; | |
| 771 | + color += paint(.5, f) * .04 * exp(-abs(fract(g.x * .5) - .5) * 40) * exp(-tFloor * .1); | |
| 772 | + float reflection = pow(1 - abs(rd.y), 5.f); | |
| 773 | + color += sky * reflection * 1.5; | |
| 774 | + return mix(sky, color, fog); | |
| 775 | + } | |
| 776 | + | |
| 777 | + // ---------------------------------------------------------------- Aerial Silks | |
| 778 | + // Circus aerial silks under a big top: long doubled fabric drops hang from the rigging, | |
| 779 | + // swinging like pendulums with ripples running down them and twisting into spiral wraps, | |
| 780 | + // inside soft spotlight cones and haze under strings of lights. Zoom speed pans along the | |
| 781 | + // ring. Bass swings the silks wider, attacks unroll a drop so its wrap slides down and | |
| 782 | + // spins loose. | |
| 783 | + | |
| 784 | + | |
| 785 | + // ---------------------------------------------------------------- Hula Hoops | |
| 786 | + // Columns of glowing LED hoops gyrate in the dark at two depths, each hoop a tilted | |
| 787 | + // ellipse of chasing LEDs that leaves a long light-painted trail, with face-on hoops | |
| 788 | + // spinning above and everything mirrored in a glossy floor. Zoom speed pans along the | |
| 789 | + // line. Bass lights extra hoops low in each column, attacks toss a hoop upward and highs | |
| 790 | + // sparkle the LEDs. | |
| 791 | + | |
| 792 | + | |
| 793 | + #define RAVE_EFFECTS(X) X(smokeRings) X(wandOrbs) X(stringResonance) X(lightBars) X(sequinCurtain) X(stadiumWave) X(liquidFloor) X(dominoRun) | |
| 794 | + RAVE_EFFECTS(NATIVE_EFFECT) |
Sources/PulseCanvas/Resources/NativeStructure.metal added
| 1 | + // Architecture, machinery and lattice designs. Original PulseCanvas procedural code. | |
| 2 | + // Every effect receives Ctx from NativeCommon.metal; audio terms are zero at zero Chaos. | |
| 3 | + | |
| 4 | + float3 normalFrom(float3 p, float e, float d0, float dx, float dy, float dz) { return normalize(float3(dx - d0, dy - d0, dz - d0)); } | |
| 5 | + | |
| 6 | + // ------------------------------------------------------------------ 32 Chrome Reef | |
| 7 | + // A flight through a labyrinth of chrome coral. A channel stays open around the camera; | |
| 8 | + // each coral branch swells with its band and attacks send ripples along the surfaces. | |
| 9 | + float2 reefPath(float z) { return float2(sin(z * .21) * 1.3, cos(z * .17) * .9); } | |
| 10 | + float reefField(float3 p, Ctx c) { | |
| 11 | + float s = 1.6 / c.size; | |
| 12 | + float3 q = p * s; | |
| 13 | + float band = c.b[int(hash31(floor(q * .5)) * 3.99)]; | |
| 14 | + q += .25 * sin(q.yzx * .7 + c.t * .2 + c.m * .35); | |
| 15 | + float gyroid = dot(sin(q), cos(q.yzx)); | |
| 16 | + float detail = dot(sin(q * 3.1 + c.t * .1), cos(q.zxy * 3.1)) * .12; | |
| 17 | + float shell = abs(gyroid + detail) - (.28 + band * .22 + c.hit * .05 * sin(q.z * 4 - c.m * 6)); | |
| 18 | + float d = shell / (s * 2.2); | |
| 19 | + float2 path = reefPath(p.z); | |
| 20 | + return max(d, 1.1 - length(p.xy - path)); | |
| 21 | + } | |
| 22 | + float3 chromeReef(Ctx c, constant NativeFrame &f) { | |
| 23 | + float z = c.travel * 1.4; | |
| 24 | + float3 ro = float3(reefPath(z), z); | |
| 25 | + float3 ahead = float3(reefPath(z + 1.5), z + 1.5) - ro; | |
| 26 | + float3 rd = cameraRay(c.uv, ahead, float3(sin(c.t * .07) * .3, 1, 0), 1.3); | |
| 27 | + float travel = 0, steps = 0; | |
| 28 | + bool hit = false; | |
| 29 | + for (int i = 0; i < 96; ++i) { | |
| 30 | + float d = reefField(ro + rd * travel, c); | |
| 31 | + if (d < .0015 * (1 + travel)) { hit = true; break; } | |
| 32 | + travel += d * .8; | |
| 33 | + steps += 1; | |
| 34 | + if (travel > 18) break; | |
| 35 | + } | |
| 36 | + float3 haze = deep(.25 + rd.y * .2, f) * .25 + paint(.6, f) * .05; | |
| 37 | + if (!hit) return haze; | |
| 38 | + float3 p = ro + rd * travel; | |
| 39 | + float e = .003, d0 = reefField(p, c); | |
| 40 | + float3 n = normalFrom(p, e, d0, reefField(p + float3(e, 0, 0), c), reefField(p + float3(0, e, 0), c), reefField(p + float3(0, 0, e), c)); | |
| 41 | + float3 r = reflect(rd, n); | |
| 42 | + float occlusion = 1 - steps / 96; | |
| 43 | + float3 environment = mix(deep(.15, f) * .3, paint(.35 + r.y * .35, f) * 1.3, smoothstep(-.3f, .5f, r.y)); | |
| 44 | + environment += paint(.95, f) * pow(max(dot(r, normalize(float3(.3, .8, .4))), 0.f), 18.f) * 2; | |
| 45 | + environment += paint(.7, f) * pow(.5 + .5 * sin(r.x * 6 + r.z * 4 + c.t * .2), 12.f) * .5; | |
| 46 | + float fresnel = .35 + .65 * pow(1 - max(dot(-rd, n), 0.f), 3.f); | |
| 47 | + float polyps = pow(.5 + .5 * sin(p.x * 18) * sin(p.y * 18) * sin(p.z * 18), 10.f) * .25 * (1 + c.b.w); | |
| 48 | + float3 color = environment * fresnel * (.35 + .65 * occlusion) + paint(.8, f) * polyps * occlusion; | |
| 49 | + return mix(haze, color, exp(-travel * (.05 + c.fog * .12))); | |
| 50 | + } | |
| 51 | + | |
| 52 | + // ------------------------------------------------------------------ 37 Ion Cathedral | |
| 53 | + // A flight down an endless gothic nave: pointed arches, ribbed vaults and columns, lit by | |
| 54 | + // ionised light that runs along the ribs. The music clock drives the light pulses; bass | |
| 55 | + // thickens the glow and attacks send a flash down the nave. | |
| 56 | + | |
| 57 | + // Each bay of the nave listens to its own band. | |
| 58 | + | |
| 59 | + | |
| 60 | + // ------------------------------------------------------------------ 38 Velvet Circuit | |
| 61 | + // A low flight over a circuit board. Truchet routing keeps every copper trace connected, | |
| 62 | + // with 45-degree chamfers, vias and chips. Signal packets race along the traces on the | |
| 63 | + // music clock; each trace family brightens with its own band. | |
| 64 | + | |
| 65 | + | |
| 66 | + // ------------------------------------------------------------------ 39 Lunar Loom | |
| 67 | + // A moonlit jacquard tapestry billows gently. Real over-under threads carry a large | |
| 68 | + // woven motif of drifting crescents; individual threads shimmer on their bands, bass | |
| 69 | + // swells the cloth and attacks send a bright shuttle thread racing across. | |
| 70 | + | |
| 71 | + | |
| 72 | + // ------------------------------------------------------------------ 71 Gear Works | |
| 73 | + // Layers of meshing brass gear trains drift toward the viewer. Neighbouring gears counter- | |
| 74 | + // rotate with matched teeth; the music clock drives each train and gears glow with their | |
| 75 | + // bands. Alternate layers use larger gears for depth. | |
| 76 | + | |
| 77 | + | |
| 78 | + // ------------------------------------------------------------------ 72 Piston Hall | |
| 79 | + // Down the length of an engine hall: rows of cylinders whose pistons pump on a shared | |
| 80 | + // crankshaft. Bass lengthens each row's stroke, attacks fire the combustion glow, and | |
| 81 | + // the music clock raises engine speed. | |
| 82 | + float pistonField(float3 p, Ctx c, thread float &fire) { | |
| 83 | + float3 q = p; | |
| 84 | + float row = repeatId(q.z, 1.6); | |
| 85 | + q.z -= row * 1.6; | |
| 86 | + float side = sign(q.x); | |
| 87 | + q.x = abs(q.x) - 1.5; | |
| 88 | + float phase = row * 1.3 + (side > 0 ? PI : 0) + c.t * 2.2 + c.m * 2.5; | |
| 89 | + float stroke = .45 + c.b.x * .8 + c.hit * .25; | |
| 90 | + float lift = sin(phase) * stroke; | |
| 91 | + float cylinder = max(length(q.xz) - .52, abs(q.y - .6) - .7); | |
| 92 | + cylinder = max(cylinder, -(length(q.xz) - .44)); | |
| 93 | + float piston = max(length(q.xz) - .42, abs(q.y - (1.45 + lift)) - .28); | |
| 94 | + piston = min(piston, max(length(q.xz) - .3, abs(q.y - (1.78 + lift)) - .05)); | |
| 95 | + float rod = sdCapsule(q, float3(0, 1.2 + lift, 0), float3(sin(phase) * .25, -.3, 0), .08); | |
| 96 | + float block = sdBox(float3(q.x, q.y + 1, q.z), float3(.8, .35, .78)); | |
| 97 | + float floorPlane = p.y + 1.4; | |
| 98 | + fire = (.5 + .5 * cos(phase)) * smoothstep(.35f, .0f, abs(q.y - 1.3)) * smoothstep(.6f, .2f, length(q.xz)); | |
| 99 | + return min(min(min(cylinder, piston), min(rod, block)), floorPlane); | |
| 100 | + } | |
| 101 | + float3 pistonHall(Ctx c, constant NativeFrame &f) { | |
| 102 | + c.travel += c.m * f.camera.w * .5; | |
| 103 | + float3 ro = float3(sin(c.t * .07) * .4, 3.1 + sin(c.t * .2) * .2, c.travel * 2); | |
| 104 | + float3 rd = cameraRay(c.uv, float3(sin(c.t * .11) * .2, -.55, 1), float3(0, 1, 0), 1.3); | |
| 105 | + float travel = 0, fire = 0, glow = 0; | |
| 106 | + bool hit = false; | |
| 107 | + for (int i = 0; i < 90; ++i) { | |
| 108 | + float3 p = ro + rd * travel; | |
| 109 | + float d = pistonField(p, c, fire); | |
| 110 | + glow += fire * .02 * exp(-max(d, 0.f) * 6); | |
| 111 | + if (d < .002) { hit = true; break; } | |
| 112 | + travel += d * .8; | |
| 113 | + if (travel > 35) break; | |
| 114 | + } | |
| 115 | + float3 color = deep(.3, f) * .08; | |
| 116 | + if (hit) { | |
| 117 | + float3 p = ro + rd * travel; | |
| 118 | + float e = .003, dummy; | |
| 119 | + float d0 = pistonField(p, c, fire); | |
| 120 | + float3 n = normalFrom(p, e, d0, pistonField(p + float3(e, 0, 0), c, dummy), pistonField(p + float3(0, e, 0), c, dummy), pistonField(p + float3(0, 0, e), c, dummy)); | |
| 121 | + float3 r = reflect(rd, n); | |
| 122 | + float3 light = normalize(float3(.4, .9, -.3)); | |
| 123 | + float diffuse = max(dot(n, light), 0.f); | |
| 124 | + float specular = pow(max(dot(r, light), 0.f), 30.f); | |
| 125 | + float stripes = pow(.5 + .5 * sin(atan2(r.x, r.z) * 6), 20.f) * smoothstep(0.f, .4f, r.y); | |
| 126 | + float3 metal = paint(.35 + n.y * .2, f) * (.12 + diffuse * .7) + paint(.95, f) * (specular * 1.5 + stripes * .8); | |
| 127 | + metal += paint(.7, f) * pow(max(r.y, 0.f), 3.f) * .4; | |
| 128 | + metal += paint(.8, f) * fire * 1.5 * (1 + c.hit * 2); | |
| 129 | + float wave = .5 + .5 * sin(p.z * 5 - c.t * 3 - c.m * 4); | |
| 130 | + metal += paint(.35 + .18 * sin(p.x * 2), f) * (c.b[int(abs(p.z) * 2) % 4] * wave * .85 + c.hit * pow(wave, 5.f)); | |
| 131 | + color = metal; | |
| 132 | + } | |
| 133 | + color += paint(.8, f) * glow * (1.5 + c.hit * 1.5 + c.b.x * 1.5); | |
| 134 | + return mix(color, deep(.3, f) * .15 + paint(.6, f) * .1, 1 - exp(-travel * (.03 + c.fog * .05))); | |
| 135 | + } | |
| 136 | + | |
| 137 | + // ------------------------------------------------------------------ 73 Orrery Engine | |
| 138 | + // A colossal brass orrery seen from above, its hub off-canvas, so engraved orbits and | |
| 139 | + // planets sweep across the frame. Orbits repeat in scale for an endless zoom; each planet | |
| 140 | + // orbits on its own band and attacks light the engraved tracks. | |
| 141 | + | |
| 142 | + | |
| 143 | + // ------------------------------------------------------------------ 74 Space Frame | |
| 144 | + // A flight through a colossal octet space-frame of box beams, lit by moving spotlights. | |
| 145 | + // Nodes flare on their own bands and light pulses run along the beams with the music. | |
| 146 | + float beam(float2 q, float w) { float2 d = abs(q) - w; return length(max(d, 0.f)) + min(max(d.x, d.y), 0.f); } | |
| 147 | + float frameField(float3 p, Ctx c, thread float &node) { | |
| 148 | + float cell = 3; | |
| 149 | + float3 id = floor(p / cell + .5); | |
| 150 | + float3 q = p - id * cell; | |
| 151 | + float w = .07 * c.size; | |
| 152 | + float d = min(min(beam(q.yz, w), beam(q.xz, w)), beam(q.xy, w)); | |
| 153 | + // Face diagonals in the xz and xy planes. | |
| 154 | + float2 diagonal = float2((q.x + q.z) * .7071, (q.x - q.z) * .7071); | |
| 155 | + d = min(d, beam(float2(min(abs(diagonal.x), abs(diagonal.y)), q.y), w * .7)); | |
| 156 | + float2 diagonal2 = float2((q.x + q.y) * .7071, (q.x - q.y) * .7071); | |
| 157 | + d = min(d, beam(float2(min(abs(diagonal2.x), abs(diagonal2.y)), q.z), w * .7)); | |
| 158 | + float band = c.b[int(hash31(id) * 3.99)]; | |
| 159 | + node = length(q) - (.22 + band * .12) * c.size; | |
| 160 | + return min(d, node); | |
| 161 | + } | |
| 162 | + float3 spaceFrame(Ctx c, constant NativeFrame &f) { | |
| 163 | + float3 ro = float3(1.5 + sin(c.t * .1) * .3, .75 + cos(c.t * .08) * .2, c.travel * 2.4); | |
| 164 | + float3 rd = cameraRay(c.uv, float3(sin(c.t * .07) * .3, sin(c.t * .05) * .2, 1), float3(sin(c.t * .04) * .3, 1, 0), 1.2); | |
| 165 | + float travel = 0, node = 9, nodeGlow = 0; | |
| 166 | + bool hit = false; | |
| 167 | + for (int i = 0; i < 100; ++i) { | |
| 168 | + float3 p = ro + rd * travel; | |
| 169 | + float d = frameField(p, c, node); | |
| 170 | + nodeGlow += exp(-max(node, 0.f) * 5) * .015; | |
| 171 | + if (d < .002) { hit = true; break; } | |
| 172 | + travel += d * .9; | |
| 173 | + if (travel > 45) break; | |
| 174 | + } | |
| 175 | + float3 sky = deep(.3 + rd.y * .2, f) * .12 + paint(.75, f) * pow(max(dot(rd, normalize(float3(.5, .4, 1))), 0.f), 12.f) * .5; | |
| 176 | + float3 color = sky; | |
| 177 | + if (hit) { | |
| 178 | + float3 p = ro + rd * travel; | |
| 179 | + float e = .003, dummy, d0 = frameField(p, c, dummy); | |
| 180 | + float3 n = normalFrom(p, e, d0, frameField(p + float3(e, 0, 0), c, dummy), frameField(p + float3(0, e, 0), c, dummy), frameField(p + float3(0, 0, e), c, dummy)); | |
| 181 | + float3 light = normalize(float3(.5, .4, 1)); | |
| 182 | + float diffuse = max(dot(n, light), 0.f); | |
| 183 | + float specular = pow(max(dot(reflect(rd, n), light), 0.f), 24.f); | |
| 184 | + float pulse = pow(.5 + .5 * sin(dot(p, float3(.3, .2, 1)) * 1.5 - c.t * 2 - c.m * 3), 10.f); | |
| 185 | + color = paint(.3 + dot(p, float3(.01, .02, .015)), f) * (.05 + diffuse * .5) + paint(.95, f) * specular * .8; | |
| 186 | + color += paint(.85, f) * pulse * .6 * (.3 + c.b.y * 1.5); | |
| 187 | + color = mix(sky, color, exp(-travel * (.035 + c.fog * .05))); | |
| 188 | + } | |
| 189 | + return color + paint(.9, f) * nodeGlow * (1 + c.hit * 2); | |
| 190 | + } | |
| 191 | + | |
| 192 | + // ------------------------------------------------------------------ 75 Brutalist Shift | |
| 193 | + // An isometric concrete megastructure under hard sunlight. Tower blocks slide up and | |
| 194 | + // down on slow schedules, each also rising with its own band; attacks pop window lights. | |
| 195 | + | |
| 196 | + | |
| 197 | + // ------------------------------------------------------------------ 76 Rose Window | |
| 198 | + // Colored light streams through a vast rose window into a dusty nave. The tracery turns | |
| 199 | + // slowly; panes brighten with their bands and attacks flare the light shafts. | |
| 200 | + | |
| 201 | + | |
| 202 | + // ------------------------------------------------------------------ 92 Atom Lattice | |
| 203 | + // A flight through a ball-and-stick crystal with two kinds of atoms. Each atom vibrates | |
| 204 | + // on its own band, bonds stretch with them, and attacks send a flash along the bonds. | |
| 205 | + float3 atomOffset(float3 id, Ctx c) { | |
| 206 | + float3 seed = hash33(id); | |
| 207 | + float band = c.b[int(seed.x * 3.99)]; | |
| 208 | + return sin(c.t * (1.3 + seed * 1.7) + c.m * 3 * seed + seed * TAU) * (.03 + band * .14); | |
| 209 | + } | |
| 210 | + float atomField(float3 p, Ctx c, thread float &kind, thread float &bond) { | |
| 211 | + // Body-centred lattice: test the nearest corner atom, the nearest centre atom and | |
| 212 | + // the single bond between them; farther primitives cannot be closer. | |
| 213 | + float cell = 2; | |
| 214 | + float3 cornerId = floor(p / cell + .5); | |
| 215 | + float3 corner = cornerId * cell + atomOffset(cornerId, c); | |
| 216 | + float3 centerId = floor(p / cell); | |
| 217 | + float3 center = (centerId + .5) * cell + atomOffset(centerId + .5, c); | |
| 218 | + float cornerRadius = (.36 + .08 * hash31(cornerId)) * c.size * .8; | |
| 219 | + float cornerAtom = length(p - corner) - cornerRadius; | |
| 220 | + float centerAtom = length(p - center) - .26 * c.size * .8; | |
| 221 | + float3 octant = centerId + step(float3(.5), fract(p / cell)); | |
| 222 | + float3 bondCorner = octant * cell + atomOffset(octant, c); | |
| 223 | + bond = sdCapsule(p, bondCorner, center, .06); | |
| 224 | + kind = centerAtom < cornerAtom ? 1. : 0.; | |
| 225 | + return min(min(cornerAtom, centerAtom), bond); | |
| 226 | + } | |
| 227 | + float3 atomLattice(Ctx c, constant NativeFrame &f) { | |
| 228 | + float3 ro = float3(1 + sin(c.t * .11) * .2, cos(c.t * .09) * .2, c.travel * 2.2); | |
| 229 | + float3 rd = cameraRay(c.uv, float3(sin(c.t * .06) * .4, cos(c.t * .05) * .3, 1), float3(0, 1, 0), 1.25); | |
| 230 | + rd.xy = rot(rd.xy, c.t * .03); | |
| 231 | + float travel = 0, kind = 0, bond = 9; | |
| 232 | + bool hit = false; | |
| 233 | + for (int i = 0; i < 90; ++i) { | |
| 234 | + float d = atomField(ro + rd * travel, c, kind, bond); | |
| 235 | + if (d < .002) { hit = true; break; } | |
| 236 | + travel += d * .9; | |
| 237 | + if (travel > 30) break; | |
| 238 | + } | |
| 239 | + float3 background = deep(.5, f) * .06; | |
| 240 | + if (!hit) return background; | |
| 241 | + float3 p = ro + rd * travel; | |
| 242 | + float e = .003, k2, b2; | |
| 243 | + float d0 = atomField(p, c, k2, b2); | |
| 244 | + float3 n = normalFrom(p, e, d0, atomField(p + float3(e, 0, 0), c, k2, b2), atomField(p + float3(0, e, 0), c, k2, b2), atomField(p + float3(0, 0, e), c, k2, b2)); | |
| 245 | + float isBond = bond < .003 ? 1. : 0.; | |
| 246 | + float3 light = normalize(float3(-.4, .7, -.5)); | |
| 247 | + float diffuse = max(dot(n, light), 0.f); | |
| 248 | + float specular = pow(max(dot(reflect(rd, n), light), 0.f), 40.f); | |
| 249 | + float rim = pow(1 - max(dot(-rd, n), 0.f), 3.f); | |
| 250 | + float3 albedo = isBond > .5 ? paint(.5, f) * .5 : paint(kind > .5 ? .85 : .2 + hash31(floor(p / 2)) * .3, f); | |
| 251 | + float flash = isBond * c.hit * pow(.5 + .5 * sin(p.z * 2 - c.m * 8), 8.f) * 2; | |
| 252 | + float3 color = albedo * (.1 + diffuse * .8) + paint(.95, f) * (specular * .9 + flash) + paint(.7, f) * rim * .5; | |
| 253 | + return mix(background, color, exp(-travel * (.04 + c.fog * .07))); | |
| 254 | + } | |
| 255 | + | |
| 256 | + // ------------------------------------------------------------------ 98 Synth Horizon | |
| 257 | + // A neon grid racing toward a striped sun behind wireframe mountains. Bass rolls waves | |
| 258 | + // through the floor toward the viewer, highs light the sun's bands, attacks flash the grid. | |
| 259 | + float3 synthHorizon(Ctx c, constant NativeFrame &f) { | |
| 260 | + float horizon = .08 * c.extent.y; | |
| 261 | + float3 color = 0.f; | |
| 262 | + if (c.uv.y > horizon) { | |
| 263 | + float h = c.uv.y - horizon; | |
| 264 | + color = mix(paint(.75, f) * .55, deep(.2, f) * .15, smoothstep(0.f, 1.2f, h)); | |
| 265 | + float2 sunCenter = float2(0, horizon + .42); | |
| 266 | + float sunDistance = length(c.uv - sunCenter); | |
| 267 | + float stripes = step(.5, fract((c.uv.y - sunCenter.y) * 14 - c.t * .3 + c.m * .2)) + step(0.f, c.uv.y - sunCenter.y + .05); | |
| 268 | + float sun = (1 - smoothstep(.48f, .5f, sunDistance)) * min(stripes, 1.f); | |
| 269 | + color = mix(color, mix(paint(.95, f), paint(.6, f), smoothstep(.4f, -.4f, c.uv.y - sunCenter.y)) * (1.3 + c.b.w * .8), sun); | |
| 270 | + color += paint(.85, f) * exp(-sunDistance * 3) * .25; | |
| 271 | + // Mountains. | |
| 272 | + float ridge = horizon + .18 * fbm2(float2(c.uv.x * 1.6 + c.travel * .02, 1), 4) + .1 * abs(sin(c.uv.x * 2.3)); | |
| 273 | + float mountain = step(c.uv.y, ridge); | |
| 274 | + float wire = exp(-abs(fract(c.uv.x * 12 + fbm2(float2(c.uv.x * 4, c.uv.y * 6), 2)) - .5) * 30) * .4 + exp(-abs(c.uv.y - ridge) * 120); | |
| 275 | + color = mix(color, deep(.2, f) * .1 + paint(.8, f) * wire * .6, mountain); | |
| 276 | + float stars = pow(hash21(floor(c.uv * 90)), 50.f) * smoothstep(.3f, .8f, h); | |
| 277 | + color += paint(.9, f) * stars; | |
| 278 | + } else { | |
| 279 | + float depth = .5 / max(horizon - c.uv.y, 1e-3f); | |
| 280 | + float2 floorUV = float2(c.uv.x * depth, depth + c.travel * 1.6 + c.t * .4); | |
| 281 | + float wave = (c.b.x * .5 + c.hit * .3) * sin(floorUV.y * .8 - c.m * 4) * exp(-depth * .08); | |
| 282 | + floorUV.x += wave * .4; | |
| 283 | + float2 grid = abs(fract(floorUV * float2(1.2, 1) / c.size) - .5); | |
| 284 | + float2 width = fwidth(floorUV * float2(1.2, 1) / c.size) * 1.2; | |
| 285 | + float lines = max(1 - smoothstep(.0f, 1.f, grid.x / max(width.x, .02f)), 1 - smoothstep(.0f, 1.f, grid.y / max(width.y, .02f))); | |
| 286 | + float glow = exp(-min(grid.x, grid.y) * 8) * .3; | |
| 287 | + float fade = exp(-depth * .05); | |
| 288 | + float ripple = c.hit * exp(-abs(fract(floorUV.y * .08 - c.m * .5) - .5) * 14); | |
| 289 | + color = deep(.25, f) * .08 + paint(.65 + wave * .2, f) * (lines * (1.1 + ripple * 1.5) + glow) * fade; | |
| 290 | + color += paint(.85, f) * exp(-(horizon - c.uv.y) * 12) * .5; | |
| 291 | + } | |
| 292 | + return color; | |
| 293 | + } | |
| 294 | + | |
| 295 | + #define STRUCTURE_EFFECTS(X) X(chromeReef) X(pistonHall) X(spaceFrame) X(atomLattice) X(synthHorizon) | |
| 296 | + STRUCTURE_EFFECTS(NATIVE_EFFECT) |
Sources/PulseCanvas/Resources/NativeTunnels.metal added
| 1 | + // PulseCanvas native designs: tunnels (scenes 100–116). Original procedural code; see | |
| 2 | + // NativeCommon.metal. Every design is a pure function of its uniforms and every audio term | |
| 3 | + // is zero at zero Chaos. | |
| 4 | + | |
| 5 | + // ---------------------------------------------------------------- shared tunnel helpers | |
| 6 | + // Wrap an angle into [-π, π]. | |
| 7 | + float tnWrap(float a) { return a - TAU * floor(a / TAU + .5); } | |
| 8 | + // Smooth Lissajous drift for a vanishing point. | |
| 9 | + float2 tnDrift(float t, float2 amount) { | |
| 10 | + return float2(sin(t * .23) + .45 * sin(t * .37 + 2.1), sin(t * .19 + 1.3) + .45 * sin(t * .31 + .4)) / 1.45 * amount; | |
| 11 | + } | |
| 12 | + // Bent tube: near walls stay centred while far depths converge on the drifting vanishing | |
| 13 | + // point. The map is smooth and one-to-one for |vanish| < .5. | |
| 14 | + float2 tnBend(float2 uv, float2 vanish) { | |
| 15 | + float2 q = uv - vanish; | |
| 16 | + return uv - vanish / (1 + 2.5 * dot(q, q)); | |
| 17 | + } | |
| 18 | + // Depth fog with the Fog control. | |
| 19 | + float tnFog(float z, Ctx c, float base) { return exp(-z * (base + c.fog * .15)); } | |
| 20 | + // Normalized attack level: 0 when quiet, 1 on a strong attack. | |
| 21 | + float tnAttack(Ctx c) { return smoothstep(.04f, .7f, c.hit); } | |
| 22 | + | |
| 23 | + // ---------------------------------------------------------------- 100 Plasma Bore | |
| 24 | + // A round bore of boiling plasma. Domain-warped noise on the cylinder forms hot filaments | |
| 25 | + // and colour bands that slide down the curving tube. Bass thickens the near filaments, | |
| 26 | + // highs crackle on the walls and attacks launch a plasma ring down the bore. | |
| 27 | + float3 plasmaBore(Ctx c, constant NativeFrame &f) { | |
| 28 | + float2 vanish = tnDrift(c.t, float2(.36, .24)); | |
| 29 | + float2 d = tnBend(c.uv, vanish); | |
| 30 | + float r = max(length(d), 1e-3f), a = atan2(d.y, d.x); | |
| 31 | + // The bore wall bulges with the bass in rings that roll toward the camera. | |
| 32 | + float bulge = 1 + c.b.x * .16 * sin((1 / r + c.travel * 2.4) * 1.3 + c.m * 2.5 + 2 * cos(a)); | |
| 33 | + float z = bulge / r, zw = z + c.travel * 2.4 + c.m * .7; | |
| 34 | + float scale = 1 / c.size; | |
| 35 | + float3 p = float3(cos(a) * 1.4, sin(a) * 1.4, zw * .42) * scale; | |
| 36 | + float3 warp = float3(fbm3(p + float3(0, 0, c.t * .31 + c.m * .3), 3), fbm3(p + float3(4.1, 1.7, -c.t * .27), 3), 0); | |
| 37 | + float n = fbm3(p * 1.5 + warp * (2.6 + c.b.y * 1.6) + float3(1.3, -.7, -c.t * .45 - c.m * .4), 4); | |
| 38 | + float near = exp(-z * .6); | |
| 39 | + float filaments = 1 - abs(sin(n * 11 + c.t * .5 + c.m * .4)); | |
| 40 | + float ridge = pow(filaments, 8 - 5 * c.b.x * near); | |
| 41 | + float strands = pow(1 - abs(sin(warp.x * 14 - c.t * .3)), 14.f); | |
| 42 | + float phase = n * 3.2 + zw * .05 - c.t * .1 + c.b.z * .5; | |
| 43 | + float cloud = smoothstep(.38f, .72f, n); | |
| 44 | + float bands = .55 + .45 * sin(zw * 1.3 - c.t * 1.4 + n * 5); | |
| 45 | + float3 color = paint(phase + .5, f) * .04 + paint(phase, f) * cloud * .3 * bands; | |
| 46 | + color += paint(phase + .15, f) * ridge * (1.1 + 2.4 * c.b.x * near) * (.6 + .4 * bands); | |
| 47 | + color += paint(phase + .55, f) * strands * .45; | |
| 48 | + color += paint(phase + .3, f) * pow(filaments, 30.f) * 1.1; | |
| 49 | + // High-band crackle: tiny sparks that flicker on the near walls. | |
| 50 | + float2 sparkCell = float2((a / TAU + .5) * 64, zw * 9); | |
| 51 | + float sparkHash = hash21(floor(sparkCell) + 17); | |
| 52 | + float twinkle = pow(.5 + .5 * sin(c.t * 23 * (.5 + sparkHash) + sparkHash * 40), 6.f); | |
| 53 | + float spark = smoothstep(.32f, 0.f, length(fract(sparkCell) - .5)) * step(.82f, sparkHash); | |
| 54 | + color += paint(phase + .5, f) * spark * twinkle * c.b.w * 5 * exp(-z * .3); | |
| 55 | + // Attack: a ring-shaped surge that rides down the tube as the attack decays. | |
| 56 | + float h = tnAttack(c); | |
| 57 | + float ringDepth = 1.3 + (1 - h) * 6; | |
| 58 | + float surge = exp(-pow((z - ringDepth) / (.12 + .1 * ringDepth), 2.f)) * c.hit; | |
| 59 | + color += paint(.85 + n * .3, f) * surge * (1 + 2.6 * filaments); | |
| 60 | + float3 core = paint(phase * .3 + .55, f) * .7 + paint(.9, f) * exp(-r * 9) * 1.4; | |
| 61 | + return mix(core, color, tnFog(z, c, .03) * smoothstep(30.f, 10.f, z)); | |
| 62 | + } | |
| 63 | + | |
| 64 | + // ---------------------------------------------------------------- 101 LED Corridor | |
| 65 | + // A square corridor tiled with LED matrices. The walls run equalizer columns (left on the | |
| 66 | + // low band, right on high-mids) under marching chevrons, the ceiling scrolls a slow colour | |
| 67 | + // field and attacks run a pixel wave down the floor. Dark seams mark every panel. | |
| 68 | + float3 ledCorridor(Ctx c, constant NativeFrame &f) { | |
| 69 | + float2 vanish = tnDrift(c.t * .8, float2(.18, .1)); | |
| 70 | + float2 d = tnBend(c.uv, vanish); | |
| 71 | + float ax = abs(d.x), ay = abs(d.y); | |
| 72 | + bool wall = ax > ay; | |
| 73 | + float z = 1 / max(max(ax, ay), 1e-3f); | |
| 74 | + // Forward drive: zoom travel plus the music clock, so energetic passages surge ahead. | |
| 75 | + float drive = c.travel * 3.2 + c.m * .9; | |
| 76 | + float zw = z + drive; | |
| 77 | + float across = (wall ? d.y : d.x) * z; | |
| 78 | + float pitch = .09 * c.size; | |
| 79 | + float2 cell = float2(across, zw) / pitch; | |
| 80 | + float2 id = floor(cell), local = fract(cell) - .5; | |
| 81 | + float centreAcross = (id.x + .5) * pitch, centreDepth = (id.y + .5) * pitch; | |
| 82 | + float relDepth = centreDepth - drive; | |
| 83 | + float height01 = centreAcross * .5 + .5; | |
| 84 | + // Every panel block listens to its own band. | |
| 85 | + float2 block = floor(float2(id.x / 5, id.y / 6)) + (wall ? (d.x < 0 ? 0 : 40) : (d.y > 0 ? 80 : 120)); | |
| 86 | + float blockBand = c.b[int(hash21(block) * 3.99)]; | |
| 87 | + float3 led = 0; | |
| 88 | + if (wall) { | |
| 89 | + bool left = d.x < 0; | |
| 90 | + if (height01 < .66) { | |
| 91 | + float column = floor(id.y / 4); | |
| 92 | + float gap = step(2.5f, id.y - column * 4); | |
| 93 | + float band = left ? c.b.x : c.b.z; | |
| 94 | + float level = .22 + .14 * sin(c.t * 2.3 + c.m * 1.5 + column * 1.37) + .09 * sin(c.t * 3.9 + column * .71) | |
| 95 | + + band * (.45 + .4 * hash11(column * 1.71 + (left ? 0 : 50))); | |
| 96 | + float h = height01 / .66; | |
| 97 | + float on = (1 - gap) * step(h, level); | |
| 98 | + float cap = (1 - gap) * step(level, h) * step(h, level + pitch * .75); | |
| 99 | + led = paint(.04 + h * .8, f) * on * 1.1 + paint(.9, f) * cap * 1.3; | |
| 100 | + } else { | |
| 101 | + float row = (centreAcross - .66) / pitch; | |
| 102 | + float march = fract((id.y + abs(row) * 1.2 - c.t * 7 - c.m * 5) / 9); | |
| 103 | + led = paint(.72 + .1 * sin(id.y * .05) + c.b.w * .25, f) * step(march, .3f) * step(.7f, height01) * step(height01, .96f) * (1 + c.b.w * 1.8); | |
| 104 | + } | |
| 105 | + } else if (d.y > 0) { | |
| 106 | + float n = noise2(float2(centreAcross * 1.2, centreDepth * .22 - c.t * .25 - c.m * .3)); | |
| 107 | + led = paint(n * 1.5 + c.t * .03 + centreDepth * .01 + c.b.y * .35, f) * (.25 + .4 * n) * (1 + blockBand * 2.4); | |
| 108 | + } else { | |
| 109 | + float lane = step(abs(abs(centreAcross) - .64), pitch * .6); | |
| 110 | + float dash = step(fract(id.y / 8 - c.t * .9 - c.m * .6), .5); | |
| 111 | + float arrow = step(fract((id.y + abs(id.x + .5) * 1.2 - c.t * 5 - c.m * 4) / 10), .22) * step(abs(centreAcross), .3f); | |
| 112 | + led = paint(.55, f) * lane * dash * (.9 + c.b.y * 2.2) + paint(.3 + c.b.x * .3, f) * arrow * (.7 + c.b.x * 2); | |
| 113 | + float h = tnAttack(c); | |
| 114 | + float front = 1.7 + (1 - h) * 7; | |
| 115 | + float wave = c.hit * exp(-pow((relDepth + abs(centreAcross) * .8 - front) / .7, 2.f)); | |
| 116 | + led += paint(.85 + .1 * centreAcross, f) * wave * 2.4; | |
| 117 | + } | |
| 118 | + float panel = 2.4; | |
| 119 | + float seam = step(fract(centreDepth / panel), pitch / panel * 1.01); | |
| 120 | + led *= 1 - seam; | |
| 121 | + float2 fw = fwidth(cell); | |
| 122 | + float blur = max(fw.x, fw.y); | |
| 123 | + float dist = length(local); | |
| 124 | + float aa = blur * .7 + .02; | |
| 125 | + float resolve = smoothstep(.9f, .35f, blur); | |
| 126 | + float dotMask = mix(.4f, 1 - smoothstep(.36f - aa, .36f + aa, dist), resolve); | |
| 127 | + float halo = mix(.4f, exp(-dist * dist * 7), resolve); | |
| 128 | + // Idle LEDs shimmer with their block's band in waves running down the corridor. | |
| 129 | + float shimmer = pow(.5 + .5 * sin(relDepth * 1.3 - c.m * 3 + hash21(block) * 6), 2.f); | |
| 130 | + float3 offLed = paint(.5 + blockBand * .4, f) * .03 * (1 - seam) * (1 + blockBand * 7 * shimmer); | |
| 131 | + float3 color = deep(.3, f) * .025 * (1 - seam * .8) + (led + offLed) * (dotMask * 1.6 + halo * .3); | |
| 132 | + float corner = exp(-abs(ax - ay) * z * 40); | |
| 133 | + color *= 1 - corner * .6; | |
| 134 | + float3 end = paint(.55, f) * .55 + paint(.85, f) * exp(-max(ax, ay) * 16) * 1.2; | |
| 135 | + return mix(end, color, tnFog(z, c, .03)); | |
| 136 | + } | |
| 137 | + | |
| 138 | + // ---------------------------------------------------------------- 102 Prism Shaft | |
| 139 | + // A triangular glass shaft that turns as it flies past. Each face carries thin-film caustic | |
| 140 | + // lines; panels alternate tint along depth and the three corners burn as bright seams. | |
| 141 | + // Highs multiply and shimmer the caustics, bass widens the seams, attacks sweep a band of | |
| 142 | + // refracted light down the faces. | |
| 143 | + float3 prismShaft(Ctx c, constant NativeFrame &f) { | |
| 144 | + float2 vanish = tnDrift(c.t * .9, float2(.22, .14)); | |
| 145 | + float2 d = tnBend(c.uv, vanish); | |
| 146 | + float r = max(length(d), 1e-3f); | |
| 147 | + float spin = c.travel * .14 + c.t * .05; | |
| 148 | + float a = atan2(d.y, d.x) - spin; | |
| 149 | + const float sector = TAU / 3; | |
| 150 | + float k = floor(a / sector + .5); | |
| 151 | + float phi = a - k * sector; | |
| 152 | + float face = k - 3 * floor(k / 3); | |
| 153 | + float z = 1 / (r * cos(phi)); | |
| 154 | + float lateral = tan(phi); | |
| 155 | + float zw = z + c.travel * 2.6; | |
| 156 | + float fs = 1 / c.size; | |
| 157 | + float2 q = float2(lateral * .9, zw * .5) * fs + float2(face * 7.3, 0); | |
| 158 | + float2 w = float2(fbm2(q * .7 + float2(0, c.t * .06), 3), fbm2(q * .7 + float2(5.2, -c.t * .05), 3)); | |
| 159 | + float n = fbm2(q * 1.3 + w * 2.2, 3); | |
| 160 | + float freq = 20 + c.b.w * 14; | |
| 161 | + float caustic = pow(1 - abs(sin(n * freq + c.t * .6 + c.m * 1.2)), 24.f); | |
| 162 | + float n2 = fbm2(q * 2.3 - w * 1.5 + float2(c.t * .05, 0), 3); | |
| 163 | + caustic += .7 * pow(1 - abs(sin(n2 * freq * 1.3 - c.t * .4 + 1.3)), 30.f) * (.35 + c.b.w * 1.2); | |
| 164 | + float segment = floor(zw / 1.8); | |
| 165 | + float parity = segment - 2 * floor(segment / 2); | |
| 166 | + float3 glass = deep(.12 + parity * .3 + face * .13, f) * .2 + paint(.3 + parity * .25 + face * .1, f) * .05; | |
| 167 | + glass *= .6 + .5 * lateral * lateral / 3; | |
| 168 | + float sheen = exp(-pow(fract(zw * .12 + lateral * .18 - c.t * .08) - .5, 2.f) * 50); | |
| 169 | + glass += paint(.75 + face * .08, f) * sheen * .12; | |
| 170 | + float3 color = glass + filmColor(n * 1.6 + lateral * .12 + zw * .025, f) * caustic * 1.6; | |
| 171 | + float segDist = abs(fract(zw / 1.8 + .5) - .5) * 1.8; | |
| 172 | + color += paint(.6 + parity * .2, f) * (1 - smoothstep(0.f, fwidth(zw) * 1.5 + .004f, segDist)) * .6; | |
| 173 | + float seamDist = r * sin(PI / 3 - abs(phi)); | |
| 174 | + float seamW = .005 + .012 * c.b.x; | |
| 175 | + color += paint(.9, f) * (exp(-seamDist / seamW) * 1.5 + exp(-seamDist / (seamW * 8)) * .3); | |
| 176 | + float h = tnAttack(c); | |
| 177 | + float bandDepth = 1.4 + (1 - h) * 5; | |
| 178 | + float band = exp(-pow((z - bandDepth) / (.15 + .08 * bandDepth), 2.f)) * c.hit; | |
| 179 | + color += mix(paint(.97, f) * 1.4, filmColor(lateral * .25 + zw * .1, f) * 1.6, smoothstep(.2f, 1.6f, abs(lateral))) * band * 1.5; | |
| 180 | + float3 core = deep(.55, f) * .6 + paint(.85, f) * exp(-r * 7) * 1.2; | |
| 181 | + return mix(core, color, tnFog(z, c, .03) * smoothstep(40.f, 14.f, z)); | |
| 182 | + } | |
| 183 | + | |
| 184 | + // ---------------------------------------------------------------- 103 Hyperloop | |
| 185 | + // Riding a glass vacuum tube at speed: support rings flash past, a guide strip glows along | |
| 186 | + // the deck and a twilight city streaks by outside. Bass pulses the guide strip in segments, | |
| 187 | + // highs glint on the glass and attacks run a ring of light down the supports ahead. | |
| 188 | + float3 hyperloop(Ctx c, constant NativeFrame &f) { | |
| 189 | + float2 vanish = tnDrift(c.t * .7, float2(.14, .06)) + float2(0, .05); | |
| 190 | + float2 d = tnBend(c.uv, vanish); | |
| 191 | + float r = max(length(d), 1e-3f), a = atan2(d.y, d.x); | |
| 192 | + float z = 1 / r; | |
| 193 | + // Forward drive: zoom travel plus the music clock, so energetic passages surge ahead. | |
| 194 | + float drive = c.travel * 4.5 + c.m * 1.2; | |
| 195 | + float zw = z + drive; | |
| 196 | + // Outside the glass, seen through a shell that ripples with the bass. | |
| 197 | + float2 view = c.uv + c.b.x * .045 * float2(sin(zw * 2.1 - c.m * 3 + a * 2), cos(zw * 1.7 - c.m * 2.5 + a)) * smoothstep(.3f, 1.2f, r); | |
| 198 | + float horizon = vanish.y - .03; | |
| 199 | + float y = view.y - horizon; | |
| 200 | + float3 outside; | |
| 201 | + if (y > 0) { | |
| 202 | + outside = mix(paint(.62, f) * .5, deep(.08, f) * .18, smoothstep(0.f, 1.1f, y)); | |
| 203 | + outside += paint(.8 + c.b.y * .25, f) * exp(-y * 9) * (.5 + c.b.y * .9); | |
| 204 | + float sx = view.x * 7 + c.travel * .08; | |
| 205 | + float tower = hash11(floor(sx) + 3); | |
| 206 | + float top = .03 + .2 * tower * tower; | |
| 207 | + if (y < top) { | |
| 208 | + float2 wc = float2(sx * 4, y * 70); | |
| 209 | + float windowHash = hash21(floor(wc)); | |
| 210 | + float window = step(.7f, windowHash) * step(.3f, fract(wc.x)) * step(.35f, fract(wc.y)); | |
| 211 | + outside = deep(.15, f) * .12 + paint(.75 + tower * .2, f) * window * (.7 + c.b[int(windowHash * 13) & 3] * 2.5); | |
| 212 | + } | |
| 213 | + outside += paint(.9, f) * step(.996f, hash21(floor(view * 140))) * smoothstep(.25f, .8f, y) * .6; | |
| 214 | + } else { | |
| 215 | + float depth = .55 / max(-y, .004f); | |
| 216 | + float X = (view.x - vanish.x) * depth; | |
| 217 | + float Zg = depth + drive; | |
| 218 | + float2 cellSize = float2(1.4, 3.2); | |
| 219 | + float2 gid = floor(float2(X, Zg) / cellSize); | |
| 220 | + float2 h2 = hash22(gid); | |
| 221 | + float lx = (gid.x + .2 + .6 * h2.x) * cellSize.x; | |
| 222 | + float lz = (gid.y + .4 * h2.y) * cellSize.y; | |
| 223 | + float trail = .5 + 1.4 * f.camera.w; | |
| 224 | + float along = Zg - lz; | |
| 225 | + float inStreak = smoothstep(0.f, .15f, along) * smoothstep(trail, 0.f, along); | |
| 226 | + float lateralScreen = abs(X - lx) / depth; | |
| 227 | + float lamp = (exp(-lateralScreen * 260) + exp(-lateralScreen * 40) * .25) * inStreak * step(.35f, h2.y); | |
| 228 | + outside = deep(.2, f) * .07 + paint(.6 + c.b.y * .25, f) * exp(y * 14) * (.35 + c.b.y * .6); | |
| 229 | + outside += paint(h2.x * .8 + .1, f) * lamp * (2.2 + c.b[int(h2.x * 3.99)] * 4) * exp(-depth * .05); | |
| 230 | + } | |
| 231 | + float3 color = outside * .85 + paint(.5, f) * .03; | |
| 232 | + color += paint(.55, f) * .1 * smoothstep(.6f, 2.f, r); | |
| 233 | + float sheen = exp(-pow(tnWrap(a - 2.1) / .04, 2.f)) + exp(-pow(tnWrap(a - 1.05) / .03, 2.f)) * .6; | |
| 234 | + color += paint(.8, f) * sheen * (.22 + c.b.z * .6) * (.6 + .4 * sin(zw * .3)); | |
| 235 | + // Glints on the glass. | |
| 236 | + float2 gc = float2((a / TAU + .5) * 48, zw * 2); | |
| 237 | + float gh = hash21(floor(gc) + 5); | |
| 238 | + float glint = smoothstep(.3f, 0.f, length(fract(gc) - .5)) * step(.86f, gh) * pow(.5 + .5 * sin(c.t * 9 * (.5 + gh) + gh * 30), 8.f); | |
| 239 | + color += paint(.9, f) * glint * c.b.w * 3.5 * exp(-z * .2); | |
| 240 | + // Deck and guide strip along the floor. | |
| 241 | + float floorAngle = tnWrap(a + PI * .5); | |
| 242 | + float deck = smoothstep(.43f, .4f, abs(floorAngle)); | |
| 243 | + if (deck > 0) { | |
| 244 | + float3 deckColor = deep(.3, f) * .08 * (.6 + .4 * step(.1f, fract(zw * .8))); | |
| 245 | + deckColor += paint(.6, f) * exp(-(.42 - abs(floorAngle)) * r * 90) * .5; | |
| 246 | + float strip = smoothstep(.05f, .035f, abs(floorAngle)) * step(fract(zw * 1.2), .6f); | |
| 247 | + float pulse = 1 + c.b.x * 3.5 * pow(.5 + .5 * sin(zw * .7 - c.t * 5 - c.m * 4), 4.f); | |
| 248 | + deckColor += paint(.7, f) * strip * 1.4 * pulse + paint(.7, f) * exp(-abs(floorAngle) * r * 30) * .25 * pulse; | |
| 249 | + color = mix(color, deckColor, deck); | |
| 250 | + } | |
| 251 | + // Support rings. | |
| 252 | + for (int k = 0; k < 6; ++k) { | |
| 253 | + float ribAngle = (float(k) + .5) * TAU / 8 - PI * .5 + TAU / 8; | |
| 254 | + float ribDist = r * abs(sin(a - ribAngle)); | |
| 255 | + color += paint(.62, f) * exp(-ribDist / (.002 + .003 * r)) * (.35 + c.b.z * 1.2) * step(0.f, cos(a - ribAngle)); | |
| 256 | + } | |
| 257 | + float spacing = 1.5 * c.size; | |
| 258 | + float ringIndex = floor(zw / spacing + .5); | |
| 259 | + float dz = zw - ringIndex * spacing; | |
| 260 | + float fwz = fwidth(zw); | |
| 261 | + float thick = .11; | |
| 262 | + float ringMask = 1 - smoothstep(thick * .5 - fwz, thick * .5 + fwz, abs(dz)); | |
| 263 | + ringMask = mix(ringMask, thick / spacing, smoothstep(.3f * spacing, spacing, fwz)); | |
| 264 | + float ringZ = ringIndex * spacing - drive; | |
| 265 | + float ringBand = c.b[int(hash11(ringIndex * 3.3) * 3.99)]; | |
| 266 | + float h = tnAttack(c); | |
| 267 | + float front = 2.2 + (1 - h) * 8; | |
| 268 | + float flash = c.hit * exp(-pow((ringZ - front) / 1.2, 2.f)); | |
| 269 | + float leds = pow(.5 + .5 * cos(a * 16), 30.f); | |
| 270 | + float3 ringColor = deep(.6, f) * .25 + paint(.65, f) * .35 * (.5 + .5 * abs(sin(a))); | |
| 271 | + ringColor += paint(.85 + hash11(ringIndex) * .1, f) * (leds * (.9 + ringBand * 3) + flash * 2.5); | |
| 272 | + color = mix(color, ringColor, ringMask); | |
| 273 | + // Each ring's lights wash the glass around it with its own band. | |
| 274 | + color += paint(.75, f) * exp(-abs(dz) * 8) * (.1 + flash * .5); | |
| 275 | + color += paint(.6 + ringBand * .3, f) * exp(-abs(dz) * 2.2) * ringBand * .45; | |
| 276 | + float3 end = paint(.7, f) * .45 + paint(.9, f) * exp(-r * 12) * 1.4; | |
| 277 | + return mix(end, color, tnFog(z, c, .02)); | |
| 278 | + } | |
| 279 | + | |
| 280 | + // ---------------------------------------------------------------- 104 Barrel Wave | |
| 281 | + // Inside the curl of a breaking wave. Deep water climbs the face on the right, arcs | |
| 282 | + // overhead and falls as a thin backlit lip on the left; foam lines stream around the curl | |
| 283 | + // toward the bright opening ahead. Bass thickens the foam, highs sparkle spray on the water | |
| 284 | + // and attacks throw a burst of spray off the lip. | |
| 285 | + float3 barrelWave(Ctx c, constant NativeFrame &f) { | |
| 286 | + float2 vanish = float2(.16 + .08 * sin(c.t * .13), .07 + .05 * sin(c.t * .19 + 1)); | |
| 287 | + float2 d = tnBend(c.uv, vanish); | |
| 288 | + float r = max(length(d), 1e-3f), ang = atan2(d.y, d.x); | |
| 289 | + // The water surface heaves with the bass in swells that roll down the barrel. | |
| 290 | + float swell = c.b.x * .11 * sin((1 / r + c.travel * 2.2) * .9 - c.m * 2.5 + ang * 2); | |
| 291 | + float radius = 1 + .18 * cos(2 * ang + .4) + swell; | |
| 292 | + float z = radius / r, zw = z + c.travel * 2.2 + c.m * .6; | |
| 293 | + // Angle around the barrel: rising face (about -1.5) to roof (0.8) to falling lip (π). | |
| 294 | + // It is unwrapped so its only seam lies inside the trough, which covers it. | |
| 295 | + float beta = tnWrap(ang - PI * .25); | |
| 296 | + beta = beta < -2.4 ? beta + TAU : beta; | |
| 297 | + float cs = 1 / c.size; | |
| 298 | + // Water thins from the face (right) over the roof to the lip (left). | |
| 299 | + float thin = smoothstep(-1.5f, 2.5f, beta); | |
| 300 | + float3 water = mix(deep(.3, f) * .12, paint(.4, f) * .17, smoothstep(-1.5f, 1.2f, beta)); | |
| 301 | + water = mix(water, paint(.58, f) * .3, smoothstep(1.f, 2.5f, beta)); | |
| 302 | + water += paint(.75 + c.b.z * .2, f) * pow(thin, 4.f) * (.2 + c.b.z * .6); | |
| 303 | + water += paint(.5, f) * swell * 1.6; | |
| 304 | + // Foam streaks flowing around the curl, faster when the music drives. | |
| 305 | + float s = beta * 1.5 + zw * .2; | |
| 306 | + float2 fp = float2(s * .7 - c.t * 1.2 - c.m * 1.1, zw * 6) * cs; | |
| 307 | + float n = fbm2(fp + float2(0, fbm2(fp * float2(.6, .2) + c.t * .15, 2) * 2), 4); | |
| 308 | + float foam = smoothstep(.6f - .1f * c.b.x, .74f, n); | |
| 309 | + float lace = exp(-abs(n - .52) * 40) * (.35 + c.b.w * 1.2); | |
| 310 | + float3 color = water + paint(.85, f) * (foam * (.65 + c.b.y * 1.3) + lace) * (.35 + .45 * thin); | |
| 311 | + // The flat trough along the bottom. | |
| 312 | + float trough = max(smoothstep(PI + .1f, PI + .45f, beta), smoothstep(-1.5f, -1.9f, beta)); | |
| 313 | + float2 tp = float2(d.x * z * 2.5, (zw + c.t * .8) * 1.4) * cs; | |
| 314 | + float troughFoam = smoothstep(.58f, .76f, fbm2(tp, 4)); | |
| 315 | + float3 troughColor = deep(.32, f) * .22 + paint(.7, f) * exp(-abs(d.x) * 5) * .2 + paint(.85, f) * troughFoam * .45; | |
| 316 | + color = mix(color, troughColor, trough); | |
| 317 | + // Where the falling lip lands in the trough: a band of churning whitewater. | |
| 318 | + float landing = beta; | |
| 319 | + float lipEnd = PI + .02 + .14 * sin(zw * .55 - c.t * 1.2) + .07 * sin(zw * 1.7 + c.t * .8); | |
| 320 | + float churn = fbm2(float2(landing * 5 - c.t * .6, zw * 3 - c.t * 2.2 - c.m * 1.5) * cs, 4); | |
| 321 | + float white = exp(-pow((landing - lipEnd) / (.3 + c.b.x * .15), 2.f)) * smoothstep(.3f, .6f, churn + .15); | |
| 322 | + color = mix(color, paint(.82, f) * (.35 + .6 * churn) * (1 + c.b.x * .8), white); | |
| 323 | + color += paint(.9, f) * exp(-abs(landing - lipEnd + .3) * 12) * .35; | |
| 324 | + // Spray drifting off the lip. | |
| 325 | + float2 sc = float2(beta * 9, zw * 4 - c.t * 1.5); | |
| 326 | + float sh = hash21(floor(sc) + 3); | |
| 327 | + float drop = smoothstep(.22f, 0.f, length(fract(sc) - .5 - (hash22(floor(sc)) - .5) * .4)); | |
| 328 | + color += paint(.95, f) * drop * step(.78f, sh) * smoothstep(1.7f, 2.6f, beta) * (1 - white) * (1 - trough) * .7; | |
| 329 | + // Highs: sparkling glints across the water. | |
| 330 | + float2 gl = float2(beta * 30, zw * 10); | |
| 331 | + float glh = hash21(floor(gl)); | |
| 332 | + color += paint(.95, f) * smoothstep(.3f, 0.f, length(fract(gl) - .5)) * step(.93f, glh) * pow(.5 + .5 * sin(c.t * 11 * glh + glh * 50), 6.f) * c.b.w * 3 * exp(-z * .25); | |
| 333 | + // Attack: a burst of spray thrown off the lip near the camera. | |
| 334 | + float h = tnAttack(c); | |
| 335 | + float burstZone = smoothstep(lipEnd - 1.1, lipEnd - .3, beta) * exp(-z * .4); | |
| 336 | + float2 bc = float2(beta * 14 + (1 - h) * 3, zw * 7 + (1 - h) * 4); | |
| 337 | + float bh = hash21(floor(bc) + 9); | |
| 338 | + float burstDrop = smoothstep(.3f, 0.f, length(fract(bc) - .5)) * step(.55f, bh); | |
| 339 | + color += (paint(.95, f) * burstDrop * 2.5 + paint(.8, f) * .2) * burstZone * c.hit; | |
| 340 | + // The barrel's open end ahead: bright sky over the sea, framed by a ragged foamy rim. | |
| 341 | + float rimDepth = 4.6 + .5 * sin(c.t * .27) + .35 * sin(ang * 3 + c.t * .5) + .2 * sin(ang * 5 - c.t * .8); | |
| 342 | + float beyond = smoothstep(rimDepth - .2, rimDepth + .2, z); | |
| 343 | + float2 view = c.uv - vanish; | |
| 344 | + float horizonY = view.y + .03; | |
| 345 | + float3 outside = mix(deep(.4, f) * .35 + paint(.6, f) * .25 * step(.6f, noise2(float2(view.x * 60, horizonY * 200 + c.t))), paint(.88, f) * .9, smoothstep(-.004f, .004f, horizonY)); | |
| 346 | + outside = mix(outside, paint(.55, f) * .5, smoothstep(.02f, .25f, horizonY)); | |
| 347 | + outside += paint(.95, f) * exp(-length(view - float2(.06, .05)) * 14) * .8; | |
| 348 | + float3 mist = paint(.6, f) * .25; | |
| 349 | + color = mix(mist, color, tnFog(z, c, .02)); | |
| 350 | + color = mix(color, outside, beyond); | |
| 351 | + color += paint(.9, f) * exp(-abs(z - rimDepth) * 2.5) * .45 * (.6 + .4 * noise2(float2(ang * 4, c.t))); | |
| 352 | + return color * .78; | |
| 353 | + } | |
| 354 | + | |
| 355 | + // ---------------------------------------------------------------- 105 Magma Tube | |
| 356 | + // A lava tube: basalt plates split by incandescent cracks, a molten river churning toward | |
| 357 | + // the viewer along the floor, heat haze and drifting embers. Bass widens the near cracks, | |
| 358 | + // highs throw embers and attacks make the river spurt. | |
| 359 | + float3 magmaTube(Ctx c, constant NativeFrame &f) { | |
| 360 | + float2 uv = c.uv; | |
| 361 | + // Heat haze shimmers harder on the bass. | |
| 362 | + float hazeAmount = (.012 + .02 * smoothstep(.3f, -1.f, uv.y)) * (1 + c.b.x * 2.5); | |
| 363 | + uv += (float2(noise2(uv * 6 + float2(0, -c.t * 2.2 - c.m * 1.5)), noise2(uv * 6 + float2(7.1, -c.t * 1.9))) - .5) * hazeAmount; | |
| 364 | + float2 vanish = tnDrift(c.t * .7, float2(.24, .12)) + float2(0, .06); | |
| 365 | + float2 d = tnBend(uv, vanish); | |
| 366 | + float r = max(length(d), 1e-3f); | |
| 367 | + float theta = atan2(-d.x, d.y); | |
| 368 | + float z = 1 / r; | |
| 369 | + // Forward drive: zoom travel plus the music clock. | |
| 370 | + float drive = c.travel * 1.8 + c.m * .5; | |
| 371 | + float zw = z + drive; | |
| 372 | + float cs = 1 / c.size; | |
| 373 | + float near = exp(-z * .45); | |
| 374 | + float floorDistance = PI - abs(theta); | |
| 375 | + float2 pc = float2(theta * 1.45, zw * 1.45) * cs; | |
| 376 | + float4 v = voronoi(pc, .85, 0); | |
| 377 | + float edge = v.y - v.x; | |
| 378 | + // Each plate's rim burns with its own band; bass widens the near cracks. | |
| 379 | + float plateBand = c.b[int(hash21(v.zw) * 3.99)]; | |
| 380 | + float crackW = .035 + .1 * c.b.x * near + .03 * plateBand; | |
| 381 | + float crack = 1 - smoothstep(crackW * .4f, crackW, edge); | |
| 382 | + float heat = exp(-edge * (9 - 4 * c.b.x * near - 3.5 * plateBand)); | |
| 383 | + float flicker = .75 + .25 * noise2(v.zw * 3.1 + c.t * 1.3); | |
| 384 | + float3 rock = deep(.06, f) * (.08 + .3 * fbm2(pc * 4, 3)) * (.5 + .5 * smoothstep(0.f, .3f, edge)); | |
| 385 | + float under = smoothstep(2.2f, .6f, floorDistance); | |
| 386 | + rock += paint(.35, f) * under * .12; | |
| 387 | + rock += paint(.3, f) * plateBand * .1 * smoothstep(.0f, .25f, edge) * (.5 + .5 * fbm2(pc * 4 + 7, 2)); | |
| 388 | + float3 color = rock + paint(.34 + .32 * heat + plateBand * .12, f) * (crack * 1.2 + heat * .5) * flicker * (1 + plateBand * 1.4); | |
| 389 | + float riverHalf = .52 + .07 * sin(zw * .8 + c.t * .4) + .04 * sin(zw * 2.1 - c.t * .7); | |
| 390 | + float riverMask = smoothstep(riverHalf + .04, riverHalf - .04, floorDistance); | |
| 391 | + if (riverMask > 0) { | |
| 392 | + float X = d.x * z; | |
| 393 | + float2 rp = float2(X * 1.7, (zw + c.t * 1.6 + c.m * 1.2) * .7) * cs; | |
| 394 | + float2 rw = float2(fbm2(rp * .8 + float2(0, c.t * .3), 3), fbm2(rp * .8 + float2(4.3, -c.t * .25), 3)); | |
| 395 | + float rn = fbm2(rp * 1.2 + rw * 2.4, 4); | |
| 396 | + float crust = smoothstep(.45f, .55f, rn); | |
| 397 | + float3 molten = paint(.3 + .36 * smoothstep(.5f, .2f, rn), f) * (.8 + .7 * smoothstep(.5f, .2f, rn)); | |
| 398 | + float3 river = mix(molten * (1 + c.b.x * .9), deep(.1, f) * .2 + paint(.35, f) * .15, crust * .9); | |
| 399 | + color = mix(color, river, riverMask); | |
| 400 | + } | |
| 401 | + color += paint(.7, f) * exp(-abs(floorDistance - riverHalf) * 14) * (.6 + c.b.y * 1.2); | |
| 402 | + // Embers drifting toward the camera. | |
| 403 | + for (int i = 0; i < 2; ++i) { | |
| 404 | + float rho = .5 + .3 * float(i); | |
| 405 | + float ze = rho / r; | |
| 406 | + if (ze < .3) continue; | |
| 407 | + float count = 30 + 10 * float(i); | |
| 408 | + float swirl = theta + c.t * (.12 + .05 * float(i)) + c.m * .1; | |
| 409 | + float2 ec = float2(swirl / TAU * count, (ze + drive + c.t * .5) * 2.5); | |
| 410 | + float2 eid = floor(ec); | |
| 411 | + eid.x -= count * floor(eid.x / count); | |
| 412 | + float eh = hash21(eid + float(i) * 37); | |
| 413 | + float2 el = fract(ec) - .5 - (hash22(eid) - .5) * .5; | |
| 414 | + float density = .05 + .3 * c.b.w; | |
| 415 | + float ember = smoothstep(.16f, 0.f, length(el)) * smoothstep(density, density - .04f, eh); | |
| 416 | + color += paint(.8, f) * ember * 2 * smoothstep(.3f, .8f, ze) * exp(-ze * .25); | |
| 417 | + } | |
| 418 | + // Attack: lava spurts from vents in the river. | |
| 419 | + float h = tnAttack(c); | |
| 420 | + const float ventSpacing = 6; | |
| 421 | + float base = floor(drive / ventSpacing); | |
| 422 | + for (int k = 1; k <= 3; ++k) { | |
| 423 | + float ventDepth = (base + float(k)) * ventSpacing - drive; | |
| 424 | + if (ventDepth < .6) continue; | |
| 425 | + float vx = (hash11(base + float(k)) - .5) * .8; | |
| 426 | + float2 foot = float2(vx, -.9) / ventDepth; | |
| 427 | + float height = (.3 + .9 * h) / ventDepth; | |
| 428 | + float2 q = d - foot; | |
| 429 | + float column = exp(-abs(q.x) / (.06 / ventDepth)) * smoothstep(height, 0.f, q.y) * smoothstep(-.02f / ventDepth, 0.f, q.y); | |
| 430 | + float splash = exp(-length(q - float2(0, height)) / (.1 / ventDepth)); | |
| 431 | + color += paint(.75, f) * (column * 2.5 + splash * 1.5) * c.hit; | |
| 432 | + } | |
| 433 | + float3 smoke = deep(.3, f) * .3 + paint(.55, f) * exp(-r * 5) * .8; | |
| 434 | + return mix(smoke, color, tnFog(z, c, .04)); | |
| 435 | + } | |
| 436 | + | |
| 437 | + // ---------------------------------------------------------------- 106 Data Conduit | |
| 438 | + // A cylindrical circuit board: traces, vias and chips in deep tones, with data packets | |
| 439 | + // racing along the traces in both directions. Each trace layer's packet density follows | |
| 440 | + // its own band; attacks fire a broad packet burst out of the vanishing point. | |
| 441 | + float3 dataConduit(Ctx c, constant NativeFrame &f) { | |
| 442 | + float2 vanish = tnDrift(c.t * .8, float2(.22, .14)); | |
| 443 | + float2 d = tnBend(c.uv, vanish); | |
| 444 | + float r = max(length(d), 1e-3f), a = atan2(d.y, d.x) + c.t * .05; | |
| 445 | + float z = 1 / r; | |
| 446 | + const float speed = 3.4, N = 72; | |
| 447 | + // Forward drive: zoom travel plus the music clock. | |
| 448 | + float zw = z + c.travel * speed + c.m * .8; | |
| 449 | + float2 g = float2(a / TAU * N, zw * N / TAU); | |
| 450 | + float2 cell = floor(g), local = fract(g) - .5; | |
| 451 | + float cx = cell.x - N * floor(cell.x / N); | |
| 452 | + float2 fw = fwidth(g); | |
| 453 | + float blur = smoothstep(.3f, .9f, max(fw.x, fw.y)); | |
| 454 | + float tw = .09 * c.size; | |
| 455 | + // Board layout. | |
| 456 | + float segRow = cell.y - 9 * floor(cell.y / 9); | |
| 457 | + float laneOn = step(hash11(cx * 1.37 + 2), .58) * step(hash21(float2(cx, floor(cell.y / 9))), .85); | |
| 458 | + float lane = laneOn * (1 - smoothstep(tw - fw.x, tw + fw.x, abs(local.x))); | |
| 459 | + float crossRow = step(hash11(cell.y * .731 + 4), .3); | |
| 460 | + float crossOn = crossRow * step(hash21(float2(floor(cx / 4), cell.y) + 5), .45); | |
| 461 | + float crossLine = crossOn * (1 - smoothstep(tw - fw.y, tw + fw.y, abs(local.y))); | |
| 462 | + float viaAt = max(laneOn * step(segRow, .5), laneOn * crossOn); | |
| 463 | + float viaRing = abs(length(local) - .2); | |
| 464 | + float via = viaAt * (1 - smoothstep(.07f - fw.x, .07f + fw.x, viaRing)); | |
| 465 | + float traces = max(max(lane, crossLine), via); | |
| 466 | + float2 chipLocal = float2(cx - 14 * floor(cx / 14) - 4 + local.x + .5, cell.y - 15 * floor(cell.y / 15) - 5 + local.y + .5); | |
| 467 | + float chipOn = step(hash21(float2(floor(cx / 14), floor(cell.y / 15)) + 11), .7); | |
| 468 | + float chipBody = sdBox2(chipLocal - float2(3, 2.5), float2(2.6, 2.0)); | |
| 469 | + float pinRow = step(abs(abs(chipLocal.y - 2.5) - 2.35), .3) * step(abs(chipLocal.x - 3), 2.3f); | |
| 470 | + float pins = pinRow * step(abs(fract(chipLocal.x * 2) - .5), .2); | |
| 471 | + // Each trace layer glows with its own band; board sectors are backlit by theirs. | |
| 472 | + float layer = floor(hash11(cx * 3.7 + 1) * 4); | |
| 473 | + float band = c.b[int(layer)]; | |
| 474 | + float rowBand = c.b[int(hash11(cell.y * .61 + 2) * 3.99)]; | |
| 475 | + float sectorBand = c.b[int(hash21(float2(floor(cx / 6), floor(cell.y / 6)) + 21) * 3.99)]; | |
| 476 | + float3 board = deep(.3, f) * .15 * (.85 + .3 * hash21(float2(floor(cx / 2), floor(cell.y / 2)) + 3)) * (1 + sectorBand * 1.6); | |
| 477 | + float3 copper = deep(.6, f) * .7; | |
| 478 | + float traceGlow = max(lane * (1 + band * 2.2), max(crossLine * (1 + rowBand * 2.2), via * (1 + band * 1.5))); | |
| 479 | + float3 color = board + copper * traceGlow * (1 - chipOn * step(chipBody, .4f)); | |
| 480 | + if (chipOn > 0) { | |
| 481 | + float bodyMask = 1 - smoothstep(-fw.x, fw.x, chipBody); | |
| 482 | + float chipBand = c.b[int(hash21(float2(floor(cx / 14), floor(cell.y / 15)) + 5) * 3.99)]; | |
| 483 | + float3 chip = deep(.12, f) * .12 + paint(.45 + chipBand * .2, f) * exp(-abs(chipBody) * (14 - 7 * chipBand)) * (.45 + chipBand * 1.2); | |
| 484 | + chip += paint(.35, f) * .2 * step(abs(chipLocal.y - 2.5), .1f) * step(abs(chipLocal.x - 3), 1.4f); | |
| 485 | + color = mix(color, chip, bodyMask); | |
| 486 | + color += copper * 1.1 * pins * (1 - bodyMask); | |
| 487 | + } | |
| 488 | + // Packets racing along the depth lanes, one band per trace layer; the music clock | |
| 489 | + // speeds them up. | |
| 490 | + float dir = hash11(cx * 5.3 + 7) < .5 ? -1 : 1; | |
| 491 | + float rate = 2 + 3 * hash11(cx * 9.1); | |
| 492 | + float pos = (g.y - dir * (c.t * 1.5 + c.m * 1.2) * rate) / 6; | |
| 493 | + float slot = floor(pos), fp = fract(pos); | |
| 494 | + float density = .22 + .6 * band; | |
| 495 | + float present = smoothstep(density, density - .1f, hash21(float2(cx, slot))); | |
| 496 | + float dash = smoothstep(0.f, .03f, fp) * smoothstep(.3f, .22f, fp); | |
| 497 | + float head = dir > 0 ? smoothstep(.12f, .3f, fp) : smoothstep(.15f, 0.f, fp); | |
| 498 | + float3 packetColor = paint(.55 + layer * .12, f); | |
| 499 | + float packet = present * dash * laneOn; | |
| 500 | + color += packetColor * packet * (exp(-abs(local.x) / (tw * .8)) * (1.5 + head * 1.8) + exp(-abs(local.x) * 5) * .25); | |
| 501 | + // Packets hopping around the ring traces. | |
| 502 | + float around = (g.x + (hash11(cell.y) < .5 ? -1 : 1) * (c.t * 3 + c.m * 2.5)) / 4; | |
| 503 | + float hopId = floor(around) - N / 4 * floor(floor(around) / (N / 4)); | |
| 504 | + float hop = crossOn * smoothstep(.25f, .15f, abs(fract(around) - .5)) * step(hash21(float2(hopId, cell.y)), .35f); | |
| 505 | + color += paint(.75, f) * hop * exp(-abs(local.y) / (tw * .8)) * 1.3; | |
| 506 | + // Attack: a packet burst spreading from the vanishing point. | |
| 507 | + float h = tnAttack(c); | |
| 508 | + float front = 1.2 + 5 * h; | |
| 509 | + float zone = smoothstep(front - .8, front, z) * sqrt(h); | |
| 510 | + float burst = smoothstep(.55f, 1.f, fract(g.y / 3 + c.t * 4)); | |
| 511 | + float3 average = board + copper * .3 + packetColor * density * .08; | |
| 512 | + color = mix(color, average, blur); | |
| 513 | + color += paint(.85, f) * zone * mix(max(lane, crossLine * .7) * (burst * 3 + .6), .5f, blur); | |
| 514 | + float3 core = paint(.5, f) * .5 + paint(.85, f) * exp(-r * 9) * 1.2; | |
| 515 | + return mix(core, color, tnFog(z, c, .03)); | |
| 516 | + } | |
| 517 | + | |
| 518 | + // ---------------------------------------------------------------- 107 Helix Stair | |
| 519 | + // Looking straight down a deep stairwell while descending the spiral. Each step's edge is a | |
| 520 | + // strip light, a handrail coils around the open well and the bottom fades into coloured | |
| 521 | + // mist. Bass rolls a swell of light down the steps, highs glint on the rail and attacks | |
| 522 | + // light a run of steps. | |
| 523 | + float3 helixStair(Ctx c, constant NativeFrame &f) { | |
| 524 | + float2 vanish = tnDrift(c.t * .6, float2(.1, .08)); | |
| 525 | + float2 d = tnBend(c.uv, vanish); | |
| 526 | + float r = max(length(d), 1e-4f), a = atan2(d.y, d.x); | |
| 527 | + const float R = 1, Ri = .4, S = 18; | |
| 528 | + float P = 1.7 * c.size; | |
| 529 | + // Descent: zoom travel plus the music clock, so energetic passages hurry down. | |
| 530 | + float descend = c.travel * .95 + c.m * .3; | |
| 531 | + float spin = descend / P * TAU * .45 + c.t * .06; | |
| 532 | + float theta = a + spin; | |
| 533 | + float stepF = theta * S / TAU; | |
| 534 | + float s0 = floor(stepF); | |
| 535 | + float frac = stepF - s0; | |
| 536 | + float z0 = s0 * P / S - descend; | |
| 537 | + float zWall = R / r; | |
| 538 | + float need = max(.18f, Ri / r); | |
| 539 | + float n = ceil((need - z0) / P); | |
| 540 | + float zs = z0 + n * P; | |
| 541 | + float stepId = s0 + n * S; | |
| 542 | + bool tread = zs * r <= R; | |
| 543 | + float zSurface = tread ? zs : zWall; | |
| 544 | + float h = tnAttack(c); | |
| 545 | + float3 color; | |
| 546 | + if (tread) { | |
| 547 | + float rho = zs * r; | |
| 548 | + float edgeScreen = (1 - frac) * TAU / S * r; | |
| 549 | + float wave = pow(.5 + .5 * sin(stepId * .42 - c.t * 3.2 - c.m * 3), 4.f); | |
| 550 | + float run = c.hit * smoothstep(P * (.6 + 2.6 * h), P * .4f, zs); | |
| 551 | + float stepBand = c.b[int(hash11(stepId * .37) * 3.99)]; | |
| 552 | + float level = .9 + c.b.x * 1.8 * wave + stepBand * 2.2 + run * 3; | |
| 553 | + float3 light = paint(stepId * .037 + .1 + stepBand * .2, f); | |
| 554 | + float plank = smoothstep(.0f, .04f, abs(fract((rho - Ri) / (R - Ri) * 3) - .5)); | |
| 555 | + float3 treadColor = deep(.25 + stepId * .011, f) * .16 * (.55 + .45 * frac) * (.7 + .3 * plank); | |
| 556 | + treadColor *= smoothstep(0.f, .25f, frac); | |
| 557 | + treadColor += light * exp(-(1 - frac) * TAU / S * rho * (30 - 16 * stepBand)) * .25 * level; | |
| 558 | + treadColor += light * (exp(-edgeScreen / .0035) * 2 + exp(-edgeScreen / .02) * .3) * level; | |
| 559 | + treadColor += paint(.6, f) * exp(-(rho - Ri) / zs / .006) * .4; | |
| 560 | + color = treadColor; | |
| 561 | + } else { | |
| 562 | + float above = floor((zWall - z0) / P); | |
| 563 | + float below = z0 + (above + 1) * P - zWall; | |
| 564 | + float groove = smoothstep(.06f, 0.f, abs(fract(theta * 12 / TAU) - .5) - .44); | |
| 565 | + float course = smoothstep(.0f, .05f, abs(fract((zWall + descend) * 2.2) - .5) - .42); | |
| 566 | + float belowId = s0 + (above + 1) * S; | |
| 567 | + float belowBand = c.b[int(hash11(belowId * .37) * 3.99)]; | |
| 568 | + float3 wallColor = (deep(.3, f) * .3 + paint(.4, f) * .1) * (1 - groove * .6) * (1 - course * .4); | |
| 569 | + wallColor += paint(.7 + c.b.z * .2, f) * groove * c.b.z * .5; | |
| 570 | + wallColor += paint(belowId * .037 + .1 + belowBand * .2, f) * exp(-below * (4 - 2 * belowBand)) * (.5 + belowBand * 1.4); | |
| 571 | + color = wallColor; | |
| 572 | + } | |
| 573 | + const float railHeight = .22; | |
| 574 | + float ramp = theta * P / TAU - descend - railHeight; | |
| 575 | + float nr = round((Ri / r - ramp) / P); | |
| 576 | + float zr = ramp + nr * P; | |
| 577 | + if (zr > .15 && zr < zSurface + .02) { | |
| 578 | + float railScreen = abs(r - Ri / zr); | |
| 579 | + float railW = .02 / zr; | |
| 580 | + float glint = pow(hash21(float2(floor(theta * 64 / TAU + nr * 64), 3)), 12.f) * pow(.5 + .5 * sin(c.t * 7 + theta * 30), 4.f); | |
| 581 | + color += paint(.85, f) * (exp(-railScreen / railW) * (1 + glint * c.b.w * 6 + c.b.w * .8) + exp(-railScreen / (railW * 5)) * (.2 + c.b.w * .4)); | |
| 582 | + } | |
| 583 | + float mist = 1 - exp(-zSurface * (.05 + c.fog * .14)); | |
| 584 | + float3 mistColor = paint(.58 + c.b.y * .25, f) * .32 + paint(.85, f) * exp(-r * 7) * .9; | |
| 585 | + return mix(color, mistColor, mist); | |
| 586 | + } | |
| 587 | + | |
| 588 | + // ---------------------------------------------------------------- 108 Mirror Regress | |
| 589 | + // An infinity mirror: nested rounded frames in the canvas shape recede forever, each lined | |
| 590 | + // with an LED strip in its own colour and tilted against its neighbours. Bands drive running | |
| 591 | + // lights along individual strips; attacks send a ripple of light inward through the frames. | |
| 592 | + | |
| 593 | + | |
| 594 | + // ---------------------------------------------------------------- 109 Laser Bore | |
| 595 | + // A bore built only of laser light: six fans of beams radiate from the vanishing point and | |
| 596 | + // counter-rotate, laser rings flash past and haze glows between. Each fan's brightness | |
| 597 | + // follows a band; attacks splay the uppermost fan open. | |
| 598 | + float3 laserBore(Ctx c, constant NativeFrame &f) { | |
| 599 | + float2 vanish = tnDrift(c.t * 1.1, float2(.25, .16)); | |
| 600 | + float2 d = tnBend(c.uv, vanish); | |
| 601 | + float r = max(length(d), 1e-3f), a = atan2(d.y, d.x); | |
| 602 | + float z = 1 / r; | |
| 603 | + const float speed = 3; | |
| 604 | + float zw = z + c.travel * speed; | |
| 605 | + float fog = tnFog(z, c, .02); | |
| 606 | + float haze = fbm3(float3(cos(a) * 1.5, sin(a) * 1.5, log(r) * 1.4 - c.t * .15), 3); | |
| 607 | + float3 color = deep(.15, f) * .07 + deep(.6, f) * .3 * haze * haze; | |
| 608 | + float3 scatter = 0; | |
| 609 | + for (int i = 0; i < 6; ++i) { | |
| 610 | + float fi = float(i); | |
| 611 | + float dir = (i & 1) ? -1.f : 1.f; | |
| 612 | + float centre = fi * TAU / 6 + dir * (c.t * (.18 + fi * .03) + c.travel * .03); | |
| 613 | + float top = .5 + .5 * cos(centre - PI * .5); | |
| 614 | + float spread = (.42 + .1 * sin(c.t * .4 + fi * 1.7)) * (1 + c.hit * 1.6 * pow(top, 4.f)); | |
| 615 | + const float M = 7; | |
| 616 | + float local = tnWrap(a - centre); | |
| 617 | + float spacing = spread / (M - 1); | |
| 618 | + float j = clamp(round(local / spacing + (M - 1) * .5), 0.f, M - 1); | |
| 619 | + float beamAngle = (j - (M - 1) * .5) * spacing; | |
| 620 | + float dist = r * abs(sin(local - beamAngle)); | |
| 621 | + float width = .0035 * c.size * (.25 + r); | |
| 622 | + float pulse = .6 + .4 * sin(zw * 1.7 - fi * 1.3 + j * 1.1); | |
| 623 | + float bright = (.5 + c.b[i & 3] * 1.8) * (.3 + .7 * fog) * pulse; | |
| 624 | + float3 beam = paint(fi * .17 + j * .02 + .05, f); | |
| 625 | + color += beam * exp(-dist / width) * 1.4 * bright; | |
| 626 | + scatter += beam * (exp(-dist / (width * 12 + .02)) + smoothstep(spread * .5f + .12f, spread * .5f - .04f, abs(local)) * .12) * bright; | |
| 627 | + } | |
| 628 | + color += scatter * (.07 + .2 * haze); | |
| 629 | + const float ringSpacing = 2.4; | |
| 630 | + float ringBase = floor(zw / ringSpacing + .5); | |
| 631 | + for (int k = -1; k <= 2; ++k) { | |
| 632 | + float id = ringBase + float(k); | |
| 633 | + float ringZ = id * ringSpacing - c.travel * speed; | |
| 634 | + if (ringZ < .2) continue; | |
| 635 | + float ringR = 1 / ringZ; | |
| 636 | + float dist = abs(r - ringR); | |
| 637 | + float width = .005 * ringR + c.px; | |
| 638 | + float3 ring = paint(hash11(id * 7.1) * .9 + .05, f); | |
| 639 | + color += ring * (exp(-dist / width) * 1.3 + exp(-dist / (width * 10)) * .2) * smoothstep(16.f, 5.f, ringZ); | |
| 640 | + } | |
| 641 | + color += paint(.9, f) * exp(-r * 10) * 1.1 + paint(.6, f) * exp(-r * 3) * .25; | |
| 642 | + return color; | |
| 643 | + } | |
| 644 | + | |
| 645 | + // ---------------------------------------------------------------- 110 Twist Checker | |
| 646 | + // A round tube of raised glossy checker tiles whose rings twist with depth and time. Bevels | |
| 647 | + // catch a sweeping specular light. Bass lifts individual tiles off the wall; attacks flip a | |
| 648 | + // ring of tiles to bright. | |
| 649 | + float3 tnCheckerWall(float a, float z, float N, float speed, Ctx c, constant NativeFrame &f) { | |
| 650 | + // Bass winds the twist tighter; the music clock speeds both twist and travel. | |
| 651 | + float twist = z * (.3 + .14 * c.b.x) + c.t * .22 + c.m * .15; | |
| 652 | + float drive = c.travel * speed + c.m * .6; | |
| 653 | + float zw = z + drive; | |
| 654 | + float2 uv = float2((a + twist) / TAU * N, zw * N / TAU); | |
| 655 | + float2 id = floor(uv), l = fract(uv); | |
| 656 | + float column = id.x - N * floor(id.x / N); | |
| 657 | + float parity = id.x + id.y - 2 * floor((id.x + id.y) * .5); | |
| 658 | + float ex = min(l.x, 1 - l.x), ey = min(l.y, 1 - l.y); | |
| 659 | + float e = min(ex, ey); | |
| 660 | + float top = smoothstep(0.f, .14f, e); | |
| 661 | + float2 slope = ex < ey ? float2(l.x < .5 ? -1 : 1, 0) : float2(0, l.y < .5 ? -1 : 1); | |
| 662 | + float2 lightDir = normalize(float2(cos(c.t * .4), .8)); | |
| 663 | + float facing = dot(slope, lightDir) * (1 - top); | |
| 664 | + // The two tones drift along the palette with the low-mid and high-mid bands. | |
| 665 | + float3 base = parity < .5 ? paint(.16 + c.b.y * .14, f) : paint(.64 + c.b.z * .14, f); | |
| 666 | + float rowBand = c.b[int(hash11(id.y * .71) * 3.99)]; | |
| 667 | + float3 color = base * (.27 + .23 * top + .42 * facing) * (.2 + .8 * smoothstep(0.f, .03f, e)) * (1 + rowBand * .5 * top); | |
| 668 | + float sweep = pow(max(cos(a - c.t * .7 - c.m * .8), 0.f), 18.f) * top; | |
| 669 | + color += paint(.95, f) * sweep * (.5 + c.b.w * 1.2); | |
| 670 | + float lift = c.b.x * smoothstep(.5f, .9f, hash21(float2(column, id.y))) * exp(-z * .2) * 1.2; | |
| 671 | + float side = step(l.y, lift * .45); | |
| 672 | + color = mix(color * (1 + lift * .9), base * .3, side); | |
| 673 | + color += paint(.9, f) * exp(-abs(l.y - lift * .45) * 40) * lift * .8; | |
| 674 | + float h = tnAttack(c); | |
| 675 | + float rowZ = (id.y + .5) * TAU / N - drive; | |
| 676 | + float front = 2.4 + 4 * (1 - h); | |
| 677 | + float flip = c.hit * exp(-pow((rowZ - front) / .5, 2.f)); | |
| 678 | + color = mix(color, paint(.92 + .08 * parity, f) * 1.6 * (.6 + .4 * top), clamp(flip, 0.f, .85f)); | |
| 679 | + float blur = smoothstep(.3f, .9f, fwidth(uv.y)); | |
| 680 | + return mix(color, (paint(.16, f) + paint(.64, f)) * .22, blur); | |
| 681 | + } | |
| 682 | + | |
| 683 | + float3 twistChecker(Ctx c, constant NativeFrame &f) { | |
| 684 | + float2 vanish = tnDrift(c.t, float2(.3, .2)); | |
| 685 | + float2 d = tnBend(c.uv, vanish); | |
| 686 | + float r = max(length(d), 1e-3f), a = atan2(d.y, d.x); | |
| 687 | + float z = 1 / r; | |
| 688 | + const float speed = 2.6; | |
| 689 | + float count = 12 / c.size; | |
| 690 | + float n0 = 2 * floor(count * .5); | |
| 691 | + float blend = fract(count * .5); | |
| 692 | + float3 color = tnCheckerWall(a, z, max(n0, 4.f), speed, c, f); | |
| 693 | + if (blend > .001) color = mix(color, tnCheckerWall(a, z, max(n0 + 2, 4.f), speed, c, f), blend); | |
| 694 | + color *= .47 + .38 * smoothstep(3.f, .6f, z); | |
| 695 | + float3 core = paint(.5, f) * .4 + paint(.85, f) * exp(-r * 8) * 1.1; | |
| 696 | + return mix(core, color, tnFog(z, c, .03)); | |
| 697 | + } | |
| 698 | + | |
| 699 | + // ---------------------------------------------------------------- 111 Foam Tube | |
| 700 | + // A tunnel of packed iridescent soap bubbles that drift and wobble: clear centres, swirling | |
| 701 | + // thin-film colour toward the rims and window highlights. Highs shimmer the small bubbles in | |
| 702 | + // the gaps, bass swells the near bubbles and attacks pop a ring of bubbles that then regrow. | |
| 703 | + float tnFoamCells(float2 p, float period, float phase, thread float2 &toSite, thread float2 &cellId, thread float &second) { | |
| 704 | + float2 cell = floor(p), fr = fract(p); | |
| 705 | + float first = 8; | |
| 706 | + second = 8; | |
| 707 | + for (int y = -1; y <= 1; ++y) for (int x = -1; x <= 1; ++x) { | |
| 708 | + float2 g = float2(x, y), id = cell + g; | |
| 709 | + float2 wrapped = float2(id.x - period * floor(id.x / period), id.y); | |
| 710 | + float2 seed = hash22(wrapped); | |
| 711 | + float2 site = g + .5 + .36 * sin(phase * (.6 + seed.yx * .8) + seed * TAU); | |
| 712 | + float2 v = site - fr; | |
| 713 | + float dd = dot(v, v); | |
| 714 | + if (dd < first) { second = first; first = dd; toSite = v; cellId = wrapped; } else if (dd < second) second = dd; | |
| 715 | + } | |
| 716 | + second = sqrt(second); | |
| 717 | + return sqrt(first); | |
| 718 | + } | |
| 719 | + | |
| 720 | + float3 tnFoamWall(float a, float z, float N, float speed, Ctx c, constant NativeFrame &f) { | |
| 721 | + float zw = z + c.travel * speed; | |
| 722 | + float2 p = float2((a / TAU + .5) * N + c.t * .05, zw * N / TAU + c.t * .12); | |
| 723 | + float2 toSite, cellId; | |
| 724 | + float second; | |
| 725 | + float first = tnFoamCells(p, N, c.t * .8, toSite, cellId, second); | |
| 726 | + float q = 2 * first / (first + second); | |
| 727 | + float cellZ = (cellId.y + .5 - c.t * .12) * TAU / N - c.travel * speed; | |
| 728 | + float h = tnAttack(c); | |
| 729 | + float front = 1.9 + 4 * (1 - h); | |
| 730 | + float pop = c.hit * exp(-pow((cellZ - front) / .7, 2.f)); | |
| 731 | + float swell = c.b.x * exp(-z * .5); | |
| 732 | + float radius = clamp(.93 + .06 * swell - pop * .8, .05f, 1.f); | |
| 733 | + float qn = q / radius; | |
| 734 | + float seed = hash21(cellId); | |
| 735 | + float3 backdrop = deep(.35 + .15 * sin(zw * .2), f) * .07; | |
| 736 | + float3 color = backdrop * .6; | |
| 737 | + if (qn < 1) { | |
| 738 | + float nz = sqrt(1 - qn * qn); | |
| 739 | + float thickness = .2 + .7 * (1 - nz) + .35 * noise2(toSite * 3 + seed * 17 + c.t * .3) + c.t * .04 + seed * 2; | |
| 740 | + float3 film = filmColor(thickness, f); | |
| 741 | + float fresnel = pow(qn, 9.f); | |
| 742 | + float swirl = pow(.5 + .5 * sin(thickness * 13 + c.t * .5), 6.f) * (1 - fresnel); | |
| 743 | + color = backdrop + film * (.03 + 1.1 * fresnel + .14 * swirl); | |
| 744 | + float2 rel = -toSite / radius; | |
| 745 | + float2 w0 = rel - float2(-.17, .2); | |
| 746 | + float window = exp(-dot(w0, w0) * 160) * 1.2 + exp(-dot(rel - float2(.2, -.22), rel - float2(.2, -.22)) * 400) * .4; | |
| 747 | + color += paint(.95, f) * window * (1 - pop); | |
| 748 | + } | |
| 749 | + float rimLine = exp(-abs(qn - 1) * 45); | |
| 750 | + color += filmColor(seed * 1.7 + c.t * .05 + .4, f) * rimLine * (.55 + pop * 4); | |
| 751 | + float2 sp = p * 3 + float2(0, c.t * .2); | |
| 752 | + float2 sid = floor(sp); | |
| 753 | + sid.x -= 3 * N * floor(sid.x / (3 * N)); | |
| 754 | + float sh = hash21(sid + 13); | |
| 755 | + float sr = length(fract(sp) - .5 - (hash22(sid) - .5) * .3) / (.12 + .1 * hash11(sh * 9)); | |
| 756 | + float small = exp(-abs(sr - 1) * 6) * step(.45f, sh) * smoothstep(.97f, 1.04f, qn); | |
| 757 | + float shimmer = .35 + c.b.w * 2.5 * pow(.5 + .5 * sin(c.t * 9 + sh * 40), 3.f); | |
| 758 | + color += filmColor(sh * 2 + c.t * .1, f) * small * shimmer * .8; | |
| 759 | + float blur = smoothstep(.35f, .9f, fwidth(p.y)); | |
| 760 | + return mix(color, filmColor(.5, f) * .2, blur); | |
| 761 | + } | |
| 762 | + | |
| 763 | + float3 foamTube(Ctx c, constant NativeFrame &f) { | |
| 764 | + float2 vanish = tnDrift(c.t * .7, float2(.26, .18)); | |
| 765 | + float2 d = tnBend(c.uv, vanish); | |
| 766 | + float r = max(length(d), 1e-3f), a = atan2(d.y, d.x); | |
| 767 | + float z = 1 / r; | |
| 768 | + const float speed = 1.5; | |
| 769 | + float count = 13 / c.size; | |
| 770 | + float n0 = floor(count); | |
| 771 | + float blend = fract(count); | |
| 772 | + float3 color = tnFoamWall(a, z, max(n0, 4.f), speed, c, f); | |
| 773 | + if (blend > .001) color = mix(color, tnFoamWall(a, z, max(n0 + 1, 4.f), speed, c, f), blend); | |
| 774 | + float3 core = filmColor(.3 + c.t * .02, f) * .35 + paint(.9, f) * exp(-r * 8); | |
| 775 | + return mix(core, color, tnFog(z, c, .03)) * .78; | |
| 776 | + } | |
| 777 | + | |
| 778 | + // ---------------------------------------------------------------- 112 Polygon Stack | |
| 779 | + // A receding stack of thick neon polygon outlines that morph between three and six sides, | |
| 780 | + // each turned a little further than the one before so the stack twists into a tunnel. Bass | |
| 781 | + // thickens the near outlines, highs add an echo outline and attacks kick one layer's spin. | |
| 782 | + // Regular polygon distance (unit circumradius) from polar coordinates. | |
| 783 | + float tnPolygon(float radius, float a, float sides) { | |
| 784 | + float sector = TAU / sides; | |
| 785 | + float local = a - sector * floor(a / sector + .5); | |
| 786 | + return radius * cos(local) - cos(PI / sides); | |
| 787 | + } | |
| 788 | + float tnPolygonMorph(float radius, float a, float sides) { | |
| 789 | + float n0 = floor(sides); | |
| 790 | + return mix(tnPolygon(radius, a, n0), tnPolygon(radius, a, n0 + 1), smoothstep(0.f, 1.f, sides - n0)); | |
| 791 | + } | |
| 792 | + | |
| 793 | + float3 polygonStack(Ctx c, constant NativeFrame &f) { | |
| 794 | + float2 vanish = tnDrift(c.t * .8, float2(.3, .2)); | |
| 795 | + float r = length(c.uv - vanish); | |
| 796 | + float haze = fbm2(rot(c.uv - vanish, c.t * .05) * 1.5 + float2(0, -c.travel * .3), 3); | |
| 797 | + float3 color = deep(.3, f) * (.06 + .06 * haze) + paint(.6, f) * exp(-r * 2.5) * .15; | |
| 798 | + float3 hot = paint(.95, f) * .06; | |
| 799 | + const int layers = 22; | |
| 800 | + for (int k = 0; k < layers; ++k) { | |
| 801 | + float2 slot = layerSlot(k, layers, c.travel * .19); | |
| 802 | + float phase = slot.x, id = slot.y; | |
| 803 | + float fade = layerFade(phase); | |
| 804 | + if (fade <= 0) continue; | |
| 805 | + float scale = layerScale(phase, 5); | |
| 806 | + float2 centre = vanish * (1 - phase) * (1 - phase); | |
| 807 | + float kick = c.hit * exp(-pow((phase - .72) / .07, 2.f)) * 1.4; | |
| 808 | + float angle = id * .13 + c.t * .12 + kick; | |
| 809 | + const float size = 3.2; | |
| 810 | + float2 q = c.uv - centre; | |
| 811 | + float sides = 4.5 + 1.5 * sin(id * .61 + c.t * .23); | |
| 812 | + float dist = tnPolygonMorph(length(q) * scale / size, atan2(q.y, q.x) + angle, sides) * size / scale; | |
| 813 | + float radius = size / scale; | |
| 814 | + float width = radius * (.007 + .014 * c.b.x * phase * phase) * c.size + c.px * .5; | |
| 815 | + if (abs(dist) > width * 26) continue; | |
| 816 | + float core = 1 - smoothstep(width - c.px, width + c.px, abs(dist)); | |
| 817 | + float halo = exp(-abs(dist) / (width * 3)); | |
| 818 | + float echo = exp(-abs(dist + width * 4) / (width * .35 + c.px)) * c.b.w * 1.6; | |
| 819 | + float3 tint = paint(id * .19 + .05 + phase * .1, f); | |
| 820 | + color += (tint * (core * .6 + halo * .07 + echo) + hot * core) * fade; | |
| 821 | + } | |
| 822 | + return color; | |
| 823 | + } | |
| 824 | + | |
| 825 | + // ---------------------------------------------------------------- 113 Gyroid Caverns | |
| 826 | + // A raymarched flight through a gyroid lattice with a corridor carved along the camera's | |
| 827 | + // path. Glowing contour bands wrap the surfaces under soft subsurface light and fog. Bass | |
| 828 | + // thickens the bands, highs sparkle on the surfaces, attacks send a glow wave outward from | |
| 829 | + // the camera. | |
| 830 | + float2 tnCavernPath(float z) { return float2(sin(z * .21) * 1.1 + sin(z * .09) * .7, cos(z * .17) * .9); } | |
| 831 | + float tnCavern(float3 p, float s, float wall, thread float &g) { | |
| 832 | + float3 q = p / s; | |
| 833 | + g = dot(sin(q), cos(q.yzx)); | |
| 834 | + float shell = (abs(g) - wall) * s * .5; | |
| 835 | + float tunnel = 1.1 - length(p.xy - tnCavernPath(p.z)); | |
| 836 | + return max(shell, tunnel); | |
| 837 | + } | |
| 838 | + | |
| 839 | + float3 gyroidCaverns(Ctx c, constant NativeFrame &f) { | |
| 840 | + float s = .7 * c.size; | |
| 841 | + // The lattice walls swell with the bass; the flight speeds up with the music clock. | |
| 842 | + float wall = .22 + .09 * c.b.x; | |
| 843 | + float zc = c.travel * 1.4 + c.m * .35; | |
| 844 | + float3 ro = float3(tnCavernPath(zc), zc); | |
| 845 | + float3 target = float3(tnCavernPath(zc + 2), zc + 2); | |
| 846 | + float3 rd = cameraRay(c.uv, target - ro, float3(sin(c.t * .13) * .5, 1, 0), 1.1); | |
| 847 | + float t = .05, glowSum = 0, g = 0; | |
| 848 | + bool hit = false; | |
| 849 | + for (int i = 0; i < 72; ++i) { | |
| 850 | + float3 p = ro + rd * t; | |
| 851 | + float dd = tnCavern(p, s, wall, g); | |
| 852 | + glowSum += exp(-max(dd, 0.f) * 14) * .01; | |
| 853 | + if (dd < .0015 * t) { hit = true; break; } | |
| 854 | + t += dd * .85; | |
| 855 | + if (t > 22) break; | |
| 856 | + } | |
| 857 | + float3 fogColor = deep(.5, f) * .06 + paint(.55, f) * .05; | |
| 858 | + float3 color = fogColor; | |
| 859 | + if (hit) { | |
| 860 | + float3 p = ro + rd * t; | |
| 861 | + const float2 e = float2(.004, -.004); | |
| 862 | + float dummy; | |
| 863 | + float3 nrm = normalize(e.xyy * tnCavern(p + e.xyy, s, wall, dummy) + e.yyx * tnCavern(p + e.yyx, s, wall, dummy) | |
| 864 | + + e.yxy * tnCavern(p + e.yxy, s, wall, dummy) + e.xxx * tnCavern(p + e.xxx, s, wall, dummy)); | |
| 865 | + float3 q = p / s; | |
| 866 | + float level = dot(cos(q * 1.3), sin(q.zxy * 1.3)); | |
| 867 | + float contour = abs(fract(level * 1.25 + c.t * .06 + c.m * .15) - .5); | |
| 868 | + float width = .035 + .06 * c.b.x; | |
| 869 | + float band = 1 - smoothstep(width * .5f, width, contour); | |
| 870 | + float bandGlow = exp(-contour * 9); | |
| 871 | + float diffuse = max(dot(nrm, -rd), 0.f); | |
| 872 | + float rim = pow(1 - diffuse, 2.f); | |
| 873 | + float occlusion = clamp(tnCavern(p + nrm * .35, s, wall, dummy) / .35, 0.f, 1.f); | |
| 874 | + float3 base = deep(.2 + level * .1 + c.b.y * .25, f) * (.05 + .45 * diffuse) * (.3 + .7 * occlusion); | |
| 875 | + base += paint(.4 + level * .1 + c.b.z * .25, f) * rim * (.3 + c.b.z * .6); | |
| 876 | + base += paint(.75 + .1 * level, f) * (band * 1.5 + bandGlow * (.25 + .7 * c.b.x)); | |
| 877 | + float3 sparkCell = floor(p * 9); | |
| 878 | + float3 sparkOffset = fract(p * 9) - .5 - (hash33(sparkCell) - .5) * .5; | |
| 879 | + float sparkle = step(.93f, hash31(sparkCell)) * exp(-dot(sparkOffset, sparkOffset) * 60) * pow(.5 + .5 * sin(c.t * 8 + dot(sparkCell, float3(7, 11, 13))), 4.f); | |
| 880 | + base += paint(.95, f) * sparkle * c.b.w * 4; | |
| 881 | + float h = tnAttack(c); | |
| 882 | + float waveDistance = 2.5 + 8 * (1 - h); | |
| 883 | + base += paint(.9, f) * c.hit * exp(-pow((t - waveDistance) * 2.5, 2.f)) * 1.6; | |
| 884 | + color = mix(fogColor, base, exp(-t * (.05 + c.fog * .12))); | |
| 885 | + } | |
| 886 | + return (color + paint(.6, f) * glowSum * (.5 + c.b.z * .9)) * .88; | |
| 887 | + } | |
| 888 | + | |
| 889 | + // ---------------------------------------------------------------- 114 Spectrum Bore | |
| 890 | + // A tube built from equalizer bars: every column of the wall extrudes inward to a height set | |
| 891 | + // by the bands (lows on the floor, highs on the ceiling, mixes between), ring after ring | |
| 892 | + // receding with travel. Bar faces are segmented like LED meters with bright peak caps. | |
| 893 | + // With no music the bars still breathe on a slow wave. | |
| 894 | + float tnBarLevel(float column, float ring, float angle, Ctx c) { | |
| 895 | + float x = (sin(angle) * .5 + .5) * 3; | |
| 896 | + int i0 = int(min(floor(x), 2.f)); | |
| 897 | + float band = mix(c.b[i0], c.b[i0 + 1], x - float(i0)); | |
| 898 | + float h = hash21(float2(column, ring)); | |
| 899 | + float breathe = .5 + .5 * sin(c.t * 1.9 + column * .8 + ring * .55); | |
| 900 | + return .08 + .12 * breathe * (.6 + .4 * h) + band * (.18 + .26 * h); | |
| 901 | + } | |
| 902 | + // Attack lift for one ring of bars that rides away from the camera as the attack decays. | |
| 903 | + float tnBarKick(float ring, float travel, float spacing, Ctx c) { | |
| 904 | + float front = 1.6 + 5 * (1 - tnAttack(c)); | |
| 905 | + return c.hit * .22 * exp(-pow((ring * spacing - travel - front) / spacing, 2.f)); | |
| 906 | + } | |
| 907 | + | |
| 908 | + float3 spectrumBore(Ctx c, constant NativeFrame &f) { | |
| 909 | + float2 vanish = tnDrift(c.t * .9, float2(.24, .15)); | |
| 910 | + float2 d = tnBend(c.uv, vanish); | |
| 911 | + float r = max(length(d), 1e-3f), a = atan2(d.y, d.x); | |
| 912 | + const float columns = 28, spacing = .9, barLength = .5, speed = 2.4, segment = .045; | |
| 913 | + float travel = c.travel * speed; | |
| 914 | + float colF = (a + PI) / TAU * columns; | |
| 915 | + float column = floor(colF); | |
| 916 | + float fa = colF - column - .5; | |
| 917 | + float columnAngle = (column + .5) / columns * TAU - PI; | |
| 918 | + float barHalf = min(.36 * c.size, .48f); | |
| 919 | + float zWall = 1 / r; | |
| 920 | + int hitType = 0; | |
| 921 | + float zHit = zWall, level = 0, ringId = 0; | |
| 922 | + if (abs(fa) < barHalf) { | |
| 923 | + float zMin = .3 / r; | |
| 924 | + float first = floor((zMin + travel) / spacing); | |
| 925 | + for (int m = 0; m < 10; ++m) { | |
| 926 | + float ring = first + float(m); | |
| 927 | + float zs = ring * spacing - travel, ze = zs + barLength; | |
| 928 | + if (zs > zWall) break; | |
| 929 | + if (ze < .05) continue; | |
| 930 | + float lv = tnBarLevel(column, ring, columnAngle, c) + tnBarKick(ring, travel, spacing, c); | |
| 931 | + float zc = (1 - lv) / r; | |
| 932 | + if (zc < zs) { | |
| 933 | + if (zs * r <= 1 && zs > .05) { hitType = 2; zHit = zs; level = lv; ringId = ring; } | |
| 934 | + break; | |
| 935 | + } | |
| 936 | + if (zc <= ze) { hitType = 1; zHit = zc; level = lv; ringId = ring; break; } | |
| 937 | + } | |
| 938 | + } | |
| 939 | + float side = smoothstep(barHalf, barHalf * .6f, abs(fa)); | |
| 940 | + float3 color; | |
| 941 | + if (hitType == 1) { | |
| 942 | + float along = (zHit - (ringId * spacing - travel)) / barLength; | |
| 943 | + float3 barTint = paint(.05 + level * 1.5, f); | |
| 944 | + float outline = 1 - smoothstep(.0f, .12f, barHalf - abs(fa)) * 1; | |
| 945 | + color = barTint * (.05 + .1 * (1 - along)) + barTint * outline * .5 * (1 - along * .6); | |
| 946 | + color += paint(.95, f) * exp(-along * 30) * .7 + barTint * exp(-(1 - along) * 25) * .3; | |
| 947 | + } else if (hitType == 2) { | |
| 948 | + float height = 1 - zHit * r; | |
| 949 | + float cells = height / segment; | |
| 950 | + float blur = fwidth(cells); | |
| 951 | + float lit = smoothstep(.12f, .12f + blur + .05f, fract(cells)) * smoothstep(.92f, .88f - blur, fract(cells)); | |
| 952 | + lit = mix(lit, .75f, smoothstep(.3f, 1.f, blur)); | |
| 953 | + float peak = exp(-(level - height) / (segment * .6)); | |
| 954 | + color = paint(.05 + height * 1.5, f) * (.12 + 1.2 * lit) * (.75 + .25 * side) + paint(.95, f) * peak * lit * .9; | |
| 955 | + } else { | |
| 956 | + float zw = zWall + travel; | |
| 957 | + float ring = floor(zw / spacing); | |
| 958 | + float u = zw - ring * spacing; | |
| 959 | + float lvNext = tnBarLevel(column, ring + 1, columnAngle, c); | |
| 960 | + float lvHere = tnBarLevel(column, ring, columnAngle, c); | |
| 961 | + float columnLight = smoothstep(.55f, .1f, abs(fa)); | |
| 962 | + color = deep(.35, f) * .04 * (.6 + .4 * columnLight); | |
| 963 | + color += paint(.05 + lvNext * 1.5, f) * exp(-(spacing - u) * 6) * .3 * columnLight; | |
| 964 | + color += paint(.05 + lvHere * 1.5, f) * .06 * step(u, barLength) * columnLight; | |
| 965 | + color += paint(.5, f) * .1 * exp(-abs(u - barLength) * 30 / max(fwidth(zw) * 8, 1.f)); | |
| 966 | + } | |
| 967 | + float3 core = paint(.6, f) * .35 + paint(.85, f) * exp(-r * 8) * 1.1; | |
| 968 | + return mix(core, color, tnFog(zHit, c, .03)); | |
| 969 | + } | |
| 970 | + | |
| 971 | + // ---------------------------------------------------------------- 115 Ribbon Vortex | |
| 972 | + // Broad translucent silk ribbons spiral together into a tube, each at its own radius and | |
| 973 | + // corkscrew rate, folding softly and overlapping in additive light. Bass widens the ribbons, | |
| 974 | + // highs sparkle along their edges and attacks ripple their edges outward. | |
| 975 | + | |
| 976 | + | |
| 977 | + // ---------------------------------------------------------------- 116 Gate Run | |
| 978 | + // Flying down an endless avenue of tall lacquered arch gates on a gently curving path over | |
| 979 | + // a mirror-dark floor, each gate hung with glowing lanterns against a horizon glow. Bass | |
| 980 | + // swings the lanterns, highs flicker their flames and attacks light a gate's beam trim. | |
| 981 | + | |
| 982 | + | |
| 983 | + // Gate facade at world position (X, Y) on its plane: rgb, opacity and additive lantern glow. | |
| 984 | + | |
| 985 | + | |
| 986 | + #define TUNNEL_EFFECTS(X) X(plasmaBore) X(ledCorridor) X(prismShaft) X(hyperloop) X(barrelWave) X(magmaTube) X(dataConduit) X(helixStair) X(laserBore) X(twistChecker) X(foamTube) X(polygonStack) X(gyroidCaverns) X(spectrumBore) | |
| 987 | + TUNNEL_EFFECTS(NATIVE_EFFECT) | |
| 988 | + | |
| 989 | + // Coaster versions: the same designs riding the roller-coaster course. | |
| 990 | + NATIVE_COASTER(plasmaBore, 100, false) | |
| 991 | + NATIVE_COASTER(ledCorridor, 101, true) | |
| 992 | + NATIVE_COASTER(magmaTube, 105, false) | |
| 993 | + NATIVE_COASTER(dataConduit, 106, false) | |
| 994 | + NATIVE_COASTER(helixStair, 107, false) | |
| 995 | + NATIVE_COASTER(laserBore, 109, false) | |
| 996 | + NATIVE_COASTER(twistChecker, 110, false) | |
| 997 | + NATIVE_COASTER(foamTube, 111, false) | |
| 998 | + NATIVE_COASTER(spectrumBore, 114, false) |
Sources/PulseCanvas/Resources/NativeVisualizers.json added
| 1 | + { | |
| 2 | + "schema": 1, | |
| 3 | + "nativeCount": 462, | |
| 4 | + "activeCount": 342, | |
| 5 | + "effects": [ | |
| 6 | + { | |
| 7 | + "id": "native:0", | |
| 8 | + "scene": 0, | |
| 9 | + "name": "Prism Wake", | |
| 10 | + "icon": "pyramid", | |
| 11 | + "retired": true, | |
| 12 | + "replacement": "native:20" | |
| 13 | + }, | |
| 14 | + { | |
| 15 | + "id": "native:1", | |
| 16 | + "scene": 1, | |
| 17 | + "name": "Lumen Veil", | |
| 18 | + "icon": "sun.haze", | |
| 19 | + "retired": true, | |
| 20 | + "replacement": "native:10" | |
| 21 | + }, | |
| 22 | + { | |
| 23 | + "id": "native:2", | |
| 24 | + "scene": 2, | |
| 25 | + "name": "Pulse Well", | |
| 26 | + "icon": "circle.circle", | |
| 27 | + "retired": true, | |
| 28 | + "replacement": "native:22" | |
| 29 | + }, | |
| 30 | + { | |
| 31 | + "id": "native:3", | |
| 32 | + "scene": 3, | |
| 33 | + "name": "Velvet Passage", | |
| 34 | + "icon": "torus", | |
| 35 | + "retired": true, | |
| 36 | + "replacement": "native:29" | |
| 37 | + }, | |
| 38 | + { | |
| 39 | + "id": "native:4", | |
| 40 | + "scene": 4, | |
| 41 | + "name": "Bead Surge", | |
| 42 | + "icon": "circle.grid.hex", | |
| 43 | + "retired": true, | |
| 44 | + "replacement": "native:101" | |
| 45 | + }, | |
| 46 | + { | |
| 47 | + "id": "native:5", | |
| 48 | + "scene": 5, | |
| 49 | + "name": "Facet Flow", | |
| 50 | + "icon": "diamond", | |
| 51 | + "retired": true, | |
| 52 | + "replacement": "native:23" | |
| 53 | + }, | |
| 54 | + { | |
| 55 | + "id": "native:6", | |
| 56 | + "scene": 6, | |
| 57 | + "name": "Glass Current", | |
| 58 | + "icon": "circle.square", | |
| 59 | + "retired": true, | |
| 60 | + "replacement": "native:29" | |
| 61 | + }, | |
| 62 | + { | |
| 63 | + "id": "native:7", | |
| 64 | + "scene": 7, | |
| 65 | + "name": "Contour Flux", | |
| 66 | + "icon": "waveform.path", | |
| 67 | + "retired": true, | |
| 68 | + "replacement": "native:17" | |
| 69 | + }, | |
| 70 | + { | |
| 71 | + "id": "native:8", | |
| 72 | + "scene": 8, | |
| 73 | + "name": "Recursive Corridor", | |
| 74 | + "icon": "square.stack.3d.up", | |
| 75 | + "retired": true, | |
| 76 | + "replacement": "native:22" | |
| 77 | + }, | |
| 78 | + { | |
| 79 | + "id": "native:9", | |
| 80 | + "scene": 9, | |
| 81 | + "name": "Spiral Tide", | |
| 82 | + "icon": "hurricane", | |
| 83 | + "retired": true, | |
| 84 | + "replacement": "native:25" | |
| 85 | + }, | |
| 86 | + { | |
| 87 | + "id": "native:10", | |
| 88 | + "scene": 10, | |
| 89 | + "name": "Aurora Fold", | |
| 90 | + "icon": "sun.horizon" | |
| 91 | + }, | |
| 92 | + { | |
| 93 | + "id": "native:11", | |
| 94 | + "scene": 11, | |
| 95 | + "name": "Petal Passage", | |
| 96 | + "icon": "rosette", | |
| 97 | + "retired": true, | |
| 98 | + "replacement": "native:15" | |
| 99 | + }, | |
| 100 | + { | |
| 101 | + "id": "native:12", | |
| 102 | + "scene": 12, | |
| 103 | + "name": "Pearl Terrain", | |
| 104 | + "icon": "circle.hexagongrid" | |
| 105 | + }, | |
| 106 | + { | |
| 107 | + "id": "native:13", | |
| 108 | + "scene": 13, | |
| 109 | + "name": "Vapor Run", | |
| 110 | + "icon": "wind", | |
| 111 | + "retired": true, | |
| 112 | + "replacement": "native:10" | |
| 113 | + }, | |
| 114 | + { | |
| 115 | + "id": "native:14", | |
| 116 | + "scene": 14, | |
| 117 | + "name": "Scatter Flight", | |
| 118 | + "icon": "point.3.connected.trianglepath.dotted", | |
| 119 | + "retired": true, | |
| 120 | + "replacement": "native:101" | |
| 121 | + }, | |
| 122 | + { | |
| 123 | + "id": "native:15", | |
| 124 | + "scene": 15, | |
| 125 | + "name": "Lotus Resonance", | |
| 126 | + "icon": "asterisk" | |
| 127 | + }, | |
| 128 | + { | |
| 129 | + "id": "native:16", | |
| 130 | + "scene": 16, | |
| 131 | + "name": "Orbit Loom", | |
| 132 | + "icon": "atom" | |
| 133 | + }, | |
| 134 | + { | |
| 135 | + "id": "native:17", | |
| 136 | + "scene": 17, | |
| 137 | + "name": "Silk Current", | |
| 138 | + "icon": "wave.3.right" | |
| 139 | + }, | |
| 140 | + { | |
| 141 | + "id": "native:18", | |
| 142 | + "scene": 18, | |
| 143 | + "name": "Double Twist", | |
| 144 | + "icon": "infinity" | |
| 145 | + }, | |
| 146 | + { | |
| 147 | + "id": "native:19", | |
| 148 | + "scene": 19, | |
| 149 | + "name": "Arc Spray", | |
| 150 | + "icon": "burst" | |
| 151 | + }, | |
| 152 | + { | |
| 153 | + "id": "native:20", | |
| 154 | + "scene": 20, | |
| 155 | + "name": "Signal Tiles", | |
| 156 | + "icon": "square.grid.3x3" | |
| 157 | + }, | |
| 158 | + { | |
| 159 | + "id": "native:21", | |
| 160 | + "scene": 21, | |
| 161 | + "name": "Resonant Shell", | |
| 162 | + "icon": "snowflake" | |
| 163 | + }, | |
| 164 | + { | |
| 165 | + "id": "native:22", | |
| 166 | + "scene": 22, | |
| 167 | + "name": "Octagon Vault", | |
| 168 | + "icon": "circle.hexagonpath" | |
| 169 | + }, | |
| 170 | + { | |
| 171 | + "id": "native:23", | |
| 172 | + "scene": 23, | |
| 173 | + "name": "Mercury Fold", | |
| 174 | + "icon": "drop" | |
| 175 | + }, | |
| 176 | + { | |
| 177 | + "id": "native:24", | |
| 178 | + "scene": 24, | |
| 179 | + "name": "Voltage Weave", | |
| 180 | + "icon": "bolt.horizontal" | |
| 181 | + }, | |
| 182 | + { | |
| 183 | + "id": "native:25", | |
| 184 | + "scene": 25, | |
| 185 | + "name": "Ink Cyclone", | |
| 186 | + "icon": "tornado" | |
| 187 | + }, | |
| 188 | + { | |
| 189 | + "id": "native:26", | |
| 190 | + "scene": 26, | |
| 191 | + "name": "Prism Rain", | |
| 192 | + "icon": "rainbow" | |
| 193 | + }, | |
| 194 | + { | |
| 195 | + "id": "native:27", | |
| 196 | + "scene": 27, | |
| 197 | + "name": "Monolith Rush", | |
| 198 | + "icon": "cube" | |
| 199 | + }, | |
| 200 | + { | |
| 201 | + "id": "native:28", | |
| 202 | + "scene": 28, | |
| 203 | + "name": "Halo Engine", | |
| 204 | + "icon": "circle.dotted.circle" | |
| 205 | + }, | |
| 206 | + { | |
| 207 | + "id": "native:29", | |
| 208 | + "scene": 29, | |
| 209 | + "name": "Tidal Glass", | |
| 210 | + "icon": "water.waves" | |
| 211 | + }, | |
| 212 | + { | |
| 213 | + "id": "native:30", | |
| 214 | + "scene": 30, | |
| 215 | + "name": "Grid Vortex", | |
| 216 | + "icon": "squareshape.dashed.squareshape", | |
| 217 | + "retired": true, | |
| 218 | + "replacement": "native:22" | |
| 219 | + }, | |
| 220 | + { | |
| 221 | + "id": "native:31", | |
| 222 | + "scene": 31, | |
| 223 | + "name": "Silk Cascade", | |
| 224 | + "icon": "scribble" | |
| 225 | + }, | |
| 226 | + { | |
| 227 | + "id": "native:32", | |
| 228 | + "scene": 32, | |
| 229 | + "name": "Chrome Reef", | |
| 230 | + "icon": "circle.hexagongrid.fill" | |
| 231 | + }, | |
| 232 | + { | |
| 233 | + "id": "native:33", | |
| 234 | + "scene": 33, | |
| 235 | + "name": "Ribbon Foundry", | |
| 236 | + "icon": "scribble.variable" | |
| 237 | + }, | |
| 238 | + { | |
| 239 | + "id": "native:34", | |
| 240 | + "scene": 34, | |
| 241 | + "name": "Electric Orchard", | |
| 242 | + "icon": "tree", | |
| 243 | + "retired": true, | |
| 244 | + "replacement": "native:101" | |
| 245 | + }, | |
| 246 | + { | |
| 247 | + "id": "native:35", | |
| 248 | + "scene": 35, | |
| 249 | + "name": "Glass Mosaic", | |
| 250 | + "icon": "rectangle.split.3x3", | |
| 251 | + "retired": true, | |
| 252 | + "replacement": "native:101" | |
| 253 | + }, | |
| 254 | + { | |
| 255 | + "id": "native:36", | |
| 256 | + "scene": 36, | |
| 257 | + "name": "Graviton Petals", | |
| 258 | + "icon": "camera.macro", | |
| 259 | + "retired": true, | |
| 260 | + "replacement": "native:101" | |
| 261 | + }, | |
| 262 | + { | |
| 263 | + "id": "native:37", | |
| 264 | + "scene": 37, | |
| 265 | + "name": "Ion Cathedral", | |
| 266 | + "icon": "building.columns", | |
| 267 | + "retired": true, | |
| 268 | + "replacement": "native:101" | |
| 269 | + }, | |
| 270 | + { | |
| 271 | + "id": "native:38", | |
| 272 | + "scene": 38, | |
| 273 | + "name": "Velvet Circuit", | |
| 274 | + "icon": "cpu", | |
| 275 | + "retired": true, | |
| 276 | + "replacement": "native:101" | |
| 277 | + }, | |
| 278 | + { | |
| 279 | + "id": "native:39", | |
| 280 | + "scene": 39, | |
| 281 | + "name": "Lunar Loom", | |
| 282 | + "icon": "moon", | |
| 283 | + "retired": true, | |
| 284 | + "replacement": "native:101" | |
| 285 | + }, | |
| 286 | + { | |
| 287 | + "id": "native:40", | |
| 288 | + "scene": 40, | |
| 289 | + "name": "Lava Estuary", | |
| 290 | + "icon": "flame", | |
| 291 | + "retired": true, | |
| 292 | + "replacement": "native:101" | |
| 293 | + }, | |
| 294 | + { | |
| 295 | + "id": "native:41", | |
| 296 | + "scene": 41, | |
| 297 | + "name": "Photon Rapids", | |
| 298 | + "icon": "sparkles", | |
| 299 | + "retired": true, | |
| 300 | + "replacement": "native:101" | |
| 301 | + }, | |
| 302 | + { | |
| 303 | + "id": "native:42", | |
| 304 | + "scene": 42, | |
| 305 | + "name": "Sonic Topography", | |
| 306 | + "icon": "map" | |
| 307 | + }, | |
| 308 | + { | |
| 309 | + "id": "native:43", | |
| 310 | + "scene": 43, | |
| 311 | + "name": "Prismatic Dunes", | |
| 312 | + "icon": "mountain.2" | |
| 313 | + }, | |
| 314 | + { | |
| 315 | + "id": "native:44", | |
| 316 | + "scene": 44, | |
| 317 | + "name": "Honeycomb Tide", | |
| 318 | + "icon": "hexagon", | |
| 319 | + "retired": true, | |
| 320 | + "replacement": "native:101" | |
| 321 | + }, | |
| 322 | + { | |
| 323 | + "id": "native:45", | |
| 324 | + "scene": 45, | |
| 325 | + "name": "Nebula Nursery", | |
| 326 | + "icon": "sparkle", | |
| 327 | + "retired": true, | |
| 328 | + "replacement": "native:101" | |
| 329 | + }, | |
| 330 | + { | |
| 331 | + "id": "native:46", | |
| 332 | + "scene": 46, | |
| 333 | + "name": "Crystal Orchard", | |
| 334 | + "icon": "triangle" | |
| 335 | + }, | |
| 336 | + { | |
| 337 | + "id": "native:47", | |
| 338 | + "scene": 47, | |
| 339 | + "name": "Opal Tessera", | |
| 340 | + "icon": "seal" | |
| 341 | + }, | |
| 342 | + { | |
| 343 | + "id": "native:48", | |
| 344 | + "scene": 48, | |
| 345 | + "name": "Velvet Nebula", | |
| 346 | + "icon": "cloud" | |
| 347 | + }, | |
| 348 | + { | |
| 349 | + "id": "native:49", | |
| 350 | + "scene": 49, | |
| 351 | + "name": "Arc Foundry", | |
| 352 | + "icon": "bolt.circle", | |
| 353 | + "retired": true, | |
| 354 | + "replacement": "native:101" | |
| 355 | + }, | |
| 356 | + { | |
| 357 | + "id": "native:50", | |
| 358 | + "scene": 50, | |
| 359 | + "name": "Magnetic Ballet", | |
| 360 | + "icon": "oval" | |
| 361 | + }, | |
| 362 | + { | |
| 363 | + "id": "native:51", | |
| 364 | + "scene": 51, | |
| 365 | + "name": "Paper Cascades", | |
| 366 | + "icon": "square.3.layers.3d", | |
| 367 | + "retired": true, | |
| 368 | + "replacement": "native:101" | |
| 369 | + }, | |
| 370 | + { | |
| 371 | + "id": "native:52", | |
| 372 | + "scene": 52, | |
| 373 | + "name": "Diamond Undertow", | |
| 374 | + "icon": "rhombus", | |
| 375 | + "retired": true, | |
| 376 | + "replacement": "native:101" | |
| 377 | + }, | |
| 378 | + { | |
| 379 | + "id": "native:53", | |
| 380 | + "scene": 53, | |
| 381 | + "name": "Fractal Canopy", | |
| 382 | + "icon": "arrow.triangle.branch", | |
| 383 | + "retired": true, | |
| 384 | + "replacement": "native:101" | |
| 385 | + }, | |
| 386 | + { | |
| 387 | + "id": "native:54", | |
| 388 | + "scene": 54, | |
| 389 | + "name": "Gyroscopic Garden", | |
| 390 | + "icon": "rotate.3d", | |
| 391 | + "retired": true, | |
| 392 | + "replacement": "native:101" | |
| 393 | + }, | |
| 394 | + { | |
| 395 | + "id": "native:55", | |
| 396 | + "scene": 55, | |
| 397 | + "name": "Bubble Choir", | |
| 398 | + "icon": "bubbles.and.sparkles", | |
| 399 | + "retired": true, | |
| 400 | + "replacement": "native:101" | |
| 401 | + }, | |
| 402 | + { | |
| 403 | + "id": "native:56", | |
| 404 | + "scene": 56, | |
| 405 | + "name": "Laser Origami", | |
| 406 | + "icon": "paperplane", | |
| 407 | + "retired": true, | |
| 408 | + "replacement": "native:101" | |
| 409 | + }, | |
| 410 | + { | |
| 411 | + "id": "native:57", | |
| 412 | + "scene": 57, | |
| 413 | + "name": "Echo Lanterns", | |
| 414 | + "icon": "lightbulb", | |
| 415 | + "retired": true, | |
| 416 | + "replacement": "native:101" | |
| 417 | + }, | |
| 418 | + { | |
| 419 | + "id": "native:58", | |
| 420 | + "scene": 58, | |
| 421 | + "name": "Kelp Cathedral", | |
| 422 | + "icon": "leaf", | |
| 423 | + "retired": true, | |
| 424 | + "replacement": "native:101" | |
| 425 | + }, | |
| 426 | + { | |
| 427 | + "id": "native:59", | |
| 428 | + "scene": 59, | |
| 429 | + "name": "Solar Filigree", | |
| 430 | + "icon": "sun.max", | |
| 431 | + "retired": true, | |
| 432 | + "replacement": "native:101" | |
| 433 | + }, | |
| 434 | + { | |
| 435 | + "id": "native:60", | |
| 436 | + "scene": 60, | |
| 437 | + "name": "Mandel Bloom", | |
| 438 | + "icon": "circle.dashed" | |
| 439 | + }, | |
| 440 | + { | |
| 441 | + "id": "native:61", | |
| 442 | + "scene": 61, | |
| 443 | + "name": "Menger Nave", | |
| 444 | + "icon": "square.grid.3x3.fill" | |
| 445 | + }, | |
| 446 | + { | |
| 447 | + "id": "native:62", | |
| 448 | + "scene": 62, | |
| 449 | + "name": "Apollonian Foam", | |
| 450 | + "icon": "circle.grid.3x3", | |
| 451 | + "retired": true, | |
| 452 | + "replacement": "native:101" | |
| 453 | + }, | |
| 454 | + { | |
| 455 | + "id": "native:63", | |
| 456 | + "scene": 63, | |
| 457 | + "name": "Hyperbolic Rosette", | |
| 458 | + "icon": "smallcircle.filled.circle", | |
| 459 | + "retired": true, | |
| 460 | + "replacement": "native:101" | |
| 461 | + }, | |
| 462 | + { | |
| 463 | + "id": "native:64", | |
| 464 | + "scene": 64, | |
| 465 | + "name": "Quasicrystal Bloom", | |
| 466 | + "icon": "staroflife" | |
| 467 | + }, | |
| 468 | + { | |
| 469 | + "id": "native:65", | |
| 470 | + "scene": 65, | |
| 471 | + "name": "Tesseract Garden", | |
| 472 | + "icon": "cube.transparent", | |
| 473 | + "retired": true, | |
| 474 | + "replacement": "native:101" | |
| 475 | + }, | |
| 476 | + { | |
| 477 | + "id": "native:66", | |
| 478 | + "scene": 66, | |
| 479 | + "name": "Harmonograph", | |
| 480 | + "icon": "lasso", | |
| 481 | + "retired": true, | |
| 482 | + "replacement": "native:101" | |
| 483 | + }, | |
| 484 | + { | |
| 485 | + "id": "native:67", | |
| 486 | + "scene": 67, | |
| 487 | + "name": "Moire Engine", | |
| 488 | + "icon": "circle.lefthalf.filled", | |
| 489 | + "retired": true, | |
| 490 | + "replacement": "native:101" | |
| 491 | + }, | |
| 492 | + { | |
| 493 | + "id": "native:68", | |
| 494 | + "scene": 68, | |
| 495 | + "name": "Riley Undulation", | |
| 496 | + "icon": "line.3.horizontal", | |
| 497 | + "retired": true, | |
| 498 | + "replacement": "native:101" | |
| 499 | + }, | |
| 500 | + { | |
| 501 | + "id": "native:69", | |
| 502 | + "scene": 69, | |
| 503 | + "name": "Kaleido Chamber", | |
| 504 | + "icon": "camera.aperture", | |
| 505 | + "retired": true, | |
| 506 | + "replacement": "native:101" | |
| 507 | + }, | |
| 508 | + { | |
| 509 | + "id": "native:70", | |
| 510 | + "scene": 70, | |
| 511 | + "name": "Girih Lattice", | |
| 512 | + "icon": "star", | |
| 513 | + "retired": true, | |
| 514 | + "replacement": "native:101" | |
| 515 | + }, | |
| 516 | + { | |
| 517 | + "id": "native:71", | |
| 518 | + "scene": 71, | |
| 519 | + "name": "Gear Works", | |
| 520 | + "icon": "gearshape.2", | |
| 521 | + "retired": true, | |
| 522 | + "replacement": "native:101" | |
| 523 | + }, | |
| 524 | + { | |
| 525 | + "id": "native:72", | |
| 526 | + "scene": 72, | |
| 527 | + "name": "Piston Hall", | |
| 528 | + "icon": "engine.combustion" | |
| 529 | + }, | |
| 530 | + { | |
| 531 | + "id": "native:73", | |
| 532 | + "scene": 73, | |
| 533 | + "name": "Orrery Engine", | |
| 534 | + "icon": "globe", | |
| 535 | + "retired": true, | |
| 536 | + "replacement": "native:101" | |
| 537 | + }, | |
| 538 | + { | |
| 539 | + "id": "native:74", | |
| 540 | + "scene": 74, | |
| 541 | + "name": "Space Frame", | |
| 542 | + "icon": "square.split.diagonal.2x2" | |
| 543 | + }, | |
| 544 | + { | |
| 545 | + "id": "native:75", | |
| 546 | + "scene": 75, | |
| 547 | + "name": "Brutalist Shift", | |
| 548 | + "icon": "building.2", | |
| 549 | + "retired": true, | |
| 550 | + "replacement": "native:101" | |
| 551 | + }, | |
| 552 | + { | |
| 553 | + "id": "native:76", | |
| 554 | + "scene": 76, | |
| 555 | + "name": "Rose Window", | |
| 556 | + "icon": "rays", | |
| 557 | + "retired": true, | |
| 558 | + "replacement": "native:101" | |
| 559 | + }, | |
| 560 | + { | |
| 561 | + "id": "native:77", | |
| 562 | + "scene": 77, | |
| 563 | + "name": "Zen Rake", | |
| 564 | + "icon": "line.3.horizontal.decrease", | |
| 565 | + "retired": true, | |
| 566 | + "replacement": "native:101" | |
| 567 | + }, | |
| 568 | + { | |
| 569 | + "id": "native:78", | |
| 570 | + "scene": 78, | |
| 571 | + "name": "Ferrofluid Crown", | |
| 572 | + "icon": "drop.fill", | |
| 573 | + "retired": true, | |
| 574 | + "replacement": "native:101" | |
| 575 | + }, | |
| 576 | + { | |
| 577 | + "id": "native:79", | |
| 578 | + "scene": 79, | |
| 579 | + "name": "Windowpane Drizzle", | |
| 580 | + "icon": "cloud.rain" | |
| 581 | + }, | |
| 582 | + { | |
| 583 | + "id": "native:80", | |
| 584 | + "scene": 80, | |
| 585 | + "name": "Ink Bloom", | |
| 586 | + "icon": "paintbrush" | |
| 587 | + }, | |
| 588 | + { | |
| 589 | + "id": "native:81", | |
| 590 | + "scene": 81, | |
| 591 | + "name": "Oil Marble", | |
| 592 | + "icon": "swirl.circle.righthalf.filled" | |
| 593 | + }, | |
| 594 | + { | |
| 595 | + "id": "native:82", | |
| 596 | + "scene": 82, | |
| 597 | + "name": "Chladni Sand", | |
| 598 | + "icon": "dot.radiowaves.left.and.right", | |
| 599 | + "retired": true, | |
| 600 | + "replacement": "native:101" | |
| 601 | + }, | |
| 602 | + { | |
| 603 | + "id": "native:83", | |
| 604 | + "scene": 83, | |
| 605 | + "name": "Ripple Tank", | |
| 606 | + "icon": "circle.dotted" | |
| 607 | + }, | |
| 608 | + { | |
| 609 | + "id": "native:84", | |
| 610 | + "scene": 84, | |
| 611 | + "name": "Chrome Metaballs", | |
| 612 | + "icon": "drop.circle" | |
| 613 | + }, | |
| 614 | + { | |
| 615 | + "id": "native:85", | |
| 616 | + "scene": 85, | |
| 617 | + "name": "Ocean Swell", | |
| 618 | + "icon": "wave.3.forward" | |
| 619 | + }, | |
| 620 | + { | |
| 621 | + "id": "native:86", | |
| 622 | + "scene": 86, | |
| 623 | + "name": "Plexus Constellations", | |
| 624 | + "icon": "point.3.filled.connected.trianglepath.dotted" | |
| 625 | + }, | |
| 626 | + { | |
| 627 | + "id": "native:87", | |
| 628 | + "scene": 87, | |
| 629 | + "name": "Murmuration", | |
| 630 | + "icon": "bird", | |
| 631 | + "retired": true, | |
| 632 | + "replacement": "native:101" | |
| 633 | + }, | |
| 634 | + { | |
| 635 | + "id": "native:88", | |
| 636 | + "scene": 88, | |
| 637 | + "name": "Ring Shepherds", | |
| 638 | + "icon": "circle.grid.cross" | |
| 639 | + }, | |
| 640 | + { | |
| 641 | + "id": "native:89", | |
| 642 | + "scene": 89, | |
| 643 | + "name": "Pendulum Wave", | |
| 644 | + "icon": "metronome", | |
| 645 | + "retired": true, | |
| 646 | + "replacement": "native:101" | |
| 647 | + }, | |
| 648 | + { | |
| 649 | + "id": "native:90", | |
| 650 | + "scene": 90, | |
| 651 | + "name": "Firework Garden", | |
| 652 | + "icon": "fireworks", | |
| 653 | + "retired": true, | |
| 654 | + "replacement": "native:101" | |
| 655 | + }, | |
| 656 | + { | |
| 657 | + "id": "native:91", | |
| 658 | + "scene": 91, | |
| 659 | + "name": "Event Horizon", | |
| 660 | + "icon": "smallcircle.circle" | |
| 661 | + }, | |
| 662 | + { | |
| 663 | + "id": "native:92", | |
| 664 | + "scene": 92, | |
| 665 | + "name": "Atom Lattice", | |
| 666 | + "icon": "circle.grid.3x3.fill" | |
| 667 | + }, | |
| 668 | + { | |
| 669 | + "id": "native:93", | |
| 670 | + "scene": 93, | |
| 671 | + "name": "Mitosis Garden", | |
| 672 | + "icon": "allergens", | |
| 673 | + "retired": true, | |
| 674 | + "replacement": "native:101" | |
| 675 | + }, | |
| 676 | + { | |
| 677 | + "id": "native:94", | |
| 678 | + "scene": 94, | |
| 679 | + "name": "Neural Bloom", | |
| 680 | + "icon": "brain", | |
| 681 | + "retired": true, | |
| 682 | + "replacement": "native:101" | |
| 683 | + }, | |
| 684 | + { | |
| 685 | + "id": "native:95", | |
| 686 | + "scene": 95, | |
| 687 | + "name": "Jellyfish Abyss", | |
| 688 | + "icon": "umbrella", | |
| 689 | + "retired": true, | |
| 690 | + "replacement": "native:101" | |
| 691 | + }, | |
| 692 | + { | |
| 693 | + "id": "native:96", | |
| 694 | + "scene": 96, | |
| 695 | + "name": "Glacier Rift", | |
| 696 | + "icon": "snowflake.circle", | |
| 697 | + "retired": true, | |
| 698 | + "replacement": "native:101" | |
| 699 | + }, | |
| 700 | + { | |
| 701 | + "id": "native:97", | |
| 702 | + "scene": 97, | |
| 703 | + "name": "Firefly Meadow", | |
| 704 | + "icon": "moon.zzz", | |
| 705 | + "retired": true, | |
| 706 | + "replacement": "native:101" | |
| 707 | + }, | |
| 708 | + { | |
| 709 | + "id": "native:98", | |
| 710 | + "scene": 98, | |
| 711 | + "name": "Synth Horizon", | |
| 712 | + "icon": "sunset" | |
| 713 | + }, | |
| 714 | + { | |
| 715 | + "id": "native:99", | |
| 716 | + "scene": 99, | |
| 717 | + "name": "Neon Calligraphy", | |
| 718 | + "icon": "signature", | |
| 719 | + "retired": true, | |
| 720 | + "replacement": "native:101" | |
| 721 | + }, | |
| 722 | + { | |
| 723 | + "id": "native:100", | |
| 724 | + "scene": 100, | |
| 725 | + "name": "Plasma Bore", | |
| 726 | + "icon": "circle.dashed.inset.filled" | |
| 727 | + }, | |
| 728 | + { | |
| 729 | + "id": "native:101", | |
| 730 | + "scene": 101, | |
| 731 | + "name": "LED Corridor", | |
| 732 | + "icon": "square.grid.4x3.fill" | |
| 733 | + }, | |
| 734 | + { | |
| 735 | + "id": "native:102", | |
| 736 | + "scene": 102, | |
| 737 | + "name": "Prism Shaft", | |
| 738 | + "icon": "triangle.fill" | |
| 739 | + }, | |
| 740 | + { | |
| 741 | + "id": "native:103", | |
| 742 | + "scene": 103, | |
| 743 | + "name": "Hyperloop", | |
| 744 | + "icon": "tram.tunnel.fill" | |
| 745 | + }, | |
| 746 | + { | |
| 747 | + "id": "native:104", | |
| 748 | + "scene": 104, | |
| 749 | + "name": "Barrel Wave", | |
| 750 | + "icon": "wave.3.left" | |
| 751 | + }, | |
| 752 | + { | |
| 753 | + "id": "native:105", | |
| 754 | + "scene": 105, | |
| 755 | + "name": "Magma Tube", | |
| 756 | + "icon": "flame.fill" | |
| 757 | + }, | |
| 758 | + { | |
| 759 | + "id": "native:106", | |
| 760 | + "scene": 106, | |
| 761 | + "name": "Data Conduit", | |
| 762 | + "icon": "memorychip" | |
| 763 | + }, | |
| 764 | + { | |
| 765 | + "id": "native:107", | |
| 766 | + "scene": 107, | |
| 767 | + "name": "Helix Stair", | |
| 768 | + "icon": "stairs" | |
| 769 | + }, | |
| 770 | + { | |
| 771 | + "id": "native:108", | |
| 772 | + "scene": 108, | |
| 773 | + "name": "Mirror Regress", | |
| 774 | + "icon": "rectangle.on.rectangle", | |
| 775 | + "retired": true, | |
| 776 | + "replacement": "native:101" | |
| 777 | + }, | |
| 778 | + { | |
| 779 | + "id": "native:109", | |
| 780 | + "scene": 109, | |
| 781 | + "name": "Laser Bore", | |
| 782 | + "icon": "bolt.horizontal.fill" | |
| 783 | + }, | |
| 784 | + { | |
| 785 | + "id": "native:110", | |
| 786 | + "scene": 110, | |
| 787 | + "name": "Twist Checker", | |
| 788 | + "icon": "checkerboard.rectangle" | |
| 789 | + }, | |
| 790 | + { | |
| 791 | + "id": "native:111", | |
| 792 | + "scene": 111, | |
| 793 | + "name": "Foam Tube", | |
| 794 | + "icon": "bubbles.and.sparkles.fill" | |
| 795 | + }, | |
| 796 | + { | |
| 797 | + "id": "native:112", | |
| 798 | + "scene": 112, | |
| 799 | + "name": "Polygon Stack", | |
| 800 | + "icon": "pentagon" | |
| 801 | + }, | |
| 802 | + { | |
| 803 | + "id": "native:113", | |
| 804 | + "scene": 113, | |
| 805 | + "name": "Gyroid Caverns", | |
| 806 | + "icon": "aqi.medium" | |
| 807 | + }, | |
| 808 | + { | |
| 809 | + "id": "native:114", | |
| 810 | + "scene": 114, | |
| 811 | + "name": "Spectrum Bore", | |
| 812 | + "icon": "chart.bar.fill" | |
| 813 | + }, | |
| 814 | + { | |
| 815 | + "id": "native:115", | |
| 816 | + "scene": 115, | |
| 817 | + "name": "Ribbon Vortex", | |
| 818 | + "icon": "wind", | |
| 819 | + "retired": true, | |
| 820 | + "replacement": "native:101" | |
| 821 | + }, | |
| 822 | + { | |
| 823 | + "id": "native:116", | |
| 824 | + "scene": 116, | |
| 825 | + "name": "Gate Run", | |
| 826 | + "icon": "building.columns.fill", | |
| 827 | + "retired": true, | |
| 828 | + "replacement": "native:101" | |
| 829 | + }, | |
| 830 | + { | |
| 831 | + "id": "native:117", | |
| 832 | + "scene": 117, | |
| 833 | + "name": "Storm Eye", | |
| 834 | + "icon": "cloud.bolt.fill" | |
| 835 | + }, | |
| 836 | + { | |
| 837 | + "id": "native:118", | |
| 838 | + "scene": 118, | |
| 839 | + "name": "Sonar Pipe", | |
| 840 | + "icon": "dot.radiowaves.forward" | |
| 841 | + }, | |
| 842 | + { | |
| 843 | + "id": "native:119", | |
| 844 | + "scene": 119, | |
| 845 | + "name": "Cube Helix", | |
| 846 | + "icon": "cube.fill" | |
| 847 | + }, | |
| 848 | + { | |
| 849 | + "id": "native:120", | |
| 850 | + "scene": 120, | |
| 851 | + "name": "Phyllo Tube", | |
| 852 | + "icon": "camera.filters" | |
| 853 | + }, | |
| 854 | + { | |
| 855 | + "id": "native:121", | |
| 856 | + "scene": 121, | |
| 857 | + "name": "Tesla Tube", | |
| 858 | + "icon": "bolt.fill" | |
| 859 | + }, | |
| 860 | + { | |
| 861 | + "id": "native:122", | |
| 862 | + "scene": 122, | |
| 863 | + "name": "Fold Tunnel", | |
| 864 | + "icon": "paperplane.fill" | |
| 865 | + }, | |
| 866 | + { | |
| 867 | + "id": "native:123", | |
| 868 | + "scene": 123, | |
| 869 | + "name": "Vector Tube", | |
| 870 | + "icon": "cylinder.split.1x2" | |
| 871 | + }, | |
| 872 | + { | |
| 873 | + "id": "native:124", | |
| 874 | + "scene": 124, | |
| 875 | + "name": "Orbital Corridor", | |
| 876 | + "icon": "rectangle.split.3x1" | |
| 877 | + }, | |
| 878 | + { | |
| 879 | + "id": "native:125", | |
| 880 | + "scene": 125, | |
| 881 | + "name": "Mirrorball Tunnel", | |
| 882 | + "icon": "square.grid.3x3.square" | |
| 883 | + }, | |
| 884 | + { | |
| 885 | + "id": "native:126", | |
| 886 | + "scene": 126, | |
| 887 | + "name": "Fractal Throat", | |
| 888 | + "icon": "triangle.circle", | |
| 889 | + "retired": true, | |
| 890 | + "replacement": "native:101" | |
| 891 | + }, | |
| 892 | + { | |
| 893 | + "id": "native:127", | |
| 894 | + "scene": 127, | |
| 895 | + "name": "Chroma Pipe", | |
| 896 | + "icon": "capsule.fill" | |
| 897 | + }, | |
| 898 | + { | |
| 899 | + "id": "native:128", | |
| 900 | + "scene": 128, | |
| 901 | + "name": "Coral Burrow", | |
| 902 | + "icon": "leaf.fill", | |
| 903 | + "retired": true, | |
| 904 | + "replacement": "native:101" | |
| 905 | + }, | |
| 906 | + { | |
| 907 | + "id": "native:129", | |
| 908 | + "scene": 129, | |
| 909 | + "name": "Rainbow Slide", | |
| 910 | + "icon": "figure.pool.swim" | |
| 911 | + }, | |
| 912 | + { | |
| 913 | + "id": "native:130", | |
| 914 | + "scene": 130, | |
| 915 | + "name": "Pulse Arteries", | |
| 916 | + "icon": "heart.fill" | |
| 917 | + }, | |
| 918 | + { | |
| 919 | + "id": "native:131", | |
| 920 | + "scene": 131, | |
| 921 | + "name": "Zebra Warp", | |
| 922 | + "icon": "line.3.horizontal.circle" | |
| 923 | + }, | |
| 924 | + { | |
| 925 | + "id": "native:132", | |
| 926 | + "scene": 132, | |
| 927 | + "name": "Pixel Tunnel", | |
| 928 | + "icon": "square.grid.2x2.fill" | |
| 929 | + }, | |
| 930 | + { | |
| 931 | + "id": "native:133", | |
| 932 | + "scene": 133, | |
| 933 | + "name": "Geode Passage", | |
| 934 | + "icon": "diamond.fill" | |
| 935 | + }, | |
| 936 | + { | |
| 937 | + "id": "native:134", | |
| 938 | + "scene": 134, | |
| 939 | + "name": "Night Highway", | |
| 940 | + "icon": "car.fill", | |
| 941 | + "retired": true, | |
| 942 | + "replacement": "native:101" | |
| 943 | + }, | |
| 944 | + { | |
| 945 | + "id": "native:135", | |
| 946 | + "scene": 135, | |
| 947 | + "name": "Neon Boulevard", | |
| 948 | + "icon": "building.2.crop.circle", | |
| 949 | + "retired": true, | |
| 950 | + "replacement": "native:101" | |
| 951 | + }, | |
| 952 | + { | |
| 953 | + "id": "native:136", | |
| 954 | + "scene": 136, | |
| 955 | + "name": "Desert Interstate", | |
| 956 | + "icon": "sun.dust.fill", | |
| 957 | + "retired": true, | |
| 958 | + "replacement": "native:101" | |
| 959 | + }, | |
| 960 | + { | |
| 961 | + "id": "native:137", | |
| 962 | + "scene": 137, | |
| 963 | + "name": "Mountain Switchbacks", | |
| 964 | + "icon": "mountain.2.fill", | |
| 965 | + "retired": true, | |
| 966 | + "replacement": "native:101" | |
| 967 | + }, | |
| 968 | + { | |
| 969 | + "id": "native:138", | |
| 970 | + "scene": 138, | |
| 971 | + "name": "Sodium Tunnel", | |
| 972 | + "icon": "lightbulb.fill", | |
| 973 | + "retired": true, | |
| 974 | + "replacement": "native:101" | |
| 975 | + }, | |
| 976 | + { | |
| 977 | + "id": "native:139", | |
| 978 | + "scene": 139, | |
| 979 | + "name": "Coastal Cruise", | |
| 980 | + "icon": "beach.umbrella", | |
| 981 | + "retired": true, | |
| 982 | + "replacement": "native:101" | |
| 983 | + }, | |
| 984 | + { | |
| 985 | + "id": "native:140", | |
| 986 | + "scene": 140, | |
| 987 | + "name": "Long Exposure", | |
| 988 | + "icon": "timelapse", | |
| 989 | + "retired": true, | |
| 990 | + "replacement": "native:101" | |
| 991 | + }, | |
| 992 | + { | |
| 993 | + "id": "native:141", | |
| 994 | + "scene": 141, | |
| 995 | + "name": "Neon Trails", | |
| 996 | + "icon": "bicycle" | |
| 997 | + }, | |
| 998 | + { | |
| 999 | + "id": "native:142", | |
| 1000 | + "scene": 142, | |
| 1001 | + "name": "Rally Forest", | |
| 1002 | + "icon": "tree.fill", | |
| 1003 | + "retired": true, | |
| 1004 | + "replacement": "native:101" | |
| 1005 | + }, | |
| 1006 | + { | |
| 1007 | + "id": "native:143", | |
| 1008 | + "scene": 143, | |
| 1009 | + "name": "Bridge Run", | |
| 1010 | + "icon": "road.lanes", | |
| 1011 | + "retired": true, | |
| 1012 | + "replacement": "native:101" | |
| 1013 | + }, | |
| 1014 | + { | |
| 1015 | + "id": "native:144", | |
| 1016 | + "scene": 144, | |
| 1017 | + "name": "Coaster Loop", | |
| 1018 | + "icon": "point.topleft.down.curvedto.point.bottomright.up", | |
| 1019 | + "retired": true, | |
| 1020 | + "replacement": "native:101" | |
| 1021 | + }, | |
| 1022 | + { | |
| 1023 | + "id": "native:145", | |
| 1024 | + "scene": 145, | |
| 1025 | + "name": "Hover Lanes", | |
| 1026 | + "icon": "airplane", | |
| 1027 | + "retired": true, | |
| 1028 | + "replacement": "native:101" | |
| 1029 | + }, | |
| 1030 | + { | |
| 1031 | + "id": "native:146", | |
| 1032 | + "scene": 146, | |
| 1033 | + "name": "Bullet Train", | |
| 1034 | + "icon": "tram.fill", | |
| 1035 | + "retired": true, | |
| 1036 | + "replacement": "native:101" | |
| 1037 | + }, | |
| 1038 | + { | |
| 1039 | + "id": "native:147", | |
| 1040 | + "scene": 147, | |
| 1041 | + "name": "Apex Chase", | |
| 1042 | + "icon": "flag.checkered", | |
| 1043 | + "retired": true, | |
| 1044 | + "replacement": "native:101" | |
| 1045 | + }, | |
| 1046 | + { | |
| 1047 | + "id": "native:148", | |
| 1048 | + "scene": 148, | |
| 1049 | + "name": "Snow Drive", | |
| 1050 | + "icon": "cloud.snow.fill", | |
| 1051 | + "retired": true, | |
| 1052 | + "replacement": "native:101" | |
| 1053 | + }, | |
| 1054 | + { | |
| 1055 | + "id": "native:149", | |
| 1056 | + "scene": 149, | |
| 1057 | + "name": "Dashboard Glow", | |
| 1058 | + "icon": "gauge.with.dots.needle.67percent", | |
| 1059 | + "retired": true, | |
| 1060 | + "replacement": "native:101" | |
| 1061 | + }, | |
| 1062 | + { | |
| 1063 | + "id": "native:150", | |
| 1064 | + "scene": 150, | |
| 1065 | + "name": "Midnight Skyline", | |
| 1066 | + "icon": "building.2.fill", | |
| 1067 | + "retired": true, | |
| 1068 | + "replacement": "native:101" | |
| 1069 | + }, | |
| 1070 | + { | |
| 1071 | + "id": "native:151", | |
| 1072 | + "scene": 151, | |
| 1073 | + "name": "Orbit Freeway", | |
| 1074 | + "icon": "infinity.circle", | |
| 1075 | + "retired": true, | |
| 1076 | + "replacement": "native:101" | |
| 1077 | + }, | |
| 1078 | + { | |
| 1079 | + "id": "native:152", | |
| 1080 | + "scene": 152, | |
| 1081 | + "name": "Canyon Run", | |
| 1082 | + "icon": "map.fill", | |
| 1083 | + "retired": true, | |
| 1084 | + "replacement": "native:101" | |
| 1085 | + }, | |
| 1086 | + { | |
| 1087 | + "id": "native:153", | |
| 1088 | + "scene": 153, | |
| 1089 | + "name": "Interchange", | |
| 1090 | + "icon": "arrow.triangle.swap", | |
| 1091 | + "retired": true, | |
| 1092 | + "replacement": "native:101" | |
| 1093 | + }, | |
| 1094 | + { | |
| 1095 | + "id": "native:154", | |
| 1096 | + "scene": 154, | |
| 1097 | + "name": "Lean Angle", | |
| 1098 | + "icon": "scooter", | |
| 1099 | + "retired": true, | |
| 1100 | + "replacement": "native:101" | |
| 1101 | + }, | |
| 1102 | + { | |
| 1103 | + "id": "native:155", | |
| 1104 | + "scene": 155, | |
| 1105 | + "name": "Runway Rush", | |
| 1106 | + "icon": "airplane.departure", | |
| 1107 | + "retired": true, | |
| 1108 | + "replacement": "native:101" | |
| 1109 | + }, | |
| 1110 | + { | |
| 1111 | + "id": "native:156", | |
| 1112 | + "scene": 156, | |
| 1113 | + "name": "Wake Racer", | |
| 1114 | + "icon": "sailboat.fill", | |
| 1115 | + "retired": true, | |
| 1116 | + "replacement": "native:101" | |
| 1117 | + }, | |
| 1118 | + { | |
| 1119 | + "id": "native:157", | |
| 1120 | + "scene": 157, | |
| 1121 | + "name": "Bobsled Chute", | |
| 1122 | + "icon": "figure.skiing.downhill", | |
| 1123 | + "retired": true, | |
| 1124 | + "replacement": "native:101" | |
| 1125 | + }, | |
| 1126 | + { | |
| 1127 | + "id": "native:158", | |
| 1128 | + "scene": 158, | |
| 1129 | + "name": "Rail Rush", | |
| 1130 | + "icon": "train.side.front.car", | |
| 1131 | + "retired": true, | |
| 1132 | + "replacement": "native:101" | |
| 1133 | + }, | |
| 1134 | + { | |
| 1135 | + "id": "native:159", | |
| 1136 | + "scene": 159, | |
| 1137 | + "name": "Starlane Convoy", | |
| 1138 | + "icon": "moon.stars.fill", | |
| 1139 | + "retired": true, | |
| 1140 | + "replacement": "native:101" | |
| 1141 | + }, | |
| 1142 | + { | |
| 1143 | + "id": "native:160", | |
| 1144 | + "scene": 160, | |
| 1145 | + "name": "Marquee Strip", | |
| 1146 | + "icon": "star.circle.fill", | |
| 1147 | + "retired": true, | |
| 1148 | + "replacement": "native:101" | |
| 1149 | + }, | |
| 1150 | + { | |
| 1151 | + "id": "native:161", | |
| 1152 | + "scene": 161, | |
| 1153 | + "name": "Sky Causeway", | |
| 1154 | + "icon": "cloud.sun.fill", | |
| 1155 | + "retired": true, | |
| 1156 | + "replacement": "native:101" | |
| 1157 | + }, | |
| 1158 | + { | |
| 1159 | + "id": "native:162", | |
| 1160 | + "scene": 162, | |
| 1161 | + "name": "Turbine Road", | |
| 1162 | + "icon": "wind.circle.fill", | |
| 1163 | + "retired": true, | |
| 1164 | + "replacement": "native:101" | |
| 1165 | + }, | |
| 1166 | + { | |
| 1167 | + "id": "native:163", | |
| 1168 | + "scene": 163, | |
| 1169 | + "name": "Chevron Rush", | |
| 1170 | + "icon": "chevron.right.2", | |
| 1171 | + "retired": true, | |
| 1172 | + "replacement": "native:101" | |
| 1173 | + }, | |
| 1174 | + { | |
| 1175 | + "id": "native:164", | |
| 1176 | + "scene": 164, | |
| 1177 | + "name": "Street Circuit", | |
| 1178 | + "icon": "flag.2.crossed.fill", | |
| 1179 | + "retired": true, | |
| 1180 | + "replacement": "native:101" | |
| 1181 | + }, | |
| 1182 | + { | |
| 1183 | + "id": "native:165", | |
| 1184 | + "scene": 165, | |
| 1185 | + "name": "Glider Valley", | |
| 1186 | + "icon": "paperplane.circle.fill", | |
| 1187 | + "retired": true, | |
| 1188 | + "replacement": "native:101" | |
| 1189 | + }, | |
| 1190 | + { | |
| 1191 | + "id": "native:166", | |
| 1192 | + "scene": 166, | |
| 1193 | + "name": "Rocket Sled", | |
| 1194 | + "icon": "bolt.car.fill", | |
| 1195 | + "retired": true, | |
| 1196 | + "replacement": "native:101" | |
| 1197 | + }, | |
| 1198 | + { | |
| 1199 | + "id": "native:167", | |
| 1200 | + "scene": 167, | |
| 1201 | + "name": "Groove Tiles", | |
| 1202 | + "icon": "square.grid.3x3.topleft.filled", | |
| 1203 | + "retired": true, | |
| 1204 | + "replacement": "native:101" | |
| 1205 | + }, | |
| 1206 | + { | |
| 1207 | + "id": "native:168", | |
| 1208 | + "scene": 168, | |
| 1209 | + "name": "Mirror Ball", | |
| 1210 | + "icon": "light.beacon.max", | |
| 1211 | + "retired": true, | |
| 1212 | + "replacement": "native:101" | |
| 1213 | + }, | |
| 1214 | + { | |
| 1215 | + "id": "native:169", | |
| 1216 | + "scene": 169, | |
| 1217 | + "name": "Drone Ballet", | |
| 1218 | + "icon": "airplane.circle", | |
| 1219 | + "retired": true, | |
| 1220 | + "replacement": "native:101" | |
| 1221 | + }, | |
| 1222 | + { | |
| 1223 | + "id": "native:170", | |
| 1224 | + "scene": 170, | |
| 1225 | + "name": "Ribbon Gymnast", | |
| 1226 | + "icon": "figure.gymnastics", | |
| 1227 | + "retired": true, | |
| 1228 | + "replacement": "native:101" | |
| 1229 | + }, | |
| 1230 | + { | |
| 1231 | + "id": "native:171", | |
| 1232 | + "scene": 171, | |
| 1233 | + "name": "Laser Haze", | |
| 1234 | + "icon": "line.3.crossed.swirl.circle", | |
| 1235 | + "retired": true, | |
| 1236 | + "replacement": "native:101" | |
| 1237 | + }, | |
| 1238 | + { | |
| 1239 | + "id": "native:172", | |
| 1240 | + "scene": 172, | |
| 1241 | + "name": "Moving Heads", | |
| 1242 | + "icon": "light.cylindrical.ceiling.fill", | |
| 1243 | + "retired": true, | |
| 1244 | + "replacement": "native:101" | |
| 1245 | + }, | |
| 1246 | + { | |
| 1247 | + "id": "native:173", | |
| 1248 | + "scene": 173, | |
| 1249 | + "name": "Conga Orbs", | |
| 1250 | + "icon": "ellipsis.circle.fill", | |
| 1251 | + "retired": true, | |
| 1252 | + "replacement": "native:101" | |
| 1253 | + }, | |
| 1254 | + { | |
| 1255 | + "id": "native:174", | |
| 1256 | + "scene": 174, | |
| 1257 | + "name": "Headspin", | |
| 1258 | + "icon": "arrow.triangle.2.circlepath", | |
| 1259 | + "retired": true, | |
| 1260 | + "replacement": "native:101" | |
| 1261 | + }, | |
| 1262 | + { | |
| 1263 | + "id": "native:175", | |
| 1264 | + "scene": 175, | |
| 1265 | + "name": "Waltz Pairs", | |
| 1266 | + "icon": "figure.socialdance", | |
| 1267 | + "retired": true, | |
| 1268 | + "replacement": "native:101" | |
| 1269 | + }, | |
| 1270 | + { | |
| 1271 | + "id": "native:176", | |
| 1272 | + "scene": 176, | |
| 1273 | + "name": "Pigment Burst", | |
| 1274 | + "icon": "paintpalette.fill" | |
| 1275 | + }, | |
| 1276 | + { | |
| 1277 | + "id": "native:177", | |
| 1278 | + "scene": 177, | |
| 1279 | + "name": "Pirouette Bloom", | |
| 1280 | + "icon": "seal.fill", | |
| 1281 | + "retired": true, | |
| 1282 | + "replacement": "native:101" | |
| 1283 | + }, | |
| 1284 | + { | |
| 1285 | + "id": "native:178", | |
| 1286 | + "scene": 178, | |
| 1287 | + "name": "Stretch Membrane", | |
| 1288 | + "icon": "hand.raised.fill" | |
| 1289 | + }, | |
| 1290 | + { | |
| 1291 | + "id": "native:179", | |
| 1292 | + "scene": 179, | |
| 1293 | + "name": "Kinetic Mirrors", | |
| 1294 | + "icon": "squares.below.rectangle" | |
| 1295 | + }, | |
| 1296 | + { | |
| 1297 | + "id": "native:180", | |
| 1298 | + "scene": 180, | |
| 1299 | + "name": "Fire Dance", | |
| 1300 | + "icon": "flame.circle" | |
| 1301 | + }, | |
| 1302 | + { | |
| 1303 | + "id": "native:181", | |
| 1304 | + "scene": 181, | |
| 1305 | + "name": "Chiffon Swirl", | |
| 1306 | + "icon": "hurricane", | |
| 1307 | + "retired": true, | |
| 1308 | + "replacement": "native:101" | |
| 1309 | + }, | |
| 1310 | + { | |
| 1311 | + "id": "native:182", | |
| 1312 | + "scene": 182, | |
| 1313 | + "name": "Fountain Show", | |
| 1314 | + "icon": "humidity.fill" | |
| 1315 | + }, | |
| 1316 | + { | |
| 1317 | + "id": "native:183", | |
| 1318 | + "scene": 183, | |
| 1319 | + "name": "Glowstick Rave", | |
| 1320 | + "icon": "wand.and.stars" | |
| 1321 | + }, | |
| 1322 | + { | |
| 1323 | + "id": "native:184", | |
| 1324 | + "scene": 184, | |
| 1325 | + "name": "Smoke Rings", | |
| 1326 | + "icon": "smoke.fill" | |
| 1327 | + }, | |
| 1328 | + { | |
| 1329 | + "id": "native:185", | |
| 1330 | + "scene": 185, | |
| 1331 | + "name": "Wand Orbs", | |
| 1332 | + "icon": "camera.metering.spot" | |
| 1333 | + }, | |
| 1334 | + { | |
| 1335 | + "id": "native:186", | |
| 1336 | + "scene": 186, | |
| 1337 | + "name": "Faraday Dish", | |
| 1338 | + "icon": "aqi.low", | |
| 1339 | + "retired": true, | |
| 1340 | + "replacement": "native:101" | |
| 1341 | + }, | |
| 1342 | + { | |
| 1343 | + "id": "native:187", | |
| 1344 | + "scene": 187, | |
| 1345 | + "name": "String Resonance", | |
| 1346 | + "icon": "guitars.fill" | |
| 1347 | + }, | |
| 1348 | + { | |
| 1349 | + "id": "native:188", | |
| 1350 | + "scene": 188, | |
| 1351 | + "name": "Light Bars", | |
| 1352 | + "icon": "rectangle.split.1x2.fill" | |
| 1353 | + }, | |
| 1354 | + { | |
| 1355 | + "id": "native:189", | |
| 1356 | + "scene": 189, | |
| 1357 | + "name": "Sequin Curtain", | |
| 1358 | + "icon": "rectangle.grid.3x2.fill" | |
| 1359 | + }, | |
| 1360 | + { | |
| 1361 | + "id": "native:190", | |
| 1362 | + "scene": 190, | |
| 1363 | + "name": "Torsion Wave", | |
| 1364 | + "icon": "wave.3.backward", | |
| 1365 | + "retired": true, | |
| 1366 | + "replacement": "native:101" | |
| 1367 | + }, | |
| 1368 | + { | |
| 1369 | + "id": "native:191", | |
| 1370 | + "scene": 191, | |
| 1371 | + "name": "Spin Paint", | |
| 1372 | + "icon": "paintbrush.pointed.fill", | |
| 1373 | + "retired": true, | |
| 1374 | + "replacement": "native:101" | |
| 1375 | + }, | |
| 1376 | + { | |
| 1377 | + "id": "native:192", | |
| 1378 | + "scene": 192, | |
| 1379 | + "name": "Stadium Wave", | |
| 1380 | + "icon": "wave.3.right.circle.fill" | |
| 1381 | + }, | |
| 1382 | + { | |
| 1383 | + "id": "native:193", | |
| 1384 | + "scene": 193, | |
| 1385 | + "name": "Liquid Floor", | |
| 1386 | + "icon": "drop.circle.fill" | |
| 1387 | + }, | |
| 1388 | + { | |
| 1389 | + "id": "native:194", | |
| 1390 | + "scene": 194, | |
| 1391 | + "name": "Confetti Storm", | |
| 1392 | + "icon": "party.popper.fill", | |
| 1393 | + "retired": true, | |
| 1394 | + "replacement": "native:101" | |
| 1395 | + }, | |
| 1396 | + { | |
| 1397 | + "id": "native:195", | |
| 1398 | + "scene": 195, | |
| 1399 | + "name": "Bokeh Club", | |
| 1400 | + "icon": "circle.hexagonpath.fill", | |
| 1401 | + "retired": true, | |
| 1402 | + "replacement": "native:101" | |
| 1403 | + }, | |
| 1404 | + { | |
| 1405 | + "id": "native:196", | |
| 1406 | + "scene": 196, | |
| 1407 | + "name": "Persistence Fans", | |
| 1408 | + "icon": "fan.fill", | |
| 1409 | + "retired": true, | |
| 1410 | + "replacement": "native:101" | |
| 1411 | + }, | |
| 1412 | + { | |
| 1413 | + "id": "native:197", | |
| 1414 | + "scene": 197, | |
| 1415 | + "name": "Domino Run", | |
| 1416 | + "icon": "square.stack.3d.forward.dottedline.fill" | |
| 1417 | + }, | |
| 1418 | + { | |
| 1419 | + "id": "native:198", | |
| 1420 | + "scene": 198, | |
| 1421 | + "name": "Aerial Silks", | |
| 1422 | + "icon": "figure.climbing", | |
| 1423 | + "retired": true, | |
| 1424 | + "replacement": "native:101" | |
| 1425 | + }, | |
| 1426 | + { | |
| 1427 | + "id": "native:199", | |
| 1428 | + "scene": 199, | |
| 1429 | + "name": "Hula Hoops", | |
| 1430 | + "icon": "smallcircle.filled.circle.fill", | |
| 1431 | + "retired": true, | |
| 1432 | + "replacement": "native:101" | |
| 1433 | + }, | |
| 1434 | + { | |
| 1435 | + "id": "native:200", | |
| 1436 | + "scene": 200, | |
| 1437 | + "name": "Chromatic Speedway", | |
| 1438 | + "icon": "road.lanes", | |
| 1439 | + "retired": true, | |
| 1440 | + "replacement": "native:101" | |
| 1441 | + }, | |
| 1442 | + { | |
| 1443 | + "id": "native:201", | |
| 1444 | + "scene": 201, | |
| 1445 | + "name": "Iridescent Raceway", | |
| 1446 | + "icon": "speedometer" | |
| 1447 | + }, | |
| 1448 | + { | |
| 1449 | + "id": "native:202", | |
| 1450 | + "scene": 202, | |
| 1451 | + "name": "Cobalt Catapult", | |
| 1452 | + "icon": "arrow.up.forward" | |
| 1453 | + }, | |
| 1454 | + { | |
| 1455 | + "id": "native:203", | |
| 1456 | + "scene": 203, | |
| 1457 | + "name": "Tangerine Rocket", | |
| 1458 | + "icon": "airplane" | |
| 1459 | + }, | |
| 1460 | + { | |
| 1461 | + "id": "native:204", | |
| 1462 | + "scene": 204, | |
| 1463 | + "name": "Prismatic Overdrive", | |
| 1464 | + "icon": "pentagon" | |
| 1465 | + }, | |
| 1466 | + { | |
| 1467 | + "id": "native:205", | |
| 1468 | + "scene": 205, | |
| 1469 | + "name": "Scarlet Slipstream", | |
| 1470 | + "icon": "flag.2.crossed" | |
| 1471 | + }, | |
| 1472 | + { | |
| 1473 | + "id": "native:206", | |
| 1474 | + "scene": 206, | |
| 1475 | + "name": "Laser Autobahn", | |
| 1476 | + "icon": "steeringwheel" | |
| 1477 | + }, | |
| 1478 | + { | |
| 1479 | + "id": "native:207", | |
| 1480 | + "scene": 207, | |
| 1481 | + "name": "Rainbow Riptide", | |
| 1482 | + "icon": "sailboat" | |
| 1483 | + }, | |
| 1484 | + { | |
| 1485 | + "id": "native:208", | |
| 1486 | + "scene": 208, | |
| 1487 | + "name": "Electric Switchback", | |
| 1488 | + "icon": "arrow.triangle.swap" | |
| 1489 | + }, | |
| 1490 | + { | |
| 1491 | + "id": "native:209", | |
| 1492 | + "scene": 209, | |
| 1493 | + "name": "Disco Transit", | |
| 1494 | + "icon": "train.side.front.car" | |
| 1495 | + }, | |
| 1496 | + { | |
| 1497 | + "id": "native:210", | |
| 1498 | + "scene": 210, | |
| 1499 | + "name": "Velvet Samba", | |
| 1500 | + "icon": "figure.dance" | |
| 1501 | + }, |
Sources/PulseCanvas/Resources/NativeWormholes.metal added
| 1 | + // PulseCanvas native designs: tunnels and wormholes (scenes 117–133). Original procedural | |
| 2 | + // code; see NativeCommon.metal. Every design is a pure function of its uniforms and every | |
| 3 | + // audio term is zero at zero Chaos. | |
| 4 | + | |
| 5 | + // ---------------------------------------------------------------- shared tube helpers | |
| 6 | + // Centreline offset of the bending tubes (in tube radii) at world depth z. | |
| 7 | + float2 whPath(float z, float bend) { | |
| 8 | + return bend * float2(sin(z * .21) + .45 * sin(z * .13 + 1.7), .75 * cos(z * .17) + .35 * sin(z * .09 + .4)); | |
| 9 | + } | |
| 10 | + // Screen offset of the bent tube centre at view depth d, for a camera riding the axis at | |
| 11 | + // world depth zc and looking along the local tangent. | |
| 12 | + float2 whCentre(float zc, float d, float bend, float lens) { | |
| 13 | + float2 slope = whPath(zc + .5, bend) - whPath(zc - .5, bend); | |
| 14 | + return (whPath(zc + d, bend) - whPath(zc, bend) - slope * d) * lens / max(d, 1e-3f); | |
| 15 | + } | |
| 16 | + // Lateral offset of the view ray from the bent tube centre at view depth d. | |
| 17 | + float2 whLateral(float2 uv, float d, float2 base, float2 slope, float zc, float bend, float lens) { | |
| 18 | + return uv * d / lens - (whPath(zc + d, bend) - base - slope * d); | |
| 19 | + } | |
| 20 | + // View of a bending tube of the given radius: the first depth at which the view ray | |
| 21 | + // leaves the tube, found by a geometric march and a short bisection so the far throat | |
| 22 | + // stays stable. x = angle around the axis, y = world depth of the wall, z = view depth, | |
| 23 | + // w = screen radius of the wall circle at that depth. | |
| 24 | + float4 whTube(float2 uv, float zc, float bend, float lens, float radius) { | |
| 25 | + float2 base = whPath(zc, bend), slope = whPath(zc + .5, bend) - whPath(zc - .5, bend); | |
| 26 | + // Start the march near the straight-tube answer when the ray is still inside there. | |
| 27 | + float guess = .5 * lens * radius / max(length(uv), 1e-3f); | |
| 28 | + float d = length(whLateral(uv, guess, base, slope, zc, bend, lens)) < radius ? min(guess, 60.f) : .04 * radius; | |
| 29 | + float lo = 0, hi = 80; | |
| 30 | + for (int i = 0; i < 26; ++i) { | |
| 31 | + if (length(whLateral(uv, d, base, slope, zc, bend, lens)) >= radius) { hi = d; break; } | |
| 32 | + lo = d; | |
| 33 | + d *= 1.35; | |
| 34 | + if (d > 80) break; | |
| 35 | + } | |
| 36 | + if (hi < 80) { | |
| 37 | + for (int i = 0; i < 7; ++i) { | |
| 38 | + float mid = .5 * (lo + hi); | |
| 39 | + if (length(whLateral(uv, mid, base, slope, zc, bend, lens)) >= radius) hi = mid; else lo = mid; | |
| 40 | + } | |
| 41 | + } | |
| 42 | + d = min(.5 * (lo + hi), 80.f); | |
| 43 | + float2 lateral = whLateral(uv, d, base, slope, zc, bend, lens); | |
| 44 | + return float4(atan2(lateral.y, lateral.x), zc + d, d, lens * radius / d); | |
| 45 | + } | |
| 46 | + float whWrap(float a) { return a - TAU * floor(a / TAU + .5); } | |
| 47 | + // Value noise and fbm that repeat every `period` cells in x, for seamless angles. | |
| 48 | + float whNoiseP(float2 p, float period) { | |
| 49 | + float2 i = floor(p), fr = fract(p), u = fr * fr * (3 - 2 * fr); | |
| 50 | + float x0 = i.x - period * floor(i.x / period); | |
| 51 | + float x1 = x0 + 1 < period ? x0 + 1 : 0.f; | |
| 52 | + return mix(mix(hash21(float2(x0, i.y)), hash21(float2(x1, i.y)), u.x), | |
| 53 | + mix(hash21(float2(x0, i.y + 1)), hash21(float2(x1, i.y + 1)), u.x), u.y); | |
| 54 | + } | |
| 55 | + float whFbmP(float2 p, float period, int octaves) { | |
| 56 | + float sum = 0, amplitude = .5; | |
| 57 | + for (int i = 0; i < octaves; ++i) { | |
| 58 | + sum += amplitude * whNoiseP(p, period); | |
| 59 | + p = p * 2 + float2(0, 1.37); | |
| 60 | + period *= 2; | |
| 61 | + amplitude *= .5; | |
| 62 | + } | |
| 63 | + return sum; | |
| 64 | + } | |
| 65 | + // Voronoi that repeats every `period` cells in x. x = nearest distance, y = second | |
| 66 | + // distance, zw = nearest cell id; toSite receives the offset to the nearest site. | |
| 67 | + float4 whVoronoiP(float2 p, float period, float jitter, thread float2 &toSite) { | |
| 68 | + float2 cell = floor(p), fr = fract(p), winner = 0; | |
| 69 | + float first = 8, second = 8; | |
| 70 | + toSite = 0; | |
| 71 | + for (int y = -1; y <= 1; ++y) for (int x = -1; x <= 1; ++x) { | |
| 72 | + float2 g = float2(x, y), id = cell + g; | |
| 73 | + id.x -= period * floor(id.x / period); | |
| 74 | + float2 delta = g + .5 + jitter * (hash22(id) - .5) - fr; | |
| 75 | + float dist = length(delta); | |
| 76 | + if (dist < first) { second = first; first = dist; winner = id; toSite = delta; } else second = min(second, dist); | |
| 77 | + } | |
| 78 | + return float4(first, second, winner); | |
| 79 | + } | |
| 80 | + // Distance fog weight (1 near, 0 far). | |
| 81 | + float whFog(float d, Ctx c, float base, float range) { return exp(-d * (base + c.fog * range)); } | |
| 82 | + | |
| 83 | + // ---------------------------------------------------------------- 117 Storm Eye | |
| 84 | + // Flying down the eye of a storm: a dense outer cloud wall and two sparse inner wisp | |
| 85 | + // shells in polar coordinates, lit softly from the calm, bright eye ahead. Attacks fire | |
| 86 | + // branching lightning inside the nearby cloud banks and light only the cloud around each | |
| 87 | + // bolt; highs bring fine rain. At zero Chaos the clouds keep a soft inner glow. | |
| 88 | + // Periodic fbm returning the full sum and the sum of its three broadest octaves. | |
| 89 | + float2 stormFbm(float2 p, int octaves) { | |
| 90 | + float sum = 0, broad = 0, amplitude = .5, period = 8; | |
| 91 | + for (int i = 0; i < octaves; ++i) { | |
| 92 | + sum += amplitude * whNoiseP(p, period); | |
| 93 | + if (i == 2) broad = sum; | |
| 94 | + p = p * 2 + float2(0, 1.37); | |
| 95 | + period *= 2; | |
| 96 | + amplitude *= .5; | |
| 97 | + } | |
| 98 | + return float2(sum, broad); | |
| 99 | + } | |
| 100 | + float2 stormWarp(float2 w, float t) { | |
| 101 | + return (float2(whFbmP(w * .5 + float2(0, t * .04), 4, 2), whFbmP(w * .5 + float2(2, 5.3 - t * .03), 4, 2)) - .5) * 2.8; | |
| 102 | + } | |
| 103 | + float stormJag(float s, float seed, float t) { | |
| 104 | + float x = s * 4 + seed * 7, k = floor(x), fr = x - k; | |
| 105 | + float coarse = mix(hash11(k + seed * 13), hash11(k + 1 + seed * 13), fr) - .5; | |
| 106 | + float y = s * 13 + seed * 3, j = floor(y), fy = y - j; | |
| 107 | + float fine = mix(hash11(j + seed * 29), hash11(j + 1 + seed * 29), fy) - .5; | |
| 108 | + float wobble = mix(sin(t * 7 + k * 1.7 + seed), sin(t * 7 + (k + 1) * 1.7 + seed), fr); | |
| 109 | + return coarse + fine * .45 + .12 * wobble; | |
| 110 | + } | |
| 111 | + // Distance from `local` (wall offset from the bolt centre) to a forked bolt. | |
| 112 | + float stormBolt(float2 local, float seed, float t) { | |
| 113 | + float angle = PI * .5 + (hash11(seed * 1.7) - .5) * 1.5; | |
| 114 | + float2 dir = float2(cos(angle), sin(angle)), nrm = float2(-dir.y, dir.x); | |
| 115 | + float len = .75 + hash11(seed + 3.1) * .45; | |
| 116 | + float s = dot(local, dir) / len, sc = clamp(s, -1.f, 1.f); | |
| 117 | + float main = length(float2((s - sc) * len, dot(local, nrm) - stormJag(sc, seed, t) * .26 * len)); | |
| 118 | + float s0 = (hash11(seed + 5.3) - .5) * .9; | |
| 119 | + float2 origin = dir * s0 * len + nrm * stormJag(s0, seed, t) * .26 * len; | |
| 120 | + float turn = (hash11(seed + 8.9) > .5 ? 1 : -1) * (.5 + hash11(seed + 2.2) * .4); | |
| 121 | + float2 bdir = float2(dir.x * cos(turn) - dir.y * sin(turn), dir.x * sin(turn) + dir.y * cos(turn)); | |
| 122 | + float blen = len * .55; | |
| 123 | + float2 bl = local - origin; | |
| 124 | + float bs = dot(bl, bdir) / blen, bsc = clamp(bs, 0.f, 1.f); | |
| 125 | + float branch = length(float2((bs - bsc) * blen, dot(bl, float2(-bdir.y, bdir.x)) - stormJag(bsc, seed + 17, t) * .2 * blen * bsc)); | |
| 126 | + return min(main, branch * 1.25); | |
| 127 | + } | |
| 128 | + float3 stormEye(Ctx c, constant NativeFrame &f) { | |
| 129 | + const float lens = 1.05, rowGap = 1.9; | |
| 130 | + // The music clock adds to the forward motion, so energetic passages speed it up. | |
| 131 | + float zc = c.travel * 1.6 + c.m * 1.2; | |
| 132 | + float4 tube = whTube(c.uv, zc, .45, lens, 1); | |
| 133 | + float a = tube.x, r = tube.w; | |
| 134 | + float3 eye = paint(.78, f) * .5 + paint(.95, f) * .1; | |
| 135 | + float3 color = 0; | |
| 136 | + float transmit = 1; | |
| 137 | + for (int s = 0; s < 3; ++s) { | |
| 138 | + float radius = s == 0 ? .5 : (s == 1 ? .74 : 1.f); | |
| 139 | + float d = min(lens * radius / max(r, 1e-3f), 80.f); | |
| 140 | + float z = zc + d; | |
| 141 | + // Fine cloud detail dissolves into the haze once it is smaller than a pixel. | |
| 142 | + float foot = c.px * d * d / lens * 1.25 / c.size; | |
| 143 | + float calm = smoothstep(.08f, .5f, foot); | |
| 144 | + float2 w = float2(a / TAU * 8 + float(s) * 2, z * 1.25 / c.size + float(s) * 17.3); | |
| 145 | + int octaves = s == 2 ? 6 : 3 + s; | |
| 146 | + // One warp serves both samples; the lighting sample needs only the broad octaves. | |
| 147 | + float2 warped = w + stormWarp(w, c.t + c.m * 2); | |
| 148 | + float2 sample = stormFbm(warped, octaves); | |
| 149 | + float dens = mix(sample.x, .5f, calm); | |
| 150 | + float ahead = mix(whFbmP(warped + float2(0, .3), 8, 3) + sample.x - sample.y, .5f, calm); | |
| 151 | + float rim = clamp((dens - ahead) * 5, -1.f, 1.f); | |
| 152 | + float cover = s == 2 ? 1.f : smoothstep(s == 0 ? .6f : .52f, s == 0 ? .8f : .72f, dens) * (s == 0 ? .75f : .9f); | |
| 153 | + float body = smoothstep(.2f, .85f, dens); | |
| 154 | + float3 cloud = mix(deep(.3 + dens * .2, f) * .18, paint(.2 + dens * .45, f) * .42, body); | |
| 155 | + cloud *= .45 + .9 * max(rim, 0.f) + .25 * body; | |
| 156 | + cloud += paint(.75, f) * pow(max(rim, 0.f), 3.f) * body * (.35 + c.b.z * 1.4); | |
| 157 | + // Soft inner glow drifting through the banks (always on, never music driven). | |
| 158 | + float pocket = smoothstep(.55f, .9f, whNoiseP(w * .5 + float2(0, -c.t * .1), 4)); | |
| 159 | + // Low and low-mid bands swell the glow pockets in their own halves of the storm. | |
| 160 | + float pocketBand = mix(c.b.x, c.b.y, step(0.f, sin(a))); | |
| 161 | + cloud += paint(.62 + dens * .2, f) * pocket * body * (.55 + .45 * sin(c.t * .9 + w.y * .7) + pocketBand * 2.2) * .3; | |
| 162 | + // Lightning in the nearest cloud cells (rows x four sectors): each bolt lights only | |
| 163 | + // its own neighbourhood of cloud. | |
| 164 | + float row = floor(z / rowGap); | |
| 165 | + float sector = floor((a + PI) / TAU * 4); | |
| 166 | + for (int k = -1; k <= 1; ++k) for (int m = -1; m <= 1; ++m) { | |
| 167 | + float id = row + float(k), boltZ = (id + .5) * rowGap, gap = boltZ - zc; | |
| 168 | + float cell = sector + float(m); | |
| 169 | + cell -= 4 * floor(cell / 4); | |
| 170 | + float seed = id * 4 + cell; | |
| 171 | + float strength = c.hit * step(.55f, hash11(seed * 3.7)) * smoothstep(.2f, 1.2f, gap) * (1 - smoothstep(5.f, 7.5f, gap)); | |
| 172 | + if (strength <= 0) continue; | |
| 173 | + strength *= .8 + .2 * sin(c.t * 31 + seed * 5); | |
| 174 | + float boltAngle = (cell + .2 + .6 * hash11(seed * 7.1)) / 4 * TAU - PI; | |
| 175 | + float3 offset = float3(whWrap(a - boltAngle), z - boltZ, (1 - radius) * 1.3); | |
| 176 | + // Compact light pool: every bolt that can reach this pixel is evaluated. | |
| 177 | + float reach = max(1 - length(offset * float3(1, .6, 1)), 0.f); | |
| 178 | + float pool = reach * reach * strength; | |
| 179 | + cloud += paint(.86, f) * pool * (.3 + body) * 1.2; | |
| 180 | + if (s == 2 && length(offset.xy) < 1.9) { | |
| 181 | + float width = max(c.px * d * d / lens, .006f); | |
| 182 | + float bolt = stormBolt(float2(offset.x * radius, offset.y), seed, c.t); | |
| 183 | + cloud += (paint(.96, f) * exp(-bolt / (width * 1.5)) + paint(.82, f) * exp(-bolt * 7) * .45) * strength * 2.4; | |
| 184 | + } | |
| 185 | + } | |
| 186 | + float clear = whFog(d, c, .05, .1); | |
| 187 | + cloud = mix(eye * (.3 + .7 * smoothstep(.2f, .9f, dens)), cloud, clear); | |
| 188 | + color += transmit * cover * cloud; | |
| 189 | + transmit *= 1 - cover; | |
| 190 | + } | |
| 191 | + color += paint(.88, f) * .3 * exp(-r * 5); | |
| 192 | + // Fine rain streaks driven by the highs. | |
| 193 | + if (c.b.w > .001) { | |
| 194 | + float rain = 0; | |
| 195 | + for (int layer = 0; layer < 2; ++layer) { | |
| 196 | + float scale = 9 + float(layer) * 6; | |
| 197 | + float2 p = c.uv * scale; | |
| 198 | + p.x += p.y * .22; | |
| 199 | + float column = floor(p.x), within = fract(p.x) - .5; | |
| 200 | + float seed = hash11(column + float(layer) * 41); | |
| 201 | + float y = fract(p.y * .12 + c.t * (1.4 + float(layer) * .6) + seed); | |
| 202 | + rain += exp(-within * within * 900) * smoothstep(0.f, .05f, y) * (1 - smoothstep(.05f, .22f, y)) * step(.45f, seed); | |
| 203 | + } | |
| 204 | + color += paint(.92, f) * rain * c.b.w * .7; | |
| 205 | + } | |
| 206 | + return color * .85; | |
| 207 | + } | |
| 208 | + | |
| 209 | + // ---------------------------------------------------------------- 118 Sonar Pipe | |
| 210 | + // Inside a brushed-metal pipe: fine circumferential grain, long anisotropic highlights, | |
| 211 | + // seams with rivets, and sonar pings (thin bright rings with trailing ripples) racing | |
| 212 | + // along the pipe in both directions so their ripples interfere. Bass strengthens the | |
| 213 | + // outbound pings, each attack launches a fresh ping from the camera, highs shimmer. | |
| 214 | + float sonarWave(float x, float spacing, float width, float outbound) { | |
| 215 | + float fr = fract(x); | |
| 216 | + float behind = (outbound > 0 ? 1 - fr : fr) * spacing; | |
| 217 | + float nearest = min(fr, 1 - fr) * spacing; | |
| 218 | + return exp(-nearest * nearest / (width * width)) + exp(-behind * .9) * cos(behind * 9) * .7; | |
| 219 | + } | |
| 220 | + float3 sonarPipe(Ctx c, constant NativeFrame &f) { | |
| 221 | + const float lens = 1.1; | |
| 222 | + // The music clock adds to the forward motion, so energetic passages speed it up. | |
| 223 | + float zc = c.travel * 1.5 + c.m * 1.0; | |
| 224 | + float4 tube = whTube(c.uv, zc, .3, lens, 1); | |
| 225 | + float a = tube.x, z = tube.y, d = tube.z; | |
| 226 | + float foot = c.px * d * d / lens; | |
| 227 | + float sharp = exp(-foot * 40); | |
| 228 | + // Brushed grain: fine lines running around the pipe. | |
| 229 | + float grain = whNoiseP(float2(a / TAU * 3, z * 170), 3) * .45 + whNoiseP(float2(a / TAU * 5 + .5, z * 55), 5) * .35 + whNoiseP(float2(a / TAU * 2, z * 9), 2) * .2; | |
| 230 | + grain = mix(.5, grain, sharp * .8 + .2 * exp(-foot * 6)); | |
| 231 | + // Seams every 1.25 with a rivet row on each side. | |
| 232 | + float seamZ = z - round(z / 1.25) * 1.25; | |
| 233 | + float seam = 1 - smoothstep(.006f, .014f + foot, abs(seamZ)); | |
| 234 | + float lip = smoothstep(.012f, .022f, abs(seamZ)) * (1 - smoothstep(.022f, .05f, abs(seamZ))); | |
| 235 | + float cellAngle = (floor(a / TAU * 16) + .5) * TAU / 16; | |
| 236 | + float2 rivet = float2(whWrap(a - cellAngle), (abs(seamZ) - .085) / clamp(d, .5f, 2.5f)); | |
| 237 | + float rivetR = length(rivet) / .032; | |
| 238 | + float dome = sqrt(max(1 - rivetR * rivetR, 0.f)); | |
| 239 | + float rivetLit = dome > 0 ? (.25 + .75 * max(dot(normalize(float3(rivet / .032, dome)), normalize(float3(-.4, .6, .7))), 0.f)) : 0.f; | |
| 240 | + float rivetSpec = dome > 0 ? pow(max(dot(normalize(float3(rivet / .032, dome)), normalize(float3(-.3, .45, .85))), 0.f), 24.f) : 0.f; | |
| 241 | + float rivetEdge = smoothstep(1.f + foot * 30, 1.f, rivetR); | |
| 242 | + // Anisotropic highlights: long streaks along the pipe, broken into rings by the grain. | |
| 243 | + float streak = pow(max(cos(a - 1.75), 0.f), 14.f) + .55 * pow(max(cos(a + 1.35), 0.f), 8.f); | |
| 244 | + float aniso = streak * (.25 + 1.6 * grain * grain) * (.45 + .55 * smoothstep(.3f, 3.f, d)); | |
| 245 | + float plate = hash11(round(z / 1.25) * 3.1); | |
| 246 | + float3 metal = mix(deep(.2, f), paint(.28 + plate * .06, f), .45) * (.07 + .24 * grain) * (.85 + .3 * plate); | |
| 247 | + metal += paint(.5 + grain * .25, f) * aniso * .85; | |
| 248 | + metal *= 1 - seam * .85; | |
| 249 | + metal += paint(.6, f) * lip * .1; | |
| 250 | + metal = mix(metal, paint(.45, f) * rivetLit * .5 + paint(.95, f) * rivetSpec * .6, rivetEdge * sharp); | |
| 251 | + // Sonar pings: an outbound and an inbound train interfere. | |
| 252 | + float spacing = 2.6 * c.size, width = .028; | |
| 253 | + float widthEff = max(width, foot * .8); | |
| 254 | + float outbound = sonarWave((z - c.t * 2.4 - c.m * 2.5) / spacing, spacing, widthEff, 1) * (1 + c.b.x * 2.2); | |
| 255 | + float inbound = sonarWave((z + c.t * 1.5 + c.m * 1.5) / (spacing * 1.47) + .31, spacing * 1.47, widthEff, -1) * (.8 + c.b.z * 1.6); | |
| 256 | + float field = (outbound + inbound) * mix(1.f, width / widthEff, .7f); | |
| 257 | + float ring = (field * field * .4 + max(field, 0.f) * .6) * smoothstep(.25f, 1.1f, d); | |
| 258 | + // A fresh ping rides out from the camera as each attack envelope decays. | |
| 259 | + float pingZ = zc + .7 + (1 - c.hit) * 9; | |
| 260 | + float behindPing = pingZ - z; | |
| 261 | + float ping = exp(-pow((z - pingZ) / widthEff, 2.f)) * 2 + step(0.f, behindPing) * exp(-behindPing * 1.2) * max(cos(behindPing * 9), 0.f) * .8; | |
| 262 | + ping *= c.hit * c.hit; | |
| 263 | + float shimmer = pow(whNoiseP(float2(a / TAU * 160, z * 140 + c.t * 5), 160), 10.f) * sharp * c.b.w * 2 * (.15 + aniso * 2.5); | |
| 264 | + float clear = whFog(d, c, .03, .09); | |
| 265 | + float3 color = metal * (.4 + .6 * clear); | |
| 266 | + color += paint(.8 + clamp(ring, 0.f, 2.f) * .08, f) * ring * .4 * (.35 + .65 * clear); | |
| 267 | + color += paint(.6, f) * max(ring, 0.f) * (aniso + .15) * .5; | |
| 268 | + color += paint(.95, f) * ping * 1.4 * (.5 + .5 * clear); | |
| 269 | + color += paint(.9, f) * shimmer * clear; | |
| 270 | + color = mix(deep(.2, f) * .1, color, .2 + .8 * clear); | |
| 271 | + return color * .78; | |
| 272 | + } | |
| 273 | + | |
| 274 | + // ---------------------------------------------------------------- 119 Cube Helix | |
| 275 | + // Raymarched glossy cubes strung on a double helix around the flight path, each spinning | |
| 276 | + // on its own axis, faces painted from the palette with a rim light, two faint glowing | |
| 277 | + // rails tracing the strands, and dark space with stars beyond. Bass swells the cubes | |
| 278 | + // nearest the camera, highs glint along their edges and attacks flip them over. | |
| 279 | + constant float helixRadius = 1.15, helixGap = .42, helixTwist = .38; | |
| 280 | + float3 helixCentre(float i, float strand, float t) { | |
| 281 | + float angle = i * helixTwist + strand * PI + t * .25; | |
| 282 | + return float3(helixRadius * cos(angle), helixRadius * sin(angle), i * helixGap); | |
| 283 | + } | |
| 284 | + // Spin of one cube: returns the two rotation angles (xy plane, then yz plane). | |
| 285 | + float2 helixSpin(float id, Ctx c) { | |
| 286 | + float seed = hash11(id * 1.37); | |
| 287 | + float flip = c.hit * 1.7 * (seed > .5 ? 1 : -1); | |
| 288 | + return float2(c.t * (.45 + seed * .8) + seed * 6.3 + flip, c.t * (.3 + seed * .5) + seed * 3.1 + flip * .6); | |
| 289 | + } | |
| 290 | + float helixSize(float i, Ctx c, float zc) { | |
| 291 | + float bass = c.b.x * .55 * exp(-max(i * helixGap - zc, 0.f) * .35); | |
| 292 | + return min(.15 * c.size, .3f) * (1 + bass); | |
| 293 | + } | |
| 294 | + float helixField(float3 p, Ctx c, float zc, thread float &which, thread float &rail) { | |
| 295 | + float best = 1e3; | |
| 296 | + float base = round(p.z / helixGap); | |
| 297 | + for (int k = -1; k <= 1; ++k) for (int s = 0; s < 2; ++s) { | |
| 298 | + float i = base + float(k), id = i * 2 + float(s); | |
| 299 | + float3 q = p - helixCentre(i, float(s), c.t + c.m * 1.2); | |
| 300 | + float2 spin = helixSpin(id, c); | |
| 301 | + q.xy = rot(q.xy, spin.x); | |
| 302 | + q.yz = rot(q.yz, spin.y); | |
| 303 | + float size = helixSize(i, c, zc); | |
| 304 | + float dist = sdBox(q, float3(size - .025)) - .025; | |
| 305 | + if (dist < best) { best = dist; which = id; } | |
| 306 | + } | |
| 307 | + rail = 1e3; | |
| 308 | + for (int s = 0; s < 2; ++s) { | |
| 309 | + float angle = p.z / helixGap * helixTwist + float(s) * PI + (c.t + c.m * 1.2) * .25; | |
| 310 | + rail = min(rail, length(p.xy - helixRadius * float2(cos(angle), sin(angle)))); | |
| 311 | + } | |
| 312 | + return best; | |
| 313 | + } | |
| 314 | + float3 cubeHelix(Ctx c, constant NativeFrame &f) { | |
| 315 | + // The music clock adds to the forward motion, so energetic passages speed it up. | |
| 316 | + float zc = c.travel * 1.8 + c.m * 1.4; | |
| 317 | + float3 ro = float3(sin(c.t * .23) * .12, cos(c.t * .19) * .12, zc); | |
| 318 | + float3 forward = float3(sin(c.t * .11) * .12, cos(c.t * .13) * .1, 1); | |
| 319 | + float3 rd = cameraRay(c.uv, forward, float3(sin(c.t * .07) * .4, 1, 0), 1.15); | |
| 320 | + // Background: faint nebula and stars. | |
| 321 | + float2 sky = rd.xy / max(rd.z, .05f); | |
| 322 | + float cloud = fbm2(sky * 1.3 + c.t * .01, 3); | |
| 323 | + float3 color = mix(paint(.97, f) * .07, paint(.03, f) * .06, smoothstep(.35f, .7f, cloud)) + paint(.8, f) * .04 * smoothstep(.55f, .8f, fbm2(sky * 2.1 + 4.2, 3)); | |
| 324 | + for (int layer = 0; layer < 2; ++layer) { | |
| 325 | + float2 g = sky * (18 + float(layer) * 23); | |
| 326 | + float2 cell = floor(g); | |
| 327 | + float h = hash21(cell + float(layer) * 31); | |
| 328 | + float2 at = hash22(cell + 7) - .5; | |
| 329 | + float star = exp(-length(fract(g) - .5 - at * .6) * 16) * step(.9f, h); | |
| 330 | + color += paint(.85 + h * .1, f) * star * (.5 + .5 * sin(c.t * (1 + h * 3) + h * 40)) * .8; | |
| 331 | + } | |
| 332 | + // March only through the annulus that holds the helix. | |
| 333 | + float2 o = ro.xy, dxy = rd.xy; | |
| 334 | + float a2 = dot(dxy, dxy), b = dot(o, dxy); | |
| 335 | + float margin = .5; | |
| 336 | + float inner = helixRadius - margin, outer = helixRadius + margin; | |
| 337 | + float tIn = (-b + sqrt(max(b * b - a2 * (dot(o, o) - inner * inner), 0.f))) / max(a2, 1e-5f); | |
| 338 | + float tOut = (-b + sqrt(max(b * b - a2 * (dot(o, o) - outer * outer), 0.f))) / max(a2, 1e-5f); | |
| 339 | + tIn = max(tIn, 0.f); | |
| 340 | + tOut = min(tOut, 32.f); | |
| 341 | + float travel = tIn, which = 0, rail = 9, railGlow = 0; | |
| 342 | + float3 glowSum = 0; | |
| 343 | + bool hit = false; | |
| 344 | + for (int i = 0; i < 56 && travel < tOut; ++i) { | |
| 345 | + float3 p = ro + rd * travel; | |
| 346 | + float d = helixField(p, c, zc, which, rail); | |
| 347 | + float fade = whFog(travel, c, .02, .07); | |
| 348 | + glowSum += paint(hash11(which * 1.37) * 1.1, f) * exp(-d * 9) * .022 * fade; | |
| 349 | + railGlow += exp(-rail * 30) * .05 * fade; | |
| 350 | + if (d < .002 * (1 + travel * .5)) { hit = true; break; } | |
| 351 | + travel += max(d * .9, .01f); | |
| 352 | + } | |
| 353 | + color += glowSum * (1 + c.b.y * 1.5) + paint(.8, f) * railGlow * (1 + c.b.z * 3); | |
| 354 | + if (hit) { | |
| 355 | + float3 p = ro + rd * travel; | |
| 356 | + float i = floor(which * .5), strand = which - i * 2; | |
| 357 | + float3 q = p - helixCentre(i, strand, c.t + c.m * 1.2); | |
| 358 | + float2 spin = helixSpin(which, c); | |
| 359 | + q.xy = rot(q.xy, spin.x); | |
| 360 | + q.yz = rot(q.yz, spin.y); | |
| 361 | + float size = helixSize(i, c, zc); | |
| 362 | + float3 aq = abs(q); | |
| 363 | + float3 nl = aq.x > aq.y && aq.x > aq.z ? float3(sign(q.x), 0, 0) : (aq.y > aq.z ? float3(0, sign(q.y), 0) : float3(0, 0, sign(q.z))); | |
| 364 | + float face = dot(nl, float3(1, 2, 3)) + 3; | |
| 365 | + float3 n = nl; | |
| 366 | + n.yz = rot(n.yz, -spin.y); | |
| 367 | + n.xy = rot(n.xy, -spin.x); | |
| 368 | + // Edge factor: the second largest coordinate approaches the half size. | |
| 369 | + float second = max(min(aq.x, aq.y), min(max(aq.x, aq.y), aq.z)); | |
| 370 | + float edge = smoothstep(size * .78, size * .98, second); | |
| 371 | + float seed = hash11(which * 1.37); | |
| 372 | + float3 albedo = paint(seed * 1.1 + face * .05 + c.t * .015, f); | |
| 373 | + float3 key = normalize(float3(.45, .75, -.45)); | |
| 374 | + float diffuse = max(dot(n, key), 0.f); | |
| 375 | + float3 r = reflect(rd, n); | |
| 376 | + float spec = pow(max(dot(r, key), 0.f), 40.f); | |
| 377 | + float rim = pow(1 - max(dot(n, -rd), 0.f), 3.f); | |
| 378 | + float3 env = deep(.3 + r.y * .2, f) * .4 + paint(.8, f) * pow(max(r.z, 0.f), 6.f) * .5; | |
| 379 | + float3 cube = albedo * (.2 + .9 * diffuse) + env * .2 + paint(.95, f) * spec * .8 + albedo * rim * .45; | |
| 380 | + cube += paint(.9, f) * edge * (.12 + c.b.w * 1.4 * (.6 + .4 * sin(c.t * 13 + seed * 50))); | |
| 381 | + float fade = whFog(travel, c, .02, .07); | |
| 382 | + color = mix(color, cube, fade) + glowSum * .5; | |
| 383 | + } | |
| 384 | + return color; | |
| 385 | + } | |
| 386 | + | |
| 387 | + // ---------------------------------------------------------------- 120 Phyllo Tube | |
| 388 | + // Glowing beads set on the golden angle along the inside of a tube, so they form the | |
| 389 | + // interlocking 13 and 21 spirals of a sunflower head unrolled around the walls. The | |
| 390 | + // lattice turns as you travel; bead size swells and shrinks along the depth index. | |
| 391 | + // Each band brightens its own family of spiral arms; attacks swell two arms. | |
| 392 | + float3 phylloTube(Ctx c, constant NativeFrame &f) { | |
| 393 | + const float lens = 1.0, alpha = .381966, rise = .016; | |
| 394 | + // The music clock adds to the forward motion, so energetic passages speed it up. | |
| 395 | + float zc = c.travel * 1.3 + c.m * 1.0; | |
| 396 | + float4 tube = whTube(c.uv, zc, .3, lens, 1); | |
| 397 | + float a = tube.x, z = tube.y, d = tube.z; | |
| 398 | + float foot = c.px * d * d / lens; | |
| 399 | + // Beads are round on screen: depth offsets are measured in view-scaled units. | |
| 400 | + float squash = clamp(d, .35f, 2.2f); | |
| 401 | + float2 p = float2((a / TAU - c.t * .035 - c.m * .04) * TAU, z); | |
| 402 | + float2 A = float2((13 * alpha - 5) * TAU, 13 * rise), B = float2((21 * alpha - 8) * TAU, 21 * rise); | |
| 403 | + float det = A.x * B.y - A.y * B.x; | |
| 404 | + float2 lattice = float2(p.x * B.y - p.y * B.x, A.x * p.y - A.y * p.x) / det; | |
| 405 | + float2 base = floor(lattice); | |
| 406 | + float3 color = deep(.3 + z * .01, f) * .08 * (.6 + .4 * whNoiseP(float2(a / TAU * 16, z * 3), 16)); | |
| 407 | + // Faint grooves along one spiral family. | |
| 408 | + float groove = abs(fract(lattice.y) - .5) * length(B) * .9; | |
| 409 | + color += paint(.35, f) * exp(-groove / max(.012f, foot)) * .08; | |
| 410 | + float best = 1e3; | |
| 411 | + float3 halo = 0; | |
| 412 | + for (int j = -1; j <= 1; ++j) for (int i = -1; i <= 1; ++i) { | |
| 413 | + float2 id = base + float2(i, j); | |
| 414 | + float n = 13 * id.x + 21 * id.y; | |
| 415 | + float2 offset = p - (id.x * A + id.y * B); | |
| 416 | + offset.y /= squash; | |
| 417 | + float arm = n - 13 * floor(n / 13); | |
| 418 | + int family = int(arm) % 4; | |
| 419 | + float swell = .62 + .38 * sin(n * TAU / 233 + 1.3); | |
| 420 | + float hitArm = (arm == 0 || arm == 7) ? c.hit : 0.f; | |
| 421 | + float radius = min(.075 * c.size * swell * (1 + hitArm * .6), .16f); | |
| 422 | + float dist = length(offset); | |
| 423 | + float lit = 1 + c.b[family] * 1.8 + hitArm * 1.6; | |
| 424 | + float3 tint = paint(fract(n * .0021 - c.t * .05) * 2 + arm * .02, f); | |
| 425 | + halo += tint * exp(-max(dist - radius, 0.f) / (.03 + foot * .3)) * .2 * lit; | |
| 426 | + float edgeWidth = foot / squash + .004; | |
| 427 | + if (dist < radius + edgeWidth && dist < best) { | |
| 428 | + best = dist; | |
| 429 | + float2 nxy = offset / radius; | |
| 430 | + float nz = sqrt(max(1 - dot(nxy, nxy), 0.f)); | |
| 431 | + // Lit from the camera side with a cool rim. | |
| 432 | + float diffuse = max(dot(float3(nxy, nz), normalize(float3(-.45, .55, .8))), 0.f); | |
| 433 | + float spec = exp(-dot(nxy - float2(-.32, .38), nxy - float2(-.32, .38)) * 26); | |
| 434 | + float rim = pow(1 - nz, 3.f); | |
| 435 | + float edge = smoothstep(radius + edgeWidth, radius - edgeWidth, dist); | |
| 436 | + float3 sphere = tint * (.18 + .85 * diffuse) * lit + paint(.97, f) * spec * .8 + paint(fract(n * .0021) * 2 + .4, f) * rim * .35; | |
| 437 | + color = mix(color, sphere, edge); | |
| 438 | + } | |
| 439 | + } | |
| 440 | + color += halo; | |
| 441 | + // Far beads blur into the glow of their spirals. | |
| 442 | + float clear = whFog(d, c, .03, .1) * exp(-foot * 2); | |
| 443 | + float3 far = paint(.55 + sin(c.t * .2) * .1, f) * .3; | |
| 444 | + return mix(far, color, clear) + paint(.85, f) * .3 * exp(-tube.w * 6); | |
| 445 | + } | |
| 446 | + | |
| 447 | + // ---------------------------------------------------------------- 121 Tesla Tube | |
| 448 | + // A dark ribbed metal tube studded with electrode knobs. Plasma arcs crackle between | |
| 449 | + // neighbouring electrodes as jagged glowing strokes that light the metal around them. | |
| 450 | + // Bass wakes more arcs and brightens them, highs spit corona sparks around the knobs and | |
| 451 | + // attacks fire a large arc straight across the tunnel a few metres ahead. | |
| 452 | + float teslaJag(float s, float seed, float t) { | |
| 453 | + float x = s * 7, k = floor(x), fr = x - k; | |
| 454 | + float a0 = hash11(k + seed * 17) - .5 + .25 * sin(t * 23 + k * 2.1 + seed); | |
| 455 | + float a1 = hash11(k + 1 + seed * 17) - .5 + .25 * sin(t * 23 + (k + 1) * 2.1 + seed); | |
| 456 | + float y = s * 19, j = floor(y), fy = y - j; | |
| 457 | + float f0 = (hash11(j + seed * 31) - .5) * sin(t * 17 + j + seed); | |
| 458 | + float f1 = (hash11(j + 1 + seed * 31) - .5) * sin(t * 17 + j + 1 + seed); | |
| 459 | + return mix(a0, a1, fr) + mix(f0, f1, fy) * .35; | |
| 460 | + } | |
| 461 | + // Distance from p to a jagged arc from a to b. | |
| 462 | + float teslaArc(float2 p, float2 a, float2 b, float seed, float t) { | |
| 463 | + float2 ab = b - a; | |
| 464 | + float len = max(length(ab), 1e-3f); | |
| 465 | + float2 dir = ab / len, nrm = float2(-dir.y, dir.x); | |
| 466 | + float s = dot(p - a, dir) / len, sc = clamp(s, 0.f, 1.f); | |
| 467 | + float offset = teslaJag(sc, seed, t) * .22 * len * sin(PI * sc); | |
| 468 | + return length(float2((s - sc) * len, dot(p - a, nrm) - offset)); | |
| 469 | + } | |
| 470 | + float3 teslaTube(Ctx c, constant NativeFrame &f) { | |
| 471 | + const float lens = 1.05, rowGap = 1.6, perRing = 6, ribGap = .4; | |
| 472 | + // The music clock adds to the forward motion, so energetic passages speed it up. | |
| 473 | + float zc = c.travel * 1.4 + c.m * 1.0; | |
| 474 | + float4 tube = whTube(c.uv, zc, .32, lens, 1); | |
| 475 | + float a = tube.x, r = tube.w; | |
| 476 | + // Ribs push the wall inward; refine the depth once against the ribbed radius. | |
| 477 | + float rib = pow(.5 + .5 * cos((zc + tube.z) * TAU / ribGap), 2.f); | |
| 478 | + float d = tube.z * (1 - .07 * rib); | |
| 479 | + float z = zc + d; | |
| 480 | + float phase = z * TAU / ribGap; | |
| 481 | + rib = pow(.5 + .5 * cos(phase), 2.f); | |
| 482 | + float foot = c.px * d * d / lens; | |
| 483 | + float sharp = exp(-foot * 10); | |
| 484 | + float facing = -sin(phase); // > 0 on the rib flank that faces the camera | |
| 485 | + float3 color = deep(.12, f) * .1 + paint(.2, f) * .03; | |
| 486 | + // Low-mids run a glow wave along the ribs. | |
| 487 | + float ribWave = c.b.y * pow(.5 + .5 * sin(z * .8 - c.t * 3 - c.m * 3), 2.f); | |
| 488 | + float ribLight = mix(.35f, .6f + .9 * max(facing, 0.f) * rib + .25 * rib, sharp) * (1 + ribWave * 2.2); | |
| 489 | + color += mix(deep(.25, f), paint(.3, f), .3) * ribLight * .18; | |
| 490 | + color += paint(.55, f) * pow(max(cos(a - 1.8), 0.f), 14.f) * pow(rib, 3.f) * .35 * sharp; | |
| 491 | + // Electrodes and the arcs between them. | |
| 492 | + float row = floor(z / rowGap); | |
| 493 | + float arcs = 0, glowLight = 0, corona = 0; | |
| 494 | + float3 knobColor = 0; | |
| 495 | + float knobMask = 0; | |
| 496 | + float squash = clamp(d, .35f, 2.5f); | |
| 497 | + for (int k = -1; k <= 1; ++k) { | |
| 498 | + float rowId = row + float(k); | |
| 499 | + float rowZ = rowId * rowGap; | |
| 500 | + float shift = fmod(fabs(rowId), 2.f) * .5; | |
| 501 | + float column = round(a / TAU * perRing - shift); | |
| 502 | + for (int i = -1; i <= 1; ++i) { | |
| 503 | + float colId = column + float(i); | |
| 504 | + float wrapped = colId - perRing * floor(colId / perRing); | |
| 505 | + float angle = (colId + shift) / perRing * TAU; | |
| 506 | + float2 local = float2(whWrap(a - angle), z - rowZ); | |
| 507 | + float seed = hash21(float2(wrapped, rowId)); | |
| 508 | + // Bass wakes more arcs; each arc also brightens with its own band. | |
| 509 | + float band = c.b[int(fract(seed * 7.3) * 3.99)]; | |
| 510 | + float wake = .5 + .5 * sin(c.t * (.6 + seed * .8) + c.m * (.8 + seed) + seed * 40) + c.b.x * .9; | |
| 511 | + float near = exp(-foot * 6) * smoothstep(7.f, 3.5f, d); | |
| 512 | + float on = smoothstep(.55f, .8f, wake) * (.75 + .25 * sin(c.t * 37 + seed * 9)) * (1 + c.b.x * .5 + band * 1.2) * near; | |
| 513 | + // Knob: a polished dome, round on screen. | |
| 514 | + float2 kl = float2(local.x, local.y / squash) / .085; | |
| 515 | + float kr = length(kl); | |
| 516 | + float kz = sqrt(max(1 - kr * kr, 0.f)); | |
| 517 | + float edge = smoothstep(1 + foot * 12, 1.f, kr) * sharp * smoothstep(9.f, 4.f, d); | |
| 518 | + float3 n = float3(kl, kz); | |
| 519 | + float spec = pow(max(dot(n, normalize(float3(-.35, .45, .82))), 0.f), 18.f); | |
| 520 | + float3 knob = deep(.3, f) * .3 + paint(.5, f) * spec * .9 + paint(.85, f) * on * (.6 + .4 * kz); | |
| 521 | + knobColor += knob * edge; | |
| 522 | + knobMask = max(knobMask, edge); | |
| 523 | + float ring = exp(-max(kr - 1, 0.f) * 3) * (1 - edge); | |
| 524 | + glowLight += ring * on * .5 * near; | |
| 525 | + corona += pow(max(sin(atan2(kl.y, kl.x) * 7 + c.t * 9 + seed * 30), 0.f), 8.f) * exp(-abs(kr - 1.4) * 4) * c.b.w * near; | |
| 526 | + // Arc to the next electrode around the ring, or to the next row. | |
| 527 | + float2 target = hash11(seed * 9 + 1) > .45 ? float2(TAU / perRing, 0) : float2(TAU / perRing * .5 * (hash11(seed * 3) > .5 ? 1 : -1), rowGap); | |
| 528 | + if (on > .001) { | |
| 529 | + float dist = teslaArc(local, 0, target, seed * 13 + rowId, c.t); | |
| 530 | + float width = max(.007f, foot * .6); | |
| 531 | + arcs += (exp(-dist / width) + exp(-dist * 30) * .3) * on; | |
| 532 | + glowLight += exp(-dist * 9) * on; | |
| 533 | + } | |
| 534 | + } | |
| 535 | + } | |
| 536 | + color = mix(color, knobColor, knobMask); | |
| 537 | + color += paint(.72, f) * glowLight * .2 + paint(.6, f) * glowLight * glowLight * .06; | |
| 538 | + color += paint(.92, f) * arcs * 1.2 + paint(.97, f) * corona * .7; | |
| 539 | + // Attack: a big arc jumps straight across the tunnel a few metres ahead. | |
| 540 | + if (c.hit > .001) { | |
| 541 | + float first = ceil((zc + 1.5) / rowGap); | |
| 542 | + for (int k = 0; k < 3; ++k) { | |
| 543 | + float rowId = first + float(k); | |
| 544 | + float gap = rowId * rowGap - zc; | |
| 545 | + float window = smoothstep(1.5f, 2.5f, gap) * (1 - smoothstep(4.5f, 6.f, gap)); | |
| 546 | + if (window <= 0) continue; | |
| 547 | + float2 centre = whCentre(zc, gap, .32, lens); | |
| 548 | + float angle = hash11(rowId * 1.3) * TAU; | |
| 549 | + float span = PI * (.75 + .3 * hash11(rowId * 2.9)); | |
| 550 | + float2 s0 = centre + lens / gap * float2(cos(angle), sin(angle)); | |
| 551 | + float2 s1 = centre + lens / gap * float2(cos(angle + span), sin(angle + span)); | |
| 552 | + float dist = teslaArc(c.uv, s0, s1, rowId * 3.3, c.t); | |
| 553 | + float strength = c.hit * window; | |
| 554 | + color += (paint(.95, f) * exp(-dist / (c.px * 2.5)) + paint(.75, f) * exp(-dist * 12) * .6) * strength * 1.8; | |
| 555 | + } | |
| 556 | + } | |
| 557 | + float clear = whFog(d, c, .03, .09); | |
| 558 | + return mix(deep(.25, f) * .12 + paint(.7, f) * .06, color, clear) + paint(.75, f) * .15 * exp(-r * 4); | |
| 559 | + } | |
| 560 | + | |
| 561 | + // ---------------------------------------------------------------- 122 Fold Tunnel | |
| 562 | + // An origami tube in a twisted, Kresling-like fold: rings of vertices alternate between | |
| 563 | + // mountain and valley radii and each ring turns a little against the last, so the wall is | |
| 564 | + // a spiral of flat triangles, each with its own lighting, crisp crease lines and a paper | |
| 565 | + // grain. The folds breathe slowly; bass deepens them and each attack unfolds a ring of | |
| 566 | + // facets just ahead, which flattens and glows through. | |
| 567 | + constant float foldColumns = 15; // a multiple of 3 keeps the vertex levels seamless | |
| 568 | + float foldDepth(float row, Ctx c, float zc, float rowH) { | |
| 569 | + float breathe = .2 + .09 * sin(c.t * .55 + c.m * .8 + row * .29); | |
| 570 | + float gap = row * rowH - zc; | |
| 571 | + float unfold = c.hit * smoothstep(1.f, 2.f, gap) * (1 - smoothstep(3.2f, 4.6f, gap)); | |
| 572 | + return breathe * (1 + c.b.x * .8) * (1 - unfold * .95); | |
| 573 | + } | |
| 574 | + // Vertex levels cycle through three radii so the three corners of every facet differ. | |
| 575 | + float foldRadius(float2 v, Ctx c, float zc, float rowH) { | |
| 576 | + float k = v.x + 2 * v.y; | |
| 577 | + float level = k - 3 * floor(k / 3); | |
| 578 | + return 1 - foldDepth(v.y, c, zc, rowH) * level * .5; | |
| 579 | + } | |
| 580 | + // Facet containing (angle, z): the three vertex lattice ids and barycentric weights. | |
| 581 | + void foldFacet(float angle, float z, float rowH, thread float2 &v0, thread float2 &v1, thread float2 &v2, thread float3 &w, thread bool &upper) { | |
| 582 | + float y = z / rowH; | |
| 583 | + float x = angle / TAU * foldColumns - y * .32; // each ring twists against the last | |
| 584 | + float2 lat = float2(x - .5 * y, y); | |
| 585 | + float2 cell = floor(lat), uv = lat - cell; | |
| 586 | + upper = uv.x + uv.y > 1; | |
| 587 | + if (!upper) { v0 = cell; v1 = cell + float2(1, 0); v2 = cell + float2(0, 1); w = float3(1 - uv.x - uv.y, uv.x, uv.y); } | |
| 588 | + else { v0 = cell + 1; v1 = cell + float2(0, 1); v2 = cell + float2(1, 0); w = float3(uv.x + uv.y - 1, 1 - uv.x, 1 - uv.y); } | |
| 589 | + } | |
| 590 | + float3 foldVertex(float2 v, float rowH, Ctx c, float zc) { | |
| 591 | + float angle = (v.x + .82 * v.y) / foldColumns * TAU; | |
| 592 | + float radius = foldRadius(v, c, zc, rowH); | |
| 593 | + return float3(radius * cos(angle), radius * sin(angle), v.y * rowH); | |
| 594 | + } | |
| 595 | + float3 foldTunnel(Ctx c, constant NativeFrame &f) { | |
| 596 | + const float lens = 1.05, bend = .35; | |
| 597 | + float rowH = .4 * c.size; | |
| 598 | + // The music clock adds to the forward motion, so energetic passages speed it up. | |
| 599 | + float zc = c.travel * 1.35 + c.m * .8; | |
| 600 | + float4 tube = whTube(c.uv, zc, bend, lens, 1); | |
| 601 | + float a = tube.x, d0 = tube.z; | |
| 602 | + float2 v0, v1, v2; | |
| 603 | + float3 w; | |
| 604 | + bool upper; | |
| 605 | + // One damped refinement gives near facets some parallax without unstable jumps. | |
| 606 | + foldFacet(a, zc + d0, rowH, v0, v1, v2, w, upper); | |
| 607 | + float radius = w.x * foldRadius(v0, c, zc, rowH) + w.y * foldRadius(v1, c, zc, rowH) + w.z * foldRadius(v2, c, zc, rowH); | |
| 608 | + float d = d0 * mix(1.f, radius, exp(-d0 * .8)); | |
| 609 | + float z = zc + d; | |
| 610 | + foldFacet(a, z, rowH, v0, v1, v2, w, upper); | |
| 611 | + float3 p0 = foldVertex(v0, rowH, c, zc), p1 = foldVertex(v1, rowH, c, zc), p2 = foldVertex(v2, rowH, c, zc); | |
| 612 | + float3 centroid = (p0 + p1 + p2) / 3; | |
| 613 | + float3 n = normalize(cross(p1 - p0, p2 - p0)); | |
| 614 | + if (dot(n, centroid * float3(1, 1, 0)) > 0) n = -n; | |
| 615 | + // Lights: a headlamp at the camera, a key from above ahead and a low fill. | |
| 616 | + float3 toCamera = normalize(float3(0, 0, zc) - centroid); | |
| 617 | + float head = max(dot(n, toCamera), 0.f); | |
| 618 | + float key = max(dot(n, normalize(float3(.3, -.8, -.5))), 0.f); | |
| 619 | + float fill = max(dot(n, normalize(float3(-.6, .5, -.6))), 0.f); | |
| 620 | + float column = v0.x - foldColumns * floor(v0.x / foldColumns); | |
| 621 | + float facetId = hash21(float2(column + (upper ? 31 : 0), v0.y)); | |
| 622 | + float3 tint = paint(facetId * .9 + v0.y * .02 + c.t * .01, f); | |
| 623 | + tint = mix(tint, paint(.97, f), .45 * hash11(facetId * 17)); | |
| 624 | + float foot = c.px * d * d / lens; | |
| 625 | + float grain = mix(1.f, .9f + .2 * noise2(float2(a * 70, z * 60)), exp(-foot * 30)); | |
| 626 | + float3 color = tint * (.18 + .5 * head + .5 * key * key + .3 * fill) * grain; | |
| 627 | + // Distant facets shrink below a pixel: settle them to their average shade. | |
| 628 | + color = mix(tint * .5, color, exp(-foot / rowH * 1.5)); | |
| 629 | + // Creases: distance to the nearest facet edge in lattice units. | |
| 630 | + float edgeDist = min(min(w.x, w.y), w.z); | |
| 631 | + float crease = (1 - smoothstep(0.f, max(.03f, foot / rowH * 1.5), edgeDist)) * exp(-foot / rowH * 2); | |
| 632 | + float valley = upper ? 1.f : 0.f; | |
| 633 | + color *= 1 - crease * (.35 + .25 * valley); | |
| 634 | + color += paint(.95, f) * crease * .12 * (1 - valley) * (head + key) * (1 + c.b.z * 4); | |
| 635 | + // Low-mids light the paper from behind along a slow band of rows. | |
| 636 | + float glowRow = pow(.5 + .5 * sin(v0.y * .5 - c.t * .8), 6.f); | |
| 637 | + color += tint * glowRow * c.b.y * .5; | |
| 638 | + // Light glowing through facets that are unfolding on an attack. | |
| 639 | + float gap = v0.y * rowH - zc; | |
| 640 | + float unfold = c.hit * smoothstep(1.f, 2.f, gap) * (1 - smoothstep(3.2f, 4.6f, gap)); | |
| 641 | + color += paint(.75 + facetId * .2, f) * unfold * .9; | |
| 642 | + float clear = whFog(d, c, .035, .1); | |
| 643 | + float3 haze = deep(.35, f) * .12 + paint(.7, f) * .06; | |
| 644 | + return (mix(haze, color, clear) + paint(.85, f) * .28 * exp(-tube.w * 5)) * .54; | |
| 645 | + } | |
| 646 | + | |
| 647 | + // ---------------------------------------------------------------- 123 Vector Tube | |
| 648 | + // A retro vector-display tunnel: glowing wireframe hoops and longitudinal beams with | |
| 649 | + // phosphor bloom and a slight beam jitter, the tube twisting and bending, with wireframe | |
| 650 | + // pyramids and cubes tumbling inside. Pure line art on black. Each band lights its own | |
| 651 | + // set of longitudinal beams; attacks fire a polygon ring burst down the tube. | |
| 652 | + float vectorBeam(float dist, float width) { | |
| 653 | + return exp(-dist * dist / (width * width)) + exp(-dist / (width * 7)) * .22; | |
| 654 | + } | |
| 655 | + // Screen position of a point at tube-local offset `local` and view depth d. | |
| 656 | + float2 vectorProject(float3 local, float zc, float bend, float lens) { | |
| 657 | + float d = max(local.z - zc, .05f); | |
| 658 | + return whCentre(zc, d, bend, lens) + local.xy * lens / d; | |
| 659 | + } | |
| 660 | + float3 vectorTube(Ctx c, constant NativeFrame &f) { | |
| 661 | + const float lens = 1.0, bend = .55, hoopGap = .9, beams = 16; | |
| 662 | + // The music clock adds to the forward motion, so energetic passages speed it up. | |
| 663 | + float zc = c.travel * 2 + c.m * 1.5; | |
| 664 | + float2 jitter = float2(noise2(float2(c.t * 37, 1.3)), noise2(float2(5.1, c.t * 41))) - .5; | |
| 665 | + float2 uv = c.uv + jitter * c.px * 1.2; | |
| 666 | + float4 tube = whTube(uv, zc, bend, lens, 1); | |
| 667 | + float a = tube.x, z = tube.y, d = tube.z, r = tube.w; | |
| 668 | + float width = c.px * (.8 + .7 * c.size); | |
| 669 | + float clear = whFog(d, c, .02, .06); | |
| 670 | + float3 color = 0; | |
| 671 | + // Hoops. | |
| 672 | + float dz = z - round(z / hoopGap) * hoopGap; | |
| 673 | + float hoopSpacing = hoopGap * r / d; | |
| 674 | + float hoopFade = smoothstep(c.px * 4, c.px * 14, hoopSpacing) * clear; | |
| 675 | + float hoopIndex = round(z / hoopGap); | |
| 676 | + float major = fmod(fabs(hoopIndex), 4.f) < .5 ? 1.f : 0.f; | |
| 677 | + color += paint(.55 + major * .1, f) * vectorBeam(fabs(dz) * r / d, width * (1 + major * .5)) * hoopFade * (.55 + major * .5); | |
| 678 | + // Longitudinal beams, twisting along the tube and over time. | |
| 679 | + float twist = z * .14 + c.t * .18 + c.m * .25; | |
| 680 | + float slot = (a - twist) / TAU * beams; | |
| 681 | + float beamId = round(slot); | |
| 682 | + float beamDist = fabs(slot - beamId) * TAU / beams * r; | |
| 683 | + float wrapped = beamId - beams * floor(beamId / beams); | |
| 684 | + int family = int(wrapped) % 4; | |
| 685 | + float beamSpacing = TAU / beams * r; | |
| 686 | + float beamFade = smoothstep(c.px * 4, c.px * 16, beamSpacing) * clear; | |
| 687 | + float level = .5 + c.b[family] * 2.2; | |
| 688 | + color += paint(.08 + float(family) * .22, f) * vectorBeam(beamDist, width) * beamFade * level; | |
| 689 | + // Far tube glow where lines merge. | |
| 690 | + color += paint(.6, f) * .1 * exp(-r * 6); | |
| 691 | + // Tumbling wireframe solids. | |
| 692 | + float first = floor((zc + .4) / 3); | |
| 693 | + for (int k = 0; k < 4; ++k) { | |
| 694 | + float id = first + float(k); | |
| 695 | + float objZ = (id + .5) * 3; | |
| 696 | + float gap = objZ - zc; | |
| 697 | + if (gap < .35) continue; | |
| 698 | + float seed = hash11(id * 3.17); | |
| 699 | + float place = seed * TAU; | |
| 700 | + float3 centre = float3(.56 * cos(place), .56 * sin(place), objZ); | |
| 701 | + float size = .24 + .06 * hash11(seed * 9); | |
| 702 | + float2 screenCentre = vectorProject(centre, zc, bend, lens); | |
| 703 | + float reach = size * 1.9 * lens / max(gap - size * 1.8, .05f); | |
| 704 | + if (length(uv - screenCentre) > reach + c.px * 30) continue; | |
| 705 | + float spinA = c.t * (.5 + seed) + seed * 7, spinB = c.t * (.35 + seed * .4) + seed * 3; | |
| 706 | + bool cube = hash11(seed * 5.3) > .45; | |
| 707 | + float3 verts[8]; | |
| 708 | + for (int v = 0; v < 8; ++v) { | |
| 709 | + float3 corner; | |
| 710 | + if (cube) corner = float3(v & 1 ? 1 : -1, v & 2 ? 1 : -1, v & 4 ? 1 : -1); | |
| 711 | + else corner = v < 4 ? float3(v == 0 || v == 3 ? -1 : 1, -.8, v < 2 ? -1 : 1) : float3(0, 1.2, 0); | |
| 712 | + corner *= size; | |
| 713 | + corner.xy = rot(corner.xy, spinA); | |
| 714 | + corner.yz = rot(corner.yz, spinB); | |
| 715 | + verts[v] = corner + centre; | |
| 716 | + } | |
| 717 | + float best = 1e3; | |
| 718 | + if (cube) { | |
| 719 | + for (int e = 0; e < 12; ++e) { | |
| 720 | + int axis = e / 4, rest = e % 4; | |
| 721 | + int lo = axis == 0 ? (rest << 1) : (axis == 1 ? ((rest & 1) | ((rest & 2) << 1)) : rest); | |
| 722 | + int hi = lo | (1 << axis); | |
| 723 | + best = min(best, sdSegment(uv, vectorProject(verts[lo], zc, bend, lens), vectorProject(verts[hi], zc, bend, lens))); | |
| 724 | + } | |
| 725 | + } else { | |
| 726 | + for (int e = 0; e < 4; ++e) { | |
| 727 | + float2 base0 = vectorProject(verts[e], zc, bend, lens); | |
| 728 | + best = min(best, sdSegment(uv, base0, vectorProject(verts[(e + 1) % 4], zc, bend, lens))); | |
| 729 | + best = min(best, sdSegment(uv, base0, vectorProject(verts[4], zc, bend, lens))); | |
| 730 | + } | |
| 731 | + } | |
| 732 | + float fade = smoothstep(.35f, 1.f, gap) * whFog(gap, c, .02, .06); | |
| 733 | + color += paint(.82 + seed * .15, f) * vectorBeam(best, width * 1.2) * fade * 1.2; | |
| 734 | + } | |
| 735 | + // Attack: a polygon ring bursts out of the tube ahead and rushes past. | |
| 736 | + if (c.hit > .001) { | |
| 737 | + float ringD = .7 + (1 - c.hit) * 6; | |
| 738 | + float2 q = uv - whCentre(zc, ringD, bend, lens); | |
| 739 | + float radius = .82 * lens / ringD; | |
| 740 | + float angle = atan2(q.y, q.x) + c.t * .5; | |
| 741 | + float sector = TAU / 12; | |
| 742 | + float local = angle - sector * floor(angle / sector) - sector * .5; | |
| 743 | + float polygon = length(q) * cos(local) - radius * cos(sector * .5); | |
| 744 | + float spoke = fabs(local) * length(q); | |
| 745 | + float burst = vectorBeam(fabs(polygon), width * 1.5) + vectorBeam(spoke, width) * smoothstep(radius * .5, radius, length(q)) * (1 - smoothstep(radius, radius * 1.35, length(q))) * step(fabs(local), .2f); | |
| 746 | + color += paint(.95, f) * burst * c.hit * 1.6; | |
| 747 | + } | |
| 748 | + return color; | |
| 749 | + } | |
| 750 | + | |
| 751 | + // ---------------------------------------------------------------- 124 Orbital Corridor | |
| 752 | + // A space-station corridor, traced analytically: an octagonal hull with octagonal frames | |
| 753 | + // every few metres, inset wall panels, recessed light strips in the corners, a floor | |
| 754 | + // grating, a ceiling light panel, and windows on the right showing a banded planet and | |
| 755 | + // stars. Bass sends a travelling chase along the light strips, attacks light up panels | |
| 756 | + // just ahead, and highs blink the status lights. | |
| 757 | + float2 orbitalNormal(int i) { float a = float(i) * PI * .25; return float2(cos(a), sin(a)); } | |
| 758 | + // Exit distance from inside an octagonal prism of apothem `apothem`; face receives the index. | |
| 759 | + float orbitalExit(float2 o, float2 dxy, float apothem, thread int &face) { | |
| 760 | + float best = 1e4; | |
| 761 | + face = 0; | |
| 762 | + for (int i = 0; i < 8; ++i) { | |
| 763 | + float2 n = orbitalNormal(i); | |
| 764 | + float den = dot(dxy, n); | |
| 765 | + if (den > 1e-4) { | |
| 766 | + float t = (apothem - dot(o, n)) / den; | |
| 767 | + if (t < best) { best = t; face = i; } | |
| 768 | + } | |
| 769 | + } | |
| 770 | + return best; | |
| 771 | + } | |
| 772 | + float3 orbitalSpace(float3 rd, Ctx c, constant NativeFrame &f) { | |
| 773 | + float3 color = deep(.2 + rd.y * .1, f) * .05; | |
| 774 | + float2 g = float2(atan2(rd.z, rd.x), rd.y) * 60; | |
| 775 | + float h = hash21(floor(g)); | |
| 776 | + color += paint(.85 + h * .1, f) * step(.93f, h) * exp(-length(fract(g) - .5) * 9) * 1.2; | |
| 777 | + float3 planetDir = normalize(float3(1, -.3, .75)); | |
| 778 | + float3 e1 = normalize(cross(planetDir, float3(0, 1, 0))), e2 = cross(e1, planetDir); | |
| 779 | + float span = .42; | |
| 780 | + float2 disk = float2(dot(rd, e1), dot(rd, e2)) / span; | |
| 781 | + float rr = dot(disk, disk); | |
| 782 | + float facing = dot(rd, planetDir); | |
| 783 | + if (facing > 0) { | |
| 784 | + float3 sun = normalize(float3(-.55, .45, .7)); | |
| 785 | + float atmosphere = exp(-fabs(sqrt(rr) - 1) * 18) * .5; | |
| 786 | + if (rr < 1) { | |
| 787 | + float3 n = float3(disk, sqrt(1 - rr)); | |
| 788 | + float lit = max(dot(n, sun), 0.f); | |
| 789 | + float bands = disk.y * 7 + .35 * sin(disk.x * 5 + disk.y * 9 + c.t * .05) + fbm2(float2(disk.x * 3 + c.t * .02, disk.y * 12), 3) * 1.5; | |
| 790 | + float3 surface = mix(paint(.25 + .1 * sin(bands), f), paint(.65 + .15 * sin(bands * 1.7), f), .5 + .5 * sin(bands * 2.3)); | |
| 791 | + color = surface * (.04 + lit * .9) + paint(.8, f) * pow(1 - n.z, 3.f) * lit * .6; | |
| 792 | + } | |
| 793 | + color += paint(.75, f) * atmosphere * (.3 + max(dot(normalize(disk + 1e-4), normalize(sun.xy)), 0.f)); | |
| 794 | + } | |
| 795 | + return color; | |
| 796 | + } | |
| 797 | + float3 orbitalCorridor(Ctx c, constant NativeFrame &f) { | |
| 798 | + const float apothem = 1, frameApothem = .84, halfFrame = .09; | |
| 799 | + float bay = 2.4 * c.size; | |
| 800 | + // The music clock adds to the forward drift, so energetic passages speed the flight. | |
| 801 | + float zc = c.travel * 1.6 + c.m * 1.2; | |
| 802 | + float3 ro = float3(sin(c.t * .21) * .12, -.1 + sin(c.t * .17) * .05, zc); | |
| 803 | + float3 rd = cameraRay(c.uv, float3(sin(c.t * .09) * .12, sin(c.t * .07) * .05, 1), float3(sin(c.t * .13) * .06, 1, 0), 1.05); | |
| 804 | + int face, frameFace; | |
| 805 | + float tWall = min(orbitalExit(ro.xy, rd.xy, apothem, face), 80.f); | |
| 806 | + float tFrame = orbitalExit(ro.xy, rd.xy, frameApothem, frameFace); | |
| 807 | + float zFrame = ro.z + rd.z * tFrame; | |
| 808 | + float slab = zFrame - round(zFrame / bay) * bay; | |
| 809 | + int kind = 0; // 0 wall, 1 frame soffit, 2 frame front face | |
| 810 | + float t = tWall; | |
| 811 | + if (tFrame < tWall && fabs(slab) < halfFrame) { kind = 1; t = tFrame; } | |
| 812 | + else if (tFrame < tWall) { | |
| 813 | + float front = ceil((zFrame + halfFrame) / bay) * bay - halfFrame; | |
| 814 | + float tFront = (front - ro.z) / max(rd.z, 1e-4f); | |
| 815 | + if (tFront < tWall) { kind = 2; t = tFront; } | |
| 816 | + } | |
| 817 | + float3 p = ro + rd * t; | |
| 818 | + int id = kind == 1 ? frameFace : face; | |
| 819 | + float2 n2 = orbitalNormal(id); | |
| 820 | + float u = dot(p.xy, float2(-n2.y, n2.x)); | |
| 821 | + float bayIndex = floor((p.z + halfFrame) / bay); | |
| 822 | + float lz = p.z + halfFrame - bayIndex * bay; // 0..bay within the bay, frame at both ends | |
| 823 | + float3 normal = kind == 2 ? float3(0, 0, -1) : float3(-n2, 0); | |
| 824 | + float foot = c.px * t; | |
| 825 | + float3 light = normalize(float3(-p.x * .6, .85 - p.y, -.3)); | |
| 826 | + float diffuse = .3 + .7 * max(dot(normal, light), 0.f); | |
| 827 | + float3 metal = mix(deep(.25, f), paint(.3, f), .35); | |
| 828 | + float3 color = metal * .12 * diffuse; | |
| 829 | + float3 glowAdd = 0; | |
| 830 | + if (kind == 0) { | |
| 831 | + float panelZ = lz / (bay * .5); | |
| 832 | + float panelId = floor(panelZ); | |
| 833 | + float2 cellLocal = float2(u / .36, fract(panelZ) * 2 - 1); | |
| 834 | + float seed = hash31(float3(float(id), bayIndex, panelId)); | |
| 835 | + float inset = sdBox2(cellLocal, float2(.86, .82)); | |
| 836 | + float groove = 1 - smoothstep(0.f, .05f + foot * 4, fabs(inset)); | |
| 837 | + float bevel = smoothstep(-.12f, 0.f, inset) * (inset < 0 ? 1.f : 0.f); | |
| 838 | + if (id == 6) { | |
| 839 | + // Floor grating with a dim glow beneath. | |
| 840 | + float2 grid = float2(u * 16, p.z * 8); | |
| 841 | + float2 bars = abs(fract(grid) - .5); | |
| 842 | + float hole = smoothstep(.32f, .26f, max(bars.x * .9, bars.y * 1.4)); | |
| 843 | + hole *= exp(-foot * 6); | |
| 844 | + // The glow under the grating rides a travelling wave that the bass feeds. | |
| 845 | + float underWave = .6 + .4 * sin(p.z * .7 - c.t - c.m * 2); | |
| 846 | + color = mix(metal * .16 * diffuse, deep(.4, f) * .12 + paint(.35, f) * (.08 + c.b.x * .45) * underWave, hole); | |
| 847 | + color += paint(.6, f) * .04 * (1 - smoothstep(.02f, .04f, fabs(fabs(u) - .2))); | |
| 848 | + } else if (id == 2) { | |
| 849 | + // Ceiling light panel, broken at each frame. | |
| 850 | + float strip = smoothstep(.2f, .17f, fabs(u)) * smoothstep(.1f, .25f, lz) * smoothstep(bay - .1f, bay - .25f, lz); | |
| 851 | + // Low-mids send a slow swell along the ceiling panels. | |
| 852 | + float swell = pow(.5 + .5 * sin(p.z * .5 - c.t * 2), 4.f) * c.b.y; | |
| 853 | + color = metal * .12 * diffuse + paint(.82, f) * strip * (.75 + c.b.y * .8 + swell * 1.5); | |
| 854 | + } else if (id == 0 && fabs(u) < .3 && lz > .25 && lz < bay - .25) { | |
| 855 | + // Window onto the planet. | |
| 856 | + float edge = min(.3 - fabs(u), min(lz - .25, bay - .25 - lz)); | |
| 857 | + float rim = 1 - smoothstep(0.f, .025f + foot * 2, edge); | |
| 858 | + color = orbitalSpace(rd, c, f) * (1 - rim) + paint(.5, f) * rim * .25; | |
| 859 | + } else { | |
| 860 | + color = metal * (.1 + .07 * seed) * diffuse * (1 - groove * .7) + paint(.4, f) * bevel * .05 * diffuse; | |
| 861 | + // Status lights blink smoothly; highs make them flicker brighter. | |
| 862 | + float2 ledAt = float2(.6, .55); | |
| 863 | + float led = exp(-length((cellLocal - ledAt) * float2(1, .9)) * 22); | |
| 864 | + float blink = pow(.5 + .5 * sin(c.t * (1.3 + seed * 3) + c.m * 2 + seed * 40), 6.f); | |
| 865 | + glowAdd += paint(fract(seed * 7) < .5 ? .15f : .55f, f) * led * blink * (.4 + c.b.w * 3.5) * step(.3f, seed); | |
| 866 | + // Attack: panels just ahead glow from inside. | |
| 867 | + float gap = p.z - zc; | |
| 868 | + float open = c.hit * step(.55f, seed) * smoothstep(.8f, 2.f, gap) * (1 - smoothstep(4.5f, 7.f, gap)); | |
| 869 | + glowAdd += paint(.7 + seed * .25, f) * open * (inset < 0 ? .9f : 0.f) * (.6 + .4 * smoothstep(0.f, -.6f, inset)); | |
| 870 | + // Every wall panel is backlit and pulses with its own band. | |
| 871 | + float panelBand = c.b[int(fract(seed * 5.3) * 3.99)]; | |
| 872 | + glowAdd += paint(.5 + seed * .35, f) * panelBand * .2 * (inset < 0 ? .4 + .6 * smoothstep(0.f, -.5f, inset) : 0.f); | |
| 873 | + } | |
| 874 | + // Recessed light strips along the corners of the diagonal faces. | |
| 875 | + if (id % 2 == 1) { | |
| 876 | + float strip = smoothstep(.375f, .395f, fabs(u)); | |
| 877 | + float chase = pow(.5 + .5 * sin(p.z * 1.4 - c.t * 5 - c.m * 3), 10.f); | |
| 878 | + glowAdd += paint(.5 + float(id) * .04, f) * strip * (.5 + c.b.x * .9 + chase * c.b.x * 3); | |
| 879 | + } | |
| 880 | + } else if (kind == 1) { | |
| 881 | + float lip = smoothstep(halfFrame - .02f, halfFrame, fabs(slab)); | |
| 882 | + color = metal * .22 * diffuse + paint(.6, f) * lip * (.25 + c.b.w * 1.2); | |
| 883 | + float bolt = exp(-length(float2(fract(u * 6) - .5, slab * 6)) * 12); | |
| 884 | + color += paint(.9, f) * bolt * .25 * exp(-foot * 8); | |
| 885 | + } else { | |
| 886 | + // Frame front face: brushed ring with a glowing inner edge. | |
| 887 | + float2 q = p.xy; | |
| 888 | + float oct = 0; | |
| 889 | + for (int i = 0; i < 8; ++i) oct = max(oct, dot(q, orbitalNormal(i))); | |
| 890 | + float inner = 1 - smoothstep(0.f, .025f + foot * 2, oct - frameApothem); | |
| 891 | + float outer = 1 - smoothstep(0.f, .02f + foot * 2, apothem - oct); | |
| 892 | + color = metal * (.18 + .08 * sin(oct * 80)) * diffuse + paint(.7, f) * inner * (.7 + c.b.z * 1.5) + paint(.4, f) * outer * .2; | |
| 893 | + float marks = step(.5f, fract((atan2(q.y, q.x) / TAU) * 32)) * smoothstep(.9f, .92f, oct) * (1 - smoothstep(.95f, .97f, oct)); | |
| 894 | + color += paint(.15, f) * marks * .25; | |
| 895 | + } | |
| 896 | + // Attack: a wave of light runs down the corridor along the strips and frames. | |
| 897 | + float waveZ = zc + .5 + (1 - c.hit) * 12; | |
| 898 | + float lightWave = c.hit * exp(-pow((p.z - waveZ) * 1.4, 2.f)); | |
| 899 | + glowAdd += paint(.9, f) * lightWave * (kind == 0 ? .35f : .8f); | |
| 900 | + color += glowAdd; | |
| 901 | + float clear = whFog(t, c, .02, .07); | |
| 902 | + float3 haze = deep(.35, f) * .1 + paint(.7, f) * .1 * exp(-length(c.uv) * 1.5); | |
| 903 | + return mix(haze, color, clear); | |
| 904 | + } | |
| 905 | + | |
| 906 | + // ---------------------------------------------------------------- 125 Mirrorball Tunnel | |
| 907 | + // A tube lined with small square mirror tiles, each tilted a little differently, so every | |
| 908 | + // tile catches its own reflection of a roaming spotlight environment and glints on its | |
| 909 | + // own, while coloured light spots sweep around the walls. Bass brightens the spots, highs | |
| 910 | + // sparkle individual tiles and each attack sends a wave of glints racing down the tube. | |
| 911 | + float3 mirrorballTunnel(Ctx c, constant NativeFrame &f) { | |
| 912 | + const float lens = 1.05; | |
| 913 | + // The music clock adds to the forward motion, so energetic passages speed it up. | |
| 914 | + float zc = c.travel * 1.5 + c.m * 1.0; | |
| 915 | + float4 tube = whTube(c.uv, zc, .35, lens, 1); | |
| 916 | + float a = tube.x, z = tube.y, d = tube.z, r = tube.w; | |
| 917 | + float columns = clamp(floor(44 / c.size + .5), 16.f, 96.f); | |
| 918 | + float tileH = TAU / columns; | |
| 919 | + float spin = c.t * .05; | |
| 920 | + float2 g = float2((a / TAU - spin) * columns, z / tileH); | |
| 921 | + float2 cell = floor(g), local = fract(g); | |
| 922 | + float column = cell.x - columns * floor(cell.x / columns); | |
| 923 | + float seed = hash21(float2(column, cell.y)); | |
| 924 | + float2 tilt = (hash22(float2(column, cell.y) + 3.7) - .5) * .32; | |
| 925 | + float centreAngle = (cell.x + .5) / columns * TAU + spin * TAU; | |
| 926 | + float3 inward = -float3(cos(centreAngle), sin(centreAngle), 0); | |
| 927 | + float3 tangent = float3(-sin(centreAngle), cos(centreAngle), 0); | |
| 928 | + float3 n = normalize(inward + tangent * tilt.x + float3(0, 0, 1) * tilt.y); | |
| 929 | + float3 view = normalize(float3(cos(a), sin(a), d)); | |
| 930 | + float3 refl = reflect(view, n); | |
| 931 | + // Reflected environment: a dim gradient and five roaming spotlights. | |
| 932 | + float3 env = deep(.3 + refl.z * .25, f) * .14; | |
| 933 | + float spotBoost = 1 + c.b.x * 1.6; | |
| 934 | + for (int k = 0; k < 5; ++k) { | |
| 935 | + float fk = float(k); | |
| 936 | + float around = (c.t + c.m * .8) * (.35 + fk * .08) * (k % 2 == 0 ? 1 : -1) + fk * 1.26; | |
| 937 | + float3 dir = normalize(float3(cos(around), sin(around), .6 * sin(c.t * .37 + fk * 2.1))); | |
| 938 | + env += paint(fk * .21 + .05, f) * pow(max(dot(refl, dir), 0.f), 22.f) * 1.8 * (spotBoost + c.b[k % 4] * .8); | |
| 939 | + } | |
| 940 | + // Light pools sweeping over the walls. | |
| 941 | + float3 pool = 0; | |
| 942 | + for (int m = 0; m < 3; ++m) { | |
| 943 | + float fm = float(m); | |
| 944 | + float centre = (c.t + c.m * .8) * (.45 + fm * .17) * (m == 1 ? -1 : 1) + fm * 2.1; | |
| 945 | + float depth = 2.2 + 1.3 * sin(c.t * .31 + fm * 1.7) + fm * .8; | |
| 946 | + float2 offset = float2(whWrap(a - centre), (z - zc - depth) * .55); | |
| 947 | + pool += paint(.15 + fm * .3, f) * exp(-dot(offset, offset) * 5) * spotBoost; | |
| 948 | + } | |
| 949 | + float poolLevel = dot(pool, float3(.33)); | |
| 950 | + // Highs sparkle single tiles; attacks send a glint wave down the tube. | |
| 951 | + float twinkle = pow(.5 + .5 * sin(c.t * (5 + seed * 7) + seed * 60), 24.f) * c.b.w * 3; | |
| 952 | + float waveZ = zc + .3 + (1 - c.hit) * 7; | |
| 953 | + float wave = c.hit * exp(-pow((z - waveZ) * 1.6, 2.f)); | |
| 954 | + float glint = dot(env, float3(.33)); | |
| 955 | + float3 tile = env * (.55 + .9 * glint) + pool * (.5 + glint * 2.5) + mix(env, paint(.95, f), .5) * (twinkle + wave * 2.5); | |
| 956 | + tile *= .85 + .3 * seed; | |
| 957 | + // Bevelled edges and dark grout between tiles. | |
| 958 | + float2 edge = min(local, 1 - local); | |
| 959 | + float edgeMin = min(edge.x, edge.y); | |
| 960 | + float foot = c.px * d * d / lens / tileH; | |
| 961 | + float grout = smoothstep(.04f, .09f + foot, edgeMin); | |
| 962 | + float3 color = mix(deep(.4, f) * .05 + pool * .08, tile, grout); | |
| 963 | + float star = (twinkle + wave * 2) * exp(-min(fabs(local.x - .5), fabs(local.y - .5)) * 30) * exp(-length(local - .5) * 4); | |
| 964 | + color += paint(.95, f) * star * .6; | |
| 965 | + // Tiles smaller than a few pixels blend into their average glow. | |
| 966 | + float tilePixels = tileH * r / d / c.px; | |
| 967 | + float3 farGlow = paint(a / TAU * 2 + c.t * .06, f) * .22 + deep(.3, f) * .06; | |
| 968 | + float3 average = env * .5 + pool * .8 + farGlow + paint(.9, f) * wave * 1.2; | |
| 969 | + color = mix(average, color, smoothstep(2.f, 5.f, tilePixels)); | |
| 970 | + float clear = whFog(d, c, .03, .09); | |
| 971 | + return mix(farGlow, color, clear) + paint(.9, f) * .25 * exp(-r * 7); | |
| 972 | + } | |
| 973 | + | |
| 974 | + // ---------------------------------------------------------------- 126 Fractal Throat | |
| 975 | + // Raymarched: a kaleidoscopic folded-box fractal (abs folds, sorting folds and rotations) | |
| 976 | + // repeating along the flight path, with a winding corridor carved through it. Sharp | |
| 977 | + // crystalline edges glow in orbit-trap colours and the far throat sinks into deep fog. | |
| 978 | + // Bass swells the fold glow; attacks spark the edges nearest the camera. | |
| 979 | + | |
| 980 | + | |
| 981 | + // ---------------------------------------------------------------- 127 Chroma Pipe | |
| 982 | + // Inside a polished chrome pipe. The wall mirrors a dark surround laced with neon stripe | |
| 983 | + // bands, and gentle dents in the metal bend the reflection into liquid, curving bands, | |
| 984 | + // with sharp specular glints on the dents. Chromatic rings, split into three palette | |
| 985 | + // channels, travel along the pipe and glint in the chrome. Bass deepens the dents so the | |
| 986 | + // stripes bend harder, highs sharpen and multiply the rings, and each attack emits a | |
| 987 | + // bright split ring from the camera. | |
| 988 | + float3 chromaEnvironment(float3 dir, Ctx c, constant NativeFrame &f) { | |
| 989 | + // Neon stripe bands around the reflected direction, on black. | |
| 990 | + float around = atan2(dir.y, dir.x) / TAU; | |
| 991 | + float stripe = around * 6 + dir.z * 2.6 - c.t * .22 - c.m * .35; | |
| 992 | + float id = floor(stripe); | |
| 993 | + id -= 6 * floor(id / 6); | |
| 994 | + float band = fract(stripe); | |
| 995 | + float neon = exp(-pow((band - .5) / .16, 2.f)); | |
| 996 | + float core = exp(-pow((band - .5) / .045, 2.f)); | |
| 997 | + float3 color = paint(id * .19 + .03, f) * (neon * (.9 + c.b[int(id) % 4] * 1.2) + core * .5); | |
| 998 | + color += paint(.6, f) * .05 * (.5 + .5 * dir.z); | |
| 999 | + return color; | |
| 1000 | + } | |
| 1001 | + float3 chromaRings(float z, Ctx c, constant NativeFrame &f, float width) { | |
| 1002 | + float split = .07 * c.size; | |
| 1003 | + float3 total = 0; | |
| 1004 | + for (int train = 0; train < 2; ++train) { | |
| 1005 | + float spacing = train == 0 ? 2.4f : 1.2f; | |
| 1006 | + float level = train == 0 ? 1.f : c.b.w * 1.4; | |
| 1007 | + if (level < .001) continue; | |
| 1008 | + float phase = (z - (c.t + c.m * 1.2) * (train == 0 ? 1.6f : 2.3f)) / spacing + (train == 0 ? 0.f : .37f); | |
| 1009 | + float dist = (fract(phase + .5) - .5) * spacing; | |
| 1010 | + float w = width * (1 - .45 * c.b.w); | |
| 1011 | + total += (paint(.02, f) * exp(-pow((dist + split) / w, 2.f)) + paint(.5, f) * exp(-pow(dist / w, 2.f)) + paint(.8, f) * exp(-pow((dist - split) / w, 2.f))) * level; | |
| 1012 | + } | |
| 1013 | + return total; | |
| 1014 | + } | |
| 1015 | + float3 chromaPipe(Ctx c, constant NativeFrame &f) { | |
| 1016 | + const float lens = 1.05; | |
| 1017 | + // The music clock adds to the forward motion, so energetic passages speed it up. | |
| 1018 | + float zc = c.travel * 1.6 + c.m * 1.0; | |
| 1019 | + float4 tube = whTube(c.uv, zc, .3, lens, 1); | |
| 1020 | + float a = tube.x, z = tube.y, d = tube.z, r = tube.w; | |
| 1021 | + float foot = c.px * d * d / lens; | |
| 1022 | + float sharp = exp(-foot * 4); | |
| 1023 | + float3 view = normalize(float3(cos(a), sin(a), d)); | |
| 1024 | + // Dents: a smooth height field around and along the pipe; bass deepens it. | |
| 1025 | + float depth = (.22 + c.b.x * .5) * sharp; | |
| 1026 | + float phaseA = a * 3 + sin(z * .9 + c.t * .4) * 1.5; | |
| 1027 | + float phaseZ = z * 2.1 - c.t * .6 + sin(a * 2 + z * .5) * .8; | |
| 1028 | + float dA = cos(phaseA) * sin(phaseZ) * 3, dZ = sin(phaseA) * cos(phaseZ) * 2.1; | |
| 1029 | + float3 inward = -float3(cos(a), sin(a), 0), tangent = float3(-sin(a), cos(a), 0); | |
| 1030 | + float3 n = normalize(inward + (tangent * dA + float3(0, 0, 1) * dZ) * depth); | |
| 1031 | + float3 refl = reflect(view, n); | |
| 1032 | + float3 color = chromaEnvironment(refl, c, f); | |
| 1033 | + // The rings show up in the chrome where the reflection crosses them. | |
| 1034 | + float t2 = -2 * dot(float2(cos(a), sin(a)), refl.xy) / max(dot(refl.xy, refl.xy), 1e-4f); | |
| 1035 | + float z2 = z + refl.z * min(t2, 30.f); | |
| 1036 | + color += chromaRings(z2, c, f, .05 * c.size) * .5; | |
| 1037 | + float fresnel = .6 + .4 * pow(1 - max(dot(-view, n), 0.f), 3.f); | |
| 1038 | + color *= fresnel; | |
| 1039 | + float glint = pow(max(dot(refl, normalize(float3(.25, .45, 1))), 0.f), 60.f) + pow(max(dot(refl, normalize(float3(-.5, -.3, 1))), 0.f), 90.f); | |
| 1040 | + color += paint(.95, f) * glint * (.7 + c.b.z * 1.5) * sharp; | |
| 1041 | + // Far down the pipe the reflections blur into a soft average. | |
| 1042 | + color = mix(paint(.5 + .1 * sin(c.t * .2), f) * .18, color, exp(-foot * 1.5)); | |
| 1043 | + // Seams on the chrome give scale. | |
| 1044 | + float seam = 1 - smoothstep(.004f, .012f + foot, fabs(z - round(z / 1.6) * 1.6)); | |
| 1045 | + color *= 1 - seam * .7; | |
| 1046 | + // The rings glow on the wall itself. | |
| 1047 | + float width = .05 * c.size; | |
| 1048 | + color += chromaRings(z, c, f, max(width, foot * .8)) * min(1.f, width / max(foot * .8, 1e-4f)) * .9; | |
| 1049 | + float pingZ = zc + .7 + (1 - c.hit) * 8; | |
| 1050 | + float dz = z - pingZ, split = .09; | |
| 1051 | + float w = max(.06f, foot); | |
| 1052 | + color += (paint(.02, f) * exp(-pow((dz + split) / w, 2.f)) + paint(.5, f) * exp(-pow(dz / w, 2.f)) + paint(.8, f) * exp(-pow((dz - split) / w, 2.f))) * c.hit * 2.2; | |
| 1053 | + float clear = whFog(d, c, .03, .08); | |
| 1054 | + return (mix(paint(.55, f) * .1 + deep(.3, f) * .08, color, clear) + paint(.9, f) * .2 * exp(-r * 6)) * .68; | |
| 1055 | + } | |
| 1056 | + | |
| 1057 | + // ---------------------------------------------------------------- 128 Coral Burrow | |
| 1058 | + // An undersea burrow: lumpy walls of porous coral (corallite cells with raised rims) | |
| 1059 | + // rippled by caustic light, set with bioluminescent polyps (glowing discs ringed by | |
| 1060 | + // swaying tentacles) and glowing plankton drifting past. Bass opens the polyps, highs | |
| 1061 | + // make the plankton twinkle and each attack flashes a ring of polyps just ahead. | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + // ---------------------------------------------------------------- 129 Rainbow Slide | |
| 1065 | + // Riding down a translucent waterslide tube in sunshine. The rider sits low in the tube, | |
| 1066 | + // banked turns roll the view, helical panels of saturated colour glow with the sun | |
| 1067 | + // shining through the plastic, flanged seams ring each section, and a sheet of water | |
| 1068 | + // with bright foam rushes along the bottom. Bass splashes the water higher up the walls, | |
| 1069 | + // highs spit droplets and attacks throw spray across the camera side. | |
| 1070 | + float2 slidePath(float z) { return float2(sin(z * .19) * 1.4 + sin(z * .083) * .8, cos(z * .15) * .7); } | |
| 1071 | + float3 rainbowSlide(Ctx c, constant NativeFrame &f) { | |
| 1072 | + const float lens = .95, sit = .38; | |
| 1073 | + float radius = c.size; | |
| 1074 | + // The music clock adds to the forward motion, so energetic passages speed it up. | |
| 1075 | + float zc = c.travel * 1.9 + c.m * 1.5; | |
| 1076 | + // Bank into the turns: lateral curvature rolls the rider and the water up the wall. | |
| 1077 | + float curve = slidePath(zc + 1.2).x - 2 * slidePath(zc).x + slidePath(zc - 1.2).x; | |
| 1078 | + float bank = clamp(-curve * 1.6, -1.f, 1.f); | |
| 1079 | + float2 uv = rot(c.uv, -bank); | |
| 1080 | + float2 down = float2(sin(bank), -cos(bank)); | |
| 1081 | + float2 cam = down * sit * radius; | |
| 1082 | + float2 slope = slidePath(zc + .5) - slidePath(zc - .5); | |
| 1083 | + float d = 2, angle = 0; | |
| 1084 | + float2 wall = 0; | |
| 1085 | + for (int i = 0; i < 3; ++i) { | |
| 1086 | + float2 centre = (slidePath(zc + d) - slidePath(zc) - slope * d) * lens / max(d, 1e-3f); | |
| 1087 | + float2 v = (uv - centre) / lens; | |
| 1088 | + float vv = max(dot(v, v), 1e-6f), vc = dot(v, cam); | |
| 1089 | + d = (-vc + sqrt(max(vc * vc - vv * (dot(cam, cam) - radius * radius), 0.f))) / vv; | |
| 1090 | + d = min(d, 70.f); | |
| 1091 | + wall = cam + v * d; | |
| 1092 | + } | |
| 1093 | + angle = atan2(wall.y, wall.x); | |
| 1094 | + float z = zc + d; | |
| 1095 | + float foot = c.px * d * d / lens; | |
| 1096 | + float sharp = exp(-foot * 6); | |
| 1097 | + // Helical colour panels with flanged seams. | |
| 1098 | + float section = 1.1; | |
| 1099 | + float stripe = angle / TAU * 6 + z / section * .35; | |
| 1100 | + float id = floor(stripe); | |
| 1101 | + id -= 6 * floor(id / 6); | |
| 1102 | + float segment = floor(z / section); | |
| 1103 | + float3 panel = paint(id < 4.5 ? id * .25 : .375f, f); // palette stops stay pure | |
| 1104 | + float edge = fract(stripe); | |
| 1105 | + float joint = (1 - smoothstep(0.f, .04f + foot * 3, edge)) + (1 - smoothstep(1.f, .96f - foot * 3, edge)); | |
| 1106 | + panel *= 1 - joint * .55 * sharp; | |
| 1107 | + // Moulded ribs inside each panel catch the light. | |
| 1108 | + float rib = pow(.5 + .5 * cos(fract(z / section) * TAU * 3), 12.f) * sharp; | |
| 1109 | + panel *= .85 + .3 * rib; | |
| 1110 | + // Sun through the plastic: the side facing the sun glows, with a soft hot spot. | |
| 1111 | + float2 outward = wall / radius; | |
| 1112 | + float2 sunDir = normalize(float2(.45, .9)); | |
| 1113 | + float through = .15 + .85 * pow(max(dot(outward, sunDir) * .5 + .5, 0.f), 2.f); | |
| 1114 | + float hotspot = exp(-pow(whWrap(angle - atan2(sunDir.y, sunDir.x) - .3 * sin(z * .2)), 2.f) * 6) * (.6 + .4 * sin(z * .9 - c.t * .5)); | |
| 1115 | + float ripple = whNoiseP(float2(angle / TAU * 24, z * 2 + c.t * .4), 24); | |
| 1116 | + float caustic = pow(1 - fabs(whNoiseP(float2(angle / TAU * 16, z * 1.4 - c.t * .8), 16) * 2 - 1), 6.f) * sharp; | |
| 1117 | + // Low-mids pulse light through the panels section by section; high-mids sharpen the caustics. | |
| 1118 | + float sectionPulse = pow(.5 + .5 * sin(segment * 1.3 - c.t * 3), 4.f) * c.b.y; | |
| 1119 | + float3 color = panel * (.08 + .8 * through + hotspot * .4 + caustic * (.35 + c.b.z * .8) * through + sectionPulse * .6) + panel * ripple * .08 * sharp; | |
| 1120 | + float sheen = pow(max(cos(angle - 2.3), 0.f), 90.f) + pow(max(cos(angle + .6), 0.f), 120.f) * .6; | |
| 1121 | + color += mix(panel, paint(.97, f), .5) * sheen * .35 * sharp; | |
| 1122 | + float seamZ = z - round(z / section) * section; | |
| 1123 | + float flange = (1 - smoothstep(.018f, .03f + foot, fabs(seamZ))) * sharp; | |
| 1124 | + color = mix(color, panel * .15 + paint(.95, f) * .2 * through, flange * .8); | |
| 1125 | + float bolts = exp(-length(float2(whWrap(angle - (floor(angle / TAU * 16) + .5) * TAU / 16) * radius, seamZ)) * 60) * sharp; | |
| 1126 | + color += paint(.97, f) * bolts * .4; | |
| 1127 | + // Water sheet along the bottom (which tilts with the bank), with foam at its edges. | |
| 1128 | + float waterAngle = atan2(down.y, down.x); | |
| 1129 | + float off = fabs(whWrap(angle - waterAngle)); | |
| 1130 | + float slosh = .5 + .12 * sin(z * .6 - c.t * 1.3) + .08 * sin(z * 1.7 + c.t * 2.1); | |
| 1131 | + float reach = slosh + c.b.x * .55 * (.6 + .4 * sin(z * 2.3 - c.t * 4)); | |
| 1132 | + float water = smoothstep(reach, reach - .08f, off); | |
| 1133 | + float flow = z * 2.2 - zc * 2.6 - c.t * 2; | |
| 1134 | + float streaks = whNoiseP(float2(angle / TAU * 60, flow), 60) * .6 + whNoiseP(float2(angle / TAU * 20, flow * .4), 20) * .4; | |
| 1135 | + streaks = mix(.5f, streaks, sharp); | |
| 1136 | + float foam = smoothstep(.12f, 0.f, fabs(off - reach)) * (.5 + .5 * whNoiseP(float2(angle / TAU * 40, flow * 1.5), 40)); | |
| 1137 | + float glitter = pow(whNoiseP(float2(angle / TAU * 90, flow * 3 + c.t), 90), 14.f) * sharp; | |
| 1138 | + float3 spray = mix(paint(.0, f), paint(.5, f), .35); | |
| 1139 | + float3 waterColor = panel * .25 + paint(.0, f) * .14 + spray * (pow(streaks, 4.f) * .8 + glitter * 1.6); | |
| 1140 | + color = mix(color, waterColor, water * .85); | |
| 1141 | + color += spray * foam * .6 * sharp; | |
| 1142 | + float clear = whFog(d, c, .02, .06); | |
| 1143 | + color = mix(paint(.8, f) * .22 + paint(.3, f) * .06, color, clear * exp(-foot * .8) + (1 - exp(-foot * .8)) * 0); | |
| 1144 | + // Droplets in the air (highs) and spray across the camera side (attacks). | |
| 1145 | + if (c.b.w > .001) { | |
| 1146 | + float2 q = uv * 7 + float2(0, c.t * 2.5); | |
| 1147 | + float2 cell = floor(q); | |
| 1148 | + float h = hash21(cell); | |
| 1149 | + float2 at = hash22(cell + 4.1) - .5; | |
| 1150 | + float drop = exp(-pow(length(fract(q) - .5 - at * .7) / .045, 2.f)) * step(.86f, h); | |
| 1151 | + color += paint(.97, f) * drop * c.b.w * 1.4; | |
| 1152 | + } | |
| 1153 | + if (c.hit > .001) { | |
| 1154 | + float spray = 0; | |
| 1155 | + for (int k = 0; k < 9; ++k) { | |
| 1156 | + float seed = hash11(float(k) * 7.31 + 2); | |
| 1157 | + float dirAngle = -PI * .5 + (seed - .5) * 2.6; | |
| 1158 | + float2 at = float2(0, -1.05) + float2(cos(dirAngle), sin(dirAngle) * .5 + .6) * (.25 + (1 - c.hit) * (.6 + seed * .5)); | |
| 1159 | + at.x *= c.extent.x; | |
| 1160 | + float size = .04 + .05 * hash11(seed * 13); | |
| 1161 | + float rr = length(uv - at) / size; | |
| 1162 | + spray += (smoothstep(1.f, .85f, rr) * .25 + exp(-pow((rr - .85) / .12, 2.f)) * .9); | |
| 1163 | + } | |
| 1164 | + color += paint(.95, f) * spray * c.hit * c.hit * 1.2; | |
| 1165 | + } | |
| 1166 | + return color * .62; | |
| 1167 | + } | |
| 1168 | + | |
| 1169 | + // ---------------------------------------------------------------- 130 Pulse Arteries | |
| 1170 | + // Flowing through a blood vessel: a soft, moist wall laced with branching veins and | |
| 1171 | + // capillaries, side vessels opening off it, and biconcave cells tumbling past toward the | |
| 1172 | + // camera. Bass drives a heartbeat dilation wave that travels along the wall, the cell | |
| 1173 | + // flow surges with the music clock, and each attack spawns a cluster of cells ahead. | |
| 1174 | + float4 arteryCell(float2 q, float2 centre, float radius, float seed, float t) { | |
| 1175 | + // Returns colour weight (x), rim (y), coverage (z) of a tumbling biconcave disc. | |
| 1176 | + float tilt = t * (.4 + seed * .6) + seed * 9; | |
| 1177 | + float spin = t * (.3 + seed * .3) + seed * 17; | |
| 1178 | + float2 local = rot(q - centre, -spin); | |
| 1179 | + float squeeze = max(fabs(cos(tilt)), .18f); | |
| 1180 | + float e = length(float2(local.x, local.y / squeeze)) / radius; | |
| 1181 | + float cover = smoothstep(1.f, .9f, e); | |
| 1182 | + float dimple = smoothstep(.15f, .75f, e) * (.55 + .45 * squeeze); | |
| 1183 | + float rim = exp(-pow((e - .8) / .18, 2.f)); | |
| 1184 | + return float4(dimple, rim, cover, e); | |
| 1185 | + } | |
| 1186 | + float3 pulseArteries(Ctx c, constant NativeFrame &f) { | |
| 1187 | + const float lens = 1.0, bend = .6; | |
| 1188 | + float vessel = c.size; | |
| 1189 | + // The music clock adds to the flow, so energetic passages rush the camera along. | |
| 1190 | + float zc = c.travel * 1.3 + c.m * .8; | |
| 1191 | + float4 tube = whTube(c.uv, zc, bend, lens, vessel); | |
| 1192 | + float a = tube.x, d0 = tube.z, r = tube.w; | |
| 1193 | + // Heartbeat dilation: a travelling bulge, stronger with bass. | |
| 1194 | + float pulseClock = c.t * 1.6 + c.m * 2.5; | |
| 1195 | + float beatPhase = (zc + d0) * .55 - pulseClock; | |
| 1196 | + float beat = pow(.5 + .5 * sin(beatPhase), 3.f); | |
| 1197 | + float dilate = 1 + (.03 + c.b.x * .24) * beat; | |
| 1198 | + float d = d0 * dilate; | |
| 1199 | + float z = zc + d; | |
| 1200 | + beat = pow(.5 + .5 * sin(z * .55 - pulseClock), 3.f); | |
| 1201 | + float foot = c.px * d * d / lens; | |
| 1202 | + float sharp = exp(-foot * 6); | |
| 1203 | + // Moist wall with folds, veins and capillaries. | |
| 1204 | + float2 w = float2(a / TAU * 8, z * 1.3 / vessel); | |
| 1205 | + float folds = whFbmP(w + float2(0, c.t * .05), 8, 4); | |
| 1206 | + float2 toSite; | |
| 1207 | + float2 warp = float2(whFbmP(w * 1.5 + 7.3, 12, 2), whFbmP(w * 1.5 + 2.1, 12, 2)) - .5; | |
| 1208 | + // Veins: wandering ridged lines of a warped noise field. | |
| 1209 | + float veinField = whFbmP(float2(a / TAU * 6, z * .9 / vessel) + warp * .9, 6, 3); | |
| 1210 | + float vein = 1 - smoothstep(0.f, .025f + foot * .3, fabs(veinField - .5)); | |
| 1211 | + float veinPulse = c.b.y * pow(.5 + .5 * sin(z * 1.1 - c.t * 2.4 - c.m * 3), 3.f); | |
| 1212 | + float4 capCells = whVoronoiP(float2(a / TAU * 30, z * 4.5 / vessel) + warp * 1.2, 30, .9, toSite); | |
| 1213 | + float capillary = (1 - smoothstep(0.f, .06f, capCells.y - capCells.x)) * sharp; | |
| 1214 | + float3 tissue = mix(deep(.08 + folds * .15, f) * .55, paint(.18 + folds * .3, f) * .55, smoothstep(.3f, .75f, folds)); | |
| 1215 | + tissue *= .55 + .6 * folds; | |
| 1216 | + tissue = mix(tissue, deep(.02, f) * .25 + paint(.05, f) * .12 + paint(.35, f) * veinPulse * 1.6, vein * .75 * (.4 + .6 * sharp)); | |
| 1217 | + tissue = mix(tissue, paint(.12, f) * .3 + paint(.4, f) * c.b.w * .35, capillary * (.18 + c.b.w * .25)); | |
| 1218 | + float sheen = smoothstep(.55f, .8f, folds) * pow(max(cos(a - 1.9), 0.f), 3.f) * sharp; | |
| 1219 | + tissue += paint(.6, f) * sheen * (.12 + c.b.z * .7); | |
| 1220 | + // The heartbeat wave flushes the wall it passes: brighter and warmer with the bass. | |
| 1221 | + tissue = tissue * (1 + beat * c.b.x * 1.1) + paint(.35, f) * beat * (.06 + c.b.x * .5); | |
| 1222 | + // Low-mids swell slow patches of the wall in and out of shadow. | |
| 1223 | + tissue *= 1 + c.b.y * .55 * smoothstep(.45f, .75f, whNoiseP(float2(a / TAU * 4, z * .35 - c.t * .2), 4)); | |
| 1224 | + // Side vessels branching off the wall. | |
| 1225 | + float holeRow = floor(z / 3.2); | |
| 1226 | + for (int k = 0; k <= 1; ++k) { | |
| 1227 | + float id = holeRow + float(k); | |
| 1228 | + float holeZ = (id + .5) * 3.2, holeA = hash11(id * 4.7) * TAU - PI; | |
| 1229 | + float2 o = float2(whWrap(a - holeA) * vessel, (z - holeZ) * .8); | |
| 1230 | + float hr = length(o) / (.32 * vessel); | |
| 1231 | + float inside = smoothstep(1.f, .85f, hr); | |
| 1232 | + float lip = exp(-pow((hr - 1) / .12, 2.f)); | |
| 1233 | + tissue = mix(tissue, deep(.05, f) * .12 + paint(.1, f) * .2 * (1 - hr) * (1 - hr), inside); | |
| 1234 | + tissue += paint(.4, f) * lip * (.25 + c.b.z * .8); | |
| 1235 | + } | |
| 1236 | + float clear = whFog(d, c, .05, .1); | |
| 1237 | + float3 haze = deep(.1, f) * .25 + paint(.15, f) * .12; | |
| 1238 | + float3 color = mix(haze, tissue, clear); | |
| 1239 | + // Cells tumbling toward the camera, composited front to back. | |
| 1240 | + float flow = c.travel * .3 + c.t * .1 + c.m * .25; | |
| 1241 | + float3 cells = 0; | |
| 1242 | + float transmit = 1; | |
| 1243 | + const int layers = 9; | |
| 1244 | + for (int k = layers - 1; k >= 0; --k) { | |
| 1245 | + float2 slot = layerSlot(k, layers, flow); | |
| 1246 | + float depth = mix(11.f, .45f, slot.x); | |
| 1247 | + float fade = layerFade(slot.x) * whFog(depth, c, .05, .1); | |
| 1248 | + float2 centreOffset = whCentre(zc, depth, bend, lens); | |
| 1249 | + float2 q = (c.uv - centreOffset) * depth / lens; | |
| 1250 | + float grid = .48 * vessel; | |
| 1251 | + float2 cell = floor(q / grid); | |
| 1252 | + float seed = hash21(cell + slot.y * 13.1); | |
| 1253 | + float2 centre = (cell + .5 + (hash22(cell + slot.y * 7.7) - .5) * .3) * grid; | |
| 1254 | + if (seed < .2 || length(centre) > .8 * vessel) continue; | |
| 1255 | + float4 disc = arteryCell(q, centre, .15 * vessel, seed, c.t); | |
| 1256 | + float alpha = disc.z * fade; | |
| 1257 | + float cellBand = c.b[int(fract(seed * 6.1) * 3.99)]; | |
| 1258 | + float3 tint = paint(.04 + seed * .14 + cellBand * .12, f) * (.35 + .65 * disc.x) * (1 + cellBand * 1.1) + paint(.5, f) * disc.y * (.35 + c.b.z * 1.2); | |
| 1259 | + cells += transmit * alpha * tint; | |
| 1260 | + transmit *= 1 - alpha; | |
| 1261 | + } | |
| 1262 | + // Attack: a cluster of cells bursts out of a point ahead and spreads. | |
| 1263 | + if (c.hit > .001) { | |
| 1264 | + // The Coaster version bursts nearer, so the cells stay in view as the tube bends away. | |
| 1265 | + float depth = f.scene == 130 ? 2.6 : 1.2; | |
| 1266 | + float2 centreOffset = whCentre(zc, depth, bend, lens); | |
| 1267 | + float2 q = (c.uv - centreOffset) * depth / lens; | |
| 1268 | + float2 hub = .35 * vessel * float2(cos(c.t * .4), sin(c.t * .4)); | |
| 1269 | + for (int k = 0; k < 7; ++k) { | |
| 1270 | + float seed = hash11(float(k) * 3.3 + 1); | |
| 1271 | + float angle = float(k) / 7 * TAU + seed; | |
| 1272 | + float2 centre = hub + float2(cos(angle), sin(angle)) * (.08 + (1 - c.hit) * .45) * vessel; | |
| 1273 | + float4 disc = arteryCell(q, centre, .1 * vessel, seed, c.t); | |
| 1274 | + float alpha = disc.z * c.hit; | |
| 1275 | + cells += transmit * alpha * (paint(.08 + seed * .1, f) * (.45 + .6 * disc.x) + paint(.6, f) * disc.y * .5); | |
| 1276 | + transmit *= 1 - alpha; | |
| 1277 | + } | |
| 1278 | + } | |
| 1279 | + return cells + transmit * color + paint(.35, f) * .15 * exp(-r * 4); | |
| 1280 | + } | |
| 1281 | + | |
| 1282 | + // ---------------------------------------------------------------- 131 Zebra Warp | |
| 1283 | + // An op-art tunnel: bold stripes in log-polar coordinates spiral out of a drifting | |
| 1284 | + // vanishing point and bend in sinusoidal warps, alternating black with two vivid palette | |
| 1285 | + // colours for a strong motion illusion. Bass deepens the warp inside a slowly turning | |
| 1286 | + // sector, highs thread thin bright lines through the black stripes and each attack | |
| 1287 | + // inverts a band of stripes that rushes outward. | |
| 1288 | + float3 zebraWarp(Ctx c, constant NativeFrame &f) { | |
| 1289 | + float2 vanish = float2(sin(c.t * .19) * .3, cos(c.t * .15) * .2 - .05); | |
| 1290 | + float2 q = c.uv - vanish; | |
| 1291 | + float r = max(length(q), 1e-4f), angle = atan2(q.y, q.x); | |
| 1292 | + float density = 8.5 / c.size; | |
| 1293 | + float lr = log(r); | |
| 1294 | + float sector = pow(.5 + .5 * cos(whWrap(angle - c.t * .35)), 3.f); | |
| 1295 | + float amp = .3 + .15 * sin(c.t * .3) + c.b.x * 1.2 * sector; | |
| 1296 | + float warp = amp * sin(angle * 3 + lr * 2.5 - c.t * .8 - c.m * .6) + .22 * sin(angle * 5 - lr * 1.5 + c.t * .5); | |
| 1297 | + // The music clock adds to the inward rush of the stripes. | |
| 1298 | + float s = lr * density - c.travel * 1.7 - c.m * 1.5 + angle / TAU * 4 + warp; | |
| 1299 | + float w = (density + 3 * amp + 2) / r * c.px; // stripe units per pixel | |
| 1300 | + float mask = smoothstep(-PI * w, PI * w, sin(PI * s)); | |
| 1301 | + // Attack: a band of inverted stripes rushes outward as the envelope decays. | |
| 1302 | + float bandR = .1 + (1 - c.hit) * 3.5; | |
| 1303 | + float invert = smoothstep(0.f, .6f, c.hit) * .85 * smoothstep(.24f, .18f, fabs(lr - log(bandR))); | |
| 1304 | + mask = mix(mask, 1 - mask, invert); | |
| 1305 | + float pick = floor((s + .5) * .5); | |
| 1306 | + pick -= 2 * floor(pick * .5); | |
| 1307 | + float3 colorA = paint(.25 + .03 * sin(c.t * .11), f), colorB = paint(.75 + .03 * sin(c.t * .13 + 1), f); | |
| 1308 | + // Low-mids and high-mids each brighten one stripe colour. | |
| 1309 | + float3 stripeColor = pick < .5 ? colorA * (1 + c.b.y * .5) : colorB * (1 + c.b.z * .5); | |
| 1310 | + float3 dark = deep(.4, f) * .03; | |
| 1311 | + float3 color = mix(dark, stripeColor, mask); | |
| 1312 | + // Highs: thin bright threads through the black stripes. | |
| 1313 | + float strand = fabs(fract(s * .5 + .25) - .5) * 2; | |
| 1314 | + color += mix(colorA, colorB, .5) * exp(-pow(strand / (.03 + w * .7), 2.f)) * (1 - mask) * c.b.w * 2.2 * smoothstep(.35f, .1f, w); | |
| 1315 | + // Stripes finer than a pixel settle to their average; the throat darkens with depth. | |
| 1316 | + float3 average = (colorA + colorB) * .25 + dark * .5; | |
| 1317 | + color = mix(color, average, smoothstep(.25f, .7f, w)); | |
| 1318 | + color *= .35 + .65 * smoothstep(0.f, .8f, r); | |
| 1319 | + return color * .62 + paint(.85, f) * .12 * exp(-r * 8); | |
| 1320 | + } | |
| 1321 | + | |
| 1322 | + // ---------------------------------------------------------------- 132 Pixel Tunnel | |
| 1323 | + // A quantized light tunnel. A square tunnel is sampled at the centre of chunky screen | |
| 1324 | + // pixels. Its dark walls carry crisp emissive pixel strips whose light runs like | |
| 1325 | + // pixel-sorted streaks (each run ramps from a dim tail to a bright head) flowing toward | |
| 1326 | + // the camera, and their glow spreads over the walls as dithered gradients quantized to a | |
| 1327 | + // few levels. Thin pixel rings mark the depth and the far end resolves into a stepped, | |
| 1328 | + // glowing core. Each band lights its own family of strips, bass sends a chase along the | |
| 1329 | + // pixel rows and each attack flashes a ring of pixels just ahead. | |
| 1330 | + float pixelBayer(float2 cell) { | |
| 1331 | + int x = int(cell.x - 4 * floor(cell.x / 4)), y = int(cell.y - 4 * floor(cell.y / 4)); | |
| 1332 | + const int m[16] = {0, 8, 2, 10, 12, 4, 14, 6, 3, 11, 1, 9, 15, 7, 13, 5}; | |
| 1333 | + return (float(m[y * 4 + x]) + .5) / 16; | |
| 1334 | + } | |
| 1335 | + // Light carried by strip column `colId` at depth z (0 when the column is dark). | |
| 1336 | + float pixelStrip(float colId, float z, Ctx c) { | |
| 1337 | + float seed = hash11(colId * 1.37 + 3); | |
| 1338 | + if (seed < .4) return 0; | |
| 1339 | + float speed = 3 + seed * 3; | |
| 1340 | + float runLength = 2 + 2.5 * hash11(colId * 2.1); | |
| 1341 | + float s = (z + (c.t + c.m * .8) * speed) / runLength + hash11(colId * 4.7); | |
| 1342 | + float along = fract(s); | |
| 1343 | + float on = step(.3f, hash11(floor(s) + colId * 13.1)); | |
| 1344 | + float ramp = floor(along * along * 6) / 6; // the run steps up toward its head | |
| 1345 | + float head = step(.9f, along); | |
| 1346 | + float band = c.b[int(fract(seed * 7.1) * 3.99)]; | |
| 1347 | + return on * (ramp * .8 + head * 1.2) * (.7 + band * 1.8); | |
| 1348 | + } | |
| 1349 | + float3 pixelTunnel(Ctx c, constant NativeFrame &f) { | |
| 1350 | + // Chunky pixels stay square on screen whatever the camera rotation or zoom. | |
| 1351 | + float2 res = max(f.resolution, float2(1)); | |
| 1352 | + float shortSide = min(res.x, res.y); | |
| 1353 | + float block = max(2.f, floor(shortSide / 90 * c.size + .5)); | |
| 1354 | + float2 cellId = floor(c.screen * res / block); | |
| 1355 | + float2 uv = ((cellId + .5) * block - res * .5) / (shortSide * .5); | |
| 1356 | + uv.y = -uv.y; | |
| 1357 | + float zoom = clamp(f.style.w, .3f, 2.f); | |
| 1358 | + uv = rot(uv, f.camera.x) / zoom; | |
| 1359 | + const float lens = 1.1, columns = 12, rowH = .5; | |
| 1360 | + // The music clock adds to the forward motion, so energetic passages speed it up. | |
| 1361 | + float zc = c.travel * 2.4 + c.m * 1.5; | |
| 1362 | + uv -= float2(sin(c.t * .31) * .08, cos(c.t * .23) * .05); | |
| 1363 | + uv = rot(uv, c.t * .04); | |
| 1364 | + // The Coaster version rides the course at each chunky pixel's centre, so blocks stay square. | |
| 1365 | + if (f.scene != 132) { | |
| 1366 | + Ctx cell = c; | |
| 1367 | + cell.uv = uv; | |
| 1368 | + uv = coasterRide(cell, 132, true).uv; | |
| 1369 | + } | |
| 1370 | + float m = max(fabs(uv.x), fabs(uv.y)); | |
| 1371 | + float d = min(lens / max(m, 1e-3f), 60.f); | |
| 1372 | + float z = zc + d; | |
| 1373 | + bool side = fabs(uv.x) > fabs(uv.y); | |
| 1374 | + float face = side ? (uv.x > 0 ? 0.f : 2.f) : (uv.y > 0 ? 1.f : 3.f); | |
| 1375 | + float across = (side ? uv.y : uv.x) / m; // -1..1 along the face | |
| 1376 | + float slot = (across + 1) * .5 * columns; | |
| 1377 | + float col = floor(slot), within = slot - col; | |
| 1378 | + float dither = pixelBayer(cellId); | |
| 1379 | + float clear = whFog(d, c, .045, .09); | |
| 1380 | + // How many screen pixels one strip column spans: thin far strips merge into glow. | |
| 1381 | + float chunk = block * c.px; // one chunky pixel in uv units | |
| 1382 | + float colPixels = 2 / columns * m / chunk; | |
| 1383 | + float resolve = smoothstep(1.5f, 3.f, colPixels); | |
| 1384 | + // The strip in this column (a crisp core) and dithered glow from it and its neighbours. | |
| 1385 | + float core = 0, glowAmount = 0, hueSeed = 0; | |
| 1386 | + for (int k = -1; k <= 1; ++k) { | |
| 1387 | + float cc = col + float(k); | |
| 1388 | + if (cc < 0 || cc >= columns) continue; | |
| 1389 | + float colId = face * columns + cc; | |
| 1390 | + // Strips sweeping right past the lens fade so no huge block flips in one frame. | |
| 1391 | + float level = pixelStrip(colId, z, c) * mix(.3f, 1.f, smoothstep(.45f, 1.3f, d)); | |
| 1392 | + float dist = fabs(slot - (cc + .5)); | |
| 1393 | + if (k == 0) { core = level * step(fabs(within - .5), .22f) * resolve; hueSeed = hash11(colId * 5.3); } | |
| 1394 | + glowAmount += level * exp(-dist * 2.2) * .45; | |
| 1395 | + } | |
| 1396 | + // Thin rings every few metres and a bass chase along the pixel rows. | |
| 1397 | + float row = floor(z / rowH); | |
| 1398 | + float ringDist = fabs(z - round(z / 4) * 4); | |
| 1399 | + float ring = step(ringDist, max(.05f, chunk * d * d / lens * .6)) * .8 * smoothstep(.7f, 1.8f, d); | |
| 1400 | + float chase = pow(.5 + .5 * sin(row * .6 - c.t * 5 - c.m * 3), 8.f) * c.b.x * 1.2; | |
| 1401 | + float gap = (row + .5) * rowH - zc; | |
| 1402 | + float flash = c.hit * 1.6 * smoothstep(1.4f, 2.2f, gap) * (1 - smoothstep(3.2f, 4.2f, gap)); | |
| 1403 | + // Quantize everything to a few dithered levels of palette colour. | |
| 1404 | + const float steps = 5; | |
| 1405 | + float glowLevel = floor(min((glowAmount + chase * .5 + flash * .6) * clear, 1.2f) * steps + dither) / steps; | |
| 1406 | + float coreLevel = floor(min((core + ring + chase * .6 + flash) * clear, 1.5f) * steps + dither) / steps; | |
| 1407 | + float hue = floor((z * .03 + face * .25 + c.t * .02) * 5 + dither) / 5; | |
| 1408 | + // Walls: a dithered gradient that brightens toward the glowing core. | |
| 1409 | + float ambient = floor((.32 + .55 * exp(-m * 2)) * 4 + dither) / 4; | |
| 1410 | + float3 wall = mix(deep(.3 + face * .1, f), paint(hue + .5, f), .45) * ambient * .3; | |
| 1411 | + float3 color = wall + paint(hue + hueSeed * .25, f) * glowLevel * .35 + paint(hue + hueSeed * .25 + .08, f) * coreLevel * .9; | |
| 1412 | + // Stepped glowing core at the far end. | |
| 1413 | + float coreGlow = floor(exp(-m * 4.5) * 6 + dither) / 6; | |
| 1414 | + color += paint(.85 + .1 * sin(c.t * .2), f) * coreGlow * .55; | |
| 1415 | + return color; | |
| 1416 | + } | |
| 1417 | + | |
| 1418 | + // ---------------------------------------------------------------- 133 Geode Passage | |
| 1419 | + // Flying through the hollow of a giant geode: walls bristling with crystal points that | |
| 1420 | + // radiate inward. Each voronoi cell is raised into a pyramid whose flat facets slope down | |
| 1421 | + // toward its neighbours, so every crystal shows crisp, individually lit faces and a | |
| 1422 | + // glowing tip; dark crevices separate the crystals, and patches of banded agate show | |
| 1423 | + // where the shell breaks through. Bass makes the crystals nearest the camera glow from | |
| 1424 | + // inside, highs sparkle on single facets and each attack lights a cluster of crystals. | |
| 1425 | + // Nearest and second-nearest site offsets of a voronoi field that repeats every | |
| 1426 | + // `period` cells in x; id receives the nearest cell. | |
| 1427 | + float4 geodeCells(float2 p, float period, thread float2 &id) { | |
| 1428 | + float2 cell = floor(p), fr = fract(p), near1 = 0, near2 = 0; | |
| 1429 | + float first = 64, second = 64; | |
| 1430 | + id = 0; | |
| 1431 | + for (int y = -1; y <= 1; ++y) for (int x = -1; x <= 1; ++x) { | |
| 1432 | + float2 g = float2(x, y), cid = cell + g; | |
| 1433 | + cid.x -= period * floor(cid.x / period); | |
| 1434 | + float2 delta = g + .5 + .8 * (hash22(cid) - .5) - fr; | |
| 1435 | + float dd = dot(delta, delta); | |
| 1436 | + if (dd < first) { second = first; near2 = near1; first = dd; near1 = delta; id = cid; } | |
| 1437 | + else if (dd < second) { second = dd; near2 = delta; } | |
| 1438 | + } | |
| 1439 | + return float4(near1, near2); | |
| 1440 | + } | |
| 1441 | + float3 geodePassage(Ctx c, constant NativeFrame &f) { | |
| 1442 | + const float lens = 1.05, columns = 22; | |
| 1443 | + // The music clock adds to the forward motion, so energetic passages speed it up. | |
| 1444 | + float zc = c.travel * 1.2 + c.m * .8; | |
| 1445 | + float4 tube = whTube(c.uv, zc, .42, lens, 1); | |
| 1446 | + float a = tube.x, d0 = tube.z, r = tube.w; | |
| 1447 | + // The geode turns slowly around the flight path; `spin` addresses its surface. | |
| 1448 | + float spin = a - c.t * .06 - c.m * .05; | |
| 1449 | + float zScale = 3.4 / c.size; | |
| 1450 | + float2 id; | |
| 1451 | + float4 sites = geodeCells(float2(spin / TAU * columns, (zc + d0) * zScale), columns, id); | |
| 1452 | + float edge = (dot(sites.zw, sites.zw) - dot(sites.xy, sites.xy)) / (2 * max(length(sites.zw - sites.xy), 1e-4f)); | |
| 1453 | + float zone = smoothstep(.36f, .48f, whFbmP(float2(spin / TAU * 5, (zc + d0) * .45), 5, 3)); | |
| 1454 | + float height = clamp(edge * 2.4, 0.f, 1.f) * zone; | |
| 1455 | + // Crystal tips stand in from the wall: one damped refinement adds parallax. | |
| 1456 | + float seed = hash21(id); | |
| 1457 | + float d = d0 * (1 - (.16 + .2 * seed) * height * exp(-d0 * .4)); | |
| 1458 | + float z = zc + d; | |
| 1459 | + sites = geodeCells(float2(spin / TAU * columns, z * zScale), columns, id); | |
| 1460 | + seed = hash21(id); | |
| 1461 | + edge = (dot(sites.zw, sites.zw) - dot(sites.xy, sites.xy)) / (2 * max(length(sites.zw - sites.xy), 1e-4f)); | |
| 1462 | + float shell = whFbmP(float2(spin / TAU * 5, z * .45), 5, 3); | |
| 1463 | + zone = smoothstep(.36f, .48f, shell); | |
| 1464 | + height = clamp(edge * 2.4, 0.f, 1.f) * zone; | |
| 1465 | + float foot = c.px * d * d / lens; | |
| 1466 | + float sharp = exp(-foot * 5); | |
| 1467 | + // The facet faces the neighbour that shares this edge: its normal leans that way. | |
| 1468 | + float2 slopeDir = normalize(sites.zw - sites.xy + 1e-5); | |
| 1469 | + float3 inward = -float3(cos(a), sin(a), 0); | |
| 1470 | + float3 tangent = float3(-sin(a), cos(a), 0), along = float3(0, 0, 1); | |
| 1471 | + float lean = .8 + .7 * seed; | |
| 1472 | + float3 n = normalize(inward + (tangent * slopeDir.x + along * slopeDir.y) * lean); | |
| 1473 | + float facetSeed = hash21(floor((sites.zw - sites.xy) * 7.3) + id); | |
| 1474 | + float3 view = normalize(float3(cos(a), sin(a), d)); | |
| 1475 | + float3 key = normalize(float3(.35, .6, -.7)); | |
| 1476 | + float diffuse = max(dot(n, key), 0.f), front = max(dot(n, -view), 0.f); | |
| 1477 | + float3 refl = reflect(view, n); | |
| 1478 | + float spec = pow(max(dot(refl, key), 0.f), 40.f) + pow(max(dot(refl, -view), 0.f), 60.f) * .5; | |
| 1479 | + float3 tint = paint(.45 + seed * .45, f); | |
| 1480 | + // Internal glow: a hot tip, a slow pulse; bass lights the nearest crystals from inside. | |
| 1481 | + float inner = pow(height, 3.f) * (.4 + .25 * sin(c.t * .7 + seed * 20) + c.b.z * .8); | |
| 1482 | + inner += (.3 + .7 * height) * c.b.x * 1.5 * exp(-d * .45) * zone; | |
| 1483 | + float clusterRow = floor(z / 4); | |
| 1484 | + float burst = 0; | |
| 1485 | + for (int k = -1; k <= 1; ++k) { | |
| 1486 | + float row = clusterRow + float(k); | |
| 1487 | + float cz = (row + .5) * 4, ca = hash11(row * 5.3) * TAU - PI; | |
| 1488 | + float window = smoothstep(.8f, 1.8f, cz - zc) * (1 - smoothstep(4.5f, 6.f, cz - zc)); | |
| 1489 | + float2 o = float2(whWrap(spin - ca), (z - cz) * .7); | |
| 1490 | + burst += window * max(1 - length(o) / 1.1, 0.f); | |
| 1491 | + } | |
| 1492 | + inner += c.hit * smoothstep(0.f, .3f, burst) * (.3 + .7 * height) * 2.4 * zone; | |
| 1493 | + float sparkle = pow(.5 + .5 * sin(c.t * (4 + facetSeed * 6) + facetSeed * 60), 20.f) * c.b.w * 2.5 * step(.55f, facetSeed); | |
| 1494 | + float facetShade = .05 + .8 * pow(diffuse, 1.5f) + .3 * front * front * (.3 + .7 * facetSeed); | |
| 1495 | + float3 crystal = tint * facetShade + paint(.93, f) * spec * .6 * sharp + paint(.78 + seed * .17, f) * inner * .6; | |
| 1496 | + crystal += paint(.97, f) * sparkle * smoothstep(.2f, .6f, height) * sharp; | |
| 1497 | + // Dark crevices where neighbouring crystals meet. | |
| 1498 | + float crevice = 1 - smoothstep(0.f, .05f + foot * 1.5, edge); | |
| 1499 | + crystal = mix(crystal, deep(.4, f) * .04, crevice * .85 * sharp); | |
| 1500 | + // Banded agate where the shell breaks through the crystal fields. | |
| 1501 | + float2 aw = float2(spin / TAU * 6, z * .9); |
Sources/PulseCanvas/Resources/Onboarding/logo.png added
Not a text file.
Sources/PulseCanvas/Resources/Onboarding/share.png added
Not a text file.
Sources/PulseCanvas/Resources/Onboarding/studio.png added
Not a text file.
Sources/PulseCanvas/Resources/ProjectM/Presets/Dancer/Aurora/271 nz+ m1 w2 i love life so much i can't stand it.milk added
| 1 | + MILKDROP_PRESET_VERSION=201 | |
| 2 | + PSVERSION=2 | |
| 3 | + PSVERSION_WARP=2 | |
| 4 | + PSVERSION_COMP=2 | |
| 5 | + [preset00] | |
| 6 | + fRating=5.000000 | |
| 7 | + fGammaAdj=0.160 | |
| 8 | + fDecay=0.960 | |
| 9 | + fVideoEchoZoom=0.997 | |
| 10 | + fVideoEchoAlpha=0.500 | |
| 11 | + nVideoEchoOrientation=1 | |
| 12 | + nWaveMode=3 | |
| 13 | + bAdditiveWaves=0 | |
| 14 | + bWaveDots=1 | |
| 15 | + bWaveThick=0 | |
| 16 | + bModWaveAlphaByVolume=0 | |
| 17 | + bMaximizeWaveColor=0 | |
| 18 | + bTexWrap=1 | |
| 19 | + bDarkenCenter=0 | |
| 20 | + bRedBlueStereo=0 | |
| 21 | + bBrighten=0 | |
| 22 | + bDarken=1 | |
| 23 | + bSolarize=0 | |
| 24 | + bInvert=0 | |
| 25 | + fWaveAlpha=0.001 | |
| 26 | + fWaveScale=0.012 | |
| 27 | + fWaveSmoothing=0.900 | |
| 28 | + fWaveParam=0.000 | |
| 29 | + fModWaveAlphaStart=0.750 | |
| 30 | + fModWaveAlphaEnd=0.950 | |
| 31 | + fWarpAnimSpeed=1.000 | |
| 32 | + fWarpScale=1.331 | |
| 33 | + fZoomExponent=1.00000 | |
| 34 | + fShader=0.000 | |
| 35 | + zoom=0.99951 | |
| 36 | + rot=0.26000 | |
| 37 | + cx=0.320 | |
| 38 | + cy=0.290 | |
| 39 | + dx=0.00000 | |
| 40 | + dy=0.00000 | |
| 41 | + warp=0.01105 | |
| 42 | + sx=1.00000 | |
| 43 | + sy=1.00000 | |
| 44 | + wave_r=0.500 | |
| 45 | + wave_g=0.400 | |
| 46 | + wave_b=0.300 | |
| 47 | + wave_x=0.500 | |
| 48 | + wave_y=0.500 | |
| 49 | + ob_size=0.500 | |
| 50 | + ob_r=0.010 | |
| 51 | + ob_g=0.000 | |
| 52 | + ob_b=0.000 | |
| 53 | + ob_a=0.000 | |
| 54 | + ib_size=0.260 | |
| 55 | + ib_r=0.250 | |
| 56 | + ib_g=0.250 | |
| 57 | + ib_b=0.250 | |
| 58 | + ib_a=0.000 | |
| 59 | + nMotionVectorsX=0.000 | |
| 60 | + nMotionVectorsY=0.000 | |
| 61 | + mv_dx=0.000 | |
| 62 | + mv_dy=0.000 | |
| 63 | + mv_l=1.000 | |
| 64 | + mv_r=1.000 | |
| 65 | + mv_g=0.910 | |
| 66 | + mv_b=0.710 | |
| 67 | + mv_a=0.000 | |
| 68 | + b1n=0.000 | |
| 69 | + b2n=0.000 | |
| 70 | + b3n=0.000 | |
| 71 | + b1x=1.000 | |
| 72 | + b2x=1.000 | |
| 73 | + b3x=1.000 | |
| 74 | + b1ed=0.300 | |
| 75 | + wavecode_0_enabled=1 | |
| 76 | + wavecode_0_samples=512 | |
| 77 | + wavecode_0_sep=0 | |
| 78 | + wavecode_0_bSpectrum=0 | |
| 79 | + wavecode_0_bUseDots=1 | |
| 80 | + wavecode_0_bDrawThick=1 | |
| 81 | + wavecode_0_bAdditive=0 | |
| 82 | + wavecode_0_scaling=1.00000 | |
| 83 | + wavecode_0_smoothing=0.50000 | |
| 84 | + wavecode_0_r=1.000 | |
| 85 | + wavecode_0_g=1.000 | |
| 86 | + wavecode_0_b=0.700 | |
| 87 | + wavecode_0_a=1.000 | |
| 88 | + wave_0_per_point1=n=sample*6.283; | |
| 89 | + wave_0_per_point2=phs=-sample * 0.2; | |
| 90 | + wave_0_per_point3=tm=q1 + ((phs*4)/q2)*0.1; | |
| 91 | + wave_0_per_point4= | |
| 92 | + wave_0_per_point5=flip=flip+1; | |
| 93 | + wave_0_per_point6=flip=flip*below(flip,2); | |
| 94 | + wave_0_per_point7= | |
| 95 | + wave_0_per_point8=xp=0; | |
| 96 | + wave_0_per_point9=yp=(flip*0.1-0.05)*(sample); | |
| 97 | + wave_0_per_point10=zp=0; | |
| 98 | + wave_0_per_point11= | |
| 99 | + wave_0_per_point12=//spin; | |
| 100 | + wave_0_per_point13=ang=tm*20 + sin(tm*76 + time*4)*0.4; | |
| 101 | + wave_0_per_point14=sa=sin(ang);ca=cos(ang); | |
| 102 | + wave_0_per_point15=xr=xp*sa + yp*ca; | |
| 103 | + wave_0_per_point16=yr=xp*ca - yp*sa; | |
| 104 | + wave_0_per_point17=zr=zp; | |
| 105 | + wave_0_per_point18= | |
| 106 | + wave_0_per_point19=xp=xr; | |
| 107 | + wave_0_per_point20=yp=yr + 0.05 + (sin(tm)*0.5 + 0.5)*0.2 + 0.05; | |
| 108 | + wave_0_per_point21=zp=zr; | |
| 109 | + wave_0_per_point22= | |
| 110 | + wave_0_per_point23=//wrist movement; | |
| 111 | + wave_0_per_point24=ang=sin(tm*2); | |
| 112 | + wave_0_per_point25= | |
| 113 | + wave_0_per_point26=xq=xp; | |
| 114 | + wave_0_per_point27=sa=sin(ang);ca=cos(ang); | |
| 115 | + wave_0_per_point28=yq=yp*sa + zp*ca; | |
| 116 | + wave_0_per_point29=zq=yp*ca - zp*sa; | |
| 117 | + wave_0_per_point30= | |
| 118 | + wave_0_per_point31= | |
| 119 | + wave_0_per_point32=ang=tm*8; | |
| 120 | + wave_0_per_point33=sa=sin(ang);ca=cos(ang); | |
| 121 | + wave_0_per_point34=xp=xq*sa + yq*ca; | |
| 122 | + wave_0_per_point35=yp=xq*ca - yq*sa; | |
| 123 | + wave_0_per_point36=zp=zq; | |
| 124 | + wave_0_per_point37= | |
| 125 | + wave_0_per_point38=//forearm movement; | |
| 126 | + wave_0_per_point39=zp=zp-0.3; | |
| 127 | + wave_0_per_point40=ang=3.14 + sin(tm*2 - 0.5)*2.5; | |
| 128 | + wave_0_per_point41=xq=xp; | |
| 129 | + wave_0_per_point42=sa=sin(ang);ca=cos(ang); | |
| 130 | + wave_0_per_point43=yq=yp*sa + zp*ca; | |
| 131 | + wave_0_per_point44=zq=yp*ca - zp*sa; | |
| 132 | + wave_0_per_point45= | |
| 133 | + wave_0_per_point46=//upper arm twist | |
| 134 | + wave_0_per_point47=ang=-1.0 + cos(tm*3 + 0.5); | |
| 135 | + wave_0_per_point48=xp=xq*sa + yq*ca; | |
| 136 | + wave_0_per_point49=yp=xq*ca - yq*sa; | |
| 137 | + wave_0_per_point50=zp=zq; | |
| 138 | + wave_0_per_point51= | |
| 139 | + wave_0_per_point52=//upper arm outward; | |
| 140 | + wave_0_per_point53=zp=zp-0.35; | |
| 141 | + wave_0_per_point54=ang=cos(tm*1)*1.75 - 1.05; | |
| 142 | + wave_0_per_point55=sa=sin(ang);ca=cos(ang); | |
| 143 | + wave_0_per_point56=xq=xp*sa + zp*ca; | |
| 144 | + wave_0_per_point57=yq=yp; | |
| 145 | + wave_0_per_point58=zq=xp*ca - zp*sa; | |
| 146 | + wave_0_per_point59= | |
| 147 | + wave_0_per_point60=//upper arm up down; | |
| 148 | + wave_0_per_point61=ang=cos(tm); | |
| 149 | + wave_0_per_point62=xp=xq; | |
| 150 | + wave_0_per_point63=sa=sin(ang);ca=cos(ang); | |
| 151 | + wave_0_per_point64=yp=yq*ca - zq*sa; | |
| 152 | + wave_0_per_point65=zp=yq*sa + zq*ca; | |
| 153 | + wave_0_per_point66= | |
| 154 | + wave_0_per_point67=//xp=xq;yp=yq;zp=zq; | |
| 155 | + wave_0_per_point68= | |
| 156 | + wave_0_per_point69= | |
| 157 | + wave_0_per_point70=//project into screenspace and draw on screen | |
| 158 | + wave_0_per_point71=zp=zp+1.5; | |
| 159 | + wave_0_per_point72=xs=xp/zp; | |
| 160 | + wave_0_per_point73=ys=yp/zp; | |
| 161 | + wave_0_per_point74= | |
| 162 | + wave_0_per_point75=x=xs+0.5; | |
| 163 | + wave_0_per_point76=y=ys*1.3+0.5; | |
| 164 | + wave_0_per_point77= | |
| 165 | + wave_0_per_point78= | |
| 166 | + wave_0_per_point79=a=(1-sample); | |
| 167 | + wave_0_per_point80= | |
| 168 | + wavecode_1_enabled=1 | |
| 169 | + wavecode_1_samples=512 | |
| 170 | + wavecode_1_sep=0 | |
| 171 | + wavecode_1_bSpectrum=0 | |
| 172 | + wavecode_1_bUseDots=1 | |
| 173 | + wavecode_1_bDrawThick=1 | |
| 174 | + wavecode_1_bAdditive=0 | |
| 175 | + wavecode_1_scaling=1.00000 | |
| 176 | + wavecode_1_smoothing=0.50000 | |
| 177 | + wavecode_1_r=1.000 | |
| 178 | + wavecode_1_g=0.900 | |
| 179 | + wavecode_1_b=0.800 | |
| 180 | + wavecode_1_a=1.000 | |
| 181 | + wave_1_per_point1=n=sample*6.283; | |
| 182 | + wave_1_per_point2=phs=-sample * 0.4 ; | |
| 183 | + wave_1_per_point3=tm=q1 + ((phs*2)/q2)*0.1 - 0.01; | |
| 184 | + wave_1_per_point4= | |
| 185 | + wave_1_per_point5=flip=flip+1; | |
| 186 | + wave_1_per_point6=flip=flip*below(flip,2); | |
| 187 | + wave_1_per_point7= | |
| 188 | + wave_1_per_point8=xp=0; | |
| 189 | + wave_1_per_point9=yp=(flip*0.2-0.1)*(sample); | |
| 190 | + wave_1_per_point10=zp=0; | |
| 191 | + wave_1_per_point11= | |
| 192 | + wave_1_per_point12=//spin; | |
| 193 | + wave_1_per_point13=ang=-tm*29 + sin(tm*76 + time*4)*0.4;; | |
| 194 | + wave_1_per_point14=sa=sin(ang);ca=cos(ang); | |
| 195 | + wave_1_per_point15=xr=xp*sa + yp*ca; | |
| 196 | + wave_1_per_point16=yr=xp*ca - yp*sa; | |
| 197 | + wave_1_per_point17=zr=zp; | |
| 198 | + wave_1_per_point18= | |
| 199 | + wave_1_per_point19=xp=xr; | |
| 200 | + wave_1_per_point20=yp=yr + 0.05 + (sin(tm)*0.5 + 0.5)*0.2 + 0.05; | |
| 201 | + wave_1_per_point21=zp=zr; | |
| 202 | + wave_1_per_point22= | |
| 203 | + wave_1_per_point23=//wrist movement; | |
| 204 | + wave_1_per_point24=ang=sin(tm*2); | |
| 205 | + wave_1_per_point25= | |
| 206 | + wave_1_per_point26=xq=xp; | |
| 207 | + wave_1_per_point27=sa=sin(ang);ca=cos(ang); | |
| 208 | + wave_1_per_point28=yq=yp*sa + zp*ca; | |
| 209 | + wave_1_per_point29=zq=yp*ca - zp*sa; | |
| 210 | + wave_1_per_point30= | |
| 211 | + wave_1_per_point31= | |
| 212 | + wave_1_per_point32=ang=tm*8; | |
| 213 | + wave_1_per_point33=sa=sin(ang);ca=cos(ang); | |
| 214 | + wave_1_per_point34=xp=xq*sa + yq*ca; | |
| 215 | + wave_1_per_point35=yp=xq*ca - yq*sa; | |
| 216 | + wave_1_per_point36=zp=zq; | |
| 217 | + wave_1_per_point37= | |
| 218 | + wave_1_per_point38=//forearm movement; | |
| 219 | + wave_1_per_point39=zp=zp-0.3; | |
| 220 | + wave_1_per_point40=ang=3.14 + sin(tm*2 - 0.5)*2.5; | |
| 221 | + wave_1_per_point41=xq=xp; | |
| 222 | + wave_1_per_point42=sa=sin(ang);ca=cos(ang); | |
| 223 | + wave_1_per_point43=yq=yp*sa + zp*ca; | |
| 224 | + wave_1_per_point44=zq=yp*ca - zp*sa; | |
| 225 | + wave_1_per_point45= | |
| 226 | + wave_1_per_point46=//upper arm twist | |
| 227 | + wave_1_per_point47=ang=-1.0 + cos(tm*3 + 0.5); | |
| 228 | + wave_1_per_point48=xp=xq*sa + yq*ca; | |
| 229 | + wave_1_per_point49=yp=xq*ca - yq*sa; | |
| 230 | + wave_1_per_point50=zp=zq; | |
| 231 | + wave_1_per_point51= | |
| 232 | + wave_1_per_point52=//upper arm outward; | |
| 233 | + wave_1_per_point53=zp=zp-0.35; | |
| 234 | + wave_1_per_point54=ang=cos(tm*1)*1.75 - 1.05; | |
| 235 | + wave_1_per_point55=sa=sin(ang);ca=cos(ang); | |
| 236 | + wave_1_per_point56=xq=xp*sa + zp*ca; | |
| 237 | + wave_1_per_point57=yq=yp; | |
| 238 | + wave_1_per_point58=zq=xp*ca - zp*sa; | |
| 239 | + wave_1_per_point59= | |
| 240 | + wave_1_per_point60=//upper arm up down; | |
| 241 | + wave_1_per_point61=ang=cos(tm); | |
| 242 | + wave_1_per_point62=xp=xq; | |
| 243 | + wave_1_per_point63=sa=sin(ang);ca=cos(ang); | |
| 244 | + wave_1_per_point64=yp=yq*ca - zq*sa; | |
| 245 | + wave_1_per_point65=zp=yq*sa + zq*ca; | |
| 246 | + wave_1_per_point66= | |
| 247 | + wave_1_per_point67=//xp=xq;yp=yq;zp=zq; | |
| 248 | + wave_1_per_point68= | |
| 249 | + wave_1_per_point69= | |
| 250 | + wave_1_per_point70=//project into screenspace and draw on screen | |
| 251 | + wave_1_per_point71=zp=zp+1.5; | |
| 252 | + wave_1_per_point72=xs=xp/zp; | |
| 253 | + wave_1_per_point73=ys=yp/zp; | |
| 254 | + wave_1_per_point74= | |
| 255 | + wave_1_per_point75=x=xs+0.5; | |
| 256 | + wave_1_per_point76=y=ys*1.3+0.5; | |
| 257 | + wave_1_per_point77= | |
| 258 | + wave_1_per_point78= | |
| 259 | + wave_1_per_point79=a=(1-sample); | |
| 260 | + wave_1_per_point80= | |
| 261 | + wavecode_2_enabled=1 | |
| 262 | + wavecode_2_samples=512 | |
| 263 | + wavecode_2_sep=0 | |
| 264 | + wavecode_2_bSpectrum=0 | |
| 265 | + wavecode_2_bUseDots=1 | |
| 266 | + wavecode_2_bDrawThick=1 | |
| 267 | + wavecode_2_bAdditive=0 | |
| 268 | + wavecode_2_scaling=1.00000 | |
| 269 | + wavecode_2_smoothing=0.50000 | |
| 270 | + wavecode_2_r=1.000 | |
| 271 | + wavecode_2_g=0.320 | |
| 272 | + wavecode_2_b=0.000 | |
| 273 | + wavecode_2_a=1.000 | |
| 274 | + wave_2_per_point1=n=sample*6.283; | |
| 275 | + wave_2_per_point2=phs=-sample * 0.4 ; | |
| 276 | + wave_2_per_point3=tm=q1 + ((phs*2)/q2)*0.1 - 2.02; | |
| 277 | + wave_2_per_point4= | |
| 278 | + wave_2_per_point5=flip=flip+1; | |
| 279 | + wave_2_per_point6=flip=flip*below(flip,2); | |
| 280 | + wave_2_per_point7= | |
| 281 | + wave_2_per_point8=xp=0; | |
| 282 | + wave_2_per_point9=yp=(flip*0.2-0.1)*(sample); | |
| 283 | + wave_2_per_point10=zp=0; | |
| 284 | + wave_2_per_point11= | |
| 285 | + wave_2_per_point12=//spin; | |
| 286 | + wave_2_per_point13=ang=tm*23 + sin(tm*76 + time*4)*0.3;; | |
| 287 | + wave_2_per_point14=sa=sin(ang);ca=cos(ang); | |
| 288 | + wave_2_per_point15=xr=xp*sa + yp*ca; | |
| 289 | + wave_2_per_point16=yr=xp*ca - yp*sa; | |
| 290 | + wave_2_per_point17=zr=zp; | |
| 291 | + wave_2_per_point18= | |
| 292 | + wave_2_per_point19=xp=xr; | |
| 293 | + wave_2_per_point20=yp=yr + 0.05 + (sin(tm)*0.5 + 0.5)*0.2 + 0.05; | |
| 294 | + wave_2_per_point21=zp=zr; | |
| 295 | + wave_2_per_point22= | |
| 296 | + wave_2_per_point23=//wrist movement; | |
| 297 | + wave_2_per_point24=ang=sin(tm*2); | |
| 298 | + wave_2_per_point25= | |
| 299 | + wave_2_per_point26=xq=xp; | |
| 300 | + wave_2_per_point27=sa=sin(ang);ca=cos(ang); | |
| 301 | + wave_2_per_point28=yq=yp*sa + zp*ca; | |
| 302 | + wave_2_per_point29=zq=yp*ca - zp*sa; | |
| 303 | + wave_2_per_point30= | |
| 304 | + wave_2_per_point31= | |
| 305 | + wave_2_per_point32=ang=tm*8; | |
| 306 | + wave_2_per_point33=sa=sin(ang);ca=cos(ang); | |
| 307 | + wave_2_per_point34=xp=xq*sa + yq*ca; | |
| 308 | + wave_2_per_point35=yp=xq*ca - yq*sa; | |
| 309 | + wave_2_per_point36=zp=zq; | |
| 310 | + wave_2_per_point37= | |
| 311 | + wave_2_per_point38=//forearm movement; | |
| 312 | + wave_2_per_point39=zp=zp-0.3; | |
| 313 | + wave_2_per_point40=ang=3.14 + sin(tm*2 - 0.5)*2.5; | |
| 314 | + wave_2_per_point41=xq=xp; | |
| 315 | + wave_2_per_point42=sa=sin(ang);ca=cos(ang); | |
| 316 | + wave_2_per_point43=yq=yp*sa + zp*ca; | |
| 317 | + wave_2_per_point44=zq=yp*ca - zp*sa; | |
| 318 | + wave_2_per_point45= | |
| 319 | + wave_2_per_point46=//upper arm twist | |
| 320 | + wave_2_per_point47=ang=-1.0 + cos(tm*3 + 0.5); | |
| 321 | + wave_2_per_point48=xp=xq*sa + yq*ca; | |
| 322 | + wave_2_per_point49=yp=xq*ca - yq*sa; | |
| 323 | + wave_2_per_point50=zp=zq; | |
| 324 | + wave_2_per_point51= | |
| 325 | + wave_2_per_point52=//upper arm outward; | |
| 326 | + wave_2_per_point53=zp=zp-0.35; | |
| 327 | + wave_2_per_point54=ang=cos(tm*1)*1.75 - 1.05; | |
| 328 | + wave_2_per_point55=sa=sin(ang);ca=cos(ang); | |
| 329 | + wave_2_per_point56=xq=xp*sa + zp*ca; | |
| 330 | + wave_2_per_point57=yq=yp; | |
| 331 | + wave_2_per_point58=zq=xp*ca - zp*sa; | |
| 332 | + wave_2_per_point59= | |
| 333 | + wave_2_per_point60=//upper arm up down; | |
| 334 | + wave_2_per_point61=ang=cos(tm); | |
| 335 | + wave_2_per_point62=xp=xq; | |
| 336 | + wave_2_per_point63=sa=sin(ang);ca=cos(ang); | |
| 337 | + wave_2_per_point64=yp=yq*ca - zq*sa; | |
| 338 | + wave_2_per_point65=zp=yq*sa + zq*ca; | |
| 339 | + wave_2_per_point66= | |
| 340 | + wave_2_per_point67=//xp=xq;yp=yq;zp=zq; | |
| 341 | + wave_2_per_point68= | |
| 342 | + wave_2_per_point69= | |
| 343 | + wave_2_per_point70=//project into screenspace and draw on screen | |
| 344 | + wave_2_per_point71=zp=zp+1.5; | |
| 345 | + wave_2_per_point72=xs=xp/zp; | |
| 346 | + wave_2_per_point73=ys=yp/zp; | |
| 347 | + wave_2_per_point74= | |
| 348 | + wave_2_per_point75=x=xs+0.5; | |
| 349 | + wave_2_per_point76=y=ys*1.3+0.5; | |
| 350 | + wave_2_per_point77= | |
| 351 | + wave_2_per_point78= | |
| 352 | + wave_2_per_point79=a=(1-sample); | |
| 353 | + wavecode_3_enabled=1 | |
| 354 | + wavecode_3_samples=512 | |
| 355 | + wavecode_3_sep=0 | |
| 356 | + wavecode_3_bSpectrum=0 | |
| 357 | + wavecode_3_bUseDots=0 | |
| 358 | + wavecode_3_bDrawThick=0 | |
| 359 | + wavecode_3_bAdditive=1 | |
| 360 | + wavecode_3_scaling=1.00000 | |
| 361 | + wavecode_3_smoothing=0.50000 | |
| 362 | + wavecode_3_r=0.600 | |
| 363 | + wavecode_3_g=0.700 | |
| 364 | + wavecode_3_b=1.000 | |
| 365 | + wavecode_3_a=1.000 | |
| 366 | + wave_3_per_point1=n=sample*6.283; | |
| 367 | + wave_3_per_point2=phs=-sample * 0.4 ; | |
| 368 | + wave_3_per_point3=tm=q1 + ((phs*2)/q2)*0.1 - 1.03; | |
| 369 | + wave_3_per_point4= | |
| 370 | + wave_3_per_point5=flip=flip+1; | |
| 371 | + wave_3_per_point6=flip=flip*below(flip,2); | |
| 372 | + wave_3_per_point7= | |
| 373 | + wave_3_per_point8=xp=0; | |
| 374 | + wave_3_per_point9=yp=(flip*0.15-0.075)*(sample); | |
| 375 | + wave_3_per_point10=zp=0; | |
| 376 | + wave_3_per_point11= | |
| 377 | + wave_3_per_point12=//spin; | |
| 378 | + wave_3_per_point13=ang=-tm*14 + sin(tm*76 + time*4)*0.2;; | |
| 379 | + wave_3_per_point14=sa=sin(ang);ca=cos(ang); | |
| 380 | + wave_3_per_point15=xr=xp*sa + yp*ca; | |
| 381 | + wave_3_per_point16=yr=xp*ca - yp*sa; | |
| 382 | + wave_3_per_point17=zr=zp; | |
| 383 | + wave_3_per_point18= | |
| 384 | + wave_3_per_point19=xp=xr; | |
| 385 | + wave_3_per_point20=yp=yr + 0.05 + (sin(tm)*0.5 + 0.5)*0.2 + 0.05; | |
| 386 | + wave_3_per_point21=zp=zr; | |
| 387 | + wave_3_per_point22= | |
| 388 | + wave_3_per_point23=//wrist movement; | |
| 389 | + wave_3_per_point24=ang=sin(tm*2); | |
| 390 | + wave_3_per_point25= | |
| 391 | + wave_3_per_point26=xq=xp; | |
| 392 | + wave_3_per_point27=sa=sin(ang);ca=cos(ang); | |
| 393 | + wave_3_per_point28=yq=yp*sa + zp*ca; | |
| 394 | + wave_3_per_point29=zq=yp*ca - zp*sa; | |
| 395 | + wave_3_per_point30= | |
| 396 | + wave_3_per_point31= | |
| 397 | + wave_3_per_point32=ang=tm*8; | |
| 398 | + wave_3_per_point33=sa=sin(ang);ca=cos(ang); | |
| 399 | + wave_3_per_point34=xp=xq*sa + yq*ca; | |
| 400 | + wave_3_per_point35=yp=xq*ca - yq*sa; | |
| 401 | + wave_3_per_point36=zp=zq; | |
| 402 | + wave_3_per_point37= | |
| 403 | + wave_3_per_point38=//forearm movement; | |
| 404 | + wave_3_per_point39=zp=zp-0.3; | |
| 405 | + wave_3_per_point40=ang=3.14 + sin(tm*2 - 0.5)*2.5; | |
| 406 | + wave_3_per_point41=xq=xp; | |
| 407 | + wave_3_per_point42=sa=sin(ang);ca=cos(ang); | |
| 408 | + wave_3_per_point43=yq=yp*sa + zp*ca; | |
| 409 | + wave_3_per_point44=zq=yp*ca - zp*sa; | |
| 410 | + wave_3_per_point45= | |
| 411 | + wave_3_per_point46=//upper arm twist | |
| 412 | + wave_3_per_point47=ang=-1.0 + cos(tm*3 + 0.5); | |
| 413 | + wave_3_per_point48=xp=xq*sa + yq*ca; | |
| 414 | + wave_3_per_point49=yp=xq*ca - yq*sa; | |
| 415 | + wave_3_per_point50=zp=zq; | |
| 416 | + wave_3_per_point51= | |
| 417 | + wave_3_per_point52=//upper arm outward; | |
| 418 | + wave_3_per_point53=zp=zp-0.35; | |
| 419 | + wave_3_per_point54=ang=cos(tm*1)*1.75 - 1.05; | |
| 420 | + wave_3_per_point55=sa=sin(ang);ca=cos(ang); | |
| 421 | + wave_3_per_point56=xq=xp*sa + zp*ca; | |
| 422 | + wave_3_per_point57=yq=yp; | |
| 423 | + wave_3_per_point58=zq=xp*ca - zp*sa; | |
| 424 | + wave_3_per_point59= | |
| 425 | + wave_3_per_point60=//upper arm up down; | |
| 426 | + wave_3_per_point61=ang=cos(tm)-3.5; | |
| 427 | + wave_3_per_point62=xp=xq; | |
| 428 | + wave_3_per_point63=sa=sin(ang);ca=cos(ang); | |
| 429 | + wave_3_per_point64=yp=yq*ca - zq*sa; | |
| 430 | + wave_3_per_point65=zp=yq*sa + zq*ca; | |
| 431 | + wave_3_per_point66= | |
| 432 | + wave_3_per_point67=//xp=xq;yp=yq;zp=zq; | |
| 433 | + wave_3_per_point68= | |
| 434 | + wave_3_per_point69= | |
| 435 | + wave_3_per_point70=//project into screenspace and draw on screen | |
| 436 | + wave_3_per_point71=zp=zp+1.5; | |
| 437 | + wave_3_per_point72=xs=xp/zp; | |
| 438 | + wave_3_per_point73=ys=yp/zp; | |
| 439 | + wave_3_per_point74= | |
| 440 | + wave_3_per_point75=x=xs+0.5; | |
| 441 | + wave_3_per_point76=y=ys*1.3+0.5; | |
| 442 | + wave_3_per_point77= | |
| 443 | + wave_3_per_point78= | |
| 444 | + wave_3_per_point79=a=(1-sample)*0.4; | |
| 445 | + shapecode_0_enabled=1 | |
| 446 | + shapecode_0_sides=6 | |
| 447 | + shapecode_0_additive=1 | |
| 448 | + shapecode_0_thickOutline=0 | |
| 449 | + shapecode_0_textured=0 | |
| 450 | + shapecode_0_num_inst=1 | |
| 451 | + shapecode_0_x=0.500 | |
| 452 | + shapecode_0_y=0.500 | |
| 453 | + shapecode_0_rad=0.04556 | |
| 454 | + shapecode_0_ang=0.00000 | |
| 455 | + shapecode_0_tex_ang=0.00000 | |
| 456 | + shapecode_0_tex_zoom=1.00000 | |
| 457 | + shapecode_0_r=1.000 | |
| 458 | + shapecode_0_g=0.700 | |
| 459 | + shapecode_0_b=0.300 | |
| 460 | + shapecode_0_a=1.000 | |
| 461 | + shapecode_0_r2=0.000 | |
| 462 | + shapecode_0_g2=0.000 | |
| 463 | + shapecode_0_b2=0.000 | |
| 464 | + shapecode_0_a2=0.000 | |
| 465 | + shapecode_0_border_r=1.000 | |
| 466 | + shapecode_0_border_g=1.000 | |
| 467 | + shapecode_0_border_b=1.000 | |
| 468 | + shapecode_0_border_a=0.000 | |
| 469 | + shape_0_per_frame1=tm=q1; | |
| 470 | + shape_0_per_frame2= | |
| 471 | + shape_0_per_frame3=flip=flip+1; | |
| 472 | + shape_0_per_frame4=flip=flip*below(flip,2); | |
| 473 | + shape_0_per_frame5= | |
| 474 | + shape_0_per_frame6=xp=0; | |
| 475 | + shape_0_per_frame7=yp=0; | |
| 476 | + shape_0_per_frame8=zp=0; | |
| 477 | + shape_0_per_frame9= | |
| 478 | + shape_0_per_frame10=//spin; | |
| 479 | + shape_0_per_frame11=ang=tm*20 + sin(tm*76 + time*4)*0.4; | |
| 480 | + shape_0_per_frame12=sa=sin(ang);ca=cos(ang); | |
| 481 | + shape_0_per_frame13=xr=xp*sa + yp*ca; | |
| 482 | + shape_0_per_frame14=yr=xp*ca - yp*sa; | |
| 483 | + shape_0_per_frame15=zr=zp; | |
| 484 | + shape_0_per_frame16= | |
| 485 | + shape_0_per_frame17=xp=xr; | |
| 486 | + shape_0_per_frame18=yp=yr + 0.05 + (sin(tm)*0.5 + 0.5)*0.2 + 0.05; | |
| 487 | + shape_0_per_frame19=zp=zr; | |
| 488 | + shape_0_per_frame20= | |
| 489 | + shape_0_per_frame21=//wrist movement; | |
| 490 | + shape_0_per_frame22=ang=sin(tm*2); | |
| 491 | + shape_0_per_frame23= | |
| 492 | + shape_0_per_frame24=xq=xp; | |
| 493 | + shape_0_per_frame25=sa=sin(ang);ca=cos(ang); | |
| 494 | + shape_0_per_frame26=yq=yp*sa + zp*ca; | |
| 495 | + shape_0_per_frame27=zq=yp*ca - zp*sa; | |
| 496 | + shape_0_per_frame28= | |
| 497 | + shape_0_per_frame29= | |
| 498 | + shape_0_per_frame30=ang=tm*8; | |
| 499 | + shape_0_per_frame31=sa=sin(ang);ca=cos(ang); | |
| 500 | + shape_0_per_frame32=xp=xq*sa + yq*ca; | |
| 501 | + shape_0_per_frame33=yp=xq*ca - yq*sa; | |
| 502 | + shape_0_per_frame34=zp=zq; | |
| 503 | + shape_0_per_frame35= | |
| 504 | + shape_0_per_frame36=//forearm movement; | |
| 505 | + shape_0_per_frame37=zp=zp-0.3; | |
| 506 | + shape_0_per_frame38=ang=3.14 + sin(tm*2 - 0.5)*2.5; | |
| 507 | + shape_0_per_frame39=xq=xp; | |
| 508 | + shape_0_per_frame40=sa=sin(ang);ca=cos(ang); | |
| 509 | + shape_0_per_frame41=yq=yp*sa + zp*ca; | |
| 510 | + shape_0_per_frame42=zq=yp*ca - zp*sa; | |
| 511 | + shape_0_per_frame43= | |
| 512 | + shape_0_per_frame44=//upper arm twist | |
| 513 | + shape_0_per_frame45=ang=-1.0 + cos(tm*3 + 0.5); | |
| 514 | + shape_0_per_frame46=xp=xq*sa + yq*ca; | |
| 515 | + shape_0_per_frame47=yp=xq*ca - yq*sa; | |
| 516 | + shape_0_per_frame48=zp=zq; | |
| 517 | + shape_0_per_frame49= | |
| 518 | + shape_0_per_frame50=//upper arm outward; | |
| 519 | + shape_0_per_frame51=zp=zp-0.35; | |
| 520 | + shape_0_per_frame52=ang=cos(tm*1)*1.75 - 1.05; | |
| 521 | + shape_0_per_frame53=sa=sin(ang);ca=cos(ang); | |
| 522 | + shape_0_per_frame54=xq=xp*sa + zp*ca; | |
| 523 | + shape_0_per_frame55=yq=yp; | |
| 524 | + shape_0_per_frame56=zq=xp*ca - zp*sa; | |
| 525 | + shape_0_per_frame57= | |
| 526 | + shape_0_per_frame58=//upper arm up down; | |
| 527 | + shape_0_per_frame59=ang=cos(tm); | |
| 528 | + shape_0_per_frame60=xp=xq; | |
| 529 | + shape_0_per_frame61=sa=sin(ang);ca=cos(ang); | |
| 530 | + shape_0_per_frame62=yp=yq*ca - zq*sa; | |
| 531 | + shape_0_per_frame63=zp=yq*sa + zq*ca; | |
| 532 | + shape_0_per_frame64= | |
| 533 | + shape_0_per_frame65=//xp=xq;yp=yq;zp=zq; | |
| 534 | + shape_0_per_frame66= | |
| 535 | + shape_0_per_frame67= | |
| 536 | + shape_0_per_frame68=//project into screenspace and draw on screen | |
| 537 | + shape_0_per_frame69=zp=zp+1.5; | |
| 538 | + shape_0_per_frame70=xs=xp/zp; | |
| 539 | + shape_0_per_frame71=ys=yp/zp; | |
| 540 | + shape_0_per_frame72= | |
| 541 | + shape_0_per_frame73=x=xs+0.5; | |
| 542 | + shape_0_per_frame74=y=ys*1.3+0.5; | |
| 543 | + shape_0_per_frame75= | |
| 544 | + shape_0_per_frame76= | |
| 545 | + shape_0_per_frame77=a=0.7; | |
| 546 | + shape_0_per_frame78= | |
| 547 | + shapecode_1_enabled=0 | |
| 548 | + shapecode_1_sides=4 | |
| 549 | + shapecode_1_additive=0 | |
| 550 | + shapecode_1_thickOutline=0 | |
| 551 | + shapecode_1_textured=0 | |
| 552 | + shapecode_1_num_inst=1 | |
| 553 | + shapecode_1_x=0.500 | |
| 554 | + shapecode_1_y=0.500 | |
| 555 | + shapecode_1_rad=0.10000 | |
| 556 | + shapecode_1_ang=0.00000 | |
| 557 | + shapecode_1_tex_ang=0.00000 | |
| 558 | + shapecode_1_tex_zoom=1.00000 | |
| 559 | + shapecode_1_r=1.000 | |
| 560 | + shapecode_1_g=0.000 | |
| 561 | + shapecode_1_b=0.000 | |
| 562 | + shapecode_1_a=1.000 | |
| 563 | + shapecode_1_r2=0.000 | |
| 564 | + shapecode_1_g2=1.000 | |
| 565 | + shapecode_1_b2=0.000 | |
| 566 | + shapecode_1_a2=0.000 | |
| 567 | + shapecode_1_border_r=1.000 | |
| 568 | + shapecode_1_border_g=1.000 | |
| 569 | + shapecode_1_border_b=1.000 | |
| 570 | + shapecode_1_border_a=0.100 | |
| 571 | + shapecode_2_enabled=0 | |
| 572 | + shapecode_2_sides=4 | |
| 573 | + shapecode_2_additive=0 | |
| 574 | + shapecode_2_thickOutline=0 | |
| 575 | + shapecode_2_textured=0 | |
| 576 | + shapecode_2_num_inst=1 | |
| 577 | + shapecode_2_x=0.500 | |
| 578 | + shapecode_2_y=0.500 | |
| 579 | + shapecode_2_rad=0.10000 | |
| 580 | + shapecode_2_ang=0.00000 | |
| 581 | + shapecode_2_tex_ang=0.00000 | |
| 582 | + shapecode_2_tex_zoom=1.00000 | |
| 583 | + shapecode_2_r=1.000 | |
| 584 | + shapecode_2_g=0.000 | |
| 585 | + shapecode_2_b=0.000 | |
| 586 | + shapecode_2_a=1.000 | |
| 587 | + shapecode_2_r2=0.000 | |
| 588 | + shapecode_2_g2=1.000 | |
| 589 | + shapecode_2_b2=0.000 | |
| 590 | + shapecode_2_a2=0.000 | |
| 591 | + shapecode_2_border_r=1.000 | |
| 592 | + shapecode_2_border_g=1.000 | |
| 593 | + shapecode_2_border_b=1.000 | |
| 594 | + shapecode_2_border_a=0.100 | |
| 595 | + shapecode_3_enabled=0 | |
| 596 | + shapecode_3_sides=4 | |
| 597 | + shapecode_3_additive=0 | |
| 598 | + shapecode_3_thickOutline=0 | |
| 599 | + shapecode_3_textured=0 | |
| 600 | + shapecode_3_num_inst=1 | |
| 601 | + shapecode_3_x=0.500 | |
| 602 | + shapecode_3_y=0.500 | |
| 603 | + shapecode_3_rad=0.10000 | |
| 604 | + shapecode_3_ang=0.00000 | |
| 605 | + shapecode_3_tex_ang=0.00000 | |
| 606 | + shapecode_3_tex_zoom=1.00000 | |
| 607 | + shapecode_3_r=1.000 | |
| 608 | + shapecode_3_g=0.000 | |
| 609 | + shapecode_3_b=0.000 | |
| 610 | + shapecode_3_a=1.000 | |
| 611 | + shapecode_3_r2=0.000 | |
| 612 | + shapecode_3_g2=1.000 | |
| 613 | + shapecode_3_b2=0.000 | |
| 614 | + shapecode_3_a2=0.000 | |
| 615 | + shapecode_3_border_r=1.000 | |
| 616 | + shapecode_3_border_g=1.000 | |
| 617 | + shapecode_3_border_b=1.000 | |
| 618 | + shapecode_3_border_a=0.100 | |
| 619 | + per_frame_1=chng=sin(time*.5); | |
| 620 | + per_frame_2=cthr=.9999; | |
| 621 | + per_frame_3=mq21=if(above(chng,cthr),rand(3),mq21); | |
| 622 | + per_frame_4=mq22=if(above(chng,cthr),rand(3),mq22); | |
| 623 | + per_frame_5=mq23=if(above(chng,cthr),rand(3),mq23); | |
| 624 | + per_frame_6=mq24=if(above(chng,cthr),rand(2),mq24); | |
| 625 | + per_frame_7=mq25=if(above(chng,cthr),rand(2),mq25); | |
| 626 | + per_frame_8=mq26=if(above(chng,cthr),rand(2),mq26); | |
| 627 | + per_frame_9=mq27=if(above(chng,cthr),rand(1),mq27); | |
| 628 | + per_frame_10=mq28=if(above(chng,cthr),rand(1),mq28); | |
| 629 | + per_frame_11=mq29=if(above(chng,cthr),rand(1)*.3,mq29); | |
| 630 | + per_frame_12=mq30=if(above(chng,cthr),rand(1)*.3,mq30); | |
| 631 | + per_frame_13=monitor=chng; | |
| 632 | + per_frame_14=q21=mq21;q22=mq22;q23=mq23;q24=mq24;q25=mq25;q26=mq26; | |
| 633 | + per_frame_15=q27=mq27;q28=mq28;q29=mq29;q30=mq30; | |
| 634 | + per_frame_16= | |
| 635 | + per_frame_17=monitor=mq1; | |
| 636 | + per_frame_18=warp = 0; | |
| 637 | + per_frame_19=//zoom = 1; | |
| 638 | + per_frame_20= | |
| 639 | + per_frame_21=tic = min(time-tin,.1); | |
| 640 | + per_frame_22=tin = time; | |
| 641 | + per_frame_23= | |
| 642 | + per_frame_24=vol = (bass_att + treb_att + mid_att)*.333333; | |
| 643 | + per_frame_25= | |
| 644 | + per_frame_26=ra = 1/tic*.25; | |
| 645 | + per_frame_27= | |
| 646 | + per_frame_28=treb_avg = tic*(treb_avg*(1/tic - ra) + ra*treb); | |
| 647 | + per_frame_29=mid_avg = tic*(mid_avg*(1/tic - ra) + ra*mid); | |
| 648 | + per_frame_30=bass_avg = tic*(bass_avg*(1/tic - ra) + ra*bass); | |
| 649 | + per_frame_31=vav = tic*(vav*(1/tic - ra) + ra*(bass+treb+mid)*.33333); | |
| 650 | + per_frame_32= | |
| 651 | + per_frame_33=tt = tt + tic*treb; | |
| 652 | + per_frame_34=mt = mt + tic*mid; | |
| 653 | + per_frame_35=bt = bt + tic*bass; | |
| 654 | + per_frame_36=vt = vt + tic*vav; | |
| 655 | + per_frame_37= | |
| 656 | + per_frame_38=q1 = tt*3;// wave morph speeds | |
| 657 | + per_frame_39=q2 = mt*3; | |
| 658 | + per_frame_40=q3 = bt*3; | |
| 659 | + per_frame_41= | |
| 660 | + per_frame_42=q4 = vt; // wave colour cycle | |
| 661 | + per_frame_43= | |
| 662 | + per_frame_44=rb = if(rb,rb,.2 + int(rand(1001))*.001*.6); | |
| 663 | + per_frame_45=rc = if(rc,rc,.2 + int(rand(1001))*.001*.6); | |
| 664 | + per_frame_46=rd = if(rd,rd,.2 + int(rand(1001))*.001*.6); | |
| 665 | + per_frame_47=re = if(re,re,.2 + int(rand(1001))*.001*.6); | |
| 666 | + per_frame_48= | |
| 667 | + per_frame_49=//rot = .26; | |
| 668 | + per_frame_50= | |
| 669 | + per_frame_51=ti = vt*2; | |
| 670 | + per_frame_52=cx = .3 + .1*sin(ti*re) + .1*cos(ti*rc); | |
| 671 | + per_frame_53=cy = .5 + .2*sin(ti*rb) + .1*cos(ti*rd); | |
| 672 | + per_frame_54= | |
| 673 | + per_pixel_1=num = 8; | |
| 674 | + per_pixel_2=pi = 3.141592654; | |
| 675 | + per_pixel_3=radi = (y-.5)*.75; | |
| 676 | + per_pixel_4=radi = (y-.5); | |
| 677 | + per_pixel_5=radi = pow(radi*radi + (x-.5)*(x-.5),.5); | |
| 678 | + per_pixel_6= | |
| 679 | + per_pixel_7=an = ang + pi + time; | |
| 680 | + per_pixel_8=an = an - pi*2*int(an/(pi*2)); | |
| 681 | + per_pixel_9= | |
| 682 | + per_pixel_10=mod = .1; | |
| 683 | + per_pixel_11= | |
| 684 | + per_pixel_12=seg = ang + pi; | |
| 685 | + per_pixel_13=seg = seg/(pi*2)*num; | |
| 686 | + per_pixel_14=seg = int(seg); | |
| 687 | + per_pixel_15=seg = seg - equal(seg,num); | |
| 688 | + per_pixel_16= | |
| 689 | + per_pixel_17=anga = (ang + pi) - (pi*2/num)*seg; | |
| 690 | + per_pixel_18=anga = if(equal(seg%2,0),(pi*2/num) - anga,anga); | |
| 691 | + per_pixel_19=//anga = anga + pi/6; // num = 6 | |
| 692 | + per_pixel_20=anga = anga + pi/4; // num = 8 | |
| 693 | + per_pixel_21=//anga = anga + .85; // num = 10 | |
| 694 | + per_pixel_22= | |
| 695 | + per_pixel_23= | |
| 696 | + per_pixel_24=ox = .5 - radi*sin(anga); | |
| 697 | + per_pixel_25=oy = .5 + radi*cos(anga); | |
| 698 | + per_pixel_26= | |
| 699 | + per_pixel_27=rot = if(equal(seg,0),rot,0); | |
| 700 | + per_pixel_28= | |
| 701 | + per_pixel_29=dx = equal(seg,3)*(x-ox); | |
| 702 | + per_pixel_30=dy = equal(seg,3)*(y-oy); | |
| 703 | + per_pixel_31= | |
| 704 | + per_pixel_32=dx = above(seg,0)*(x-ox); | |
| 705 | + per_pixel_33=dy = above(seg,0)*(y-oy); | |
| 706 | + per_pixel_34= | |
| 707 | + per_pixel_35=//dx = equal(seg,1)*(x - .5)*2; | |
| 708 | + warp_1=`shader_body | |
| 709 | + warp_2=`{ | |
| 710 | + warp_3=` | |
| 711 | + warp_4=`//Geiss's Motion Blur | |
| 712 | + warp_5=` | |
| 713 | + warp_6=` // sample previous frame | |
| 714 | + warp_7=` ret = tex2D( sampler_main, uv ).xyz; | |
| 715 | + warp_8=` | |
| 716 | + warp_9=` // this vector points exactly one pixel, in the direction of motion | |
| 717 | + warp_10=` float2 v = normalize(uv-uv_orig)*texsize.zw; | |
| 718 | + warp_11=` | |
| 719 | + warp_12=` float3 s; | |
| 720 | + warp_13=` ret = max(ret, tex2D(sampler_main, uv+v)*0.97); | |
| 721 | + warp_14=` ret = max(ret, tex2D(sampler_main, uv-v)*0.97); | |
| 722 | + warp_15=` ret = max(ret, tex2D(sampler_main, uv+v*2)*0.90); | |
| 723 | + warp_16=` ret = max(ret, tex2D(sampler_main, uv-v*2)*0.90); | |
| 724 | + warp_17=` | |
| 725 | + warp_18=` // darken over time | |
| 726 | + warp_19=` ret *= 0.90; | |
| 727 | + warp_20=`float4 noise9 = tex3D(sampler_noisevol_hq, | |
| 728 | + warp_21=` ((uv.xyy*q27 | |
| 729 | + warp_22=` )*texsize.xyy*texsize_noisevol_hq.zww | |
| 730 | + warp_23=` ).xyz* | |
| 731 | + warp_24=` float3(1,1,0)*0.05 + | |
| 732 | + warp_25=` time*float3(0,0,1)*q29 | |
| 733 | + warp_26=` ); | |
| 734 | + warp_27=`if(ret.x> q21*roam_cos.y && ret.x<= q24*roam_sin.x)ret.y -= (noise9).x*.5; | |
| 735 | + warp_28=`if(ret.y> q22*roam_sin.x && ret.y<= q25*roam_cos.x)ret.z -= (noise9).y*.5; | |
| 736 | + warp_29=`if(ret.z> q23*roam_cos.x && ret.z<= q26*roam_sin.y)ret.x -= (noise9).z*.5; | |
| 737 | + warp_30=`} | |
| 738 | + comp_1=`// to access a texture on disk: make a sampler. This example loads "lichen.{tga/jpg/etc}". | |
| 739 | + comp_2=`sampler2D sampler_fw_lichen; // _FW = filtering + wrap; _PC = point sampling + edge clamp; etc. | |
| 740 | + comp_3=`float4 texsize_lichen; // auto-binds; .xy = (w,h); .zw = (1/w,1/h) | |
| 741 | + comp_4=` | |
| 742 | + comp_5=` | |
| 743 | + comp_6=`shader_body | |
| 744 | + comp_7=`{ | |
| 745 | + comp_8=` ret = tex2D(sampler_main, uv).xyz; | |
| 746 | + comp_9=` ret = max(ret, tex2D(sampler_main, float2(1-uv.x,uv.y))); | |
| 747 | + comp_10=`float4 noise9 = tex3D(sampler_noisevol_hq, | |
| 748 | + comp_11=` ((uv.xyy*q28 | |
| 749 | + comp_12=` )*texsize.xyy*texsize_noisevol_hq.zww | |
| 750 | + comp_13=` ).xyz* | |
| 751 | + comp_14=` float3(1,1,0)*0.05 + | |
| 752 | + comp_15=` time*float3(0,0,1)*q30 | |
| 753 | + comp_16=` ); | |
| 754 | + comp_17=`if(ret.x> q26*roam_cos.y && ret.x<= q23*roam_sin.x)ret.z -= (noise9).x*.5; | |
| 755 | + comp_18=`if(ret.y> q25*roam_sin.x && ret.y<= q22*roam_cos.x)ret.x -= (noise9).y*.5; | |
| 756 | + comp_19=`if(ret.z> q24*roam_cos.x && ret.z<= q21*roam_sin.y)ret.y -= (noise9).z*.5; | |
| 757 | + comp_20=` ret += GetBlur1(1-uv)*2; | |
| 758 | + comp_21=`ret += GetBlur3(-uv)*0.5; | |
| 759 | + comp_22=` ret *= 0.90; //old gamma effect | |
| 760 | + comp_23=` | |
| 761 | + comp_24=`} |
Sources/PulseCanvas/Resources/ProjectM/Presets/Dancer/Aurora/suksma - shifter - urchin kali echos - bowel nz+.milk added
| 1 | + MILKDROP_PRESET_VERSION=201 | |
| 2 | + PSVERSION=3 | |
| 3 | + PSVERSION_WARP=3 | |
| 4 | + PSVERSION_COMP=3 | |
| 5 | + [preset00] | |
| 6 | + fRating=5.000000 | |
| 7 | + fGammaAdj=1.000 | |
| 8 | + fDecay=0.900 | |
| 9 | + fVideoEchoZoom=1.104 | |
| 10 | + fVideoEchoAlpha=0.500 | |
| 11 | + nVideoEchoOrientation=0 | |
| 12 | + nWaveMode=7 | |
| 13 | + bAdditiveWaves=1 | |
| 14 | + bWaveDots=0 | |
| 15 | + bWaveThick=0 | |
| 16 | + bModWaveAlphaByVolume=1 | |
| 17 | + bMaximizeWaveColor=0 | |
| 18 | + bTexWrap=1 | |
| 19 | + bDarkenCenter=0 | |
| 20 | + bRedBlueStereo=0 | |
| 21 | + bBrighten=1 | |
| 22 | + bDarken=1 | |
| 23 | + bSolarize=0 | |
| 24 | + bInvert=0 | |
| 25 | + fWaveAlpha=0.001 | |
| 26 | + fWaveScale=1.286 | |
| 27 | + fWaveSmoothing=0.630 | |
| 28 | + fWaveParam=0.000 | |
| 29 | + fModWaveAlphaStart=0.710 | |
| 30 | + fModWaveAlphaEnd=1.300 | |
| 31 | + fWarpAnimSpeed=1.000 | |
| 32 | + fWarpScale=1.331 | |
| 33 | + fZoomExponent=1.00000 | |
| 34 | + fShader=0.000 | |
| 35 | + zoom=0.99951 | |
| 36 | + rot=0.26000 | |
| 37 | + cx=0.320 | |
| 38 | + cy=0.290 | |
| 39 | + dx=0.00000 | |
| 40 | + dy=0.00000 | |
| 41 | + warp=0.01105 | |
| 42 | + sx=1.00000 | |
| 43 | + sy=1.00000 | |
| 44 | + wave_r=0.650 | |
| 45 | + wave_g=0.650 | |
| 46 | + wave_b=0.650 | |
| 47 | + wave_x=0.500 | |
| 48 | + wave_y=0.500 | |
| 49 | + ob_size=0.500 | |
| 50 | + ob_r=0.010 | |
| 51 | + ob_g=0.000 | |
| 52 | + ob_b=0.000 | |
| 53 | + ob_a=0.000 | |
| 54 | + ib_size=0.260 | |
| 55 | + ib_r=0.250 | |
| 56 | + ib_g=0.250 | |
| 57 | + ib_b=0.250 | |
| 58 | + ib_a=0.000 | |
| 59 | + nMotionVectorsX=12.000 | |
| 60 | + nMotionVectorsY=9.000 | |
| 61 | + mv_dx=0.000 | |
| 62 | + mv_dy=0.000 | |
| 63 | + mv_l=0.900 | |
| 64 | + mv_r=1.000 | |
| 65 | + mv_g=1.000 | |
| 66 | + mv_b=1.000 | |
| 67 | + mv_a=0.000 | |
| 68 | + b1n=0.000 | |
| 69 | + b2n=0.000 | |
| 70 | + b3n=0.000 | |
| 71 | + b1x=1.000 | |
| 72 | + b2x=1.000 | |
| 73 | + b3x=1.000 | |
| 74 | + b1ed=0.250 | |
| 75 | + wavecode_0_enabled=1 | |
| 76 | + wavecode_0_samples=512 | |
| 77 | + wavecode_0_sep=0 | |
| 78 | + wavecode_0_bSpectrum=0 | |
| 79 | + wavecode_0_bUseDots=0 | |
| 80 | + wavecode_0_bDrawThick=0 | |
| 81 | + wavecode_0_bAdditive=1 | |
| 82 | + wavecode_0_scaling=1.00000 | |
| 83 | + wavecode_0_smoothing=0.50000 | |
| 84 | + wavecode_0_r=0.000 | |
| 85 | + wavecode_0_g=0.000 | |
| 86 | + wavecode_0_b=1.000 | |
| 87 | + wavecode_0_a=0.050 | |
| 88 | + wave_0_init1=t1 = .2 + .6*int(rand(1001))*.001; | |
| 89 | + wave_0_init2=t2 = .2 + .6*int(rand(1001))*.001; | |
| 90 | + wave_0_init3=t3 = .2 + .6*int(rand(1001))*.001; | |
| 91 | + wave_0_init4=t4 = .2 + .6*int(rand(1001))*.001; | |
| 92 | + wave_0_init5=t5 = .2 + .6*int(rand(1001))*.001; | |
| 93 | + wave_0_init6=t6 = .2 + .6*int(rand(1001))*.001; | |
| 94 | + wave_0_init7=t7 = .2 + .6*int(rand(1001))*.001; | |
| 95 | + wave_0_init8=t8 = .2 + .6*int(rand(1001))*.001; | |
| 96 | + wave_0_per_point1=ti = q1; | |
| 97 | + wave_0_per_point2= | |
| 98 | + wave_0_per_point3=xa = .25 + .25*sin(ti*t1); | |
| 99 | + wave_0_per_point4=xb = .25 + .25*sin(ti*t2); | |
| 100 | + wave_0_per_point5=xc = .25 + .25*sin(ti*t3); | |
| 101 | + wave_0_per_point6=xd = .25 + .25*sin(ti*t4); | |
| 102 | + wave_0_per_point7= | |
| 103 | + wave_0_per_point8=ya = .25 + .25*sin(ti*t5); | |
| 104 | + wave_0_per_point9=yb = .25 + .25*sin(ti*t6); | |
| 105 | + wave_0_per_point10=yc = .25 + .25*sin(ti*t7); | |
| 106 | + wave_0_per_point11=yd = .25 + .25*sin(ti*t8); | |
| 107 | + wave_0_per_point12= | |
| 108 | + wave_0_per_point13= | |
| 109 | + wave_0_per_point14=it = (it + 1)*above(sample,0); | |
| 110 | + wave_0_per_point15=sw = (1-sw)*above(sample,0); | |
| 111 | + wave_0_per_point16= | |
| 112 | + wave_0_per_point17=sa = 1-sample; | |
| 113 | + wave_0_per_point18=x = if(sw,xa*sample + sa*xb,xc*sample + xd*sa); | |
| 114 | + wave_0_per_point19=y = if(sw,ya*sample + sa*yb,yc*sample + yd*sa); | |
| 115 | + wave_0_per_point20= | |
| 116 | + wave_0_per_point21=y = .5 - y*(.5-x)*2; | |
| 117 | + wave_0_per_point22= | |
| 118 | + wave_0_per_point23= | |
| 119 | + wave_0_per_point24=ti = q4; | |
| 120 | + wave_0_per_point25=r = .5 + .5*sin(ti); | |
| 121 | + wave_0_per_point26=g = .5 + .5*sin(ti + 2.0944); | |
| 122 | + wave_0_per_point27=b = .5 + .5*sin(ti + 4.1888); | |
| 123 | + wavecode_1_enabled=1 | |
| 124 | + wavecode_1_samples=512 | |
| 125 | + wavecode_1_sep=0 | |
| 126 | + wavecode_1_bSpectrum=0 | |
| 127 | + wavecode_1_bUseDots=0 | |
| 128 | + wavecode_1_bDrawThick=0 | |
| 129 | + wavecode_1_bAdditive=1 | |
| 130 | + wavecode_1_scaling=1.00000 | |
| 131 | + wavecode_1_smoothing=0.50000 | |
| 132 | + wavecode_1_r=0.000 | |
| 133 | + wavecode_1_g=1.000 | |
| 134 | + wavecode_1_b=0.000 | |
| 135 | + wavecode_1_a=0.050 | |
| 136 | + wave_1_init1=t1 = .2 + .6*int(rand(1001))*.001; | |
| 137 | + wave_1_init2=t2 = .2 + .6*int(rand(1001))*.001; | |
| 138 | + wave_1_init3=t3 = .2 + .6*int(rand(1001))*.001; | |
| 139 | + wave_1_init4=t4 = .2 + .6*int(rand(1001))*.001; | |
| 140 | + wave_1_init5=t5 = .2 + .6*int(rand(1001))*.001; | |
| 141 | + wave_1_init6=t6 = .2 + .6*int(rand(1001))*.001; | |
| 142 | + wave_1_init7=t7 = .2 + .6*int(rand(1001))*.001; | |
| 143 | + wave_1_init8=t8 = .2 + .6*int(rand(1001))*.001; | |
| 144 | + wave_1_per_point1=ti = q2; | |
| 145 | + wave_1_per_point2= | |
| 146 | + wave_1_per_point3=xa = .25 + .25*sin(ti*t1); | |
| 147 | + wave_1_per_point4=xb = .25 + .25*sin(ti*t2); | |
| 148 | + wave_1_per_point5=xc = .25 + .25*sin(ti*t3); | |
| 149 | + wave_1_per_point6=xd = .25 + .25*sin(ti*t4); | |
| 150 | + wave_1_per_point7= | |
| 151 | + wave_1_per_point8=ya = .25 + .25*sin(ti*t5); | |
| 152 | + wave_1_per_point9=yb = .25 + .25*sin(ti*t6); | |
| 153 | + wave_1_per_point10=yc = .25 + .25*sin(ti*t7); | |
| 154 | + wave_1_per_point11=yd = .25 + .25*sin(ti*t8); | |
| 155 | + wave_1_per_point12= | |
| 156 | + wave_1_per_point13= | |
| 157 | + wave_1_per_point14=it = (it + 1)*above(sample,0); | |
| 158 | + wave_1_per_point15=sw = (1-sw)*above(sample,0); | |
| 159 | + wave_1_per_point16= | |
| 160 | + wave_1_per_point17=sa = 1-sample; | |
| 161 | + wave_1_per_point18=x = if(sw,xa*sample + sa*xb,xc*sample + xd*sa); | |
| 162 | + wave_1_per_point19=y = if(sw,ya*sample + sa*yb,yc*sample + yd*sa); | |
| 163 | + wave_1_per_point20= | |
| 164 | + wave_1_per_point21=y = .5 - y*(.5-x)*2; | |
| 165 | + wave_1_per_point22= | |
| 166 | + wave_1_per_point23=ti = q4 + 2.0944; | |
| 167 | + wave_1_per_point24=r = .5 + .5*sin(ti); | |
| 168 | + wave_1_per_point25=g = .5 + .5*sin(ti + 2.0944); | |
| 169 | + wave_1_per_point26=b = .5 + .5*sin(ti + 4.1888); | |
| 170 | + wavecode_2_enabled=1 | |
| 171 | + wavecode_2_samples=512 | |
| 172 | + wavecode_2_sep=0 | |
| 173 | + wavecode_2_bSpectrum=0 | |
| 174 | + wavecode_2_bUseDots=0 | |
| 175 | + wavecode_2_bDrawThick=0 | |
| 176 | + wavecode_2_bAdditive=1 | |
| 177 | + wavecode_2_scaling=1.00000 | |
| 178 | + wavecode_2_smoothing=0.50000 | |
| 179 | + wavecode_2_r=1.000 | |
| 180 | + wavecode_2_g=0.000 | |
| 181 | + wavecode_2_b=0.000 | |
| 182 | + wavecode_2_a=0.050 | |
| 183 | + wave_2_init1=t1 = .2 + .6*int(rand(1001))*.001; | |
| 184 | + wave_2_init2=t2 = .2 + .6*int(rand(1001))*.001; | |
| 185 | + wave_2_init3=t3 = .2 + .6*int(rand(1001))*.001; | |
| 186 | + wave_2_init4=t4 = .2 + .6*int(rand(1001))*.001; | |
| 187 | + wave_2_init5=t5 = .2 + .6*int(rand(1001))*.001; | |
| 188 | + wave_2_init6=t6 = .2 + .6*int(rand(1001))*.001; | |
| 189 | + wave_2_init7=t7 = .2 + .6*int(rand(1001))*.001; | |
| 190 | + wave_2_init8=t8 = .2 + .6*int(rand(1001))*.001; | |
| 191 | + wave_2_per_point1=ti = q3; | |
| 192 | + wave_2_per_point2= | |
| 193 | + wave_2_per_point3=xa = .25 + .25*sin(ti*t1); | |
| 194 | + wave_2_per_point4=xb = .25 + .25*sin(ti*t2); | |
| 195 | + wave_2_per_point5=xc = .25 + .25*sin(ti*t3); | |
| 196 | + wave_2_per_point6=xd = .25 + .25*sin(ti*t4); | |
| 197 | + wave_2_per_point7= | |
| 198 | + wave_2_per_point8=ya = .25 + .25*sin(ti*t5); | |
| 199 | + wave_2_per_point9=yb = .25 + .25*sin(ti*t6); | |
| 200 | + wave_2_per_point10=yc = .25 + .25*sin(ti*t7); | |
| 201 | + wave_2_per_point11=yd = .25 + .25*sin(ti*t8); | |
| 202 | + wave_2_per_point12= | |
| 203 | + wave_2_per_point13= | |
| 204 | + wave_2_per_point14=it = (it + 1)*above(sample,0); | |
| 205 | + wave_2_per_point15=sw = (1-sw)*above(sample,0); | |
| 206 | + wave_2_per_point16= | |
| 207 | + wave_2_per_point17=sa = 1-sample; | |
| 208 | + wave_2_per_point18=x = if(sw,xa*sample + sa*xb,xc*sample + xd*sa); | |
| 209 | + wave_2_per_point19=y = if(sw,ya*sample + sa*yb,yc*sample + yd*sa); | |
| 210 | + wave_2_per_point20= | |
| 211 | + wave_2_per_point21=y = .5 - y*(.5-x)*2; | |
| 212 | + wave_2_per_point22= | |
| 213 | + wave_2_per_point23=ti = q4 + 4.1888; | |
| 214 | + wave_2_per_point24=r = .5 + .5*sin(ti); | |
| 215 | + wave_2_per_point25=g = .5 + .5*sin(ti + 2.0944); | |
| 216 | + wave_2_per_point26=b = .5 + .5*sin(ti + 4.1888); | |
| 217 | + wavecode_3_enabled=0 | |
| 218 | + wavecode_3_samples=512 | |
| 219 | + wavecode_3_sep=0 | |
| 220 | + wavecode_3_bSpectrum=0 | |
| 221 | + wavecode_3_bUseDots=0 | |
| 222 | + wavecode_3_bDrawThick=0 | |
| 223 | + wavecode_3_bAdditive=0 | |
| 224 | + wavecode_3_scaling=1.00000 | |
| 225 | + wavecode_3_smoothing=0.50000 | |
| 226 | + wavecode_3_r=1.000 | |
| 227 | + wavecode_3_g=1.000 | |
| 228 | + wavecode_3_b=1.000 | |
| 229 | + wavecode_3_a=1.000 | |
| 230 | + shapecode_0_enabled=1 | |
| 231 | + shapecode_0_sides=54 | |
| 232 | + shapecode_0_additive=0 | |
| 233 | + shapecode_0_thickOutline=0 | |
| 234 | + shapecode_0_textured=1 | |
| 235 | + shapecode_0_num_inst=1 | |
| 236 | + shapecode_0_x=0.000 | |
| 237 | + shapecode_0_y=0.500 | |
| 238 | + shapecode_0_rad=0.24486 | |
| 239 | + shapecode_0_ang=0.00000 | |
| 240 | + shapecode_0_tex_ang=0.00000 | |
| 241 | + shapecode_0_tex_zoom=1.81669 | |
| 242 | + shapecode_0_r=1.000 | |
| 243 | + shapecode_0_g=1.000 | |
| 244 | + shapecode_0_b=1.000 | |
| 245 | + shapecode_0_a=1.000 | |
| 246 | + shapecode_0_r2=1.000 | |
| 247 | + shapecode_0_g2=1.000 | |
| 248 | + shapecode_0_b2=1.000 | |
| 249 | + shapecode_0_a2=0.000 | |
| 250 | + shapecode_0_border_r=1.000 | |
| 251 | + shapecode_0_border_g=1.000 | |
| 252 | + shapecode_0_border_b=1.000 | |
| 253 | + shapecode_0_border_a=0.000 | |
| 254 | + shape_0_per_frame1=//tex_zoom = 1/rad*.9; | |
| 255 | + shapecode_1_enabled=1 | |
| 256 | + shapecode_1_sides=54 | |
| 257 | + shapecode_1_additive=0 | |
| 258 | + shapecode_1_thickOutline=0 | |
| 259 | + shapecode_1_textured=1 | |
| 260 | + shapecode_1_num_inst=1 | |
| 261 | + shapecode_1_x=0.250 | |
| 262 | + shapecode_1_y=0.400 | |
| 263 | + shapecode_1_rad=0.33000 | |
| 264 | + shapecode_1_ang=0.00000 | |
| 265 | + shapecode_1_tex_ang=0.00000 | |
| 266 | + shapecode_1_tex_zoom=1.81669 | |
| 267 | + shapecode_1_r=1.000 | |
| 268 | + shapecode_1_g=1.000 | |
| 269 | + shapecode_1_b=1.000 | |
| 270 | + shapecode_1_a=1.000 | |
| 271 | + shapecode_1_r2=1.000 | |
| 272 | + shapecode_1_g2=1.000 | |
| 273 | + shapecode_1_b2=1.000 | |
| 274 | + shapecode_1_a2=0.000 | |
| 275 | + shapecode_1_border_r=1.000 | |
| 276 | + shapecode_1_border_g=1.000 | |
| 277 | + shapecode_1_border_b=1.000 | |
| 278 | + shapecode_1_border_a=0.000 | |
| 279 | + shape_1_per_frame1=//tex_zoom = 1/rad*.9; | |
| 280 | + shapecode_2_enabled=0 | |
| 281 | + shapecode_2_sides=4 | |
| 282 | + shapecode_2_additive=0 | |
| 283 | + shapecode_2_thickOutline=0 | |
| 284 | + shapecode_2_textured=0 | |
| 285 | + shapecode_2_num_inst=1 | |
| 286 | + shapecode_2_x=0.500 | |
| 287 | + shapecode_2_y=0.500 | |
| 288 | + shapecode_2_rad=0.10000 | |
| 289 | + shapecode_2_ang=0.00000 | |
| 290 | + shapecode_2_tex_ang=0.00000 | |
| 291 | + shapecode_2_tex_zoom=1.00000 | |
| 292 | + shapecode_2_r=1.000 | |
| 293 | + shapecode_2_g=0.000 | |
| 294 | + shapecode_2_b=0.000 | |
| 295 | + shapecode_2_a=1.000 | |
| 296 | + shapecode_2_r2=0.000 | |
| 297 | + shapecode_2_g2=1.000 | |
| 298 | + shapecode_2_b2=0.000 | |
| 299 | + shapecode_2_a2=0.000 | |
| 300 | + shapecode_2_border_r=1.000 | |
| 301 | + shapecode_2_border_g=1.000 | |
| 302 | + shapecode_2_border_b=1.000 | |
| 303 | + shapecode_2_border_a=0.100 | |
| 304 | + shapecode_3_enabled=0 | |
| 305 | + shapecode_3_sides=4 | |
| 306 | + shapecode_3_additive=0 | |
| 307 | + shapecode_3_thickOutline=0 | |
| 308 | + shapecode_3_textured=0 | |
| 309 | + shapecode_3_num_inst=1 | |
| 310 | + shapecode_3_x=0.500 | |
| 311 | + shapecode_3_y=0.500 | |
| 312 | + shapecode_3_rad=0.10000 | |
| 313 | + shapecode_3_ang=0.00000 | |
| 314 | + shapecode_3_tex_ang=0.00000 | |
| 315 | + shapecode_3_tex_zoom=1.00000 | |
| 316 | + shapecode_3_r=1.000 | |
| 317 | + shapecode_3_g=0.000 | |
| 318 | + shapecode_3_b=0.000 | |
| 319 | + shapecode_3_a=1.000 | |
| 320 | + shapecode_3_r2=0.000 | |
| 321 | + shapecode_3_g2=1.000 | |
| 322 | + shapecode_3_b2=0.000 | |
| 323 | + shapecode_3_a2=0.000 | |
| 324 | + shapecode_3_border_r=1.000 | |
| 325 | + shapecode_3_border_g=1.000 | |
| 326 | + shapecode_3_border_b=1.000 | |
| 327 | + shapecode_3_border_a=0.100 | |
| 328 | + per_frame_1=warp = 0; | |
| 329 | + per_frame_2=//zoom = 1; | |
| 330 | + per_frame_3= | |
| 331 | + per_frame_4=tic = min(time-tin,.1); | |
| 332 | + per_frame_5=tin = time; | |
| 333 | + per_frame_6= | |
| 334 | + per_frame_7=vol = (bass_att + treb_att + mid_att)*.333333; | |
| 335 | + per_frame_8= | |
| 336 | + per_frame_9=ra = 1/tic*.25; | |
| 337 | + per_frame_10= | |
| 338 | + per_frame_11=treb_avg = tic*(treb_avg*(1/tic - ra) + ra*treb); | |
| 339 | + per_frame_12=mid_avg = tic*(mid_avg*(1/tic - ra) + ra*mid); | |
| 340 | + per_frame_13=bass_avg = tic*(bass_avg*(1/tic - ra) + ra*bass); | |
| 341 | + per_frame_14=vav = tic*(vav*(1/tic - ra) + ra*(bass+treb+mid)*.33333); | |
| 342 | + per_frame_15= | |
| 343 | + per_frame_16=tt = tt + tic*treb; | |
| 344 | + per_frame_17=mt = mt + tic*mid; | |
| 345 | + per_frame_18=bt = bt + tic*bass; | |
| 346 | + per_frame_19=vt = vt + tic*vav; | |
| 347 | + per_frame_20= | |
| 348 | + per_frame_21=q1 = tt*3;// wave morph speeds | |
| 349 | + per_frame_22=q2 = mt*3; | |
| 350 | + per_frame_23=q3 = bt*3; | |
| 351 | + per_frame_24= | |
| 352 | + per_frame_25=q4 = vt; // wave colour cycle | |
| 353 | + per_frame_26= | |
| 354 | + per_frame_27=rb = if(rb,rb,.2 + int(rand(1001))*.001*.6); | |
| 355 | + per_frame_28=rc = if(rc,rc,.2 + int(rand(1001))*.001*.6); | |
| 356 | + per_frame_29=rd = if(rd,rd,.2 + int(rand(1001))*.001*.6); | |
| 357 | + per_frame_30=re = if(re,re,.2 + int(rand(1001))*.001*.6); | |
| 358 | + per_frame_31= | |
| 359 | + per_frame_32=//rot = .26; | |
| 360 | + per_frame_33= | |
| 361 | + per_frame_34=ti = vt*2; | |
| 362 | + per_frame_35=cx = .3 + .1*sin(ti*re) + .1*cos(ti*rc); | |
| 363 | + per_frame_36=cy = .5 + .2*sin(ti*rb) + .1*cos(ti*rd); | |
| 364 | + per_frame_37= | |
| 365 | + per_frame_38=chng=sin(time*.5); | |
| 366 | + per_frame_39=cthr=.9999; | |
| 367 | + per_frame_40=mq21=if(above(chng,cthr),rand(3),mq21); | |
| 368 | + per_frame_41=mq22=if(above(chng,cthr),rand(3),mq22); | |
| 369 | + per_frame_42=mq23=if(above(chng,cthr),rand(3),mq23); | |
| 370 | + per_frame_43=mq24=if(above(chng,cthr),rand(2),mq24); | |
| 371 | + per_frame_44=mq25=if(above(chng,cthr),rand(2),mq25); | |
| 372 | + per_frame_45=mq26=if(above(chng,cthr),rand(2),mq26); | |
| 373 | + per_frame_46=mq27=if(above(chng,cthr),rand(1),mq27); | |
| 374 | + per_frame_47=mq28=if(above(chng,cthr),rand(1),mq28); | |
| 375 | + per_frame_48=mq29=if(above(chng,cthr),rand(1)*.3,mq29); | |
| 376 | + per_frame_49=mq31=if(above(chng,cthr),rand(1)*.3,mq31); | |
| 377 | + per_frame_50=monitor=chng; | |
| 378 | + per_frame_51=q21=mq21;q22=mq22;q23=mq23;q24=mq24;q25=mq25;q26=mq26; | |
| 379 | + per_frame_52=q27=mq27;q28=mq28;q29=mq29;q31=mq31; | |
| 380 | + per_frame_53= | |
| 381 | + per_frame_54=monitor=mq1; | |
| 382 | + per_frame_55=vol=bass+treb+mid; | |
| 383 | + per_frame_56=atime=atime+vol; | |
| 384 | + per_frame_57=q1=.4+sin(atime*.006 )*3.4; | |
| 385 | + per_frame_58=q2=.4+cos(atime*.00613828348)*3.4; | |
| 386 | + per_frame_59=q3=.4+sin(atime*.00598593455)*3.4; | |
| 387 | + per_frame_60=monitor=q3; | |
| 388 | + per_frame_61= | |
| 389 | + per_pixel_1=num = 8; | |
| 390 | + per_pixel_2=pi = 3.141592654; | |
| 391 | + per_pixel_3=radi = (y-.5)*.75; | |
| 392 | + per_pixel_4=radi = (y-.5); | |
| 393 | + per_pixel_5=radi = pow(radi*radi + (x-.5)*(x-.5),.5); | |
| 394 | + per_pixel_6= | |
| 395 | + per_pixel_7=an = ang + pi + time; | |
| 396 | + per_pixel_8=an = an - pi*2*int(an/(pi*2)); | |
| 397 | + per_pixel_9= | |
| 398 | + per_pixel_10=mod = .1; | |
| 399 | + per_pixel_11= | |
| 400 | + per_pixel_12=seg = ang + pi; | |
| 401 | + per_pixel_13=seg = seg/(pi*2)*num; | |
| 402 | + per_pixel_14=seg = int(seg); | |
| 403 | + per_pixel_15=seg = seg - equal(seg,num); | |
| 404 | + per_pixel_16= | |
| 405 | + per_pixel_17=anga = (ang + pi) - (pi*2/num)*seg; | |
| 406 | + per_pixel_18=anga = if(equal(seg%2,0),(pi*2/num) - anga,anga); | |
| 407 | + per_pixel_19=//anga = anga + pi/6; // num = 6 | |
| 408 | + per_pixel_20=anga = anga + pi/4; // num = 8 | |
| 409 | + per_pixel_21=//anga = anga + .85; // num = 10 | |
| 410 | + per_pixel_22= | |
| 411 | + per_pixel_23= | |
| 412 | + per_pixel_24=ox = .5 - radi*sin(anga); | |
| 413 | + per_pixel_25=oy = .5 + radi*cos(anga); | |
| 414 | + per_pixel_26= | |
| 415 | + per_pixel_27=rot = if(equal(seg,0),rot,0); | |
| 416 | + per_pixel_28= | |
| 417 | + per_pixel_29=dx = equal(seg,3)*(x-ox); | |
| 418 | + per_pixel_30=dy = equal(seg,3)*(y-oy); | |
| 419 | + per_pixel_31= | |
| 420 | + per_pixel_32=dx = above(seg,0)*(x-ox); | |
| 421 | + per_pixel_33=dy = above(seg,0)*(y-oy); | |
| 422 | + per_pixel_34= | |
| 423 | + per_pixel_35=//dx = equal(seg,1)*(x - .5)*2; | |
| 424 | + warp_1=`shader_body | |
| 425 | + warp_2=`{ | |
| 426 | + warp_3=` // sample previous frame | |
| 427 | + warp_4=` ret = tex2D( sampler_main, uv ).xyz; | |
| 428 | + warp_5=` | |
| 429 | + warp_6=` // darken (decay) over time | |
| 430 | + warp_7=` ret = ret- (ret*.5); | |
| 431 | + warp_8=`float4 noise9 = tex3D(sampler_noisevol_hq, | |
| 432 | + warp_9=` ((uv.xyy*q27 | |
| 433 | + warp_10=` )*texsize.xyy*texsize_noisevol_hq.zww | |
| 434 | + warp_11=` ).xyz* | |
| 435 | + warp_12=` float3(1,1,0)*0.05 + | |
| 436 | + warp_13=` time*float3(0,0,1)*q29 | |
| 437 | + warp_14=` ); | |
| 438 | + warp_15=`if(ret.x> q21*q3 && ret.x<= q24*q1 )ret.y -= (noise9).x*.5; | |
| 439 | + warp_16=`if(ret.y> q22*q1 && ret.y<= q25*q2 )ret.z -= (noise9).y*.5; | |
| 440 | + warp_17=`if(ret.z> q23*q2 && ret.z<= q26*q3 )ret.x -= (noise9).z*.5; | |
| 441 | + warp_18=` ret = ret*(abs(GetBlur2(uv)-.5))*5; | |
| 442 | + warp_19=` ret = ret - .01; | |
| 443 | + warp_20=`} | |
| 444 | + comp_1=`sampler sampler_fc_sunrise; | |
| 445 | + comp_2=`float2 factorA, factorB, product; | |
| 446 | + comp_3=`float2 numerator, denominator, fraction; | |
| 447 | + comp_4=`shader_body | |
| 448 | + comp_5=`{ | |
| 449 | + comp_6=`float2 uvo = uv; | |
| 450 | + comp_7=`uv = (uv-0.5); | |
| 451 | + comp_8=`factorA = uv+ float2(q1,q2); | |
| 452 | + comp_9=`factorB = float2(8,0); | |
| 453 | + comp_10=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 454 | + comp_11=`float2 uv1 = product; | |
| 455 | + comp_12=`factorA = uv+ float2(q3,q4); | |
| 456 | + comp_13=`factorB = float2(8,0); | |
| 457 | + comp_14=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 458 | + comp_15=`float2 uv2 = product; | |
| 459 | + comp_16=`factorA = uv+ float2(q5,q6); | |
| 460 | + comp_17=`factorB = float2(8,0); | |
| 461 | + comp_18=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 462 | + comp_19=`float2 uv3 = product; | |
| 463 | + comp_20=`factorA = uv+ float2(q7,q8); | |
| 464 | + comp_21=`factorB = float2(8,0); | |
| 465 | + comp_22=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 466 | + comp_23=`float2 uv4 = product; | |
| 467 | + comp_24=`factorA = uv1; | |
| 468 | + comp_25=`factorB = uv2; | |
| 469 | + comp_26=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 470 | + comp_27=`float2 uv12 = product; | |
| 471 | + comp_28=`factorA = uv3; | |
| 472 | + comp_29=`factorB = uv4; | |
| 473 | + comp_30=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 474 | + comp_31=`float2 uv34 = product; | |
| 475 | + comp_32=`factorA = uv12; | |
| 476 | + comp_33=`factorB = uv34; | |
| 477 | + comp_34=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 478 | + comp_35=`numerator = float2(1,0); | |
| 479 | + comp_36=`denominator = product; | |
| 480 | + comp_37=`fraction = float2( numerator.x*denominator.x + numerator.y*denominator.y, // the fractions real part | |
| 481 | + comp_38=` numerator.y*denominator.x - numerator.x*denominator.y)/ // the fractions imaginary part | |
| 482 | + comp_39=` (denominator.x*denominator.x + denominator.y*denominator.y); | |
| 483 | + comp_40=`uv = fraction*(16); | |
| 484 | + comp_41=`uv = lerp(0.5 + (uvo-0.5)*(2+(bass_att-treb_att)*0.02),uv+0.5,0.5); | |
| 485 | + comp_42=` | |
| 486 | + comp_43=`float l = length(uv-0.5); | |
| 487 | + comp_44=`uv = 0.5 + (1.0 - abs( frac( uv * 0.5 ) * 2 - 1.0 )-0.5); // Eo.S. mirror code with cutted borders | |
| 488 | + comp_45=` | |
| 489 | + comp_46=`ret = GetPixel(uv).y*float3(1,0.6,0); | |
| 490 | + comp_47=`ret = lerp(saturate(ret),0,GetBlur2(uv).z*0.5); | |
| 491 | + comp_48=`ret = lerp(saturate(ret),float3(0.3,0.4,0.5),GetBlur2(uv).x*4); | |
| 492 | + comp_49=`float4 noise9 = tex3D(sampler_noisevol_hq, | |
| 493 | + comp_50=` ((uv.xyy*q28 | |
| 494 | + comp_51=` )*texsize.xyy*texsize_noisevol_hq.zww | |
| 495 | + comp_52=` ).xyz* | |
| 496 | + comp_53=` float3(1,1,0)*0.05 + | |
| 497 | + comp_54=` time*float3(0,0,1)*q31 | |
| 498 | + comp_55=` ); | |
| 499 | + comp_56=`if(ret.x> q26*q3 && ret.x<= q23*q1 )ret.z -= (noise9).x*.5; | |
| 500 | + comp_57=`if(ret.y> q25*q1 && ret.y<= q22*q2 )ret.x -= (noise9).y*.5; | |
| 501 | + comp_58=`if(ret.z> q24*q2 && ret.z<= q21*q3 )ret.y -= (noise9).z*.5; | |
| 502 | + comp_59=`ret = lerp(saturate(ret),1,GetPixel(uv).z); | |
| 503 | + comp_60=`ret = lerp(saturate(ret),0,GetPixel(uv).x*0.6); | |
| 504 | + comp_61=`ret*=saturate(1.6-pow(l,6)*0.004); | |
| 505 | + comp_62=`} |
Sources/PulseCanvas/Resources/ProjectM/Presets/Dancer/Aurora/suksma - shifter - urchin kali echos - bowel roams nz+.milk added
| 1 | + MILKDROP_PRESET_VERSION=201 | |
| 2 | + PSVERSION=3 | |
| 3 | + PSVERSION_WARP=3 | |
| 4 | + PSVERSION_COMP=3 | |
| 5 | + [preset00] | |
| 6 | + fRating=5.000000 | |
| 7 | + fGammaAdj=1.000 | |
| 8 | + fDecay=0.900 | |
| 9 | + fVideoEchoZoom=1.104 | |
| 10 | + fVideoEchoAlpha=0.500 | |
| 11 | + nVideoEchoOrientation=0 | |
| 12 | + nWaveMode=7 | |
| 13 | + bAdditiveWaves=1 | |
| 14 | + bWaveDots=0 | |
| 15 | + bWaveThick=0 | |
| 16 | + bModWaveAlphaByVolume=1 | |
| 17 | + bMaximizeWaveColor=0 | |
| 18 | + bTexWrap=1 | |
| 19 | + bDarkenCenter=0 | |
| 20 | + bRedBlueStereo=0 | |
| 21 | + bBrighten=1 | |
| 22 | + bDarken=1 | |
| 23 | + bSolarize=0 | |
| 24 | + bInvert=0 | |
| 25 | + fWaveAlpha=0.001 | |
| 26 | + fWaveScale=1.286 | |
| 27 | + fWaveSmoothing=0.630 | |
| 28 | + fWaveParam=0.000 | |
| 29 | + fModWaveAlphaStart=0.710 | |
| 30 | + fModWaveAlphaEnd=1.300 | |
| 31 | + fWarpAnimSpeed=1.000 | |
| 32 | + fWarpScale=1.331 | |
| 33 | + fZoomExponent=1.00000 | |
| 34 | + fShader=0.000 | |
| 35 | + zoom=0.99951 | |
| 36 | + rot=0.26000 | |
| 37 | + cx=0.320 | |
| 38 | + cy=0.290 | |
| 39 | + dx=0.00000 | |
| 40 | + dy=0.00000 | |
| 41 | + warp=0.01105 | |
| 42 | + sx=1.00000 | |
| 43 | + sy=1.00000 | |
| 44 | + wave_r=0.650 | |
| 45 | + wave_g=0.650 | |
| 46 | + wave_b=0.650 | |
| 47 | + wave_x=0.500 | |
| 48 | + wave_y=0.500 | |
| 49 | + ob_size=0.500 | |
| 50 | + ob_r=0.010 | |
| 51 | + ob_g=0.000 | |
| 52 | + ob_b=0.000 | |
| 53 | + ob_a=0.000 | |
| 54 | + ib_size=0.260 | |
| 55 | + ib_r=0.250 | |
| 56 | + ib_g=0.250 | |
| 57 | + ib_b=0.250 | |
| 58 | + ib_a=0.000 | |
| 59 | + nMotionVectorsX=12.000 | |
| 60 | + nMotionVectorsY=9.000 | |
| 61 | + mv_dx=0.000 | |
| 62 | + mv_dy=0.000 | |
| 63 | + mv_l=0.900 | |
| 64 | + mv_r=1.000 | |
| 65 | + mv_g=1.000 | |
| 66 | + mv_b=1.000 | |
| 67 | + mv_a=0.000 | |
| 68 | + b1n=0.000 | |
| 69 | + b2n=0.000 | |
| 70 | + b3n=0.000 | |
| 71 | + b1x=1.000 | |
| 72 | + b2x=1.000 | |
| 73 | + b3x=1.000 | |
| 74 | + b1ed=0.250 | |
| 75 | + wavecode_0_enabled=1 | |
| 76 | + wavecode_0_samples=512 | |
| 77 | + wavecode_0_sep=0 | |
| 78 | + wavecode_0_bSpectrum=0 | |
| 79 | + wavecode_0_bUseDots=0 | |
| 80 | + wavecode_0_bDrawThick=0 | |
| 81 | + wavecode_0_bAdditive=1 | |
| 82 | + wavecode_0_scaling=1.00000 | |
| 83 | + wavecode_0_smoothing=0.50000 | |
| 84 | + wavecode_0_r=0.000 | |
| 85 | + wavecode_0_g=0.000 | |
| 86 | + wavecode_0_b=1.000 | |
| 87 | + wavecode_0_a=0.050 | |
| 88 | + wave_0_init1=t1 = .2 + .6*int(rand(1001))*.001; | |
| 89 | + wave_0_init2=t2 = .2 + .6*int(rand(1001))*.001; | |
| 90 | + wave_0_init3=t3 = .2 + .6*int(rand(1001))*.001; | |
| 91 | + wave_0_init4=t4 = .2 + .6*int(rand(1001))*.001; | |
| 92 | + wave_0_init5=t5 = .2 + .6*int(rand(1001))*.001; | |
| 93 | + wave_0_init6=t6 = .2 + .6*int(rand(1001))*.001; | |
| 94 | + wave_0_init7=t7 = .2 + .6*int(rand(1001))*.001; | |
| 95 | + wave_0_init8=t8 = .2 + .6*int(rand(1001))*.001; | |
| 96 | + wave_0_per_point1=ti = q1; | |
| 97 | + wave_0_per_point2= | |
| 98 | + wave_0_per_point3=xa = .25 + .25*sin(ti*t1); | |
| 99 | + wave_0_per_point4=xb = .25 + .25*sin(ti*t2); | |
| 100 | + wave_0_per_point5=xc = .25 + .25*sin(ti*t3); | |
| 101 | + wave_0_per_point6=xd = .25 + .25*sin(ti*t4); | |
| 102 | + wave_0_per_point7= | |
| 103 | + wave_0_per_point8=ya = .25 + .25*sin(ti*t5); | |
| 104 | + wave_0_per_point9=yb = .25 + .25*sin(ti*t6); | |
| 105 | + wave_0_per_point10=yc = .25 + .25*sin(ti*t7); | |
| 106 | + wave_0_per_point11=yd = .25 + .25*sin(ti*t8); | |
| 107 | + wave_0_per_point12= | |
| 108 | + wave_0_per_point13= | |
| 109 | + wave_0_per_point14=it = (it + 1)*above(sample,0); | |
| 110 | + wave_0_per_point15=sw = (1-sw)*above(sample,0); | |
| 111 | + wave_0_per_point16= | |
| 112 | + wave_0_per_point17=sa = 1-sample; | |
| 113 | + wave_0_per_point18=x = if(sw,xa*sample + sa*xb,xc*sample + xd*sa); | |
| 114 | + wave_0_per_point19=y = if(sw,ya*sample + sa*yb,yc*sample + yd*sa); | |
| 115 | + wave_0_per_point20= | |
| 116 | + wave_0_per_point21=y = .5 - y*(.5-x)*2; | |
| 117 | + wave_0_per_point22= | |
| 118 | + wave_0_per_point23= | |
| 119 | + wave_0_per_point24=ti = q4; | |
| 120 | + wave_0_per_point25=r = .5 + .5*sin(ti); | |
| 121 | + wave_0_per_point26=g = .5 + .5*sin(ti + 2.0944); | |
| 122 | + wave_0_per_point27=b = .5 + .5*sin(ti + 4.1888); | |
| 123 | + wavecode_1_enabled=1 | |
| 124 | + wavecode_1_samples=512 | |
| 125 | + wavecode_1_sep=0 | |
| 126 | + wavecode_1_bSpectrum=0 | |
| 127 | + wavecode_1_bUseDots=0 | |
| 128 | + wavecode_1_bDrawThick=0 | |
| 129 | + wavecode_1_bAdditive=1 | |
| 130 | + wavecode_1_scaling=1.00000 | |
| 131 | + wavecode_1_smoothing=0.50000 | |
| 132 | + wavecode_1_r=0.000 | |
| 133 | + wavecode_1_g=1.000 | |
| 134 | + wavecode_1_b=0.000 | |
| 135 | + wavecode_1_a=0.050 | |
| 136 | + wave_1_init1=t1 = .2 + .6*int(rand(1001))*.001; | |
| 137 | + wave_1_init2=t2 = .2 + .6*int(rand(1001))*.001; | |
| 138 | + wave_1_init3=t3 = .2 + .6*int(rand(1001))*.001; | |
| 139 | + wave_1_init4=t4 = .2 + .6*int(rand(1001))*.001; | |
| 140 | + wave_1_init5=t5 = .2 + .6*int(rand(1001))*.001; | |
| 141 | + wave_1_init6=t6 = .2 + .6*int(rand(1001))*.001; | |
| 142 | + wave_1_init7=t7 = .2 + .6*int(rand(1001))*.001; | |
| 143 | + wave_1_init8=t8 = .2 + .6*int(rand(1001))*.001; | |
| 144 | + wave_1_per_point1=ti = q2; | |
| 145 | + wave_1_per_point2= | |
| 146 | + wave_1_per_point3=xa = .25 + .25*sin(ti*t1); | |
| 147 | + wave_1_per_point4=xb = .25 + .25*sin(ti*t2); | |
| 148 | + wave_1_per_point5=xc = .25 + .25*sin(ti*t3); | |
| 149 | + wave_1_per_point6=xd = .25 + .25*sin(ti*t4); | |
| 150 | + wave_1_per_point7= | |
| 151 | + wave_1_per_point8=ya = .25 + .25*sin(ti*t5); | |
| 152 | + wave_1_per_point9=yb = .25 + .25*sin(ti*t6); | |
| 153 | + wave_1_per_point10=yc = .25 + .25*sin(ti*t7); | |
| 154 | + wave_1_per_point11=yd = .25 + .25*sin(ti*t8); | |
| 155 | + wave_1_per_point12= | |
| 156 | + wave_1_per_point13= | |
| 157 | + wave_1_per_point14=it = (it + 1)*above(sample,0); | |
| 158 | + wave_1_per_point15=sw = (1-sw)*above(sample,0); | |
| 159 | + wave_1_per_point16= | |
| 160 | + wave_1_per_point17=sa = 1-sample; | |
| 161 | + wave_1_per_point18=x = if(sw,xa*sample + sa*xb,xc*sample + xd*sa); | |
| 162 | + wave_1_per_point19=y = if(sw,ya*sample + sa*yb,yc*sample + yd*sa); | |
| 163 | + wave_1_per_point20= | |
| 164 | + wave_1_per_point21=y = .5 - y*(.5-x)*2; | |
| 165 | + wave_1_per_point22= | |
| 166 | + wave_1_per_point23=ti = q4 + 2.0944; | |
| 167 | + wave_1_per_point24=r = .5 + .5*sin(ti); | |
| 168 | + wave_1_per_point25=g = .5 + .5*sin(ti + 2.0944); | |
| 169 | + wave_1_per_point26=b = .5 + .5*sin(ti + 4.1888); | |
| 170 | + wavecode_2_enabled=1 | |
| 171 | + wavecode_2_samples=512 | |
| 172 | + wavecode_2_sep=0 | |
| 173 | + wavecode_2_bSpectrum=0 | |
| 174 | + wavecode_2_bUseDots=0 | |
| 175 | + wavecode_2_bDrawThick=0 | |
| 176 | + wavecode_2_bAdditive=1 | |
| 177 | + wavecode_2_scaling=1.00000 | |
| 178 | + wavecode_2_smoothing=0.50000 | |
| 179 | + wavecode_2_r=1.000 | |
| 180 | + wavecode_2_g=0.000 | |
| 181 | + wavecode_2_b=0.000 | |
| 182 | + wavecode_2_a=0.050 | |
| 183 | + wave_2_init1=t1 = .2 + .6*int(rand(1001))*.001; | |
| 184 | + wave_2_init2=t2 = .2 + .6*int(rand(1001))*.001; | |
| 185 | + wave_2_init3=t3 = .2 + .6*int(rand(1001))*.001; | |
| 186 | + wave_2_init4=t4 = .2 + .6*int(rand(1001))*.001; | |
| 187 | + wave_2_init5=t5 = .2 + .6*int(rand(1001))*.001; | |
| 188 | + wave_2_init6=t6 = .2 + .6*int(rand(1001))*.001; | |
| 189 | + wave_2_init7=t7 = .2 + .6*int(rand(1001))*.001; | |
| 190 | + wave_2_init8=t8 = .2 + .6*int(rand(1001))*.001; | |
| 191 | + wave_2_per_point1=ti = q3; | |
| 192 | + wave_2_per_point2= | |
| 193 | + wave_2_per_point3=xa = .25 + .25*sin(ti*t1); | |
| 194 | + wave_2_per_point4=xb = .25 + .25*sin(ti*t2); | |
| 195 | + wave_2_per_point5=xc = .25 + .25*sin(ti*t3); | |
| 196 | + wave_2_per_point6=xd = .25 + .25*sin(ti*t4); | |
| 197 | + wave_2_per_point7= | |
| 198 | + wave_2_per_point8=ya = .25 + .25*sin(ti*t5); | |
| 199 | + wave_2_per_point9=yb = .25 + .25*sin(ti*t6); | |
| 200 | + wave_2_per_point10=yc = .25 + .25*sin(ti*t7); | |
| 201 | + wave_2_per_point11=yd = .25 + .25*sin(ti*t8); | |
| 202 | + wave_2_per_point12= | |
| 203 | + wave_2_per_point13= | |
| 204 | + wave_2_per_point14=it = (it + 1)*above(sample,0); | |
| 205 | + wave_2_per_point15=sw = (1-sw)*above(sample,0); | |
| 206 | + wave_2_per_point16= | |
| 207 | + wave_2_per_point17=sa = 1-sample; | |
| 208 | + wave_2_per_point18=x = if(sw,xa*sample + sa*xb,xc*sample + xd*sa); | |
| 209 | + wave_2_per_point19=y = if(sw,ya*sample + sa*yb,yc*sample + yd*sa); | |
| 210 | + wave_2_per_point20= | |
| 211 | + wave_2_per_point21=y = .5 - y*(.5-x)*2; | |
| 212 | + wave_2_per_point22= | |
| 213 | + wave_2_per_point23=ti = q4 + 4.1888; | |
| 214 | + wave_2_per_point24=r = .5 + .5*sin(ti); | |
| 215 | + wave_2_per_point25=g = .5 + .5*sin(ti + 2.0944); | |
| 216 | + wave_2_per_point26=b = .5 + .5*sin(ti + 4.1888); | |
| 217 | + wavecode_3_enabled=0 | |
| 218 | + wavecode_3_samples=512 | |
| 219 | + wavecode_3_sep=0 | |
| 220 | + wavecode_3_bSpectrum=0 | |
| 221 | + wavecode_3_bUseDots=0 | |
| 222 | + wavecode_3_bDrawThick=0 | |
| 223 | + wavecode_3_bAdditive=0 | |
| 224 | + wavecode_3_scaling=1.00000 | |
| 225 | + wavecode_3_smoothing=0.50000 | |
| 226 | + wavecode_3_r=1.000 | |
| 227 | + wavecode_3_g=1.000 | |
| 228 | + wavecode_3_b=1.000 | |
| 229 | + wavecode_3_a=1.000 | |
| 230 | + shapecode_0_enabled=1 | |
| 231 | + shapecode_0_sides=54 | |
| 232 | + shapecode_0_additive=0 | |
| 233 | + shapecode_0_thickOutline=0 | |
| 234 | + shapecode_0_textured=1 | |
| 235 | + shapecode_0_num_inst=1 | |
| 236 | + shapecode_0_x=0.000 | |
| 237 | + shapecode_0_y=0.500 | |
| 238 | + shapecode_0_rad=0.24486 | |
| 239 | + shapecode_0_ang=0.00000 | |
| 240 | + shapecode_0_tex_ang=0.00000 | |
| 241 | + shapecode_0_tex_zoom=1.81669 | |
| 242 | + shapecode_0_r=1.000 | |
| 243 | + shapecode_0_g=1.000 | |
| 244 | + shapecode_0_b=1.000 | |
| 245 | + shapecode_0_a=1.000 | |
| 246 | + shapecode_0_r2=1.000 | |
| 247 | + shapecode_0_g2=1.000 | |
| 248 | + shapecode_0_b2=1.000 | |
| 249 | + shapecode_0_a2=0.000 | |
| 250 | + shapecode_0_border_r=1.000 | |
| 251 | + shapecode_0_border_g=1.000 | |
| 252 | + shapecode_0_border_b=1.000 | |
| 253 | + shapecode_0_border_a=0.000 | |
| 254 | + shape_0_per_frame1=//tex_zoom = 1/rad*.9; | |
| 255 | + shapecode_1_enabled=1 | |
| 256 | + shapecode_1_sides=54 | |
| 257 | + shapecode_1_additive=0 | |
| 258 | + shapecode_1_thickOutline=0 | |
| 259 | + shapecode_1_textured=1 | |
| 260 | + shapecode_1_num_inst=1 | |
| 261 | + shapecode_1_x=0.250 | |
| 262 | + shapecode_1_y=0.400 | |
| 263 | + shapecode_1_rad=0.33000 | |
| 264 | + shapecode_1_ang=0.00000 | |
| 265 | + shapecode_1_tex_ang=0.00000 | |
| 266 | + shapecode_1_tex_zoom=1.81669 | |
| 267 | + shapecode_1_r=1.000 | |
| 268 | + shapecode_1_g=1.000 | |
| 269 | + shapecode_1_b=1.000 | |
| 270 | + shapecode_1_a=1.000 | |
| 271 | + shapecode_1_r2=1.000 | |
| 272 | + shapecode_1_g2=1.000 | |
| 273 | + shapecode_1_b2=1.000 | |
| 274 | + shapecode_1_a2=0.000 | |
| 275 | + shapecode_1_border_r=1.000 | |
| 276 | + shapecode_1_border_g=1.000 | |
| 277 | + shapecode_1_border_b=1.000 | |
| 278 | + shapecode_1_border_a=0.000 | |
| 279 | + shape_1_per_frame1=//tex_zoom = 1/rad*.9; | |
| 280 | + shapecode_2_enabled=0 | |
| 281 | + shapecode_2_sides=4 | |
| 282 | + shapecode_2_additive=0 | |
| 283 | + shapecode_2_thickOutline=0 | |
| 284 | + shapecode_2_textured=0 | |
| 285 | + shapecode_2_num_inst=1 | |
| 286 | + shapecode_2_x=0.500 | |
| 287 | + shapecode_2_y=0.500 | |
| 288 | + shapecode_2_rad=0.10000 | |
| 289 | + shapecode_2_ang=0.00000 | |
| 290 | + shapecode_2_tex_ang=0.00000 | |
| 291 | + shapecode_2_tex_zoom=1.00000 | |
| 292 | + shapecode_2_r=1.000 | |
| 293 | + shapecode_2_g=0.000 | |
| 294 | + shapecode_2_b=0.000 | |
| 295 | + shapecode_2_a=1.000 | |
| 296 | + shapecode_2_r2=0.000 | |
| 297 | + shapecode_2_g2=1.000 | |
| 298 | + shapecode_2_b2=0.000 | |
| 299 | + shapecode_2_a2=0.000 | |
| 300 | + shapecode_2_border_r=1.000 | |
| 301 | + shapecode_2_border_g=1.000 | |
| 302 | + shapecode_2_border_b=1.000 | |
| 303 | + shapecode_2_border_a=0.100 | |
| 304 | + shapecode_3_enabled=0 | |
| 305 | + shapecode_3_sides=4 | |
| 306 | + shapecode_3_additive=0 | |
| 307 | + shapecode_3_thickOutline=0 | |
| 308 | + shapecode_3_textured=0 | |
| 309 | + shapecode_3_num_inst=1 | |
| 310 | + shapecode_3_x=0.500 | |
| 311 | + shapecode_3_y=0.500 | |
| 312 | + shapecode_3_rad=0.10000 | |
| 313 | + shapecode_3_ang=0.00000 | |
| 314 | + shapecode_3_tex_ang=0.00000 | |
| 315 | + shapecode_3_tex_zoom=1.00000 | |
| 316 | + shapecode_3_r=1.000 | |
| 317 | + shapecode_3_g=0.000 | |
| 318 | + shapecode_3_b=0.000 | |
| 319 | + shapecode_3_a=1.000 | |
| 320 | + shapecode_3_r2=0.000 | |
| 321 | + shapecode_3_g2=1.000 | |
| 322 | + shapecode_3_b2=0.000 | |
| 323 | + shapecode_3_a2=0.000 | |
| 324 | + shapecode_3_border_r=1.000 | |
| 325 | + shapecode_3_border_g=1.000 | |
| 326 | + shapecode_3_border_b=1.000 | |
| 327 | + shapecode_3_border_a=0.100 | |
| 328 | + per_frame_1=chng=sin(time*.5); | |
| 329 | + per_frame_2=cthr=.99; | |
| 330 | + per_frame_3=mq21=if(above(chng,cthr),rand(3),mq21); | |
| 331 | + per_frame_4=mq22=if(above(chng,cthr),rand(3),mq22); | |
| 332 | + per_frame_5=mq23=if(above(chng,cthr),rand(3),mq23); | |
| 333 | + per_frame_6=mq24=if(above(chng,cthr),rand(2),mq24); | |
| 334 | + per_frame_7=mq25=if(above(chng,cthr),rand(2),mq25); | |
| 335 | + per_frame_8=mq26=if(above(chng,cthr),rand(2),mq26); | |
| 336 | + per_frame_9=mq27=if(above(chng,cthr),rand(1),mq27); | |
| 337 | + per_frame_10=mq28=if(above(chng,cthr),rand(1),mq28); | |
| 338 | + per_frame_11=mq29=if(above(chng,cthr),rand(1)*.3,mq29); | |
| 339 | + per_frame_12=mq30=if(above(chng,cthr),rand(1)*.3,mq30); | |
| 340 | + per_frame_13=monitor=chng; | |
| 341 | + per_frame_14=q21=mq21;q22=mq22;q23=mq23;q24=mq24;q25=mq25;q26=mq26; | |
| 342 | + per_frame_15=q27=mq27;q28=mq28;q29=mq29;q30=mq30; | |
| 343 | + per_frame_16= | |
| 344 | + per_frame_17=monitor=mq1; | |
| 345 | + per_frame_18=warp = 0; | |
| 346 | + per_frame_19=//zoom = 1; | |
| 347 | + per_frame_20= | |
| 348 | + per_frame_21=tic = min(time-tin,.1); | |
| 349 | + per_frame_22=tin = time; | |
| 350 | + per_frame_23= | |
| 351 | + per_frame_24=vol = (bass_att + treb_att + mid_att)*.333333; | |
| 352 | + per_frame_25= | |
| 353 | + per_frame_26=ra = 1/tic*.25; | |
| 354 | + per_frame_27= | |
| 355 | + per_frame_28=treb_avg = tic*(treb_avg*(1/tic - ra) + ra*treb); | |
| 356 | + per_frame_29=mid_avg = tic*(mid_avg*(1/tic - ra) + ra*mid); | |
| 357 | + per_frame_30=bass_avg = tic*(bass_avg*(1/tic - ra) + ra*bass); | |
| 358 | + per_frame_31=vav = tic*(vav*(1/tic - ra) + ra*(bass+treb+mid)*.33333); | |
| 359 | + per_frame_32= | |
| 360 | + per_frame_33=tt = tt + tic*treb; | |
| 361 | + per_frame_34=mt = mt + tic*mid; | |
| 362 | + per_frame_35=bt = bt + tic*bass; | |
| 363 | + per_frame_36=vt = vt + tic*vav; | |
| 364 | + per_frame_37= | |
| 365 | + per_frame_38=q1 = tt*3;// wave morph speeds | |
| 366 | + per_frame_39=q2 = mt*3; | |
| 367 | + per_frame_40=q3 = bt*3; | |
| 368 | + per_frame_41= | |
| 369 | + per_frame_42=q4 = vt; // wave colour cycle | |
| 370 | + per_frame_43= | |
| 371 | + per_frame_44=rb = if(rb,rb,.2 + int(rand(1001))*.001*.6); | |
| 372 | + per_frame_45=rc = if(rc,rc,.2 + int(rand(1001))*.001*.6); | |
| 373 | + per_frame_46=rd = if(rd,rd,.2 + int(rand(1001))*.001*.6); | |
| 374 | + per_frame_47=re = if(re,re,.2 + int(rand(1001))*.001*.6); | |
| 375 | + per_frame_48= | |
| 376 | + per_frame_49=//rot = .26; | |
| 377 | + per_frame_50= | |
| 378 | + per_frame_51=ti = vt*2; | |
| 379 | + per_frame_52=cx = .3 + .1*sin(ti*re) + .1*cos(ti*rc); | |
| 380 | + per_frame_53=cy = .5 + .2*sin(ti*rb) + .1*cos(ti*rd); | |
| 381 | + per_frame_54= | |
| 382 | + per_pixel_1=num = 8; | |
| 383 | + per_pixel_2=pi = 3.141592654; | |
| 384 | + per_pixel_3=radi = (y-.5)*.75; | |
| 385 | + per_pixel_4=radi = (y-.5); | |
| 386 | + per_pixel_5=radi = pow(radi*radi + (x-.5)*(x-.5),.5); | |
| 387 | + per_pixel_6= | |
| 388 | + per_pixel_7=an = ang + pi + time; | |
| 389 | + per_pixel_8=an = an - pi*2*int(an/(pi*2)); | |
| 390 | + per_pixel_9= | |
| 391 | + per_pixel_10=mod = .1; | |
| 392 | + per_pixel_11= | |
| 393 | + per_pixel_12=seg = ang + pi; | |
| 394 | + per_pixel_13=seg = seg/(pi*2)*num; | |
| 395 | + per_pixel_14=seg = int(seg); | |
| 396 | + per_pixel_15=seg = seg - equal(seg,num); | |
| 397 | + per_pixel_16= | |
| 398 | + per_pixel_17=anga = (ang + pi) - (pi*2/num)*seg; | |
| 399 | + per_pixel_18=anga = if(equal(seg%2,0),(pi*2/num) - anga,anga); | |
| 400 | + per_pixel_19=//anga = anga + pi/6; // num = 6 | |
| 401 | + per_pixel_20=anga = anga + pi/4; // num = 8 | |
| 402 | + per_pixel_21=//anga = anga + .85; // num = 10 | |
| 403 | + per_pixel_22= | |
| 404 | + per_pixel_23= | |
| 405 | + per_pixel_24=ox = .5 - radi*sin(anga); | |
| 406 | + per_pixel_25=oy = .5 + radi*cos(anga); | |
| 407 | + per_pixel_26= | |
| 408 | + per_pixel_27=rot = if(equal(seg,0),rot,0); | |
| 409 | + per_pixel_28= | |
| 410 | + per_pixel_29=dx = equal(seg,3)*(x-ox); | |
| 411 | + per_pixel_30=dy = equal(seg,3)*(y-oy); | |
| 412 | + per_pixel_31= | |
| 413 | + per_pixel_32=dx = above(seg,0)*(x-ox); | |
| 414 | + per_pixel_33=dy = above(seg,0)*(y-oy); | |
| 415 | + per_pixel_34= | |
| 416 | + per_pixel_35=//dx = equal(seg,1)*(x - .5)*2; | |
| 417 | + warp_1=`shader_body | |
| 418 | + warp_2=`{ | |
| 419 | + warp_3=` // sample previous frame | |
| 420 | + warp_4=` ret = tex2D( sampler_main, uv ).xyz; | |
| 421 | + warp_5=`float4 noise9 = tex3D(sampler_noisevol_hq, | |
| 422 | + warp_6=` ((uv.xyy*q27 | |
| 423 | + warp_7=` )*texsize.xyy*texsize_noisevol_hq.zww | |
| 424 | + warp_8=` ).xyz* | |
| 425 | + warp_9=` float3(1,1,0)*0.05 + | |
| 426 | + warp_10=` time*float3(0,0,1)*q29 | |
| 427 | + warp_11=` ); | |
| 428 | + warp_12=`if(ret.x> q21*roam_cos.y && ret.x<= q24*roam_sin.x)ret.y -= (noise9).x*.5; | |
| 429 | + warp_13=`if(ret.y> q22*roam_sin.x && ret.y<= q25*roam_cos.x)ret.z -= (noise9).y*.5; | |
| 430 | + warp_14=`if(ret.z> q23*roam_cos.x && ret.z<= q26*roam_sin.y)ret.x -= (noise9).z*.5; | |
| 431 | + warp_15=` | |
| 432 | + warp_16=` // darken (decay) over time | |
| 433 | + warp_17=` ret = ret- (ret*.5); | |
| 434 | + warp_18=` ret = ret*(abs(GetBlur2(uv)-.5))*5; | |
| 435 | + warp_19=` ret = ret - .01; | |
| 436 | + warp_20=`} | |
| 437 | + comp_1=`sampler sampler_fc_sunrise; | |
| 438 | + comp_2=`float2 factorA, factorB, product; | |
| 439 | + comp_3=`float2 numerator, denominator, fraction; | |
| 440 | + comp_4=`shader_body | |
| 441 | + comp_5=`{ | |
| 442 | + comp_6=`float2 uvo = uv; | |
| 443 | + comp_7=`uv = (uv-0.5); | |
| 444 | + comp_8=`factorA = uv+ float2(q1,q2); | |
| 445 | + comp_9=`factorB = float2(8,0); | |
| 446 | + comp_10=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 447 | + comp_11=`float2 uv1 = product; | |
| 448 | + comp_12=`factorA = uv+ float2(q3,q4); | |
| 449 | + comp_13=`factorB = float2(8,0); | |
| 450 | + comp_14=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 451 | + comp_15=`float2 uv2 = product; | |
| 452 | + comp_16=`factorA = uv+ float2(q5,q6); | |
| 453 | + comp_17=`factorB = float2(8,0); | |
| 454 | + comp_18=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 455 | + comp_19=`float2 uv3 = product; | |
| 456 | + comp_20=`factorA = uv+ float2(q7,q8); | |
| 457 | + comp_21=`factorB = float2(8,0); | |
| 458 | + comp_22=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 459 | + comp_23=`float2 uv4 = product; | |
| 460 | + comp_24=`factorA = uv1; | |
| 461 | + comp_25=`factorB = uv2; | |
| 462 | + comp_26=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 463 | + comp_27=`float2 uv12 = product; | |
| 464 | + comp_28=`factorA = uv3; | |
| 465 | + comp_29=`factorB = uv4; | |
| 466 | + comp_30=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 467 | + comp_31=`float2 uv34 = product; | |
| 468 | + comp_32=`factorA = uv12; | |
| 469 | + comp_33=`factorB = uv34; | |
| 470 | + comp_34=`product = float2( factorA.x*factorB.x - factorA.y*factorB.y, factorA.x*factorB.y + factorA.y*factorB.x); | |
| 471 | + comp_35=`numerator = float2(1,0); | |
| 472 | + comp_36=`denominator = product; | |
| 473 | + comp_37=`fraction = float2( numerator.x*denominator.x + numerator.y*denominator.y, // the fractions real part | |
| 474 | + comp_38=` numerator.y*denominator.x - numerator.x*denominator.y)/ // the fractions imaginary part | |
| 475 | + comp_39=` (denominator.x*denominator.x + denominator.y*denominator.y); | |
| 476 | + comp_40=`uv = fraction*(16); | |
| 477 | + comp_41=`uv = lerp(0.5 + (uvo-0.5)*(2+(bass_att-treb_att)*0.02),uv+0.5,0.5); | |
| 478 | + comp_42=`float l = length(uv-0.5); | |
| 479 | + comp_43=`uv = 0.5 + (1.0 - abs( frac( uv * 0.5 ) * 2 - 1.0 )-0.5); // Eo.S. mirror code with cutted borders | |
| 480 | + comp_44=`ret = GetPixel(uv).y*float3(1,0.6,0); | |
| 481 | + comp_45=`ret = lerp(saturate(ret),0,GetBlur2(uv).z*0.5); | |
| 482 | + comp_46=`ret = lerp(saturate(ret),float3(0.3,0.4,0.5),GetBlur2(uv).x*4); | |
| 483 | + comp_47=`ret = lerp(saturate(ret),1,GetPixel(uv).z); | |
| 484 | + comp_48=`float4 noise9 = tex3D(sampler_noisevol_hq, | |
| 485 | + comp_49=` ((uv.xyy*q28 | |
| 486 | + comp_50=` )*texsize.xyy*texsize_noisevol_hq.zww | |
| 487 | + comp_51=` ).xyz* | |
| 488 | + comp_52=` float3(1,1,0)*0.05 + | |
| 489 | + comp_53=` time*float3(0,0,1)*q30 | |
| 490 | + comp_54=` ); | |
| 491 | + comp_55=` | |
| 492 | + comp_56=`if(ret.x> q26*roam_cos.y && ret.x<= q23*roam_sin.x)ret.z -= (noise9).x*.5; | |
| 493 | + comp_57=`if(ret.y> q25*roam_sin.x && ret.y<= q22*roam_cos.x)ret.x -= (noise9).y*.5; | |
| 494 | + comp_58=`if(ret.z> q24*roam_cos.x && ret.z<= q21*roam_sin.y)ret.y -= (noise9).z*.5; | |
| 495 | + comp_59=`ret = lerp(saturate(ret),0,GetPixel(uv).x*0.6); | |
| 496 | + comp_60=`ret*=saturate(1.6-pow(l,6)*0.004); | |
| 497 | + comp_61=`} |
Sources/PulseCanvas/Resources/ProjectM/Presets/Dancer/Blobby Mirror/Flexi, Geiss and Rovastar - mindless tokamak color pox [end of the world mix] nickle'.milk added
| 1 | + MILKDROP_PRESET_VERSION=201 | |
| 2 | + PSVERSION=3 | |
| 3 | + PSVERSION_WARP=2 | |
| 4 | + PSVERSION_COMP=3 | |
| 5 | + [preset00] | |
| 6 | + fRating=5.000000 | |
| 7 | + fGammaAdj=1.000 | |
| 8 | + fDecay=1.000 | |
| 9 | + fVideoEchoZoom=1.000 | |
| 10 | + fVideoEchoAlpha=0.000 | |
| 11 | + nVideoEchoOrientation=2 | |
| 12 | + nWaveMode=5 | |
| 13 | + bAdditiveWaves=1 | |
| 14 | + bWaveDots=0 | |
| 15 | + bWaveThick=0 | |
| 16 | + bModWaveAlphaByVolume=1 | |
| 17 | + bMaximizeWaveColor=0 | |
| 18 | + bTexWrap=0 | |
| 19 | + bDarkenCenter=0 | |
| 20 | + bRedBlueStereo=0 | |
| 21 | + bBrighten=0 | |
| 22 | + bDarken=0 | |
| 23 | + bSolarize=0 | |
| 24 | + bInvert=0 | |
| 25 | + fWaveAlpha=1.136 | |
| 26 | + fWaveScale=1.229 | |
| 27 | + fWaveSmoothing=0.000 | |
| 28 | + fWaveParam=0.200 | |
| 29 | + fModWaveAlphaStart=0.710 | |
| 30 | + fModWaveAlphaEnd=1.300 | |
| 31 | + fWarpAnimSpeed=1.000 | |
| 32 | + fWarpScale=1.331 | |
| 33 | + fZoomExponent=1.00000 | |
| 34 | + fShader=0.000 | |
| 35 | + zoom=1.00400 | |
| 36 | + rot=0.00000 | |
| 37 | + cx=0.500 | |
| 38 | + cy=0.500 | |
| 39 | + dx=0.00000 | |
| 40 | + dy=0.00000 | |
| 41 | + warp=0.19788 | |
| 42 | + sx=0.99967 | |
| 43 | + sy=0.99990 | |
| 44 | + wave_r=0.000 | |
| 45 | + wave_g=0.000 | |
| 46 | + wave_b=0.000 | |
| 47 | + wave_x=0.500 | |
| 48 | + wave_y=0.500 | |
| 49 | + ob_size=0.000 | |
| 50 | + ob_r=1.000 | |
| 51 | + ob_g=0.000 | |
| 52 | + ob_b=0.000 | |
| 53 | + ob_a=0.700 | |
| 54 | + ib_size=0.000 | |
| 55 | + ib_r=0.000 | |
| 56 | + ib_g=0.000 | |
| 57 | + ib_b=0.000 | |
| 58 | + ib_a=1.000 | |
| 59 | + nMotionVectorsX=64.000 | |
| 60 | + nMotionVectorsY=48.000 | |
| 61 | + mv_dx=0.000 | |
| 62 | + mv_dy=0.000 | |
| 63 | + mv_l=1.850 | |
| 64 | + mv_r=0.500 | |
| 65 | + mv_g=0.500 | |
| 66 | + mv_b=0.500 | |
| 67 | + mv_a=0.000 | |
| 68 | + b1n=0.000 | |
| 69 | + b2n=0.000 | |
| 70 | + b3n=0.000 | |
| 71 | + b1x=1.000 | |
| 72 | + b2x=1.000 | |
| 73 | + b3x=1.000 | |
| 74 | + b1ed=0.000 | |
| 75 | + wavecode_0_enabled=0 | |
| 76 | + wavecode_0_samples=512 | |
| 77 | + wavecode_0_sep=0 | |
| 78 | + wavecode_0_bSpectrum=0 | |
| 79 | + wavecode_0_bUseDots=1 | |
| 80 | + wavecode_0_bDrawThick=0 | |
| 81 | + wavecode_0_bAdditive=0 | |
| 82 | + wavecode_0_scaling=0.89152 | |
| 83 | + wavecode_0_smoothing=0.82000 | |
| 84 | + wavecode_0_r=1.000 | |
| 85 | + wavecode_0_g=1.000 | |
| 86 | + wavecode_0_b=1.000 | |
| 87 | + wavecode_0_a=0.600 | |
| 88 | + wave_0_init1=t1 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 89 | + wave_0_init2=t2 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 90 | + wave_0_init3=t3 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 91 | + wave_0_init4=t4 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 92 | + wave_0_init5=t5 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 93 | + wave_0_init6=t6 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 94 | + wave_0_init7=t7 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 95 | + wave_0_init8=t8 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 96 | + wave_0_init9= | |
| 97 | + wave_0_per_frame1=t1 = time - int (time); | |
| 98 | + wave_0_per_point1= | |
| 99 | + wave_0_per_point2=t_abs = sample*3; | |
| 100 | + wave_0_per_point3=t_rel = sample-time/5; | |
| 101 | + wave_0_per_point4= | |
| 102 | + wave_0_per_point5=ampl = 2*t_abs/2 ; | |
| 103 | + wave_0_per_point6= | |
| 104 | + wave_0_per_point7=k1=sin(time/13); | |
| 105 | + wave_0_per_point8=k2=sin(time/12); | |
| 106 | + wave_0_per_point9=ox = ampl*sin (t_abs*(31+5*k1)) + sin(time/25)*(1-t_abs)*0.4 ; | |
| 107 | + wave_0_per_point10=oy = ampl*cos (t_abs*(31+5*k2)); | |
| 108 | + wave_0_per_point11=oz = -1 ; | |
| 109 | + wave_0_per_point12= | |
| 110 | + wave_0_per_point13= | |
| 111 | + wave_0_per_point14=r = sqr(sin(t_rel*3.4)); | |
| 112 | + wave_0_per_point15=g = sqr(sin(t_rel)); | |
| 113 | + wave_0_per_point16=b = sqr (cos(t_rel*1.8)); | |
| 114 | + wave_0_per_point17= | |
| 115 | + wave_0_per_point18=a=0.1*(sin(t_abs*3)) | |
| 116 | + wave_0_per_point19= + 0.6*q3*below (abs(1-t_abs-t1 ),0.3); | |
| 117 | + wave_0_per_point20= | |
| 118 | + wave_0_per_point21=xang = time/9.5; | |
| 119 | + wave_0_per_point22=yang = 0*time/7; | |
| 120 | + wave_0_per_point23=zang = -time/22; | |
| 121 | + wave_0_per_point24=fov = 0.5; | |
| 122 | + wave_0_per_point25= | |
| 123 | + wave_0_per_point26= | |
| 124 | + wave_0_per_point27=// Rotation um x,y,z | |
| 125 | + wave_0_per_point28= | |
| 126 | + wave_0_per_point29=mx = ox*cos(zang) - oy*sin(zang); | |
| 127 | + wave_0_per_point30=my = ox*sin(zang) + oy*cos(zang); | |
| 128 | + wave_0_per_point31= | |
| 129 | + wave_0_per_point32=ox = mx; | |
| 130 | + wave_0_per_point33=oy = my; | |
| 131 | + wave_0_per_point34=mx = ox*cos(yang) + oz*sin(yang); | |
| 132 | + wave_0_per_point35=mz = - ox*sin(yang) + oz*cos(yang); | |
| 133 | + wave_0_per_point36=ox = mx; | |
| 134 | + wave_0_per_point37=oz = mz; | |
| 135 | + wave_0_per_point38=my = oy*cos(xang) - oz*sin(xang); | |
| 136 | + wave_0_per_point39=mz = oy*sin(xang) + oz*cos(xang); | |
| 137 | + wave_0_per_point40=oy = my; | |
| 138 | + wave_0_per_point41=oz = mz; | |
| 139 | + wave_0_per_point42= | |
| 140 | + wave_0_per_point43=oz = oz - 6; | |
| 141 | + wave_0_per_point44=x = ox*fov/oz +0.5; | |
| 142 | + wave_0_per_point45=//x = (x-.5)*0.75 + 0.5; | |
| 143 | + wave_0_per_point46=y = oy*fov/oz + 0.5; | |
| 144 | + wave_0_per_point47= | |
| 145 | + wavecode_1_enabled=0 | |
| 146 | + wavecode_1_samples=512 | |
| 147 | + wavecode_1_sep=0 | |
| 148 | + wavecode_1_bSpectrum=0 | |
| 149 | + wavecode_1_bUseDots=0 | |
| 150 | + wavecode_1_bDrawThick=1 | |
| 151 | + wavecode_1_bAdditive=0 | |
| 152 | + wavecode_1_scaling=0.89152 | |
| 153 | + wavecode_1_smoothing=0.82000 | |
| 154 | + wavecode_1_r=1.000 | |
| 155 | + wavecode_1_g=1.000 | |
| 156 | + wavecode_1_b=1.000 | |
| 157 | + wavecode_1_a=0.100 | |
| 158 | + wave_1_init1=t1 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 159 | + wave_1_init2=t2 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 160 | + wave_1_init3=t3 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 161 | + wave_1_init4=t4 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 162 | + wave_1_init5=t5 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 163 | + wave_1_init6=t6 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 164 | + wave_1_init7=t7 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 165 | + wave_1_init8=t8 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 166 | + wave_1_init9= | |
| 167 | + wave_1_per_frame1=tm = time*.1; | |
| 168 | + wave_1_per_frame2=t1 = t1*sin(tm*t4) + (1-t1)*sin(tm*t7); | |
| 169 | + wave_1_per_frame3=t2 = t2*sin(tm*t5) + (1-t2)*sin(tm*t8); | |
| 170 | + wave_1_per_frame4=t3 = t3*sin(tm*t6) + (1-t3)*sin(tm*1); | |
| 171 | + wave_1_per_frame5= | |
| 172 | + wave_1_per_frame6=tic = min(time - tin,1); | |
| 173 | + wave_1_per_frame7=tin = time; | |
| 174 | + wave_1_per_frame8= | |
| 175 | + wave_1_per_frame9=tva = (tic*q1*.5); | |
| 176 | + wave_1_per_frame10=tvb = (tic*q2*.5); | |
| 177 | + wave_1_per_frame11=tvc = (tic*q3*.5); | |
| 178 | + wave_1_per_frame12= | |
| 179 | + wave_1_per_frame13=q1 = tva; | |
| 180 | + wave_1_per_frame14=q2 = tvb; | |
| 181 | + wave_1_per_frame15=q3 = tvc; | |
| 182 | + wave_1_per_frame16= | |
| 183 | + wave_1_per_frame17=sz = .5; | |
| 184 | + wave_1_per_frame18=len = q4; | |
| 185 | + wave_1_per_frame19=t4 = len; | |
| 186 | + wave_1_per_point1=ang = 0; | |
| 187 | + wave_1_per_point2=len = t4; | |
| 188 | + wave_1_per_point3=mad = .6; | |
| 189 | + wave_1_per_point4= | |
| 190 | + wave_1_per_point5=it = if(above(sample,0),(it+equal(lev,7)),1); | |
| 191 | + wave_1_per_point6=ita = (ita + 1)*above(sample,0); | |
| 192 | + wave_1_per_point7= | |
| 193 | + wave_1_per_point8=mod = if(equal(it%2,0),1, if(equal((it+1)%4,0),2, if(equal((it+3)%8,0),3, if(equal((it+7)%16,0),4, if(equal((it+15)%32,0),5, if(equal((it+31)%64,0),6, if(equal((it+63)%128,0),7,7) )))))); | |
| 194 | + wave_1_per_point9= | |
| 195 | + wave_1_per_point10=sw = sw - 1; | |
| 196 | + wave_1_per_point11=sw = if(equal(lev,7),mod,sw)*above(sample,0); | |
| 197 | + wave_1_per_point12= | |
| 198 | + wave_1_per_point13=lev = if(above(sample,0),if(above(sw,0),lev-1,lev+1),7); | |
| 199 | + wave_1_per_point14=a = lev*.1*1.46; | |
| 200 | + wave_1_per_point15= | |
| 201 | + wave_1_per_point16=ar = if(above(sample,0),ar,1); | |
| 202 | + wave_1_per_point17=ar = if(equal(lev,0),ar*-1,ar); | |
| 203 | + wave_1_per_point18=br = if(above(sample,0),br,1); | |
| 204 | + wave_1_per_point19=br = if(equal(lev,1),br*-1,br); | |
| 205 | + wave_1_per_point20=cr = if(above(sample,0),cr,1); | |
| 206 | + wave_1_per_point21=cr = if(equal(lev,2),cr*-1,cr); | |
| 207 | + wave_1_per_point22=dr = if(above(sample,0),dr,1); | |
| 208 | + wave_1_per_point23=dr = if(equal(lev,3),dr*-1,dr); | |
| 209 | + wave_1_per_point24=er = if(above(sample,0),er,1); | |
| 210 | + wave_1_per_point25=er = if(equal(lev,4),er*-1,er); | |
| 211 | + wave_1_per_point26=fr = if(above(sample,0),fr,1); | |
| 212 | + wave_1_per_point27=fr = if(equal(lev,5),fr*-1,fr); | |
| 213 | + wave_1_per_point28=gr = if(above(sample,0),gr,1); | |
| 214 | + wave_1_per_point29=gr = if(equal(lev,6),gr*-1,gr); | |
| 215 | + wave_1_per_point30= | |
| 216 | + wave_1_per_point31=mlev = lev*above(sample,0); | |
| 217 | + wave_1_per_point32= | |
| 218 | + wave_1_per_point33=swi = equal(q4,0)*equal(sample,0); | |
| 219 | + wave_1_per_point34= | |
| 220 | + wave_1_per_point35=ha = if(swi,1-2*int(rand(2)),ha); | |
| 221 | + wave_1_per_point36=hb = if(swi,1-2*int(rand(2)),hb); | |
| 222 | + wave_1_per_point37=hc = if(swi,1-2*int(rand(2)),hc); | |
| 223 | + wave_1_per_point38=hd = if(swi,1-2*int(rand(2)),hd); | |
| 224 | + wave_1_per_point39=he = if(swi,1-2*int(rand(2)),he); | |
| 225 | + wave_1_per_point40=hf = if(swi,1-2*int(rand(2)),hf); | |
| 226 | + wave_1_per_point41=hg = if(swi,1-2*int(rand(2)),hg); | |
| 227 | + wave_1_per_point42= | |
| 228 | + wave_1_per_point43=aang = if(above(sample,0),aang,aang + (q1*.8 + q2*.1 + q3*.1)*ha*1); | |
| 229 | + wave_1_per_point44=bang = if(above(sample,0),bang,bang + (q1*.57 + q2*.33 + q3*.1)*hb*1.33); | |
| 230 | + wave_1_per_point45=cang = if(above(sample,0),cang,cang + (q1*.33 + q2*.57 + q3*.1)*hc*1.67); | |
| 231 | + wave_1_per_point46=dang = if(above(sample,0),dang,dang + (q1*.1 + q2*.8 + q3*.1)*hd*2); | |
| 232 | + wave_1_per_point47=eang = if(above(sample,0),eang,eang + (q1*.1 + q2*.57 + q3*.33)*he*2.33); | |
| 233 | + wave_1_per_point48=fang = if(above(sample,0),fang,fang + (q1*.1 + q2*.33 + q3*.57)*hf*2.67); | |
| 234 | + wave_1_per_point49=gang = if(above(sample,0),gang,gang + (q1*.1 + q2*.1 + q3*.8)*hg*3); | |
| 235 | + wave_1_per_point50= | |
| 236 | + wave_1_per_point51=aang = 1.57; | |
| 237 | + wave_1_per_point52=bang = 1.57; | |
| 238 | + wave_1_per_point53=cang = 1.57; | |
| 239 | + wave_1_per_point54=dang = 1.57; | |
| 240 | + wave_1_per_point55=eang = 1.57; | |
| 241 | + wave_1_per_point56=fang = 1.57; | |
| 242 | + wave_1_per_point57=gang = 1.57; | |
| 243 | + wave_1_per_point58= | |
| 244 | + wave_1_per_point59=oz = 0; | |
| 245 | + wave_1_per_point60= | |
| 246 | + wave_1_per_point61=len = len*mad; | |
| 247 | + wave_1_per_point62=ox = above(lev,0)*sin(aang)*len*ar; | |
| 248 | + wave_1_per_point63=oy = above(lev,0)*cos(aang)*len; | |
| 249 | + wave_1_per_point64= | |
| 250 | + wave_1_per_point65=an = (ar*aang + br*bang)*br; | |
| 251 | + wave_1_per_point66=len = len*mad; | |
| 252 | + wave_1_per_point67=oy = oy + above(lev,1)*sin(an)*len*br; | |
| 253 | + wave_1_per_point68=oz = oz + above(lev,1)*cos(an)*len; | |
| 254 | + wave_1_per_point69= | |
| 255 | + wave_1_per_point70=an = (ar*aang + br*bang + cr*cang)*cr; | |
| 256 | + wave_1_per_point71=len = len*mad; | |
| 257 | + wave_1_per_point72=ox = ox + above(lev,2)*sin(an)*len*cr; | |
| 258 | + wave_1_per_point73=oz = oz + above(lev,2)*cos(an)*len; | |
| 259 | + wave_1_per_point74= | |
| 260 | + wave_1_per_point75=an = (ar*aang + br*bang + cr*cang + dr*dang)*dr; | |
| 261 | + wave_1_per_point76=len = len*mad; | |
| 262 | + wave_1_per_point77=ox = ox + above(lev,3)*sin(an)*len*dr; | |
| 263 | + wave_1_per_point78=oy = oy + above(lev,3)*cos(an)*len; | |
| 264 | + wave_1_per_point79= | |
| 265 | + wave_1_per_point80=an = (ar*aang + br*bang + cr*cang + dr*dang + er*eang)*er; | |
| 266 | + wave_1_per_point81=len = len*mad; | |
| 267 | + wave_1_per_point82=ox = ox + above(lev,4)*sin(an)*len*er; | |
| 268 | + wave_1_per_point83=oz = oz + above(lev,4)*cos(an)*len; | |
| 269 | + wave_1_per_point84= | |
| 270 | + wave_1_per_point85=an = (ar*aang + br*bang + cr*cang + dr*dang + er*eang + fr*fang)*fr; | |
| 271 | + wave_1_per_point86=len = len*mad; | |
| 272 | + wave_1_per_point87=ox = ox + above(lev,5)*sin(an)*len*fr; | |
| 273 | + wave_1_per_point88=oz = oz + above(lev,5)*cos(an)*len; | |
| 274 | + wave_1_per_point89= | |
| 275 | + wave_1_per_point90=an = (ar*aang + br*bang + cr*cang + dr*dang + er*eang + fr*fang + gr*gang)*gr; | |
| 276 | + wave_1_per_point91=len = len*mad; | |
| 277 | + wave_1_per_point92=oy = oy + above(lev,6)*sin(an)*len*gr; | |
| 278 | + wave_1_per_point93=ox = ox + above(lev,6)*cos(an)*len; | |
| 279 | + wave_1_per_point94= | |
| 280 | + wave_1_per_point95= | |
| 281 | + wave_1_per_point96=xang = time*1.132; | |
| 282 | + wave_1_per_point97=xang = q5; | |
| 283 | + wave_1_per_point98=yang = time*1.153; | |
| 284 | + wave_1_per_point99=yang = q6; | |
| 285 | + wave_1_per_point100=zang = time*1.110; | |
| 286 | + wave_1_per_point101=zang = q7 + 1.57; | |
| 287 | + wave_1_per_point102=fov = .5; | |
| 288 | + wave_1_per_point103= | |
| 289 | + wave_1_per_point104=mx = ox*cos(zang) - oy*sin(zang); | |
| 290 | + wave_1_per_point105=my = ox*sin(zang) + oy*cos(zang); | |
| 291 | + wave_1_per_point106=ox = mx; | |
| 292 | + wave_1_per_point107=oy = my; | |
| 293 | + wave_1_per_point108=mx = ox*cos(yang) + oz*sin(yang); | |
| 294 | + wave_1_per_point109=mz = - ox*sin(yang) + oz*cos(yang); | |
| 295 | + wave_1_per_point110=ox = mx; | |
| 296 | + wave_1_per_point111=oz = mz; | |
| 297 | + wave_1_per_point112=my = oy*cos(xang) - oz*sin(xang); | |
| 298 | + wave_1_per_point113=mz = oy*sin(xang) + oz*cos(xang); | |
| 299 | + wave_1_per_point114=oy = my; | |
| 300 | + wave_1_per_point115=oz = mz; | |
| 301 | + wave_1_per_point116= | |
| 302 | + wave_1_per_point117=oz = oz - 2; | |
| 303 | + wave_1_per_point118=x = ox*fov/oz + 0.5; | |
| 304 | + wave_1_per_point119=x = (x-.5)*0.75 + 0.5; | |
| 305 | + wave_1_per_point120=y = oy*fov/oz + 0.5; | |
| 306 | + wave_1_per_point121= | |
| 307 | + wavecode_2_enabled=0 | |
| 308 | + wavecode_2_samples=512 | |
| 309 | + wavecode_2_sep=0 | |
| 310 | + wavecode_2_bSpectrum=0 | |
| 311 | + wavecode_2_bUseDots=0 | |
| 312 | + wavecode_2_bDrawThick=1 | |
| 313 | + wavecode_2_bAdditive=0 | |
| 314 | + wavecode_2_scaling=0.89152 | |
| 315 | + wavecode_2_smoothing=0.82000 | |
| 316 | + wavecode_2_r=1.000 | |
| 317 | + wavecode_2_g=1.000 | |
| 318 | + wavecode_2_b=1.000 | |
| 319 | + wavecode_2_a=0.100 | |
| 320 | + wave_2_init1=t1 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 321 | + wave_2_init2=t2 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 322 | + wave_2_init3=t3 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 323 | + wave_2_init4=t4 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 324 | + wave_2_init5=t5 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 325 | + wave_2_init6=t6 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 326 | + wave_2_init7=t7 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 327 | + wave_2_init8=t8 = 1 + (int(rand(101))*.01 - int(rand(101))*.01)*.3; | |
| 328 | + wave_2_init9= | |
| 329 | + wavecode_3_enabled=0 | |
| 330 | + wavecode_3_samples=512 | |
| 331 | + wavecode_3_sep=0 | |
| 332 | + wavecode_3_bSpectrum=1 | |
| 333 | + wavecode_3_bUseDots=1 | |
| 334 | + wavecode_3_bDrawThick=0 | |
| 335 | + wavecode_3_bAdditive=0 | |
| 336 | + wavecode_3_scaling=1.00000 | |
| 337 | + wavecode_3_smoothing=0.50000 | |
| 338 | + wavecode_3_r=1.000 | |
| 339 | + wavecode_3_g=1.000 | |
| 340 | + wavecode_3_b=1.000 | |
| 341 | + wavecode_3_a=1.000 | |
| 342 | + shapecode_0_enabled=1 | |
| 343 | + shapecode_0_sides=12 | |
| 344 | + shapecode_0_additive=0 | |
| 345 | + shapecode_0_thickOutline=0 | |
| 346 | + shapecode_0_textured=0 | |
| 347 | + shapecode_0_num_inst=272 | |
| 348 | + shapecode_0_x=0.800 | |
| 349 | + shapecode_0_y=0.500 | |
| 350 | + shapecode_0_rad=0.02705 | |
| 351 | + shapecode_0_ang=1.57080 | |
| 352 | + shapecode_0_tex_ang=1.25664 | |
| 353 | + shapecode_0_tex_zoom=3.07268 | |
| 354 | + shapecode_0_r=1.000 | |
| 355 | + shapecode_0_g=1.000 | |
| 356 | + shapecode_0_b=1.000 | |
| 357 | + shapecode_0_a=1.000 | |
| 358 | + shapecode_0_r2=0.000 | |
| 359 | + shapecode_0_g2=0.000 | |
| 360 | + shapecode_0_b2=0.000 | |
| 361 | + shapecode_0_a2=0.000 | |
| 362 | + shapecode_0_border_r=1.000 | |
| 363 | + shapecode_0_border_g=0.000 | |
| 364 | + shapecode_0_border_b=0.000 | |
| 365 | + shapecode_0_border_a=0.000 | |
| 366 | + shape_0_per_frame1=t1 = time - int (time); | |
| 367 | + shape_0_per_frame2=sample = instance/num_inst; | |
| 368 | + shape_0_per_frame3=t_abs = sample*3; | |
| 369 | + shape_0_per_frame4=t_rel = sample-time/5; | |
| 370 | + shape_0_per_frame5= | |
| 371 | + shape_0_per_frame6=ampl = 2*t_abs/2 ; | |
| 372 | + shape_0_per_frame7= | |
| 373 | + shape_0_per_frame8=k1=sin(time/13); | |
| 374 | + shape_0_per_frame9=k2=sin(time/12); | |
| 375 | + shape_0_per_frame10=ox = ampl*sin (t_abs*(31+5*k1)) + sin(time/25)*(1-t_abs)*0.4 ; | |
| 376 | + shape_0_per_frame11=oy = ampl*cos (t_abs*(31+5*k2)); | |
| 377 | + shape_0_per_frame12=oz = -1 ; | |
| 378 | + shape_0_per_frame13= | |
| 379 | + shape_0_per_frame14= | |
| 380 | + shape_0_per_frame15=r = sqr(sin(t_rel*3.4+instance)); | |
| 381 | + shape_0_per_frame16=g = sqr(sin(t_rel+instance)); | |
| 382 | + shape_0_per_frame17=b = sqr (cos(t_rel*1.8+instance)); | |
| 383 | + shape_0_per_frame18=r2=.5-r; | |
| 384 | + shape_0_per_frame19=g2=.5-g; | |
| 385 | + shape_0_per_frame20=b2=.5-b; | |
| 386 | + shape_0_per_frame21= | |
| 387 | + shape_0_per_frame22= | |
| 388 | + shape_0_per_frame23=//a=(0.1*(sin(t_abs*3)) + 0.6*q3*below (abs(1-t_abs-t1 ),0.3))*a; | |
| 389 | + shape_0_per_frame24= | |
| 390 | + shape_0_per_frame25=xang = time/9.5; | |
| 391 | + shape_0_per_frame26=yang = 1*time/7; | |
| 392 | + shape_0_per_frame27=zang = -time/22; | |
| 393 | + shape_0_per_frame28=fov = 0.5; | |
| 394 | + shape_0_per_frame29= | |
| 395 | + shape_0_per_frame30= | |
| 396 | + shape_0_per_frame31=// Rotation um x,y,z | |
| 397 | + shape_0_per_frame32= | |
| 398 | + shape_0_per_frame33=mx = ox*cos(zang) - oy*sin(zang); | |
| 399 | + shape_0_per_frame34=my = ox*sin(zang) + oy*cos(zang); | |
| 400 | + shape_0_per_frame35= | |
| 401 | + shape_0_per_frame36=ox = mx; | |
| 402 | + shape_0_per_frame37=oy = my; | |
| 403 | + shape_0_per_frame38=mx = ox*cos(yang) + oz*sin(yang); | |
| 404 | + shape_0_per_frame39=mz = - ox*sin(yang) + oz*cos(yang); | |
| 405 | + shape_0_per_frame40=ox = mx; | |
| 406 | + shape_0_per_frame41=oz = mz; | |
| 407 | + shape_0_per_frame42=my = oy*cos(xang) - oz*sin(xang); | |
| 408 | + shape_0_per_frame43=mz = oy*sin(xang) + oz*cos(xang); | |
| 409 | + shape_0_per_frame44=oy = my; | |
| 410 | + shape_0_per_frame45=oz = mz; | |
| 411 | + shape_0_per_frame46= | |
| 412 | + shape_0_per_frame47=oz = oz - 6; | |
| 413 | + shape_0_per_frame48=x = ox*fov/oz +0.5; | |
| 414 | + shape_0_per_frame49=//x = (x-.5)*0.75 + 0.5; | |
| 415 | + shape_0_per_frame50=y = oy*fov/oz + 0.5; | |
| 416 | + shape_0_per_frame51= | |
| 417 | + shape_0_per_frame52=rad=1/oz*instance*.004; | |
| 418 | + shapecode_1_enabled=0 | |
| 419 | + shapecode_1_sides=63 | |
| 420 | + shapecode_1_additive=0 | |
| 421 | + shapecode_1_thickOutline=0 | |
| 422 | + shapecode_1_textured=1 | |
| 423 | + shapecode_1_num_inst=1 | |
| 424 | + shapecode_1_x=0.500 | |
| 425 | + shapecode_1_y=0.500 | |
| 426 | + shapecode_1_rad=1.99863 | |
| 427 | + shapecode_1_ang=0.00000 | |
| 428 | + shapecode_1_tex_ang=0.00000 | |
| 429 | + shapecode_1_tex_zoom=0.49981 | |
| 430 | + shapecode_1_r=1.000 | |
| 431 | + shapecode_1_g=1.000 | |
| 432 | + shapecode_1_b=1.000 | |
| 433 | + shapecode_1_a=0.100 | |
| 434 | + shapecode_1_r2=1.000 | |
| 435 | + shapecode_1_g2=1.000 | |
| 436 | + shapecode_1_b2=1.000 | |
| 437 | + shapecode_1_a2=0.600 | |
| 438 | + shapecode_1_border_r=0.500 | |
| 439 | + shapecode_1_border_g=0.500 | |
| 440 | + shapecode_1_border_b=0.500 | |
| 441 | + shapecode_1_border_a=0.000 | |
| 442 | + shapecode_2_enabled=0 | |
| 443 | + shapecode_2_sides=63 | |
| 444 | + shapecode_2_additive=0 | |
| 445 | + shapecode_2_thickOutline=0 | |
| 446 | + shapecode_2_textured=1 | |
| 447 | + shapecode_2_num_inst=1 | |
| 448 | + shapecode_2_x=0.123 | |
| 449 | + shapecode_2_y=0.000 | |
| 450 | + shapecode_2_rad=0.27319 | |
| 451 | + shapecode_2_ang=0.00000 | |
| 452 | + shapecode_2_tex_ang=0.00000 | |
| 453 | + shapecode_2_tex_zoom=0.49981 | |
| 454 | + shapecode_2_r=1.000 | |
| 455 | + shapecode_2_g=1.000 | |
| 456 | + shapecode_2_b=1.000 | |
| 457 | + shapecode_2_a=1.000 | |
| 458 | + shapecode_2_r2=1.000 | |
| 459 | + shapecode_2_g2=1.000 | |
| 460 | + shapecode_2_b2=1.000 | |
| 461 | + shapecode_2_a2=0.000 | |
| 462 | + shapecode_2_border_r=0.500 | |
| 463 | + shapecode_2_border_g=0.500 | |
| 464 | + shapecode_2_border_b=0.500 | |
| 465 | + shapecode_2_border_a=0.000 | |
| 466 | + shapecode_3_enabled=0 | |
| 467 | + shapecode_3_sides=63 | |
| 468 | + shapecode_3_additive=0 | |
| 469 | + shapecode_3_thickOutline=0 | |
| 470 | + shapecode_3_textured=1 | |
| 471 | + shapecode_3_num_inst=1 | |
| 472 | + shapecode_3_x=0.500 | |
| 473 | + shapecode_3_y=1.000 | |
| 474 | + shapecode_3_rad=0.54822 | |
| 475 | + shapecode_3_ang=0.00000 | |
| 476 | + shapecode_3_tex_ang=0.00000 | |
| 477 | + shapecode_3_tex_zoom=0.49981 | |
| 478 | + shapecode_3_r=1.000 | |
| 479 | + shapecode_3_g=1.000 | |
| 480 | + shapecode_3_b=1.000 | |
| 481 | + shapecode_3_a=1.000 | |
| 482 | + shapecode_3_r2=1.000 | |
| 483 | + shapecode_3_g2=1.000 | |
| 484 | + shapecode_3_b2=1.000 | |
| 485 | + shapecode_3_a2=0.000 | |
| 486 | + shapecode_3_border_r=0.500 | |
| 487 | + shapecode_3_border_g=0.500 | |
| 488 | + shapecode_3_border_b=0.500 | |
| 489 | + shapecode_3_border_a=0.000 | |
| 490 | + per_frame_1=mv_r = mv_r + 0.2*( 0.60*sin(0.980*time) + 0.40*sin(1.047*time) ); | |
| 491 | + per_frame_2=mv_g = mv_g + 0.2*( 0.60*sin(0.835*time) + 0.40*sin(1.081*time) ); | |
| 492 | + per_frame_3=mv_b = mv_b + 0.2*( 0.60*sin(0.814*time) + 0.40*sin(1.011*time) ); | |
| 493 | + per_frame_4=q1 = (cx*2-1) + 0.6*( 0.60*sin(0.374*time) + 0.40*sin(0.294*time) ); | |
| 494 | + per_frame_5=q2 = (cy*2-1) + 0.6*( 0.60*sin(0.393*time) + 0.40*sin(0.223*time) ); | |
| 495 | + per_frame_6=ob_r = 1- 0.4*abs(q1); | |
| 496 | + per_frame_7=ob_g = 0.3*abs(q2); | |
| 497 | + per_frame_8=ob_b = 0.4*abs(q1); | |
| 498 | + per_frame_9=wave_x = 1-abs(q2)-0.05; | |
| 499 | + per_frame_10=wave_y = 1-abs(q1)-0.06; | |
| 500 | + per_frame_11=wave_r = wave_r + 0.4*( 0.60*sin(0.514*time) + 0.40*sin(1.211*time) ); | |
| 501 | + per_frame_12=wave_b = wave_b + 0.4*( 0.60*sin(0.714*time) + 0.40*sin(q2) ); | |
| 502 | + per_frame_13=wave_g = wave_g + 0.4*( 0.60*sin(10*q1) + 0.40*sin(10*q2) ); | |
| 503 | + per_frame_14=zoom = 1.001; | |
| 504 | + per_pixel_1=du = (x*2-1) - q1; | |
| 505 | + per_pixel_2=dv = (y*2-1) - q2; | |
| 506 | + per_pixel_3=dist = sqrt(du*du+dv*dv); | |
| 507 | + per_pixel_4=ang2 = atan2(du,dv) + time*0.15; | |
| 508 | + per_pixel_5=mult = 0.15*sin(dist*0.05); | |
| 509 | + per_pixel_6=dx = mult*sin(ang2*2-1.5)*aspectx; | |
| 510 | + per_pixel_7=dy = mult*cos(ang2*2-1.5)*aspecty; | |
| 511 | + warp_1=`shader_body | |
| 512 | + warp_2=`{ | |
| 513 | + warp_3=` // sample previous frame | |
| 514 | + warp_4=` ret = tex2D( sampler_main, uv ).xyz; | |
| 515 | + warp_5=` float3 ret2 = tex2D( sampler_fc_main, uv ).xyz; | |
| 516 | + warp_6=` | |
| 517 | + warp_7=` ret.x = tex2D( sampler_main, (uv-0.5)*1.00+0.5 ).x; | |
| 518 | + warp_8=` ret.y = tex2D( sampler_main, (uv-0.5)*0.98+0.5 ).y; | |
| 519 | + warp_9=` ret.z = tex2D( sampler_main, (uv-0.5)*0.96+0.5 ).z; | |
| 520 | + warp_10=` | |
| 521 | + warp_11=`float4 noise2 = tex3D(sampler_noisevol_hq, | |
| 522 | + warp_12=` ((uv.xyy*.5 | |
| 523 | + warp_13=` )*texsize.xyy*texsize_noisevol_hq.zww | |
| 524 | + warp_14=` ).xyz* | |
| 525 | + warp_15=` float3(1,1,0)*0.05 + | |
| 526 | + warp_16=` time*float3(0,0,1)*0.1 | |
| 527 | + warp_17=` ); | |
| 528 | + warp_18=`//if(ret.x+ret.y+ret.z>.5)ret -= (noise2)*.1; | |
| 529 | + warp_19=` // darken (decay) over time | |
| 530 | + warp_20=` ret = ret- (ret*.5); | |
| 531 | + warp_21=` ret = ret*(abs(GetBlur2(uv)-.5))*5; | |
| 532 | + warp_22=` ret = ret - .01; | |
| 533 | + warp_23=`if(ret.x+ret.y+ret.z>.5)ret -= (1.5-noise2)*.2; | |
| 534 | + warp_24=`} | |
| 535 | + comp_1=`shader_body | |
| 536 | + comp_2=`{ | |
| 537 | + comp_3=` | |
| 538 | + comp_4=` | |
| 539 | + comp_5=` | |
| 540 | + comp_6=`float2 uva = uv; | |
| 541 | + comp_7=`float2 uvb = float2(1-uv.x,uv.y); | |
| 542 | + comp_8=` | |
| 543 | + comp_9=`ret = tex2D(sampler_main, uva).x + tex2D(sampler_main, uvb).x; | |
| 544 | + comp_10=` | |
| 545 | + comp_11=`float3 blurs = GetBlur1(uva).x + GetBlur3(uva).x; | |
| 546 | + comp_12=`blurs += GetBlur1(uvb).x + GetBlur3(uvb).x; | |
| 547 | + comp_13=` | |
| 548 | + comp_14=` | |
| 549 | + comp_15=`float2 uv3 = (uv-.5)*(1-GetBlur1(uv).zzz)+.5; | |
| 550 | + comp_16=`ret += saturate(pow(tex2D(sampler_main, uv3).zzz,.5)*(1-ret.x*2)), | |
| 551 | + comp_17=`ret += saturate(pow(GetBlur1(uv3).zzz,.5)*(1-ret.x*2)), | |
| 552 | + comp_18=`ret = lerp (blurs,ret,pow(ret,1)); | |
| 553 | + comp_19=`float4 noise2 = tex3D(sampler_noisevol_hq, | |
| 554 | + comp_20=` ((uv.xyy*.8 | |
| 555 | + comp_21=` )*texsize.xyy*texsize_noisevol_hq.zww | |
| 556 | + comp_22=` ).xyz* | |
| 557 | + comp_23=` float3(1,1,0)*0.05 + | |
| 558 | + comp_24=` time*float3(0,0,1)*.1 | |
| 559 | + comp_25=` ); | |
| 560 | + comp_26=`if(ret.x+ret.y+ret.z<1.5)ret += (noise2)*.3; | |
| 561 | + comp_27=`//ret = pow(ret,.5+4*roam_cos); | |
| 562 | + comp_28=` ret = pow(ret,2*(2-noise2)); | |
| 563 | + comp_29=`ret += pow(tex2D(sampler_main, float2(uv.x,1-uv.y)).yyy+tex2D(sampler_main, 1-uv).yyy,float3(.6,.95,5)); | |
| 564 | + comp_30=` | |
| 565 | + comp_31=`ret = 1-exp(-2*ret); | |
| 566 | + comp_32=`if(ret.x+ret.y+ret.z>1)ret += (1-noise2)*.5; | |
| 567 | + comp_33=`} |
Sources/PulseCanvas/Resources/ProjectM/Presets/Dancer/Blobby/some say the end is near.milk added
| 1 | + MILKDROP_PRESET_VERSION=201 | |
| 2 | + PSVERSION=2 | |
| 3 | + PSVERSION_WARP=2 | |
| 4 | + PSVERSION_COMP=2 | |
| 5 | + [preset00] | |
| 6 | + fRating=5.000000 | |
| 7 | + fGammaAdj=1.000 | |
| 8 | + fDecay=0.950 | |
| 9 | + fVideoEchoZoom=0.498 | |
| 10 | + fVideoEchoAlpha=0.000 | |
| 11 | + nVideoEchoOrientation=2 | |
| 12 | + nWaveMode=2 | |
| 13 | + bAdditiveWaves=0 | |
| 14 | + bWaveDots=1 | |
| 15 | + bWaveThick=0 | |
| 16 | + bModWaveAlphaByVolume=0 | |
| 17 | + bMaximizeWaveColor=0 | |
| 18 | + bTexWrap=1 | |
| 19 | + bDarkenCenter=0 | |
| 20 | + bRedBlueStereo=0 | |
| 21 | + bBrighten=0 | |
| 22 | + bDarken=0 | |
| 23 | + bSolarize=0 | |
| 24 | + bInvert=0 | |
| 25 | + fWaveAlpha=0.001 | |
| 26 | + fWaveScale=0.012 | |
| 27 | + fWaveSmoothing=0.900 | |
| 28 | + fWaveParam=0.000 | |
| 29 | + fModWaveAlphaStart=0.750 | |
| 30 | + fModWaveAlphaEnd=0.950 | |
| 31 | + fWarpAnimSpeed=1.000 | |
| 32 | + fWarpScale=1.331 | |
| 33 | + fZoomExponent=1.00000 | |
| 34 | + fShader=0.000 | |
| 35 | + zoom=13.29089 | |
| 36 | + rot=0.00000 | |
| 37 | + cx=0.500 | |
| 38 | + cy=0.500 | |
| 39 | + dx=-0.28000 | |
| 40 | + dy=-0.32000 | |
| 41 | + warp=0.01000 | |
| 42 | + sx=1.00000 | |
| 43 | + sy=1.00000 | |
| 44 | + wave_r=0.500 | |
| 45 | + wave_g=0.400 | |
| 46 | + wave_b=0.300 | |
| 47 | + wave_x=0.500 | |
| 48 | + wave_y=0.500 | |
| 49 | + ob_size=0.040 | |
| 50 | + ob_r=0.000 | |
| 51 | + ob_g=0.000 | |
| 52 | + ob_b=0.000 | |
| 53 | + ob_a=1.000 | |
| 54 | + ib_size=0.500 | |
| 55 | + ib_r=1.000 | |
| 56 | + ib_g=0.000 | |
| 57 | + ib_b=1.000 | |
| 58 | + ib_a=0.000 | |
| 59 | + nMotionVectorsX=64.000 | |
| 60 | + nMotionVectorsY=48.000 | |
| 61 | + mv_dx=0.000 | |
| 62 | + mv_dy=0.000 | |
| 63 | + mv_l=5.000 | |
| 64 | + mv_r=0.000 | |
| 65 | + mv_g=0.000 | |
| 66 | + mv_b=0.000 | |
| 67 | + mv_a=0.000 | |
| 68 | + b1n=0.000 | |
| 69 | + b2n=0.000 | |
| 70 | + b3n=0.000 | |
| 71 | + b1x=1.000 | |
| 72 | + b2x=1.000 | |
| 73 | + b3x=1.000 | |
| 74 | + b1ed=0.250 | |
| 75 | + wavecode_0_enabled=1 | |
| 76 | + wavecode_0_samples=512 | |
| 77 | + wavecode_0_sep=0 | |
| 78 | + wavecode_0_bSpectrum=0 | |
| 79 | + wavecode_0_bUseDots=0 | |
| 80 | + wavecode_0_bDrawThick=1 | |
| 81 | + wavecode_0_bAdditive=1 | |
| 82 | + wavecode_0_scaling=1.00000 | |
| 83 | + wavecode_0_smoothing=0.50000 | |
| 84 | + wavecode_0_r=0.450 | |
| 85 | + wavecode_0_g=0.650 | |
| 86 | + wavecode_0_b=1.000 | |
| 87 | + wavecode_0_a=1.000 | |
| 88 | + wave_0_per_frame1=advance=advance+0.006*q6; | |
| 89 | + wave_0_per_frame2=advance=if(above(advance,1), advance-1, advance); | |
| 90 | + wave_0_per_frame3=t1=advance; | |
| 91 | + wave_0_per_point1=n=sample*6.283; | |
| 92 | + wave_0_per_point2=step=sample*128; | |
| 93 | + wave_0_per_point3=step2=(int(step)/128)*6.283; | |
| 94 | + wave_0_per_point4=step3=(step - int(step)); | |
| 95 | + wave_0_per_point5=tm = t1 * 6.283 - 3.1415; | |
| 96 | + wave_0_per_point6= | |
| 97 | + wave_0_per_point7=//star lines | |
| 98 | + wave_0_per_point8=xp=sin(step2) * 0.4; | |
| 99 | + wave_0_per_point9=yp=cos(step2) * 0.4; | |
| 100 | + wave_0_per_point10=zp=sin(step2*19.3)*3.1415 + step3*0.35 - tm; | |
| 101 | + wave_0_per_point11=zp=if(below(zp,-3.1415), zp+6.283 , zp); | |
| 102 | + wave_0_per_point12= | |
| 103 | + wave_0_per_point13= | |
| 104 | + wave_0_per_point14=//kill stray lines from front to back | |
| 105 | + wave_0_per_point15=a=if(below(step3,0.36) , 0 , 1); | |
| 106 | + wave_0_per_point16=a=if(above(step3,0.64) , 0 , a); | |
| 107 | + wave_0_per_point17=a=if(below(zp,-3) , 0 , a); | |
| 108 | + wave_0_per_point18=a=if(above(zp,3) , 0 , a); | |
| 109 | + wave_0_per_point19= | |
| 110 | + wave_0_per_point20=//a=a*(zp/6.08); | |
| 111 | + wave_0_per_point21=a=a*(1-step3); | |
| 112 | + wave_0_per_point22=a=min( max(a,0) , 1); | |
| 113 | + wave_0_per_point23= | |
| 114 | + wave_0_per_point24= | |
| 115 | + wave_0_per_point25=zp=zp*2 - 3.1415; | |
| 116 | + wave_0_per_point26= | |
| 117 | + wave_0_per_point27=//zp=if(below(zp,-3.1415), zp+6.283 , zp); | |
| 118 | + wave_0_per_point28= | |
| 119 | + wave_0_per_point29=a=a * (1-(zp+2.1415)/6.283); | |
| 120 | + wave_0_per_point30= | |
| 121 | + wave_0_per_point31=a=if(below(zp,-1.5) , 0 , a); | |
| 122 | + wave_0_per_point32=a=if(above(zp,4.0) , 0 , a); | |
| 123 | + wave_0_per_point33= | |
| 124 | + wave_0_per_point34=//shift back when pointing away from camera | |
| 125 | + wave_0_per_point35=zp=zp-q4*2; | |
| 126 | + wave_0_per_point36= | |
| 127 | + wave_0_per_point37=//z rotation | |
| 128 | + wave_0_per_point38=sang=sin(q1);cang=cos(q1); | |
| 129 | + wave_0_per_point39=xn=xp*sang + yp*cang; | |
| 130 | + wave_0_per_point40=yn=xp*cang - yp*sang; | |
| 131 | + wave_0_per_point41=zn=zp; | |
| 132 | + wave_0_per_point42=xp=xn;yp=yn;zp=zn; | |
| 133 | + wave_0_per_point43= | |
| 134 | + wave_0_per_point44=//y rotation; | |
| 135 | + wave_0_per_point45=sang=sin(q2);cang=cos(q2); | |
| 136 | + wave_0_per_point46=xn=xp*sang + zp*(cang); | |
| 137 | + wave_0_per_point47=yn=yp; | |
| 138 | + wave_0_per_point48=zn=xp*cang - zp*sang; | |
| 139 | + wave_0_per_point49=xp=xn;yp=yn;zp=zn; | |
| 140 | + wave_0_per_point50= | |
| 141 | + wave_0_per_point51=//x rotation; | |
| 142 | + wave_0_per_point52=sang=sin(q3);cang=cos(q3); | |
| 143 | + wave_0_per_point53=xn=xp; | |
| 144 | + wave_0_per_point54=yn=yp*sang + zp*cang; | |
| 145 | + wave_0_per_point55=zn=yp*cang - zp*sang; | |
| 146 | + wave_0_per_point56=xp=xn;yp=yn;zp=zn; | |
| 147 | + wave_0_per_point57= | |
| 148 | + wave_0_per_point58= | |
| 149 | + wave_0_per_point59= | |
| 150 | + wave_0_per_point60=zp=zp*2+1.55; | |
| 151 | + wave_0_per_point61= | |
| 152 | + wave_0_per_point62=//near clipping plane | |
| 153 | + wave_0_per_point63=a=a*above(zp,0.75); | |
| 154 | + wave_0_per_point64=//a=a*below(zp,8.55); | |
| 155 | + wave_0_per_point65= | |
| 156 | + wave_0_per_point66=x=xp/zp+ 0.5; | |
| 157 | + wave_0_per_point67=y=yp/zp * 1.3 + 0.5; | |
| 158 | + wave_0_per_point68= | |
| 159 | + wave_0_per_point69=a=a*0.5 | |
| 160 | + wavecode_1_enabled=1 | |
| 161 | + wavecode_1_samples=512 | |
| 162 | + wavecode_1_sep=0 | |
| 163 | + wavecode_1_bSpectrum=0 | |
| 164 | + wavecode_1_bUseDots=0 | |
| 165 | + wavecode_1_bDrawThick=1 | |
| 166 | + wavecode_1_bAdditive=1 | |
| 167 | + wavecode_1_scaling=1.00000 | |
| 168 | + wavecode_1_smoothing=0.50000 | |
| 169 | + wavecode_1_r=0.450 | |
| 170 | + wavecode_1_g=0.650 | |
| 171 | + wavecode_1_b=1.000 | |
| 172 | + wavecode_1_a=1.000 | |
| 173 | + wave_1_per_frame1=advance=advance+0.005*q6; | |
| 174 | + wave_1_per_frame2=advance=advance * below(advance,1); | |
| 175 | + wave_1_per_frame3=t1=advance; | |
| 176 | + wave_1_per_point1=n=sample*6.283; | |
| 177 | + wave_1_per_point2=step=sample*128; | |
| 178 | + wave_1_per_point3=step2=(int(step)/128)*6.283; | |
| 179 | + wave_1_per_point4=step3=(step - int(step)); | |
| 180 | + wave_1_per_point5=tm = t1 * 6.283 - 3.1415; | |
| 181 | + wave_1_per_point6= | |
| 182 | + wave_1_per_point7=//star lines | |
| 183 | + wave_1_per_point8=xp=sin(step2) * 0.4; | |
| 184 | + wave_1_per_point9=yp=cos(step2) * 0.4; | |
| 185 | + wave_1_per_point10=zp=sin(step2*19.3)*3.1415 + step3*0.35 - tm; | |
| 186 | + wave_1_per_point11=zp=if(below(zp,-3.1415), zp+6.283 , zp); | |
| 187 | + wave_1_per_point12= | |
| 188 | + wave_1_per_point13= | |
| 189 | + wave_1_per_point14=//kill stray lines from front to back | |
| 190 | + wave_1_per_point15=a=if(below(step3,0.36) , 0 , 1); | |
| 191 | + wave_1_per_point16=a=if(above(step3,0.64) , 0 , a); | |
| 192 | + wave_1_per_point17=a=if(below(zp,-3) , 0 , a); | |
| 193 | + wave_1_per_point18=a=if(above(zp,3) , 0 , a); | |
| 194 | + wave_1_per_point19= | |
| 195 | + wave_1_per_point20=//a=a*(zp/6.08); | |
| 196 | + wave_1_per_point21=a=a*(1-step3); | |
| 197 | + wave_1_per_point22=a=min( max(a,0) , 1); | |
| 198 | + wave_1_per_point23= | |
| 199 | + wave_1_per_point24= | |
| 200 | + wave_1_per_point25=zp=zp*2 - 3.1415; | |
| 201 | + wave_1_per_point26= | |
| 202 | + wave_1_per_point27=//zp=if(below(zp,-3.1415), zp+6.283 , zp); | |
| 203 | + wave_1_per_point28= | |
| 204 | + wave_1_per_point29=a=a * (1-(zp+2.1415)/6.283); | |
| 205 | + wave_1_per_point30= | |
| 206 | + wave_1_per_point31=a=if(below(zp,-1.5) , 0 , a); | |
| 207 | + wave_1_per_point32=a=if(above(zp,4.0) , 0 , a); | |
| 208 | + wave_1_per_point33= | |
| 209 | + wave_1_per_point34=//shift back when pointing away from camera | |
| 210 | + wave_1_per_point35=zp=zp-q4*2; | |
| 211 | + wave_1_per_point36= | |
| 212 | + wave_1_per_point37=//z rotation | |
| 213 | + wave_1_per_point38=sang=sin(q1);cang=cos(q1); | |
| 214 | + wave_1_per_point39=xn=xp*sang + yp*cang; | |
| 215 | + wave_1_per_point40=yn=xp*cang - yp*sang; | |
| 216 | + wave_1_per_point41=zn=zp; | |
| 217 | + wave_1_per_point42=xp=xn;yp=yn;zp=zn; | |
| 218 | + wave_1_per_point43= | |
| 219 | + wave_1_per_point44=//y rotation; | |
| 220 | + wave_1_per_point45=sang=sin(q2);cang=cos(q2); | |
| 221 | + wave_1_per_point46=xn=xp*sang + zp*(cang); | |
| 222 | + wave_1_per_point47=yn=yp; | |
| 223 | + wave_1_per_point48=zn=xp*cang - zp*sang; | |
| 224 | + wave_1_per_point49=xp=xn;yp=yn;zp=zn; | |
| 225 | + wave_1_per_point50= | |
| 226 | + wave_1_per_point51=//x rotation; | |
| 227 | + wave_1_per_point52=sang=sin(q3);cang=cos(q3); | |
| 228 | + wave_1_per_point53=xn=xp; | |
| 229 | + wave_1_per_point54=yn=yp*sang + zp*cang; | |
| 230 | + wave_1_per_point55=zn=yp*cang - zp*sang; | |
| 231 | + wave_1_per_point56=xp=xn;yp=yn;zp=zn; | |
| 232 | + wave_1_per_point57= | |
| 233 | + wave_1_per_point58= | |
| 234 | + wave_1_per_point59= | |
| 235 | + wave_1_per_point60=zp=zp*2+1.55; | |
| 236 | + wave_1_per_point61= | |
| 237 | + wave_1_per_point62=//near clipping plane | |
| 238 | + wave_1_per_point63=a=a*above(zp,0.75); | |
| 239 | + wave_1_per_point64=//a=a*below(zp,8.55); | |
| 240 | + wave_1_per_point65= | |
| 241 | + wave_1_per_point66=x=-xp/zp+ 0.5; | |
| 242 | + wave_1_per_point67=y=yp/zp * 1.3 + 0.5; | |
| 243 | + wave_1_per_point68=a=a*0.5 | |
| 244 | + wavecode_2_enabled=0 | |
| 245 | + wavecode_2_samples=512 | |
| 246 | + wavecode_2_sep=0 | |
| 247 | + wavecode_2_bSpectrum=0 | |
| 248 | + wavecode_2_bUseDots=0 | |
| 249 | + wavecode_2_bDrawThick=1 | |
| 250 | + wavecode_2_bAdditive=1 | |
| 251 | + wavecode_2_scaling=1.00000 | |
| 252 | + wavecode_2_smoothing=0.50000 | |
| 253 | + wavecode_2_r=0.300 | |
| 254 | + wavecode_2_g=0.600 | |
| 255 | + wavecode_2_b=1.000 | |
| 256 | + wavecode_2_a=1.000 | |
| 257 | + wave_2_per_frame1=advance=advance+0.005*q6; | |
| 258 | + wave_2_per_frame2=advance=advance * below(advance,1); | |
| 259 | + wave_2_per_frame3=t1=advance; | |
| 260 | + wave_2_per_point1=n=sample*6.283; | |
| 261 | + wave_2_per_point2=step=sample*128; | |
| 262 | + wave_2_per_point3=step2=(int(step)/128)*6.283; | |
| 263 | + wave_2_per_point4=step3=(step - int(step)); | |
| 264 | + wave_2_per_point5=tm = t1 * 6.283 - 3.1415; | |
| 265 | + wave_2_per_point6= | |
| 266 | + wave_2_per_point7=//star lines | |
| 267 | + wave_2_per_point8=xp=sin(step2) * 1.1; | |
| 268 | + wave_2_per_point9=yp=cos(step2) * 1.1; | |
| 269 | + wave_2_per_point10=zp=sin(step2*15.3)*3.1415 + step3*0.35 - tm; | |
| 270 | + wave_2_per_point11=zp=if(below(zp,-3.1415), zp+6.283 , zp); | |
| 271 | + wave_2_per_point12= | |
| 272 | + wave_2_per_point13= | |
| 273 | + wave_2_per_point14=//kill stray lines from front to back | |
| 274 | + wave_2_per_point15=a=if(below(step3,0.36) , 0 , 1); | |
| 275 | + wave_2_per_point16=a=if(above(step3,0.64) , 0 , a); | |
| 276 | + wave_2_per_point17=a=if(below(zp,-3) , 0 , a); | |
| 277 | + wave_2_per_point18=a=if(above(zp,3) , 0 , a); | |
| 278 | + wave_2_per_point19= | |
| 279 | + wave_2_per_point20=//a=a*(zp/6.08); | |
| 280 | + wave_2_per_point21=a=a*(1-step3); | |
| 281 | + wave_2_per_point22=a=min( max(a,0) , 1); | |
| 282 | + wave_2_per_point23= | |
| 283 | + wave_2_per_point24= | |
| 284 | + wave_2_per_point25=zp=zp*2 - 3.1415; | |
| 285 | + wave_2_per_point26= | |
| 286 | + wave_2_per_point27=//zp=if(below(zp,-3.1415), zp+6.283 , zp); | |
| 287 | + wave_2_per_point28= | |
| 288 | + wave_2_per_point29=a=a * (1-(zp+2.1415)/6.283); | |
| 289 | + wave_2_per_point30= | |
| 290 | + wave_2_per_point31=a=if(below(zp,-1.5) , 0 , a); | |
| 291 | + wave_2_per_point32=a=if(above(zp,4.0) , 0 , a); | |
| 292 | + wave_2_per_point33= | |
| 293 | + wave_2_per_point34=//shift back when pointing away from camera | |
| 294 | + wave_2_per_point35=zp=zp-q4*2; | |
| 295 | + wave_2_per_point36= | |
| 296 | + wave_2_per_point37= | |
| 297 | + wave_2_per_point38=//z rotation | |
| 298 | + wave_2_per_point39=sang=sin(q1);cang=cos(q1); | |
| 299 | + wave_2_per_point40=xn=xp*sang + yp*cang; | |
| 300 | + wave_2_per_point41=yn=xp*cang - yp*sang; | |
| 301 | + wave_2_per_point42=zn=zp; | |
| 302 | + wave_2_per_point43=xp=xn;yp=yn;zp=zn; | |
| 303 | + wave_2_per_point44= | |
| 304 | + wave_2_per_point45=//y rotation; | |
| 305 | + wave_2_per_point46=sang=sin(q2);cang=cos(q2); | |
| 306 | + wave_2_per_point47=xn=xp*sang + zp*(cang); | |
| 307 | + wave_2_per_point48=yn=yp; | |
| 308 | + wave_2_per_point49=zn=xp*cang - zp*sang; | |
| 309 | + wave_2_per_point50=xp=xn;yp=yn;zp=zn; | |
| 310 | + wave_2_per_point51= | |
| 311 | + wave_2_per_point52=//x rotation; | |
| 312 | + wave_2_per_point53=sang=sin(q3);cang=cos(q3); | |
| 313 | + wave_2_per_point54=xn=xp; | |
| 314 | + wave_2_per_point55=yn=yp*sang + zp*cang; | |
| 315 | + wave_2_per_point56=zn=yp*cang - zp*sang; | |
| 316 | + wave_2_per_point57=xp=xn;yp=yn;zp=zn; | |
| 317 | + wave_2_per_point58= | |
| 318 | + wave_2_per_point59= | |
| 319 | + wave_2_per_point60= | |
| 320 | + wave_2_per_point61=zp=zp*2+1.55; | |
| 321 | + wave_2_per_point62= | |
| 322 | + wave_2_per_point63=//near clipping plane | |
| 323 | + wave_2_per_point64=a=a*above(zp,0.75); | |
| 324 | + wave_2_per_point65=//a=a*below(zp,8.55); | |
| 325 | + wave_2_per_point66= | |
| 326 | + wave_2_per_point67=x=xp/zp+ 0.5; | |
| 327 | + wave_2_per_point68=y=yp/zp * 1.3 + 0.5; | |
| 328 | + wavecode_3_enabled=0 | |
| 329 | + wavecode_3_samples=512 | |
| 330 | + wavecode_3_sep=0 | |
| 331 | + wavecode_3_bSpectrum=0 | |
| 332 | + wavecode_3_bUseDots=0 | |
| 333 | + wavecode_3_bDrawThick=1 | |
| 334 | + wavecode_3_bAdditive=1 | |
| 335 | + wavecode_3_scaling=1.00000 | |
| 336 | + wavecode_3_smoothing=0.50000 | |
| 337 | + wavecode_3_r=0.000 | |
| 338 | + wavecode_3_g=0.400 | |
| 339 | + wavecode_3_b=1.000 | |
| 340 | + wavecode_3_a=1.000 | |
| 341 | + wave_3_per_frame1=advance=advance+0.004*q6; | |
| 342 | + wave_3_per_frame2=advance=advance * below(advance,1); | |
| 343 | + wave_3_per_frame3=t1=advance; | |
| 344 | + wave_3_per_point1=n=sample*6.283; | |
| 345 | + wave_3_per_point2=step=sample*128; | |
| 346 | + wave_3_per_point3=step2=(int(step)/128)*6.283; | |
| 347 | + wave_3_per_point4=step3=(step - int(step)); | |
| 348 | + wave_3_per_point5=tm = t1 * 6.283 - 3.1415; | |
| 349 | + wave_3_per_point6= | |
| 350 | + wave_3_per_point7=//star lines | |
| 351 | + wave_3_per_point8=xp=sin(step2) * 1.6; | |
| 352 | + wave_3_per_point9=yp=cos(step2) * 1.6; | |
| 353 | + wave_3_per_point10=zp=sin(step2*11.3)*3.1415 + step3*0.35 - tm; | |
| 354 | + wave_3_per_point11=zp=if(below(zp,-3.1415), zp+6.283 , zp); | |
| 355 | + wave_3_per_point12= | |
| 356 | + wave_3_per_point13= | |
| 357 | + wave_3_per_point14=//kill stray lines from front to back | |
| 358 | + wave_3_per_point15=a=if(below(step3,0.36) , 0 , 1); | |
| 359 | + wave_3_per_point16=a=if(above(step3,0.64) , 0 , a); | |
| 360 | + wave_3_per_point17=a=if(below(zp,-3) , 0 , a); | |
| 361 | + wave_3_per_point18=a=if(above(zp,3) , 0 , a); | |
| 362 | + wave_3_per_point19= | |
| 363 | + wave_3_per_point20=//a=a*(zp/6.08); | |
| 364 | + wave_3_per_point21=a=a*(1-step3); | |
| 365 | + wave_3_per_point22=a=min( max(a,0) , 1); | |
| 366 | + wave_3_per_point23= | |
| 367 | + wave_3_per_point24= | |
| 368 | + wave_3_per_point25=zp=zp*2 - 3.1415; | |
| 369 | + wave_3_per_point26= | |
| 370 | + wave_3_per_point27=//zp=if(below(zp,-3.1415), zp+6.283 , zp); | |
| 371 | + wave_3_per_point28= | |
| 372 | + wave_3_per_point29=a=a * (1-(zp+2.1415)/6.283); | |
| 373 | + wave_3_per_point30= | |
| 374 | + wave_3_per_point31=a=if(below(zp,-1.5) , 0 , a); | |
| 375 | + wave_3_per_point32=a=if(above(zp,4.0) , 0 , a); | |
| 376 | + wave_3_per_point33= | |
| 377 | + wave_3_per_point34=//shift back when pointing away from camera | |
| 378 | + wave_3_per_point35=zp=zp-q4*2; | |
| 379 | + wave_3_per_point36= | |
| 380 | + wave_3_per_point37= | |
| 381 | + wave_3_per_point38=//z rotation | |
| 382 | + wave_3_per_point39=sang=sin(q1);cang=cos(q1); | |
| 383 | + wave_3_per_point40=xn=xp*sang + yp*cang; | |
| 384 | + wave_3_per_point41=yn=xp*cang - yp*sang; | |
| 385 | + wave_3_per_point42=zn=zp; | |
| 386 | + wave_3_per_point43=xp=xn;yp=yn;zp=zn; | |
| 387 | + wave_3_per_point44= | |
| 388 | + wave_3_per_point45=//y rotation; | |
| 389 | + wave_3_per_point46=sang=sin(q2);cang=cos(q2); | |
| 390 | + wave_3_per_point47=xn=xp*sang + zp*(cang); | |
| 391 | + wave_3_per_point48=yn=yp; | |
| 392 | + wave_3_per_point49=zn=xp*cang - zp*sang; | |
| 393 | + wave_3_per_point50=xp=xn;yp=yn;zp=zn; | |
| 394 | + wave_3_per_point51= | |
| 395 | + wave_3_per_point52=//x rotation; | |
| 396 | + wave_3_per_point53=sang=sin(q3);cang=cos(q3); | |
| 397 | + wave_3_per_point54=xn=xp; | |
| 398 | + wave_3_per_point55=yn=yp*sang + zp*cang; | |
| 399 | + wave_3_per_point56=zn=yp*cang - zp*sang; | |
| 400 | + wave_3_per_point57=xp=xn;yp=yn;zp=zn; | |
| 401 | + wave_3_per_point58= | |
| 402 | + wave_3_per_point59= | |
| 403 | + wave_3_per_point60= | |
| 404 | + wave_3_per_point61=zp=zp*2+1.55; | |
| 405 | + wave_3_per_point62= | |
| 406 | + wave_3_per_point63=//near clipping plane | |
| 407 | + wave_3_per_point64=a=a*above(zp,0.75); | |
| 408 | + wave_3_per_point65=//a=a*below(zp,8.55); | |
| 409 | + wave_3_per_point66= | |
| 410 | + wave_3_per_point67=x=xp/zp+ 0.5; | |
| 411 | + wave_3_per_point68=y=yp/zp * 1.3 + 0.5; | |
| 412 | + shapecode_0_enabled=1 | |
| 413 | + shapecode_0_sides=5 | |
| 414 | + shapecode_0_additive=0 | |
| 415 | + shapecode_0_thickOutline=0 | |
| 416 | + shapecode_0_textured=1 | |
| 417 | + shapecode_0_num_inst=1 | |
| 418 | + shapecode_0_x=0.500 | |
| 419 | + shapecode_0_y=0.500 | |
| 420 | + shapecode_0_rad=0.38700 | |
| 421 | + shapecode_0_ang=0.00000 | |
| 422 | + shapecode_0_tex_ang=0.00000 | |
| 423 | + shapecode_0_tex_zoom=1.69447 | |
| 424 | + shapecode_0_r=1.000 | |
| 425 | + shapecode_0_g=1.000 | |
| 426 | + shapecode_0_b=1.000 | |
| 427 | + shapecode_0_a=1.000 | |
| 428 | + shapecode_0_r2=0.800 | |
| 429 | + shapecode_0_g2=1.000 | |
| 430 | + shapecode_0_b2=1.000 | |
| 431 | + shapecode_0_a2=0.000 | |
| 432 | + shapecode_0_border_r=1.000 | |
| 433 | + shapecode_0_border_g=1.000 | |
| 434 | + shapecode_0_border_b=1.000 | |
| 435 | + shapecode_0_border_a=0.000 | |
| 436 | + shapecode_1_enabled=1 | |
| 437 | + shapecode_1_sides=5 | |
| 438 | + shapecode_1_additive=1 | |
| 439 | + shapecode_1_thickOutline=0 | |
| 440 | + shapecode_1_textured=1 | |
| 441 | + shapecode_1_num_inst=1 | |
| 442 | + shapecode_1_x=0.610 | |
| 443 | + shapecode_1_y=0.410 | |
| 444 | + shapecode_1_rad=0.48170 | |
| 445 | + shapecode_1_ang=1.00531 | |
| 446 | + shapecode_1_tex_ang=0.00000 | |
| 447 | + shapecode_1_tex_zoom=1.10462 | |
| 448 | + shapecode_1_r=1.000 | |
| 449 | + shapecode_1_g=1.000 | |
| 450 | + shapecode_1_b=1.000 | |
| 451 | + shapecode_1_a=0.400 | |
| 452 | + shapecode_1_r2=0.400 | |
| 453 | + shapecode_1_g2=0.600 | |
| 454 | + shapecode_1_b2=1.000 | |
| 455 | + shapecode_1_a2=0.000 | |
| 456 | + shapecode_1_border_r=1.000 | |
| 457 | + shapecode_1_border_g=1.000 | |
| 458 | + shapecode_1_border_b=1.000 | |
| 459 | + shapecode_1_border_a=0.000 | |
| 460 | + shape_1_init1=flip=1 | |
| 461 | + shape_1_per_frame1=flip=-flip; | |
| 462 | + shape_1_per_frame2= | |
| 463 | + shape_1_per_frame3=x=sin(q7)*0.2*flip + 0.5; | |
| 464 | + shape_1_per_frame4=y=cos(q7)*0.2*1.3 + 0.5; | |
| 465 | + shape_1_per_frame5=ang=-time*0.5; | |
| 466 | + shape_1_per_frame6= | |
| 467 | + shape_1_per_frame7=vol=(bass+mid+treb)*0.25; | |
| 468 | + shape_1_per_frame8=vol=vol*vol; | |
| 469 | + shape_1_per_frame9= | |
| 470 | + shape_1_per_frame10=a=a*min(vol,1); | |
| 471 | + shapecode_2_enabled=1 | |
| 472 | + shapecode_2_sides=5 | |
| 473 | + shapecode_2_additive=0 | |
| 474 | + shapecode_2_thickOutline=0 | |
| 475 | + shapecode_2_textured=1 | |
| 476 | + shapecode_2_num_inst=1 | |
| 477 | + shapecode_2_x=0.500 | |
| 478 | + shapecode_2_y=0.500 | |
| 479 | + shapecode_2_rad=0.28999 | |
| 480 | + shapecode_2_ang=0.00000 | |
| 481 | + shapecode_2_tex_ang=0.00000 | |
| 482 | + shapecode_2_tex_zoom=2.59927 | |
| 483 | + shapecode_2_r=1.000 | |
| 484 | + shapecode_2_g=1.000 | |
| 485 | + shapecode_2_b=1.000 | |
| 486 | + shapecode_2_a=1.000 | |
| 487 | + shapecode_2_r2=1.000 | |
| 488 | + shapecode_2_g2=0.500 | |
| 489 | + shapecode_2_b2=0.700 | |
| 490 | + shapecode_2_a2=0.000 | |
| 491 | + shapecode_2_border_r=1.000 | |
| 492 | + shapecode_2_border_g=1.000 | |
| 493 | + shapecode_2_border_b=1.000 | |
| 494 | + shapecode_2_border_a=0.000 | |
| 495 | + shape_2_per_frame1=x=sin(q8*2)*0.2; | |
| 496 | + shape_2_per_frame2=y=cos(q8*2)*0.2; | |
| 497 | + shape_2_per_frame3= | |
| 498 | + shape_2_per_frame4= | |
| 499 | + shape_2_per_frame5= | |
| 500 | + shape_2_per_frame6=x=x+0.2; | |
| 501 | + shape_2_per_frame7=ang=q7*1; | |
| 502 | + shape_2_per_frame8=sang=sin(ang);cang=cos(ang); | |
| 503 | + shape_2_per_frame9=xn=x*sang + y*cang; | |
| 504 | + shape_2_per_frame10=yn=x*cang - y*sang; | |
| 505 | + shape_2_per_frame11=x=xn + 0.5; | |
| 506 | + shape_2_per_frame12=y=yn*1.3 + 0.5; | |
| 507 | + shape_2_per_frame13= | |
| 508 | + shape_2_per_frame14= | |
| 509 | + shape_2_per_frame15=ang=-time*2; | |
| 510 | + shapecode_3_enabled=1 | |
| 511 | + shapecode_3_sides=15 | |
| 512 | + shapecode_3_additive=1 | |
| 513 | + shapecode_3_thickOutline=0 | |
| 514 | + shapecode_3_textured=0 | |
| 515 | + shapecode_3_num_inst=1 | |
| 516 | + shapecode_3_x=0.500 | |
| 517 | + shapecode_3_y=0.500 | |
| 518 | + shapecode_3_rad=0.17987 | |
| 519 | + shapecode_3_ang=0.00000 | |
| 520 | + shapecode_3_tex_ang=0.00000 | |
| 521 | + shapecode_3_tex_zoom=1.00000 | |
| 522 | + shapecode_3_r=1.000 | |
| 523 | + shapecode_3_g=0.600 | |
| 524 | + shapecode_3_b=0.500 | |
| 525 | + shapecode_3_a=1.000 | |
| 526 | + shapecode_3_r2=0.000 | |
| 527 | + shapecode_3_g2=0.600 | |
| 528 | + shapecode_3_b2=1.000 | |
| 529 | + shapecode_3_a2=0.000 | |
| 530 | + shapecode_3_border_r=1.000 | |
| 531 | + shapecode_3_border_g=1.000 | |
| 532 | + shapecode_3_border_b=1.000 | |
| 533 | + shapecode_3_border_a=0.000 | |
| 534 | + shape_3_per_frame1=vol=(bass+mid+treb)*0.25; | |
| 535 | + shape_3_per_frame2=vol=vol*vol; | |
| 536 | + shape_3_per_frame3= | |
| 537 | + shape_3_per_frame4=a=min(vol,1); | |
| 538 | + per_frame_init_1= | |
| 539 | + per_frame_init_2=zoom=1; | |
| 540 | + per_frame_init_3=xpos=0; | |
| 541 | + per_frame_init_4=ypos=0; | |
| 542 | + per_frame_1=decay=1; | |
| 543 | + per_frame_2= | |
| 544 | + per_frame_3=warp = 0; | |
| 545 | + per_frame_4= | |
| 546 | + per_frame_5=tic = min(time - tin,.1); | |
| 547 | + per_frame_6=tin = time; | |
| 548 | + per_frame_7= | |
| 549 | + per_frame_8=ra = 10; | |
| 550 | + per_frame_9= | |
| 551 | + per_frame_10=treb_avg = tic*(treb_avg*(1/tic - ra) + ra*treb); | |
| 552 | + per_frame_11=mid_avg = tic*(mid_avg*(1/tic - ra) + ra*mid); | |
| 553 | + per_frame_12=bass_avg = tic*(bass_avg*(1/tic - ra) + ra*bass); | |
| 554 | + per_frame_13= | |
| 555 | + per_frame_14=rb = 1; | |
| 556 | + per_frame_15=vav = tic*(vav*(1/tic - rb) + rb*(bass+treb+mid)*.33333); | |
| 557 | + per_frame_16= | |
| 558 | + per_frame_17=q1 = treb_avg; | |
| 559 | + per_frame_18=q2 = mid_avg; | |
| 560 | + per_frame_19=q3 = bass_avg; | |
| 561 | + per_frame_20=q4 = vav; | |
| 562 | + per_frame_21= | |
| 563 | + per_frame_22=mt=(mt+tic*vav*100)*below(mt,10000); | |
| 564 | + per_frame_23= | |
| 565 | + per_frame_24=q7=sin(mt*0.02)*0.01; | |
| 566 | + per_frame_25=q8=sin(mt*0.01)*0.115; | |
| 567 | + per_frame_26= | |
| 568 | + per_frame_27=dx=sin(mt*0.1)*0.07; | |
| 569 | + per_frame_28=dy=cos(mt*0.069)*0.07; | |
| 570 | + per_frame_29= | |
| 571 | + per_frame_30=monitor = mt; | |
| 572 | + per_pixel_1=rd=sqrt( sqr( (x-0.5-q7)*1) + sqr( (y-0.5+q8)*1.9 ) ); | |
| 573 | + per_pixel_2=tm=time+rad; | |
| 574 | + per_pixel_3=zoom=(rad+sin(rd-3.5))/rad; | |
| 575 | + per_pixel_4=rot=rd+(tm/3) | |
| 576 | + warp_1=`#define MyGet GetPixel //GetBlur1 | |
| 577 | + warp_2=`shader_body | |
| 578 | + warp_3=`{ | |
| 579 | + warp_4=` // GROW EFFECT - bright pixels spread radially outward. | |
| 580 | + warp_5=` // BE CAREFUL - this can really thrash the texture cache! (SLOW) | |
| 581 | + warp_6=` float grad_rad = 3; //TWEAK | |
| 582 | + warp_7=` float str = 2.3; //TWEAK | |
| 583 | + warp_8=` float3 d = float3(texsize.zw, 0) * grad_rad; | |
| 584 | + warp_9=` float4 lums = 0; | |
| 585 | + warp_10=` lums.x = lum( MyGet(uv + texsize.zw*d.xz) ); | |
| 586 | + warp_11=` lums.y = lum( MyGet(uv - texsize.zw*d.xz) ); | |
| 587 | + warp_12=` lums.z = lum( MyGet(uv + texsize.zw*d.zy) ); | |
| 588 | + warp_13=` lums.w = lum( MyGet(uv - texsize.zw*d.zy) ); | |
| 589 | + warp_14=` float2 grad = float2(lums.x-lums.y, lums.z-lums.w)*str*1000/grad_rad; | |
| 590 | + warp_15=` grad = (saturate(grad*0.5+0.5)*2-1)*1.4; | |
| 591 | + warp_16=` | |
| 592 | + warp_17=` // sample previous frame | |
| 593 | + warp_18=` ret = tex2D( sampler_fc_main, uv + grad*texsize.zw ).xyz; | |
| 594 | + warp_19=` | |
| 595 | + warp_20=`float2 uv_echo = (uv - 0.5)*float2(-1,1) + 0.5; | |
| 596 | + warp_21=` | |
| 597 | + warp_22=` float4 lums2 = 0; | |
| 598 | + warp_23=` lums2.x = lum( MyGet(uv_echo + texsize.zw*d.xz) ); | |
| 599 | + warp_24=` lums2.y = lum( MyGet(uv_echo - texsize.zw*d.xz) ); | |
| 600 | + warp_25=` lums2.z = lum( MyGet(uv_echo + texsize.zw*d.zy) ); | |
| 601 | + warp_26=` lums2.w = lum( MyGet(uv_echo - texsize.zw*d.zy) ); | |
| 602 | + warp_27=` float2 grad2 = float2(lums2.x-lums2.y, lums2.z-lums2.w)*str*1000/grad_rad; | |
| 603 | + warp_28=` grad2 = (saturate(grad2*0.5+0.5)*2-1)*1.4; | |
| 604 | + warp_29=` | |
| 605 | + warp_30=`float3 ret2 = tex2D(sampler_fc_main, uv_echo + grad2*texsize.zw).xyz; | |
| 606 | + warp_31=` | |
| 607 | + warp_32=`ret = lerp(ret,ret2,0.50); | |
| 608 | + warp_33=` | |
| 609 | + warp_34=` // darken (decay) over time | |
| 610 | + warp_35=` ret *= 0.95; //or try: ret -= 0.004; | |
| 611 | + warp_36=`} | |
| 612 | + comp_1=`float3 ret1, ret2, reta; | |
| 613 | + comp_2=`float2 sam; | |
| 614 | + comp_3=`shader_body | |
| 615 | + comp_4=`{ | |
| 616 | + comp_5=` sam = tex2D(sampler_main,uv*.5); | |
| 617 | + comp_6=` ret1 = tex2D(sampler_main, float2(uv.x, uv.y)); | |
| 618 | + comp_7=` sam *= GetBlur1(uv)-GetBlur3(uv); | |
| 619 | + comp_8=` | |
| 620 | + comp_9=` reta = tex2D(sampler_main, sam+uv ).rgb; | |
| 621 | + comp_10=` ret1 = reta.r * (.5*bass_att*uv_orig.y+reta) + (reta.r)*ret1; | |
| 622 | + comp_11=` ret1 *= (ret1+1)/2; //gamma | |
| 623 | + comp_12=` | |
| 624 | + comp_13=`uv = (uv-.5)*.3+.5; | |
| 625 | + comp_14=` sam = tex2D(sampler_main,uv*.5); | |
| 626 | + comp_15=` ret2 = tex2D(sampler_main, float2(uv.x, uv.y)); | |
| 627 | + comp_16=` sam *= GetBlur1(uv)-GetBlur3(uv); | |
| 628 | + comp_17=` | |
| 629 | + comp_18=` reta = tex2D(sampler_main, sam+uv ).rgb; | |
| 630 | + comp_19=` ret2 = reta.r * (.5*bass_att*uv_orig.y+reta) + (reta.r)*ret2; | |
| 631 | + comp_20=` ret2 *= (ret1+1); //gamma | |
| 632 | + comp_21=` | |
| 633 | + comp_22=` | |
| 634 | + comp_23=` | |
| 635 | + comp_24=`ret = max(ret1, ret2); | |
| 636 | + comp_25=`ret *= .5+.5*lum(ret); | |
| 637 | + comp_26=`//ret = (1+ret1)*ret2; | |
| 638 | + comp_27=` | |
| 639 | + comp_28=`} | |
| 640 | + comp_29=` | |
| 641 | + comp_30=` |
Sources/PulseCanvas/Resources/ProjectM/Presets/Dancer/Blobby/suksma - bounce shape exp 4 2 - cross teacher name on board punish.milk added
| 1 | + MILKDROP_PRESET_VERSION=201 | |
| 2 | + PSVERSION=2 | |
| 3 | + PSVERSION_WARP=2 | |
| 4 | + PSVERSION_COMP=2 | |
| 5 | + [preset00] | |
| 6 | + fRating=5.000000 | |
| 7 | + fGammaAdj=1.000 | |
| 8 | + fDecay=0.995 | |
| 9 | + fVideoEchoZoom=1.007 | |
| 10 | + fVideoEchoAlpha=0.000 | |
| 11 | + nVideoEchoOrientation=3 | |
| 12 | + nWaveMode=0 | |
| 13 | + bAdditiveWaves=1 | |
| 14 | + bWaveDots=0 | |
| 15 | + bWaveThick=0 | |
| 16 | + bModWaveAlphaByVolume=1 | |
| 17 | + bMaximizeWaveColor=0 | |
| 18 | + bTexWrap=0 | |
| 19 | + bDarkenCenter=0 | |
| 20 | + bRedBlueStereo=0 | |
| 21 | + bBrighten=0 | |
| 22 | + bDarken=0 | |
| 23 | + bSolarize=0 | |
| 24 | + bInvert=0 | |
| 25 | + fWaveAlpha=1.413 | |
| 26 | + fWaveScale=1.131 | |
| 27 | + fWaveSmoothing=0.000 | |
| 28 | + fWaveParam=-0.660 | |
| 29 | + fModWaveAlphaStart=2.000 | |
| 30 | + fModWaveAlphaEnd=2.000 | |
| 31 | + fWarpAnimSpeed=0.626 | |
| 32 | + fWarpScale=1.331 | |
| 33 | + fZoomExponent=1.00000 | |
| 34 | + fShader=10.000 | |
| 35 | + zoom=0.99951 | |
| 36 | + rot=0.00000 | |
| 37 | + cx=0.500 | |
| 38 | + cy=0.500 | |
| 39 | + dx=0.00000 | |
| 40 | + dy=0.00000 | |
| 41 | + warp=0.08925 | |
| 42 | + sx=1.00000 | |
| 43 | + sy=1.00000 | |
| 44 | + wave_r=0.000 | |
| 45 | + wave_g=0.000 | |
| 46 | + wave_b=1.000 | |
| 47 | + wave_x=0.240 | |
| 48 | + wave_y=0.440 | |
| 49 | + ob_size=0.500 | |
| 50 | + ob_r=0.010 | |
| 51 | + ob_g=0.000 | |
| 52 | + ob_b=0.000 | |
| 53 | + ob_a=0.000 | |
| 54 | + ib_size=0.260 | |
| 55 | + ib_r=0.250 | |
| 56 | + ib_g=0.250 | |
| 57 | + ib_b=0.250 | |
| 58 | + ib_a=0.000 | |
| 59 | + nMotionVectorsX=64.000 | |
| 60 | + nMotionVectorsY=48.000 | |
| 61 | + mv_dx=0.000 | |
| 62 | + mv_dy=0.000 | |
| 63 | + mv_l=0.000 | |
| 64 | + mv_r=1.000 | |
| 65 | + mv_g=1.000 | |
| 66 | + mv_b=1.000 | |
| 67 | + mv_a=0.000 | |
| 68 | + b1n=0.000 | |
| 69 | + b2n=0.000 | |
| 70 | + b3n=0.000 | |
| 71 | + b1x=1.000 | |
| 72 | + b2x=1.000 | |
| 73 | + b3x=1.000 | |
| 74 | + b1ed=0.250 | |
| 75 | + wavecode_0_enabled=0 | |
| 76 | + wavecode_0_samples=512 | |
| 77 | + wavecode_0_sep=256 | |
| 78 | + wavecode_0_bSpectrum=1 | |
| 79 | + wavecode_0_bUseDots=0 | |
| 80 | + wavecode_0_bDrawThick=1 | |
| 81 | + wavecode_0_bAdditive=0 | |
| 82 | + wavecode_0_scaling=1.00000 | |
| 83 | + wavecode_0_smoothing=0.00000 | |
| 84 | + wavecode_0_r=1.000 | |
| 85 | + wavecode_0_g=1.000 | |
| 86 | + wavecode_0_b=1.000 | |
| 87 | + wavecode_0_a=1.000 | |
| 88 | + wave_0_per_point1=sw = (1-sw)*above(sample,0); | |
| 89 | + wave_0_per_point2= | |
| 90 | + wave_0_per_point3=osa = sample*above(sample,0); | |
| 91 | + wave_0_per_point4= | |
| 92 | + wave_0_per_point5=mod = pow(value1*2,2)*sign(value1)*.5; | |
| 93 | + wave_0_per_point6= | |
| 94 | + wave_0_per_point7=mod = value1; | |
| 95 | + wave_0_per_point8=mod = mod*sw; | |
| 96 | + wave_0_per_point9= | |
| 97 | + wave_0_per_point10=y = if(sw,osa,sample); | |
| 98 | + wave_0_per_point11=y = sample; | |
| 99 | + wave_0_per_point12=x = .5 - mod*.5; | |
| 100 | + wave_0_per_point13= | |
| 101 | + wave_0_per_point14=osa = sample; | |
| 102 | + wave_0_per_point15= | |
| 103 | + wave_0_per_point16=mo = 3.7 + mod*6 + q10; | |
| 104 | + wave_0_per_point17= | |
| 105 | + wave_0_per_point18=r = q16;//.5 + sin(mo)*.5; | |
| 106 | + wave_0_per_point19=g = q17;//.5 + sin(mo + 1.0472)*.5; | |
| 107 | + wave_0_per_point20=b = q15;//.5 + sin(mo + 2.0944)*.5; | |
| 108 | + wave_0_per_point21= | |
| 109 | + wave_0_per_point22=a = 1 - abs(mod)*12; | |
| 110 | + wave_0_per_point23=a = 1-sw; | |
| 111 | + wave_0_per_point24=a = max(0,min(a,1)); | |
| 112 | + wave_0_per_point25= | |
| 113 | + wave_0_per_point26=x = (x-0.5)*(q31/q32) + 0.5; | |
| 114 | + wave_0_per_point27=y = (y-0.5)*(q32/q31) + 0.5; | |
| 115 | + wavecode_1_enabled=0 | |
| 116 | + wavecode_1_samples=512 | |
| 117 | + wavecode_1_sep=256 | |
| 118 | + wavecode_1_bSpectrum=1 | |
| 119 | + wavecode_1_bUseDots=0 | |
| 120 | + wavecode_1_bDrawThick=1 | |
| 121 | + wavecode_1_bAdditive=0 | |
| 122 | + wavecode_1_scaling=1.00000 | |
| 123 | + wavecode_1_smoothing=0.00000 | |
| 124 | + wavecode_1_r=1.000 | |
| 125 | + wavecode_1_g=1.000 | |
| 126 | + wavecode_1_b=1.000 | |
| 127 | + wavecode_1_a=1.000 | |
| 128 | + wave_1_per_point1=sw = (1-sw)*below(sample,1); | |
| 129 | + wave_1_per_point2= | |
| 130 | + wave_1_per_point3=osa = sample*above(sample,0); | |
| 131 | + wave_1_per_point4= | |
| 132 | + wave_1_per_point5=mod = pow(value2*2,2)*sign(value2)*.5; | |
| 133 | + wave_1_per_point6= | |
| 134 | + wave_1_per_point7=mod = value2; | |
| 135 | + wave_1_per_point8=mod = mod*sw; | |
| 136 | + wave_1_per_point9= | |
| 137 | + wave_1_per_point10=y = if(sw,osa,sample); | |
| 138 | + wave_1_per_point11=y = sample; | |
| 139 | + wave_1_per_point12=x = .5 + mod*.5; | |
| 140 | + wave_1_per_point13= | |
| 141 | + wave_1_per_point14=osa = sample; | |
| 142 | + wave_1_per_point15= | |
| 143 | + wave_1_per_point16=mo = 3.7 + mod*6 + q10; | |
| 144 | + wave_1_per_point17= | |
| 145 | + wave_1_per_point18=r = q17;//.5 + sin(mo)*.5; | |
| 146 | + wave_1_per_point19=g = q15;//.5 + sin(mo + 1.0472)*.5; | |
| 147 | + wave_1_per_point20=b = q16;//.5 + sin(mo + 2.0944)*.5; | |
| 148 | + wave_1_per_point21= | |
| 149 | + wave_1_per_point22=a = 1 - abs(mod)*12; | |
| 150 | + wave_1_per_point23=a = 1-sw; | |
| 151 | + wave_1_per_point24=a = max(0,min(a,1)); | |
| 152 | + wave_1_per_point25= | |
| 153 | + wave_1_per_point26=x = (x-0.5)*(q31/q32) + 0.5; | |
| 154 | + wave_1_per_point27=y = (y-0.5)*(q32/q31) + 0.5; | |
| 155 | + wavecode_2_enabled=0 | |
| 156 | + wavecode_2_samples=512 | |
| 157 | + wavecode_2_sep=0 | |
| 158 | + wavecode_2_bSpectrum=1 | |
| 159 | + wavecode_2_bUseDots=0 | |
| 160 | + wavecode_2_bDrawThick=0 | |
| 161 | + wavecode_2_bAdditive=0 | |
| 162 | + wavecode_2_scaling=1.00000 | |
| 163 | + wavecode_2_smoothing=0.50000 | |
| 164 | + wavecode_2_r=1.000 | |
| 165 | + wavecode_2_g=0.000 | |
| 166 | + wavecode_2_b=0.000 | |
| 167 | + wavecode_2_a=1.000 | |
| 168 | + wave_2_init1=chance = 0; | |
| 169 | + wave_2_per_frame1=x = if(q9,q15,x); | |
| 170 | + wave_2_per_frame2=y = if(q9,q16,y); | |
| 171 | + wave_2_per_frame3=v = if(q9,q19,v); | |
| 172 | + wave_2_per_frame4=w = if(q9,q20,w); | |
| 173 | + wave_2_per_frame5= | |
| 174 | + wave_2_per_frame6=ref_w = if(q9, q10, ref_w); | |
| 175 | + wave_2_per_frame7= | |
| 176 | + wave_2_per_frame8=t1 = x; | |
| 177 | + wave_2_per_frame9=t2 = y; | |
| 178 | + wave_2_per_frame10=t3 = v; | |
| 179 | + wave_2_per_frame11=t4 = w; | |
| 180 | + wave_2_per_frame12=t5 = ref_w; | |
| 181 | + wave_2_per_frame13= | |
| 182 | + wave_2_per_frame14=t8 = 1; | |
| 183 | + wave_2_per_point1=x = t1 + sample*sin(t5)*t3*20*cos(t4-t5); | |
| 184 | + wave_2_per_point2=y = t2 + sample*cos(t5)*t3*20*cos(t4-t5); | |
| 185 | + wave_2_per_point3= | |
| 186 | + wave_2_per_point4=x = 0.5 + (x-0.5); | |
| 187 | + wave_2_per_point5=y = 0.5 + (y-0.5); | |
| 188 | + wavecode_3_enabled=0 | |
| 189 | + wavecode_3_samples=512 | |
| 190 | + wavecode_3_sep=0 | |
| 191 | + wavecode_3_bSpectrum=1 | |
| 192 | + wavecode_3_bUseDots=0 | |
| 193 | + wavecode_3_bDrawThick=0 | |
| 194 | + wavecode_3_bAdditive=0 | |
| 195 | + wavecode_3_scaling=1.00000 | |
| 196 | + wavecode_3_smoothing=0.50000 | |
| 197 | + wavecode_3_r=1.000 | |
| 198 | + wavecode_3_g=0.000 | |
| 199 | + wavecode_3_b=0.000 | |
| 200 | + wavecode_3_a=1.000 | |
| 201 | + wave_3_init1=chance = 0; | |
| 202 | + wave_3_per_frame1=x = if(q9,q15,x); | |
| 203 | + wave_3_per_frame2=y = if(q9,q16,y); | |
| 204 | + wave_3_per_frame3=v = if(q9,q19,v); | |
| 205 | + wave_3_per_frame4=w = if(q9,q20,w); | |
| 206 | + wave_3_per_frame5= | |
| 207 | + wave_3_per_frame6=ref_w = if(q9, q10 + asin(1), ref_w); | |
| 208 | + wave_3_per_frame7= | |
| 209 | + wave_3_per_frame8=t1 = x; | |
| 210 | + wave_3_per_frame9=t2 = y; | |
| 211 | + wave_3_per_frame10=t3 = v; | |
| 212 | + wave_3_per_frame11=t4 = w; | |
| 213 | + wave_3_per_frame12=t5 = ref_w; | |
| 214 | + wave_3_per_frame13= | |
| 215 | + wave_3_per_frame14=t8 = 1; | |
| 216 | + wave_3_per_point1=x = t1 + sample*sin(t5)*t3*20*cos(t4-t5); | |
| 217 | + wave_3_per_point2=y = t2 + sample*cos(t5)*t3*20*cos(t4-t5); | |
| 218 | + wave_3_per_point3= | |
| 219 | + wave_3_per_point4=x = 0.5 + (x-0.5); | |
| 220 | + wave_3_per_point5=y = 0.5 + (y-0.5); | |
| 221 | + shapecode_0_enabled=1 | |
| 222 | + shapecode_0_sides=3 | |
| 223 | + shapecode_0_additive=1 | |
| 224 | + shapecode_0_thickOutline=0 | |
| 225 | + shapecode_0_textured=0 | |
| 226 | + shapecode_0_num_inst=41 | |
| 227 | + shapecode_0_x=0.500 | |
| 228 | + shapecode_0_y=0.500 | |
| 229 | + shapecode_0_rad=0.02770 | |
| 230 | + shapecode_0_ang=6.03186 | |
| 231 | + shapecode_0_tex_ang=6.03186 | |
| 232 | + shapecode_0_tex_zoom=0.68390 | |
| 233 | + shapecode_0_r=1.000 | |
| 234 | + shapecode_0_g=0.000 | |
| 235 | + shapecode_0_b=0.000 | |
| 236 | + shapecode_0_a=0.200 | |
| 237 | + shapecode_0_r2=1.000 | |
| 238 | + shapecode_0_g2=0.000 | |
| 239 | + shapecode_0_b2=0.000 | |
| 240 | + shapecode_0_a2=0.200 | |
| 241 | + shapecode_0_border_r=0.000 | |
| 242 | + shapecode_0_border_g=0.000 | |
| 243 | + shapecode_0_border_b=0.000 | |
| 244 | + shapecode_0_border_a=0.200 | |
| 245 | + shape_0_per_frame1=x = q3; | |
| 246 | + shape_0_per_frame2=y = q4; | |
| 247 | + shape_0_per_frame3=rad = q5; | |
| 248 | + shape_0_per_frame4= | |
| 249 | + shape_0_per_frame5=isiz=q30; | |
| 250 | + shape_0_per_frame6=volint=int((bass+treb+mid)*2.5); | |
| 251 | + shape_0_per_frame7=coff1=(int(rand(instance-instance+10))%volint+.01)*.1; | |
| 252 | + shape_0_per_frame8=coff2=(int(rand(instance-instance+10))%volint+.01)*.1; | |
| 253 | + shape_0_per_frame9=negsw1=pow(-1,int(rand(2))%2); | |
| 254 | + shape_0_per_frame10=negsw2=pow(-1,int(rand(2))%2); | |
| 255 | + shape_0_per_frame11=x = 0.5 + isiz*coff1*negsw1+(x-0.5); | |
| 256 | + shape_0_per_frame12=y = 0.5 + isiz*coff2*negsw2+(y-0.5); | |
| 257 | + shape_0_per_frame13=//x = 0.5 + (x-0.5); | |
| 258 | + shape_0_per_frame14=//y = 0.5 + (y-0.5); | |
| 259 | + shape_0_per_frame15= | |
| 260 | + shape_0_per_frame16=xdir = x - t1; | |
| 261 | + shape_0_per_frame17=ydir = y - t2; | |
| 262 | + shape_0_per_frame18=dir = xdir/ydir; | |
| 263 | + shape_0_per_frame19=bdir = .5*bdir + .5*dir; | |
| 264 | + shape_0_per_frame20=roll = roll - bdir; | |
| 265 | + shape_0_per_frame21= | |
| 266 | + shape_0_per_frame22=ang = roll/6.28; | |
| 267 | + shape_0_per_frame23= | |
| 268 | + shape_0_per_frame24=t1 = x; | |
| 269 | + shape_0_per_frame25=t2 = y; | |
| 270 | + shape_0_per_frame26=r=q15; | |
| 271 | + shape_0_per_frame27=g=q16; | |
| 272 | + shape_0_per_frame28=b=q17; | |
| 273 | + shape_0_per_frame29=r2=q16; | |
| 274 | + shape_0_per_frame30=g2=q15; | |
| 275 | + shape_0_per_frame31=b2=q17; | |
| 276 | + shape_0_per_frame32=border_r=q17; | |
| 277 | + shape_0_per_frame33=border_g=q16; | |
| 278 | + shape_0_per_frame34=border_b=q15; | |
| 279 | + shapecode_1_enabled=1 | |
| 280 | + shapecode_1_sides=4 | |
| 281 | + shapecode_1_additive=1 | |
| 282 | + shapecode_1_thickOutline=0 | |
| 283 | + shapecode_1_textured=0 | |
| 284 | + shapecode_1_num_inst=41 | |
| 285 | + shapecode_1_x=0.500 | |
| 286 | + shapecode_1_y=0.500 | |
| 287 | + shapecode_1_rad=0.02770 | |
| 288 | + shapecode_1_ang=6.03186 | |
| 289 | + shapecode_1_tex_ang=6.03186 | |
| 290 | + shapecode_1_tex_zoom=0.68390 | |
| 291 | + shapecode_1_r=0.000 | |
| 292 | + shapecode_1_g=0.000 | |
| 293 | + shapecode_1_b=1.000 | |
| 294 | + shapecode_1_a=0.200 | |
| 295 | + shapecode_1_r2=0.000 | |
| 296 | + shapecode_1_g2=0.000 | |
| 297 | + shapecode_1_b2=1.000 | |
| 298 | + shapecode_1_a2=0.200 | |
| 299 | + shapecode_1_border_r=0.000 | |
| 300 | + shapecode_1_border_g=0.000 | |
| 301 | + shapecode_1_border_b=0.000 | |
| 302 | + shapecode_1_border_a=0.200 | |
| 303 | + shape_1_per_frame1=x = q6; | |
| 304 | + shape_1_per_frame2=y = q7; | |
| 305 | + shape_1_per_frame3=rad = q8; | |
| 306 | + shape_1_per_frame4= | |
| 307 | + shape_1_per_frame5= | |
| 308 | + shape_1_per_frame6=isiz=q30; | |
| 309 | + shape_1_per_frame7=volint=int((bass+treb+mid)*2.5); | |
| 310 | + shape_1_per_frame8=coff1=(int(rand(instance-instance+10))%volint+.01)*.1; | |
| 311 | + shape_1_per_frame9=coff2=(int(rand(instance-instance+10))%volint+.01)*.1; | |
| 312 | + shape_1_per_frame10=negsw1=pow(-1,int(rand(2))%2); | |
| 313 | + shape_1_per_frame11=negsw2=pow(-1,int(rand(2))%2); | |
| 314 | + shape_1_per_frame12=x = 0.5 + isiz*coff1*negsw1+(x-0.5); | |
| 315 | + shape_1_per_frame13=y = 0.5 + isiz*coff2*negsw2+(y-0.5); | |
| 316 | + shape_1_per_frame14=//x = 0.5 + (x-0.5); | |
| 317 | + shape_1_per_frame15=//y = 0.5 + (y-0.5); | |
| 318 | + shape_1_per_frame16= | |
| 319 | + shape_1_per_frame17= | |
| 320 | + shape_1_per_frame18= | |
| 321 | + shape_1_per_frame19=xdir = x - t1; | |
| 322 | + shape_1_per_frame20=ydir = y - t2; | |
| 323 | + shape_1_per_frame21=dir = xdir/ydir; | |
| 324 | + shape_1_per_frame22=bdir = .5*bdir + .5*dir; | |
| 325 | + shape_1_per_frame23=roll = roll - bdir; | |
| 326 | + shape_1_per_frame24=ang = roll/6.28; | |
| 327 | + shape_1_per_frame25= | |
| 328 | + shape_1_per_frame26=t1 = x; | |
| 329 | + shape_1_per_frame27=t2 = y; | |
| 330 | + shape_1_per_frame28=r=q17; | |
| 331 | + shape_1_per_frame29=g=q15; | |
| 332 | + shape_1_per_frame30=b=q16; | |
| 333 | + shape_1_per_frame31=r2=q16; | |
| 334 | + shape_1_per_frame32=g2=q17; | |
| 335 | + shape_1_per_frame33=b2=q15; | |
| 336 | + shape_1_per_frame34=border_r=q16; | |
| 337 | + shape_1_per_frame35=border_g=q15; | |
| 338 | + shape_1_per_frame36=border_b=q17; | |
| 339 | + shapecode_2_enabled=1 | |
| 340 | + shapecode_2_sides=5 | |
| 341 | + shapecode_2_additive=1 | |
| 342 | + shapecode_2_thickOutline=0 | |
| 343 | + shapecode_2_textured=0 | |
| 344 | + shapecode_2_num_inst=41 | |
| 345 | + shapecode_2_x=0.500 | |
| 346 | + shapecode_2_y=0.500 | |
| 347 | + shapecode_2_rad=0.02770 | |
| 348 | + shapecode_2_ang=6.03186 | |
| 349 | + shapecode_2_tex_ang=6.03186 | |
| 350 | + shapecode_2_tex_zoom=0.68390 | |
| 351 | + shapecode_2_r=0.000 | |
| 352 | + shapecode_2_g=1.000 | |
| 353 | + shapecode_2_b=0.000 | |
| 354 | + shapecode_2_a=0.200 | |
| 355 | + shapecode_2_r2=0.000 | |
| 356 | + shapecode_2_g2=1.000 | |
| 357 | + shapecode_2_b2=0.000 | |
| 358 | + shapecode_2_a2=0.200 | |
| 359 | + shapecode_2_border_r=0.000 | |
| 360 | + shapecode_2_border_g=0.000 | |
| 361 | + shapecode_2_border_b=0.000 | |
| 362 | + shapecode_2_border_a=0.200 | |
| 363 | + shape_2_per_frame1=x = q9; | |
| 364 | + shape_2_per_frame2=y = q10; | |
| 365 | + shape_2_per_frame3=rad = q11; | |
| 366 | + shape_2_per_frame4= | |
| 367 | + shape_2_per_frame5=//x = 0.5 + (x-0.5); | |
| 368 | + shape_2_per_frame6=//y = 0.5 + (y-0.5); | |
| 369 | + shape_2_per_frame7= | |
| 370 | + shape_2_per_frame8=isiz=q30; | |
| 371 | + shape_2_per_frame9=volint=int((bass+treb+mid)*2.5); | |
| 372 | + shape_2_per_frame10=coff1=(int(rand(instance-instance+10))%volint+.01)*.1; | |
| 373 | + shape_2_per_frame11=coff2=(int(rand(instance-instance+10))%volint+.01)*.1; | |
| 374 | + shape_2_per_frame12=negsw1=pow(-1,int(rand(2))%2); | |
| 375 | + shape_2_per_frame13=negsw2=pow(-1,int(rand(2))%2); | |
| 376 | + shape_2_per_frame14=x = 0.5 + isiz*coff1*negsw1+(x-0.5); | |
| 377 | + shape_2_per_frame15=y = 0.5 + isiz*coff2*negsw2+(y-0.5); | |
| 378 | + shape_2_per_frame16= | |
| 379 | + shape_2_per_frame17= | |
| 380 | + shape_2_per_frame18=xdir = x - t1; | |
| 381 | + shape_2_per_frame19=ydir = y - t2; | |
| 382 | + shape_2_per_frame20=dir = xdir/ydir; | |
| 383 | + shape_2_per_frame21=bdir = .5*bdir + .5*dir; | |
| 384 | + shape_2_per_frame22=roll = roll - bdir; | |
| 385 | + shape_2_per_frame23=ang = roll/6.28; | |
| 386 | + shape_2_per_frame24= | |
| 387 | + shape_2_per_frame25=t1 = x; | |
| 388 | + shape_2_per_frame26=t2 = y; | |
| 389 | + shape_2_per_frame27=r=q17; | |
| 390 | + shape_2_per_frame28=g=q16; | |
| 391 | + shape_2_per_frame29=b=q15; | |
| 392 | + shape_2_per_frame30=r2=q16; | |
| 393 | + shape_2_per_frame31=g2=q17; | |
| 394 | + shape_2_per_frame32=b2=q15; | |
| 395 | + shape_2_per_frame33=border_r=q15; | |
| 396 | + shape_2_per_frame34=border_g=q16; | |
| 397 | + shape_2_per_frame35=border_b=q17; | |
| 398 | + shapecode_3_enabled=1 | |
| 399 | + shapecode_3_sides=7 | |
| 400 | + shapecode_3_additive=1 | |
| 401 | + shapecode_3_thickOutline=1 | |
| 402 | + shapecode_3_textured=0 | |
| 403 | + shapecode_3_num_inst=41 | |
| 404 | + shapecode_3_x=0.500 | |
| 405 | + shapecode_3_y=0.500 | |
| 406 | + shapecode_3_rad=0.02770 | |
| 407 | + shapecode_3_ang=6.03186 | |
| 408 | + shapecode_3_tex_ang=6.03186 | |
| 409 | + shapecode_3_tex_zoom=0.68390 | |
| 410 | + shapecode_3_r=0.000 | |
| 411 | + shapecode_3_g=1.000 | |
| 412 | + shapecode_3_b=0.000 | |
| 413 | + shapecode_3_a=0.000 | |
| 414 | + shapecode_3_r2=0.000 | |
| 415 | + shapecode_3_g2=1.000 | |
| 416 | + shapecode_3_b2=0.000 | |
| 417 | + shapecode_3_a2=0.000 | |
| 418 | + shapecode_3_border_r=1.000 | |
| 419 | + shapecode_3_border_g=1.000 | |
| 420 | + shapecode_3_border_b=1.000 | |
| 421 | + shapecode_3_border_a=1.000 | |
| 422 | + shape_3_per_frame1=x = q12; | |
| 423 | + shape_3_per_frame2=y = q13; | |
| 424 | + shape_3_per_frame3=rad = q14; | |
| 425 | + shape_3_per_frame4= | |
| 426 | + shape_3_per_frame5=isiz=q30; | |
| 427 | + shape_3_per_frame6=volint=int((bass+treb+mid)*2.5); | |
| 428 | + shape_3_per_frame7=coff1=(int(rand(instance-instance+10))%volint+.01)*.1; | |
| 429 | + shape_3_per_frame8=coff2=(int(rand(instance-instance+10))%volint+.01)*.1; | |
| 430 | + shape_3_per_frame9=negsw1=pow(-1,int(rand(2))%2); | |
| 431 | + shape_3_per_frame10=negsw2=pow(-1,int(rand(2))%2); | |
| 432 | + shape_3_per_frame11=x = 0.5 + isiz*coff1*negsw1+(x-0.5); | |
| 433 | + shape_3_per_frame12=y = 0.5 + isiz*coff2*negsw2+(y-0.5); | |
| 434 | + shape_3_per_frame13=//x = 0.5 + (x-0.5); | |
| 435 | + shape_3_per_frame14=//y = 0.5 + (y-0.5); | |
| 436 | + shape_3_per_frame15= | |
| 437 | + shape_3_per_frame16=xdir = x - t1; | |
| 438 | + shape_3_per_frame17=ydir = y - t2; | |
| 439 | + shape_3_per_frame18=dir = xdir/ydir; | |
| 440 | + shape_3_per_frame19=bdir = .5*bdir + .5*dir; | |
| 441 | + shape_3_per_frame20=roll = roll + bdir; | |
| 442 | + shape_3_per_frame21=ang = roll/6.28; | |
| 443 | + shape_3_per_frame22= | |
| 444 | + shape_3_per_frame23=t1 = x; | |
| 445 | + shape_3_per_frame24=t2 = y; | |
| 446 | + shape_3_per_frame25=border_r=q15; | |
| 447 | + shape_3_per_frame26=border_g=q17; | |
| 448 | + shape_3_per_frame27=border_b=q16; | |
| 449 | + per_frame_init_1=x1 = 0.5; | |
| 450 | + per_frame_init_2=x2 = 0.51; | |
| 451 | + per_frame_init_3= | |
| 452 | + per_frame_init_4=y2 = 0.9; | |
| 453 | + per_frame_init_5=y1 = 0.7; | |
| 454 | + per_frame_init_6= | |
| 455 | + per_frame_init_7=x3 = 0.8; | |
| 456 | + per_frame_init_8=y3 = 0.5; | |
| 457 | + per_frame_init_9= | |
| 458 | + per_frame_init_10=x4 = 0.2; | |
| 459 | + per_frame_init_11=y4 = 0.5; | |
| 460 | + per_frame_init_12= | |
| 461 | + per_frame_init_13= | |
| 462 | + per_frame_init_14=ax1 = 0; | |
| 463 | + per_frame_init_15=ay1 = 0; | |
| 464 | + per_frame_init_16=ax2 = 0; | |
| 465 | + per_frame_init_17=ay2 = 0; | |
| 466 | + per_frame_init_18=ax3 = 0; | |
| 467 | + per_frame_init_19=ay3 = 0; | |
| 468 | + per_frame_init_20= | |
| 469 | + per_frame_init_21=vx1 = 0.000; | |
| 470 | + per_frame_init_22=vx2 = 0.000; | |
| 471 | + per_frame_1=zoom = 1; | |
| 472 | + per_frame_2=warp = 0; | |
| 473 | + per_frame_3=wave_a = 0; | |
| 474 | + per_frame_4= | |
| 475 | + per_frame_5=//pogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogo | |
| 476 | + per_frame_6=r = 0.04+ max(bass_att,treb_att)*0.04; | |
| 477 | + per_frame_7=bounce = below(y1,r);y1 = y1+vy1;vy1 = if(bounce, abs(vy1)*0.94 + (r-y1)*0.1, vy1-0.0003*60/fps); | |
| 478 | + per_frame_8=bounce = below(x1,r);x1 = x1+vx1;vx1 = if(bounce, abs(vx1)*0.94 + (r-x1)*0.1, vx1); | |
| 479 | + per_frame_9=bounce = above(x1,1-r);vx1 = if(bounce, - abs(vx1)*0.94 + (1-r-x1)*0.04, vx1); | |
| 480 | + per_frame_10=bounce = above(y1,1-r);vy1 = if(bounce, - abs(vy1)*0.94 + (1-r-y1)*0.04, vy1);//test ceiling | |
| 481 | + per_frame_11= | |
| 482 | + per_frame_12=bounce = below(y2,r);y2 = y2 + vy2;vy2 = if(bounce,abs(vy2)*0.94+(r-y2)*.1, vy2-0.0003*60/fps); | |
| 483 | + per_frame_13=bounce = below(x2,r);x2 = x2+ vx2;vx2 = if(bounce, abs(vx2)*0.94 + (r-x2)*0.1, vx2); | |
| 484 | + per_frame_14=bounce = above(x2,1-r);vx2 = if(bounce, - abs(vx2)*0.94 + (1-r-x2)*0.1, vx2); | |
| 485 | + per_frame_15=bounce = above(y2,1-r);vy2 = if(bounce, - abs(vy2)*0.94 + (1-r-y2)*0.1, vy2); | |
| 486 | + per_frame_16= | |
| 487 | + per_frame_17=bounce = below(y3,r);y3 = y3 + vy3;vy3 = if(bounce,abs(vy3)*0.94+(r-y3)*.1, vy3-0.0003*60/fps); | |
| 488 | + per_frame_18=bounce = below(x3,r);x3 = x3+ vx3;vx3 = if(bounce, abs(vx3)*0.94 + (r-x3)*0.1, vx3); | |
| 489 | + per_frame_19=bounce = above(x3,1-r);vx3 = if(bounce, - abs(vx3)*0.94 + (1-r-x3)*0.1, vx3); | |
| 490 | + per_frame_20=bounce = above(y3,1-r);vy3 = if(bounce, - abs(vy3)*0.94 + (1-r-y3)*0.1, vy3); | |
| 491 | + per_frame_21= | |
| 492 | + per_frame_22=bounce = below(y4,r);y4 = y4 + vy4;vy4 = if(bounce,abs(vy4)*0.94+(r-y4)*.1, vy4-0.0003*60/fps); | |
| 493 | + per_frame_23=bounce = below(x4,r);x4 = x4+ vx4;vx4 = if(bounce, abs(vx4)*0.94 + (r-x4)*0.1, vx4); | |
| 494 | + per_frame_24=bounce = above(x4,1-r);vx4 = if(bounce, - abs(vx4)*0.94 + (1-r-x4)*0.1, vx4); | |
| 495 | + per_frame_25=bounce = above(y4,1-r);vy4 = if(bounce, - abs(vy4)*0.94 + (1-r-y4)*0.1, vy4); | |
| 496 | + per_frame_26= | |
| 497 | + per_frame_27=bounce = below( sqrt( sqr(x1+vx1-x2-vx2) + sqr(y1+vy1-y2-vy2)), 2*r); | |
| 498 | + per_frame_28=ref_ang = atan2(x2-x1,y2-y1)+asin(1); // common tangent | |
| 499 | + per_frame_29=v1 = sqrt(vx1*vx1+vy1*vy1);v2 = sqrt(vx2*vx2+vy2*vy2);w1 = atan2(vx1,vy1);w2 = atan2(vx2,vy2); | |
| 500 | + per_frame_30=vx1 = if(bounce,sin(ref_ang)*v1*cos(w1-ref_ang) + sin(ref_ang+asin(1))*v2*cos(w2-ref_ang-asin(1)), vx1); | |
| 501 | + per_frame_31=vy1 = if(bounce,cos(ref_ang)*v1*cos(w1-ref_ang) + cos(ref_ang+asin(1))*v2*cos(w2-ref_ang-asin(1)), vy1); | |
| 502 | + per_frame_32=vx2 = if(bounce,sin(ref_ang)*v2*cos(w2-ref_ang) + sin(ref_ang+asin(1))*v1*cos(w1-ref_ang-asin(1)), vx2); | |
| 503 | + per_frame_33=vy2 = if(bounce,cos(ref_ang)*v2*cos(w2-ref_ang) + cos(ref_ang+asin(1))*v1*cos(w1-ref_ang-asin(1)), vy2); | |
| 504 | + per_frame_34=bounce = below( sqrt( sqr(x1+vx1-x3-vx3) + sqr(y1+vy1-y3-vy3)), 2*r); | |
| 505 | + per_frame_35=ref_ang = atan2(x3-x1,y3-y1)+asin(1); // common tangent | |
| 506 | + per_frame_36=v1 = sqrt(vx1*vx1+vy1*vy1);v2 = sqrt(vx3*vx3+vy3*vy3);w1 = atan2(vx1,vy1);w2 = atan2(vx3,vy3); | |
| 507 | + per_frame_37=vx1 = if(bounce,sin(ref_ang)*v1*cos(w1-ref_ang) + sin(ref_ang+asin(1))*v2*cos(w2-ref_ang-asin(1)), vx1); | |
| 508 | + per_frame_38=vy1 = if(bounce,cos(ref_ang)*v1*cos(w1-ref_ang) + cos(ref_ang+asin(1))*v2*cos(w2-ref_ang-asin(1)), vy1); | |
| 509 | + per_frame_39=vx3 = if(bounce,sin(ref_ang)*v2*cos(w2-ref_ang) + sin(ref_ang+asin(1))*v1*cos(w1-ref_ang-asin(1)), vx3); | |
| 510 | + per_frame_40=vy3 = if(bounce,cos(ref_ang)*v2*cos(w2-ref_ang) + cos(ref_ang+asin(1))*v1*cos(w1-ref_ang-asin(1)), vy3); | |
| 511 | + per_frame_41=bounce = below( sqrt( sqr(x2+vx2-x3-vx3) + sqr(y2+vy2-y3-vy3)), 2*r); | |
| 512 | + per_frame_42=ref_ang = atan2(x3-x2,y3-y2)+asin(1); // common tangent | |
| 513 | + per_frame_43=v1 = sqrt(vx2*vx2+vy2*vy2);v2 = sqrt(vx3*vx3+vy3*vy3);w1 = atan2(vx2,vy2);w2 = atan2(vx3,vy3); | |
| 514 | + per_frame_44=vx2 = if(bounce,sin(ref_ang)*v1*cos(w1-ref_ang) + sin(ref_ang+asin(1))*v2*cos(w2-ref_ang-asin(1)), vx2); | |
| 515 | + per_frame_45=vy2 = if(bounce,cos(ref_ang)*v1*cos(w1-ref_ang) + cos(ref_ang+asin(1))*v2*cos(w2-ref_ang-asin(1)), vy2); | |
| 516 | + per_frame_46=vx3 = if(bounce,sin(ref_ang)*v2*cos(w2-ref_ang) + sin(ref_ang+asin(1))*v1*cos(w1-ref_ang-asin(1)), vx3); | |
| 517 | + per_frame_47=vy3 = if(bounce,cos(ref_ang)*v2*cos(w2-ref_ang) + cos(ref_ang+asin(1))*v1*cos(w1-ref_ang-asin(1)), vy3); | |
| 518 | + per_frame_48=bounce = below( sqrt( sqr(x1+vx1-x4-vx4) + sqr(y1+vy1-y4-vy4)), 2*r); | |
| 519 | + per_frame_49=ref_ang = atan2(x4-x1,y4-y1)+asin(1); // common tangent | |
| 520 | + per_frame_50=v1 = sqrt(vx1*vx1+vy1*vy1);v2 = sqrt(vx4*vx4+vy4*vy4);w1 = atan2(vx1,vy1);w2 = atan2(vx4,vy4); | |
| 521 | + per_frame_51=vx1 = if(bounce,sin(ref_ang)*v1*cos(w1-ref_ang) + sin(ref_ang+asin(1))*v2*cos(w2-ref_ang-asin(1)), vx1); | |
| 522 | + per_frame_52=vy1 = if(bounce,cos(ref_ang)*v1*cos(w1-ref_ang) + cos(ref_ang+asin(1))*v2*cos(w2-ref_ang-asin(1)), vy1); | |
| 523 | + per_frame_53=vx4 = if(bounce,sin(ref_ang)*v2*cos(w2-ref_ang) + sin(ref_ang+asin(1))*v1*cos(w1-ref_ang-asin(1)), vx4); | |
| 524 | + per_frame_54=vy4 = if(bounce,cos(ref_ang)*v2*cos(w2-ref_ang) + cos(ref_ang+asin(1))*v1*cos(w1-ref_ang-asin(1)), vy4); | |
| 525 | + per_frame_55=bounce = below( sqrt( sqr(x2+vx2-x4-vx4) + sqr(y2+vy2-y4-vy4)), 2*r); | |
| 526 | + per_frame_56=ref_ang = atan2(x4-x2,y4-y2)+asin(1); // common tangent | |
| 527 | + per_frame_57=v1 = sqrt(vx2*vx2+vy2*vy2);v2 = sqrt(vx4*vx4+vy4*vy4);w1 = atan2(vx2,vy2);w2 = atan2(vx4,vy4); | |
| 528 | + per_frame_58=vx2 = if(bounce,sin(ref_ang)*v1*cos(w1-ref_ang) + sin(ref_ang+asin(1))*v2*cos(w2-ref_ang-asin(1)), vx2); | |
| 529 | + per_frame_59=vy2 = if(bounce,cos(ref_ang)*v1*cos(w1-ref_ang) + cos(ref_ang+asin(1))*v2*cos(w2-ref_ang-asin(1)), vy2); | |
| 530 | + per_frame_60=vx4 = if(bounce,sin(ref_ang)*v2*cos(w2-ref_ang) + sin(ref_ang+asin(1))*v1*cos(w1-ref_ang-asin(1)), vx4); | |
| 531 | + per_frame_61=vy4 = if(bounce,cos(ref_ang)*v2*cos(w2-ref_ang) + cos(ref_ang+asin(1))*v1*cos(w1-ref_ang-asin(1)), vy4); | |
| 532 | + per_frame_62=bounce = below( sqrt( sqr(x3+vx3-x4-vx4) + sqr(y3+vy3-y4-vy4)), 2*r); | |
| 533 | + per_frame_63=ref_ang = atan2(x4-x3,y4-y3)+asin(1); // common tangent | |
| 534 | + per_frame_64=v1 = sqrt(vx3*vx3+vy3*vy3);v2 = sqrt(vx4*vx4+vy4*vy4);w1 = atan2(vx3,vy3);w2 = atan2(vx4,vy4); | |
| 535 | + per_frame_65=vx3 = if(bounce,sin(ref_ang)*v1*cos(w1-ref_ang) + sin(ref_ang+asin(1))*v2*cos(w2-ref_ang-asin(1)), vx3); | |
| 536 | + per_frame_66=vy3 = if(bounce,cos(ref_ang)*v1*cos(w1-ref_ang) + cos(ref_ang+asin(1))*v2*cos(w2-ref_ang-asin(1)), vy3); | |
| 537 | + per_frame_67=vx4 = if(bounce,sin(ref_ang)*v2*cos(w2-ref_ang) + sin(ref_ang+asin(1))*v1*cos(w1-ref_ang-asin(1)), vx4); | |
| 538 | + per_frame_68=vy4 = if(bounce,cos(ref_ang)*v2*cos(w2-ref_ang) + cos(ref_ang+asin(1))*v1*cos(w1-ref_ang-asin(1)), vy4); | |
| 539 | + per_frame_69=//pogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogopogo | |
| 540 | + per_frame_70= | |
| 541 | + per_frame_71=q1 = aspectx; | |
| 542 | + per_frame_72=q2 = aspecty; | |
| 543 | + per_frame_73=q3 = x1; q4 = y1; q5 = r*2; | |
| 544 | + per_frame_74=q6 = x2; q7 = y2; q8 = r*2; | |
| 545 | + per_frame_75=q9 = x3; q10 = y3; q11 = r*2; | |
| 546 | + per_frame_76=q12 = x4; q13 = y4; q14 = r*2; | |
| 547 | + per_frame_77=q30=.2; | |
| 548 | + per_frame_78=q20=4*asin(-1)*.33333333333333; | |
| 549 | + per_frame_79=q15= (sin((time+bass+treb+mid)*.4-0*q20)+1)*.5; | |
| 550 | + per_frame_80=q16= (sin((time+bass+treb+mid)*.4-1*q20)+1)*.5; | |
| 551 | + per_frame_81=q17= (sin((time+bass+treb+mid)*.4-2*q20)+1)*.5; | |
| 552 | + per_frame_82=monitor=q19; | |
| 553 | + per_frame_83=q31=pixelsx; | |
| 554 | + per_frame_84=q32=pixelsy; | |
| 555 | + per_frame_85=dx=-(bass+treb+mid)*.01; | |
| 556 | + warp_1=`shader_body | |
| 557 | + warp_2=`{ | |
| 558 | + warp_3=` float2 noise_uv = uv*texsize.xy*texsize_noise_lq.zw + rand_frame.xy; | |
| 559 | + warp_4=` float4 noiseVal = tex2D(sampler_noise_lq, noise_uv); | |
| 560 | + warp_5=` | |
| 561 | + warp_6=`float2 adj = texsize.zw; | |
| 562 | + warp_7=`//float2 adj = 0; | |
| 563 | + warp_8=` | |
| 564 | + warp_9=`float2 uvn = uv + .005*noiseVal + float2(-1.1,-1.5)*adj; | |
| 565 | + warp_10=` | |
| 566 | + warp_11=`// sample previous frame | |
| 567 | + warp_12=` ret = tex2D( sampler_main, uv ).xyz; | |
| 568 | + warp_13=`// darken (decay) over time | |
| 569 | + warp_14=` ret.x = (ret.x-1.4*q6)*(1-q6*2.5); //or try: ret -= 0.004; | |
| 570 | + warp_15=` | |
| 571 | + warp_16=` | |
| 572 | + warp_17=`float burn = saturate(GetBlur1(uvn).x + (0.5-noiseVal)*.15); | |
| 573 | + warp_18=`float fuel = pow(ret.z*1 + GetBlur1(uv).z*.0,1); | |
| 574 | + warp_19=` | |
| 575 | + warp_20=`ret.y = 0; | |
| 576 | + warp_21=` | |
| 577 | + warp_22=`if (burn > 0.1) | |
| 578 | + warp_23=`{ | |
| 579 | + warp_24=`ret.x = fuel*q6*60; | |
| 580 | + warp_25=`ret.z -= ret.z*q6*120; | |
| 581 | + warp_26=`} | |
| 582 | + warp_27=` | |
| 583 | + warp_28=`else {ret.z += 1.3*q6; | |
| 584 | + warp_29=`//ret.x = 0; | |
| 585 | + warp_30=`} | |
| 586 | + warp_31=` | |
| 587 | + warp_32=`} | |
| 588 | + comp_1=`shader_body | |
| 589 | + comp_2=`{ | |
| 590 | + comp_3=`ret = tex2D(sampler_main, uv).x, | |
| 591 | + comp_4=` | |
| 592 | + comp_5=`ret = lerp ( | |
| 593 | + comp_6=`GetBlur1(uv).x + GetBlur3(uv).x, | |
| 594 | + comp_7=`ret, | |
| 595 | + comp_8=`pow(ret,1)); | |
| 596 | + comp_9=` | |
| 597 | + comp_10=`// ret = tex2D(sampler_main, uv).x - GetBlur1(uv).x; | |
| 598 | + comp_11=` ret = pow(ret,float3(5,1,.5)); | |
| 599 | + comp_12=` ret *= 1.0; //gamma | |
| 600 | + comp_13=` | |
| 601 | + comp_14=`} |
1597 more files changed.