Kevin Reid's blog

Latest Posts


Kevin Reid
My Website



Skipped Back 20

July 8th, 2012

Status update


Arrived in California a few days ago; setting up assorted arrangements. I start work in a week.

June 30th, 2012

Porting GLToy to WebGL


Started a new project, GLToyJS; I’m porting my GLToy to WebGL. The advantage, besides using a higher-level language and modern OpenGL (shaders!), is that it is more cross-platform, rather than being a Mac-only screensaver. The disadvantage is that it’s not a screensaver at all, but a web page; I plan to add a wrapper to fix that, and I have a working proof of concept.

So far I’ve put together the core framework and ported 6 of the original 13 effects (most of the in-my-current-opinion good ones, of course). An additional feature is that an effect’s parameters are described in JSON, which will be used to allow you to save a particularly good random result for future viewing. (I could just put them in the URL, in fact — I think I’ll try that next.)

I haven't yet created any new effects, so nothing takes obvious advantage of the additional capabilities provided by shaders (other than refinements such as Phong-rather-than-Gouraud lighting and GPU-side particle systems). I also wrote a sketchy compatibility layer for the GLSL Sandbox’s interface so that you can drop in a fragment shader from there to make an effect; a possible thing to do would be automatically downloading from their gallery (if politeness and copyright law permits).

It's not published as a web page anywhere yet, but it should be and I’ll let you know as soon as it is.

June 25th, 2012

The draft-standard Gamepad API allows JavaScript in the browser to obtain input from connected gamepad/joystick devices. This is of course useful for games, so I have worked on adding support for it to Cubes.

This (about) is the only Gamepad API demo that I found that worked with arbitrary gamepads (or rather, the junk one I had around) rather than ignoring or crashing on anything that wasn't a known-to-it devices such as a PS3 or Xbox controller. (It's part of a game framework called Construct 2, but I haven't investigated that further.) It was critical to my early setup in making sure that I had a compatible gamepad and browser configuration.

(There's a reason for libraries having information about specific devices — the Gamepad API just gives you a list of inputs and doesn't tell you what the buttons should be called in the user interface — and these days you're almost expected to have pictures of the buttons, too. But there's no reason not to have a fallback, too. Incidentally, the USB HID protocol which most gamepads use is capable of including some information about the layout/function of buttons, but this information is often incorrect and the Gamepad API does not expose it.)

In order to integrate gamepad support into Chrome, I used Toji's Game Shim library, a very nice lightweight library which only adapts browser-provided interfaces to the current draft standards so that you can use the Gamepad API, as well as requestAnimationFrame, fullscreen, and pointer lock, without making your code full of conditionals or browser-specific prefixes.

June 7th, 2012

Graphics bugs are fun


An early stage in the development of lighting in Cubes (long since past).

May 28th, 2012

It seems I entirely forgot to blog this previously: Google hired me full-time after my last internship; I start in July. I'm currently working on all the arrangements for getting myself there, which includes:

I want your recommendations for housing in Mountain View, CA or the close vicinity.

I am interested in recommendations either for permanent housing or a temporary place-to-stay (so that I can do research in person). I intend to initially pack two-suitcases light and have All My Stuff shipped later, so just about anything will do temporarily, but for permanent housing I am thinking of something along the lines of a one-bedroom apartment, though I would consider some sort of sharing.

Update: I have found a room for my immediate needs. I am still interested in recommendations for permanent housing.

I particularly desire, not general advice on how or where to search unless it is especially specific, but personal recommendations of locations you or a friend have had a good experience with.

Regarding location, these attributes would be of interest: comfortably accessible by public transport and/or bike routes (that is, I plan to attempt to get away with not owning a car); close to Google's campus (Amphitheatre Parkway); and lastly, close to such amenities as a good grocery store. But above all else, I want your recommendations of quality and value.

May 12th, 2012

(no subject)


Tags: ,

May 4th, 2012

Done, done, done,



I have completed my last final exam and my last course project of my last semester. I will be graduating a week from now. I have a job starting in July.


Tags: ,

April 23rd, 2012

