Multithreading

After quite a bit of frustration, the engine now supports multithreading. I thought it would be one of those things that it would take months to figure out. Thankfully, however, threading wasn't that scary. It just took two solid nights of frustrating failures.

But that's over now, and launching multithreaded jobs is sleek and easy. The polygonization algorithm (Crawling Cubes), which was my main motivation for exploring multithreading, received around a 20 to 25% speed up after making it multithreaded. Unfortunately, that's not as good as I was expecting (I thought using two cores would make it somewhere in the vicinity of twice as fast...). Still, any improvement to procedural mesh algorithms is one that I'm most certainly willing to take, considering how pivotal these algorithms will be in ANR.

I'm also working on advanced metaballs that include rotation, and should have some progress to report in that field (get it?) sooner than later.

Text, Transparency, and Tonemapping

Since I don't have class this week and I'm putting off studying for finals, I've had a lot of time to make improvements to the engine.

First, the shader library (XSL) has been restructured. Previously, it was just too spread out to keep track of. Each shader had its own header file that contained only a few lines of code. Now, all shaders are kept in a set of anonymous structures that make for extremely easy access. Shaders can be access with the convenient dot-notation ("shaderLibrary.Draw.Pretransformed") and are automatically loaded and managed by the shader library class. This makes adding new shaders much, much easier than before. I've also created some macros that allow some of the larger shaders (read: Perlin noise shaders) to be disabled completely for the sake of executable size.

Second, I've implemented render-to-surface capabilities, so that the geometry is now rendered to a texture, which is later rendered to the backbuffer. Postprocessing can occur in between by using the ping-pong, double backbuffer technique.

Third, text now renders correctly with a transparent background and customizable coloring.  This hinges on a new option for alpha-blending in the device.

Finally, I wrote a little pilot postprocessing shader that performs simple tonemapping on the input using power functions.

Add it all together, and here's what you get:

Not bad at all.

Per-Triangle Picking

After about a month of ultra-slow progress, per-triangle picking is finally done. It's really not that picking is a difficult problem, it's just that the framework to do it correctly and efficiently took a good deal of work. It required implementation of AABBs, ray structures, ray/AABB collision testing, ray/triangle collision testing, and, finally, CPU-side vertex buffers for fast memory access.

It may not be the most complex human-computer interaction ever, but being able to drag the output of Crawling Cubes around the screen sure is fun.