Real-time ASCII/Unicode rendering in Javascript - Ray Tracing (part 3)
Here is a shot of the latest build. Gaiapp has added antialiasing and motion blur.
Source can be found at my github.
Here is a shot of the latest build. Gaiapp has added antialiasing and motion blur.
Source can be found at my github.
As an Xmas present to all the backpackers lost in Europe, we’ve decided to drop the price of Europe Travel Guide from $0.99 to Free.
Since it’s free, we might as well go all the way and open-source the code. I’m sure the community could add more features like maps and reviews. If there’s interest I will clean up the code and put it on github.
If you would like to produce some renders of the Mauldin Gasket like the one above, you can check out the C code on my github. And, set NUM_THREADS = the number of cores on your machine for best performance.

The TSP asks us to visit all cities in a graph with the least possible cost. I recently put together a solution to this problem that relies upon the Ant Colony Optimization heuristic.
This method is embarrassingly easy to parallelize: each ant is given his own thread to execute on. You can check out the code (python) on my github.
I tested it with the Norway graph above (14 cities) and it zips along quite nicely. I would like to hear how it performs with larger networks.
Recently I was involved in developing a radio app a certain mobile provider wants to pre-install on all their new phones. Near the end of the project, testing revealed that a handful of the new phones had a firmware bug which prevented them from playing MP3 streams (AwesomePlayer would consistently crash).
We tried a few workarounds with so-so results. The best of these involved writing chunks of the stream to files and then having MediaPlayer play these short files in sequence. No crashes here, but pops and gaps were noticeable.
Writing off MP3-streaming entirely, we asked our stream provider to give us something else. All that was available was an FLV-wrapped HE-AAC source. While aacdecoder-android is able to play AAC streams, we needed a way to extract the AAC frames from the FLV container and pass them through.
The FLV format consists of a series of blocks called “tags” of different types. A typical file has a few hundred bytes of AUDIO followed by a few hundred of VIDEO, then AUDIO, etc. There are also metadata tags that can contain song-info or album art. For our purposes, we only concerned ourselves with the AUDIO tags and the raw AAC data contained within them.
Raw AAC data is unplayable by aacdecoder-android unless you provide some header info. ADTS is the header format you need to use to tell your player about the AAC version, sample rate, and frame length. I chose to make a frame out of the 300 bytes or so of raw AAC data extracted from each tag but I could have easily merged multiple chunks into one frame. Every frame is required to have this ADTS header.
I contributed FlashAACInputStream.java and FlashAACPlayer.java back to the aacdecoder-android project. To start playing FLV-wrapped AAC streams just pass the stream url to the play() function of FlashAACPlayer.
There was a nice reaction to my raytracing demo on reddit and I got great feedback. One redditor has been helping me optimize the codebase and we’ve open sourced our combined efforts. Here is a demo of the current build (NB: broken rendering in OS X). Much smoother.
The rendering is nearly fast enough for use in games. A simple 3D Asteroids isn’t out of the question.
If you would like to contribute to the project, it is hosted on github.
UPDATE: Here is the demo of the current build. If you want to contribute to the project, it’s all hosted on github
Stepping things up a notch. I managed to get real-time raytracing working at an acceptable framerate (with ASCII rendering of course). Play with the demo.
I’m not able to get Chrome and FF to render <pre>’s the same way yet. At the time of writing the demo looks better in FF than Chrome, but it screams in Chrome without any threading. Some credit goes to the author of JayTracer, a canvas-based renderer. I took quite a bit of core code and built upon it, adding optimizations where I saw fit. If anyone wants to further optimize this go ahead.
As I approach my high-20s birthday I’m feeling nostalgic for the demo coding days of my youth. I was never on the level of FC but managed some real time fire demos, plasma, bump mapping etc.
I was playing around with ASCII rendering to a <pre> block and it’s fast enough in modern browsers to pull off a reasonably high resolution fractal zoomer: Demo here.
Collaborating with Peter, we produced another Android app.
Basically, it’s an offline Wikitravel with just the most important European pages. It’s good for backpacking when you have unreliable internet.
Compressing 200+MB of pages down to a 22MB app was slightly challenging. We ended up extracting all the content from various sections and storing in JSON on the filesystem. I also found out that the encodings on some wikitravel pages are a mess and had to write a script to isolate non-UTF-8 sections, guess the encoding with chardet, decode that, and then stitch everything back together after re-encoding to UTF-8.
It costs $0.99, and you can get it here. When there’s time we will release a free version, only containing country information (no cities, regions, excursions, etc.).
Travel sites have consistently annoyed me. When you want to explore your options for getting from Country A to Country B you’re basically stuck plowing through a drop down of cities. Using a dataset I found somewhere it was short work to reorganize things into a db that lets you search flights from country to country. I packaged everything into a Titanium-based Android application. It’s called Budget Airlines Beta, and you can download it for free.
The flight-data will need to be refreshed soon and since I’m busy with other projects I may open source this app if there’s interest.