It's Raining Cubes

So a dozen years ago I wrote “hey, 4 kilobyte intros are starting to get interesting”. Fast forward to 2019, and we made an attempt to make a 4KB demo with my team at work. None of us have any previous size-limited demo experience? ✅ We have no idea what the demo would be about? ✅ Does it have a high chance of being totally “not good”? ✅ So we did the only thing that made sense in this situation – try to do it!

We did not follow the modern trend of making 4KB demos that are purely “one giant shader that does raymarching”, and instead did most of the code on the CPU in C++. Physics simulation? Sure why not. Deferred rendering? Of course. Just write it in regular programming style, without paying that much attention to size coding tricks (see in4k or sizecoding)? Naturally.

Maybe that’s why this did not fit into 4 kilobytes :) and ended up being 6.6KB in size.

Executable: ItsRainingCubes.exe (6.6KB)
Source: Zip with VS2019 projects
Pouët: Link

Tech details:

  • Verlet style physics simulation. Simulates points and springs between them; also approximates each cube with a sphere :) and pushes points outside of them.
  • Deferred rendering (world’s most pointless deferred usage?) with colors, normals and the Z-buffer. There’s one shadowmap for the light source. The whole G-buffer is blurred (including depth and normals too!) with an Masaki Kawase style iterative filter and then the lighting is computed. That’s what produces the bloom-like outlines, soft edges on cubes and weird shadow shapes. It should not have worked at all.
  • Music is made in Renoise, using 4klang for playback.
  • Executable compressed using Crinkler, and shaders minified using Shader Minifier.
  • Visual Studio 2019, C++, OpenGL (compatibility profile with some GL3/GL4 extensions) was used.

Credits: Ascentress, shana, TomasK, NeARAZ.

Youtube video capture:

While it’s not impressive by any standards, I kinda expected us to achieve even less. Again, no previous experience in this area whatsoever! Four (well ok, almost seven…) kilobytes is not much, but with tools like Crinkler (great executable size reporting there, by the way - here’s an example) it’s manageable. There’s some wrestling with MSVC if you want to ignore all the default libraries, like you have to make your own implementations of _fltused, _ftol2(), _ftol2_sse(), memset(); load functions like cos() manually from the old msvcrt.dll, and so on. Funtimes. But once the basic setup is done, then it’s “just programming” really.

That’s it! Go make some demos.