I've got the notion to do an occasional Minecraft video series, mainly to show off my mechanism designs and otherwise increase the value (to other people) of all those hours I spend playing. I bought screen recording software just for the purpose.

However, I haven't gotten around to recording an “episode” yet (mainly because I wanted to start with a script to reduce the “um”s, and make sure I have a quiet environment, and that hasn't coincided with enthusiasm for the project). The following video is just a test of recording and uploading to YouTube; there's no voice-over and it's short.

Let me know what you think of this proposed endeavor. I figure to do tours of existing builds with a focus on mechanism, not playing on camera.

April 2nd, 2012

Run your program on a platform slow enough that you

  1. care, and
  2. can feel where the problems are.

(Something — I assume a Chrome update — caused Cubes to run more slowly. Over fifteen seconds of startup time is just not fun for debugging, so I went looking for problems. Unfortunately, it wasn't anything straightforwardly bad, but the heaviest thing in the profile was the color-picking while constructing the default blockset, so I optimized that and got the startup down to about six seconds. Still slower than it really ought to be.)

March 13th, 2012

You've probably heard (if you’re a programmer) about the cardboard programmer or rubber duck debugging.

These days, my rubber duck is the Ask a Question form at Stack Overflow (or another Stack Exchange Network site appropriate for the topic at hand). Writing a clear and considered question serves the same purpose as the hypothetical cardboard cutout or coworker — and if you don’t find your solution by the rubber duck method, then you have the question all ready to go, so no effort is wasted.

I haven’t gotten around to talking about it before, but I’m a big fan of Stack Exchange — it's a great place to get answers and give them, and focused on being a good resource in the long term and for all the web, not just another forum for discussions.

[profile for Kevin Reid on Stack Exchange]

March 9th, 2012

Cubes update


Some new features in Cubes:

  • An automated test suite. It’s hardly complete coverage, but at least it exists and so can grow. (I ended up going with Jasmine for in-browser testing. I’m not a big fan of the Englishy syntax, but it does the job reasonably well and has niceties like rerunning individual tests and adequate support for asynchronous tests.)
  • Precise collision against rotated blocks: you can now walk up the slope of those funky pyramid blocks, and so on. Stairs, anyone?
  • Performance monitoring widget with fancy graphs. (If you click the “[-]” to hide it, then it won’t waste CPU time updating itself, either.)

February 22nd, 2012

.innerText and .textContent


Today I learned that there is a standard-DOM alternative to the convenient IEism element.innerText (a close relative of element.innerHTML): element.textContent.

It is slightly different, according to MDN: .innerText returns the visible text (omitting scripts and CSS-hidden text), whereas .textContent returns everything, more like walking the document tree.

(This information crossed my awareness while working on Caja, but I didn't recognize it as something I could actually make use of until now.)

February 17th, 2012

My favorite git aliases

	st = status
	hw = help -w
	ff = merge --ff-only
	unpushed = log @{u}..

February 16th, 2012

I’ve uploaded almost all of my published Git repositories (previously hosted on a git-only server on on, which is down at the moment) to my account on GitHub. Please update your remote URLs if you have any git clones.

The motivation for this change is simply that GitHub offers better visibility — an automatic web presence for each project, including viewing repository contents. I am not intending to depend on GitHub’s continued existence, of course; I still have local copies of each project, and additionally I plan to arrange so automatically mirrors my GitHub repositories.

What I've just uploaded to GitHub also includes a project which I have not previously mentioned, timeline-ui:

A user interface experiment. Multiple types of time-series data, variously static/interactive, historical/future, etc. are displayed in a single view. (This was an idea I had floating around and which I used in 2010 for a class project; there is a lot more that could be done with it.) Written in Java.

I was going to write more about the concept, but I never got around to it; this will have to do.

List of projects just moved to GitHub:

February 3rd, 2012

Cubes vs. Minecraft


[I was asked about Cubes “Where do you think you might take the game play next?” and it turned into this.]

My original motivation for creating Cubes was a combination of the “blocks out of blocks” idea — which itself came from immersion in the graphics of Minecraft — and also dissatisfaction with certain bugs, limitations, and design choices in Minecraft. As a result, I’m not just building a voxel game; I’m building a game that shares what I like about Minecraft.

(What I like about Minecraft, broadly, is survival and engineering — I like building structures and machines to make my virtual life easier.)

Now, creating a Minecraft clone would be lame, rude, closer to using someone else’s intellectual property, and just plain unoriginal. But I don’t have experience with what little exists of a genre of voxel building games to synthesize my own thing, and I myself am looking for something like Minecraft. What can I do? Here’s what I’ve been trying:

  • Be different.

    Whenever I see an opportunity to do something specifically unlike Minecraft, that doesn’t compromise what I’m trying to do, I take it and see what happens. However, most of these experiments have failed; for example, Cubes originally had a larger-scaled player character, but this turned out bad because it means tunneling and building is 8× more tedious, and it reduces the apparent size of the world. Also, it leads to thinking “OK, add this feature Minecraft has — but (superficially) differently!”

  • Be generic.

    This is my long-term goal, and it is one that ties neatly into the “blocks made of blocks” theme. The characteristics of blocks can be defined by building circuits (programs) inside them. What I’m aiming for is that by creating a blockset (collection of block designs which the player can build with), one is defining the game that can be played, by giving those blocks specific behaviors.

    In this way, I am working towards having a game which can be programmed to emulate Minecraft.

    (I have a working prototype of an importer for Minecraft worlds as well as for Minecraft blocks — that is, turning the terrain.png from a Minecraft texture pack into Cubes' 3D blocks — but I am not going to release that code until and unless I determine that Mojang doesn’t mind my doing so. I still love Minecraft and they deserve my not stepping on their toes that far.)

    However, this means both that Cubes itself needs to be very generic, and that the built-in example uses of such features should feel different from Minecraft.

So, returning to the original topic of “where am I going next”, I need to add the following functionality to the game world:

  • Extend the circuits feature so that there can be blocks that are active and interactive (e.g. opening and closing doors, “physics” like Minecraft falling sand and growing plants).

  • Add moving objects (for vehicles and mobs). I intend to generalize these so that they are worlds in themselves — this will allow large or unique vehicles, and mean that they can be designed using the same game tools.

  • Add some form of resource constraints/conservation laws (as in Minecraft survival mode) — that is, you have to gather stuff to make it into other stuff. I haven’t figured out specifically how I want to do this yet, and this seems particularly tricky to make programmable. One idea that keeps coming to mind is that when you break a block, specific subcubes are “resource cubes” (according to their type in the block world) which you collect, and in order to place a block you need to have the corresponding resources for its type. However, I’m not sure I like the “raw material counter” feel of this.

  • Add player attributes that can be modified (e.g. health) so that e.g. death, or other effects-by-the-world can be supported.

Less grandly, I plan to work on one of these specific technical features soon:

  • Allowing circuit blocks to be rotated to change their connectivity. (Right now, circuit blocks have specific faces — e.g. on a certain one the +X direction is always the output.)
  • Figure out what more circuit primitives I want to add. (Right now, the circuits are definitely not Turing-complete, and not capable of all the effects on the world they should be, but there are also already a lot of different primitives; I may have to invent new block-picking UI just to make them practical.)
  • Add moving objects (bodies) — things which can collide with the terrain as the player does. The current code is entangled with player behavior, and the player does not persist in a world.
  • Add subworld/multiple-world handling — the ability for more than one world (grid of blocks) to be present in the same space. Right now, there are hardwired assumptions that the player is in the single world’s coordinate system.

Another core feature which is currently missing is the ability to design a blockset and then reuse it for multiple worlds. The problem right now is that we're using a simple object-graph serializer, so each world has its own blockset which is modified independently. To fix this, it needs to be possible to save a blockset under a user-visible name, and have individual worlds which reference that blockset; also, the world generator needs to decouple blockset generation from terrain generation. The “persistence” framework which added support for multiple worlds is a step towards this; the main thing I am pondering is what the semantics of these separate-named-persistent objects are and what the user interface for editing them is.

January 13th, 2012

Based on the feedback I’ve received, I conclude that the white-screen/crash problem with Cubes is hardware/driver-specific and not very widespread. Since

  • this is a hobby project and an experiment, not a Game to be Published,
  • the problem looks hard to debug,
  • I don't have a variety of machines to test on, and
  • I replaced the MacBook Pro in question with a newer model which does not exhibit the same problem,

I have decided not to debug it further at this time. I've added a note about the problem to the documentation, and I’ll instead work on the problems Cubes exhibits on the new machine :-) (such as a speckling of not-the-right-texture-tile at the edges of blocks, and a strange input lag) or adding new features, like more useful saving/persistence, sub-block collision detection, or subworlds.

December 29th, 2011

I upgraded to Mac OS X 10.7 Lion this month, and ever since then Cubes has crashed or otherwise misbehaved on my machine. However, I have only the one to test on, so I would like your help in figuring out what the extent of the incompatibility is — whether this is a GPU driver bug or something Cubes is doing wrong.

If you have a WebGL-capable browser (such as Chrome or Firefox) and GPU, and especially if you're running Lion or are otherwise similar to my configuration, please run Cubes (no installation is required) and tell me whether it works and what your system configuration is, including these properties:

PropertyI have
Hardware modelMacBookPro5,1
GPU modelNVIDIA GeForce 9600M GT
OS versionMac OS X 10.7.2
GPU driver version?
Browser versionChrome 17.0.963.12, Firefox 8.0

(For some MacBook Pro models such as mine, the GPU used (9600M or 9600M GT) depends on the “Graphics” setting in Energy Saver preferences.)

The problems I observe are:

  • All blocks (terrain) being flat white except for lighting; the sky and particle effects still have color. (For the interested, this appears to be a mis-execution of the over-unity-to-white code introduced in commit 48674f….)
  • After some amount of usage, a crash (in Firefox, the browser exits; in Chrome, the display goes gray and the Web Inspector console says “WARNING: WebGL content on the page might have caused the graphics card to reset” while the in-page text says “Previous GL errors: INVALID_OPERATION”).

I will appreciate any help as this is making it quite impractical to work on Cubes.

December 5th, 2011

I just invented a new (to me) abuse of the C preprocessor. From a Stack Overflow answer I just wrote:

My understanding is that you are defining a constant, using it later to size one or more arrays, and also want that constant to be a symbol, preferably without a messy namespace. (If it were a matter of exporting the size of a single array, I would instead suggest sizeof(array) / sizeof(*array) as missingno did.)

static const int ASIZE = 10;
#define ASIZE            10
int array[ASIZE];

Here, there is a variable with the desired value which will be in the object file, but the preprocessor macro shadows it with the value itself, so the array definition also succeeds.

However, you may find the need to duplicate the value expression ugly. Wouldn't it be nice if we could define the variable in terms of the macro?

static const int ASIZE =
#define ASIZE 10
int array[ASIZE];

I'm not sure whether this is actually a better idea maintainability-wise than the above, but it works (and I couldn't get gcc to be offended by it) and it contains no duplication other than of the identifier. And it's amusing.

Previous C adventures: A dreadful thing

Tags: ,

November 16th, 2011

I need to stash this info somewhere; might as well be well-indexed.

Stereo photos such as those taken by the Nintendo 3DS, with a .MPO file extension, are actually JPEG right-eye images with the left-eye image embedded as extra data. They can be interpreted as JPEG files (perhaps after changing the extension to convince your software to read them), and the left-eye image can be extracted with exiftool, as follows:

exiftool input.mpo -mpimage2 -b > L.jpg

A standalone right-eye image without the extra data can be produced with

exiftool -trailer:all= input.mpo -o R.jpg

Source, via.

November 13th, 2011

I've finally gotten around to uploading my custom Mac OS X keyboard layout. The most significant additions over the standard U.S. keyboard layout are: mathematical symbols (relevant to calculus and symbolic logic), Greek characters, and arrows. It also makes (, ), :, and | unshifted.

Powered by