XScreenSaver 6.15 is out now, including
iOS (soon) and
Android. A whopping
thirteen new savers this time:
- New hack by me, worldpieces.
- New Shadertoy hacks brought into the fold: bestill, bubblecolors, darktransit, downfall, driftclouds, goldenapollian, noxfire, prococean, rigrekt, trainmandala, trizm and universeball.
Shadertoys are so wild; you'll see like 30 lines of code, and when it runs it build an entire environment without there being a polygon or a model apparent anywhere. What witchcraft is this?? Well, here's a really good article that explains the techniques used: Painting With Math: A Gentle Study of Raymarching.
I fixed a bunch of Android bullshit, too (some of which meant needing to reimplement glRotatef etc. from first principles). Android's implementation of GLES is a buggy mess. Also I think Android has again lost the ability to ask for permission to load photos. I can't figure it out, so someone who gives a shit will have to send me a patch. I also still can't figure out why transparency doesn't work on Android. This makes Peepers be particularly horrifying.
Map Scroller: I updated the list of available maps, and made it show the name of the nearest city. One of the new map sets that works is the Google Satellite Map, and if you have two monitors, I highly recommend running that map in "Fully random location" mode. It has a habit of picking two places many thousands of miles apart that look surprisingly similar, like Greenland and Syria.
Boy do I have a lot to say about
World Pieces: This one took so much time! Most of my screensavers are pretty quick; generally they'll percolate in my head for a while, then I do the first 90% in half a day, and then the second 90% in another half day to two days. But this one was composed entirely of ratholes.
- Oh, first I have to find some sane way to get the country outlines. That means learning about GeoJSON and getting the proper data set from Natural Earth Data. Then that data has to be massaged and merged, and while there's probably some command-line way to do that, using mapshaper.org was easier.
- Now I've got a bunch of polylines with weird "hole" rules (not winding-rule!) and I need to triangulate them. Next rathole: learning how to use triangle.c correctly.
- Then I notice that while the GeoJSON has population data for countries, it does not for states and provinces. Ok, that should be easy to grab from Wikipedia, right? Next rathole: learning about SparQL, the Wikidata query language. It is one of the nastiest and most baffling query languages I've seen. Good job on that.
- Then I realize that while the GeoJSON contains the names of the countries translated into various languages, it doesn't tell you which ones are the official languages! Next rathole! Ok, surely we can get that from Wikidata too... Nope. While the Wikipedia pages contain the endonyms in the local character set, the Wikidata items only have them transliterated into Latin characters. To fix that, I had to scrape the Wikipedia page and parse the Wiki markup using regexps, dooming us to inhuman toil, etc. etc. Anyway, I got it working so that Japan can be spelled 日本...
- ...on macOS, iOS and Android. Why doesn't it work on Linux? Oh ho ho ho, another rathole, this one un-solved! So on Linux it notices when all of the characters came out as square boxes and falls back to the transliterated Latin versions. You're welcome.
- Ok, it's starting to come together. But since I'm zooming in a lot, the Earth imagery is looking a little grainy, since the image I have is 2048x1024. Well let's just go upgrade that. Next rathole! The old images I had were from the public domain 2002 NASA "Blue Marble" images and 2000 "Visible Earth, City Lights" images none of which still exist on NASA's site (all praise archive.org!)
They seem to have deprecated those data sets in favor of the 2025 "Blue Marble: Next Generation" images and the 2012 "Black Marble" images. But... they're weird. First, both sets of images completely omit the North polar ice. Second, the 2025 daytime oceans are colored completely flat, whereas the 2002 images contained bathymetry details. And third, and worst of all, is no pairing of 2025 day images and 2016 night images where the pair have the same ice extents. This means that when we blend between the day and night images, it looks very weird. It took me days to finally accept that there was nothing that I could do to work around that.
- So now that those various ratholes are out of the way, it's trigonometry time. The way the countries pop up and face forward toward whereever the camera is a technique called "billboarding" and it's pretty easy. But what's not easy is doing a smooth transition between the object being billboarded, and the object being back in the scene. Especially since it's position in the scene is spinning and wobbling about willy-nilly. (Remember, you can also spin the globe with the mouse, and it has to keep track of that as well!)
- So the final rathole was finally coming to terms with quaternions. Quaternions and I have had a passing acquaintance for many years, but I finally had to get down and dirty and really understand them to make all of this work.
Wikipedia describes quaternions as:
Quaternions form a four-dimensional associative normed division algebra over the real numbers, and therefore a ring, also a division ring and a domain. It is a special case of a Clifford algebra, classified as Cl₀,₂(ℝ)≅Cl⁺₃,₀(ℝ). According to the Frobenius theorem, the algebra ℍ is one of only two finite-dimensional division rings containing a proper subring isomorphic to the real numbers; the other being the complex numbers.
"I did not understand a math thing, and then I read the Wikipedia article on it, and now I understand the math thing" -- said literally no one ever. As far as I can tell, every math article on Wikipedia is written with the target audience of "person who wrote their grad school thesis on it" and no one else. Wikipedia's math articles are absolutely fucking useless for purposes of, you know, education.
Anyway, 3Blue1Brown has a good intro video that is not like that!
By the way, I propose that "Quaternions" should be pronounced like extruded cornmeal toroid "Funyuns".
Previously, previously, previously.