4kb of code generated this amazing video

And Akronyme Analogiker wrote the code. [Creative Applications]


      1. A lot of useful routines are already “baked into” the video card — so a single line of code can trigger an effect (such as light blooming) that is actually performed by more elaborate code in the hardware itself.

        I think that’s what he means! Some folks think that modern demoscene stuff is ‘cheating’ unless it avoids OS libraries and shader languages and what have you.

        1.  Not quite.  (Note, I’ve just taken the shader code and converted it to the shader language of DirectX, so I have a fair idea what it’s doing!)

          The shader code is all primitive stuff – mostly just basic operations on 3d vectors.  The power of the GPU is just that it has hundreds of units for doing lots of these operations in parallel.  So there’s nothing in this demo that’s really “cheating” – other than necessary high level operations like creating the window etc.

          Regarding the noisy scanline effect – I think this is a slightly cheeky addition to cover up the fact that the fractal is being rendered at a rather lower res than it’s presented at!

          All very impressive anyway.

          1. The creator’s description says they added the scanline affect to avoid it looking too “sterile”, but I think you may be right! Great effect either way.

      2. I’m not an expert coder, but I am enthusiastic about math.

        The reason why so much visual complexity can be packed into such minimal code is because all the objects are fractals.  You only need to write the first iteration of the fractal, in an absolutely minimal amount of code, then say repeat and shrink forever.  Fractals are essentially self-compressing, while demonstrating infinite complexity from a set of simple rules.

  1. Wow, and the new 4K MP4 option from YouTube is now in place as well.  It’s 620 MBs, but I’m downloading it now because this video is worth it.

    This is some of the best stuff I’ve ever seen with fractals.

    The only thing I don’t like is the banding effect with the scan lines he added. I love the atmosphere and love, love, love the rays of light, but the old-school scan lines take away from the detail I was hoping to see after watching the 1080p MP4 just now.

    I’m still downloading the 4k Revision to see what on earth that looks like.
    update: watched the 4K…. seriously, ditch the scan lines, ugh… so great except for that.

      1. It’s like Leonardo da Vinci added a special touch to his Mona Lisa at the end by getting out a ruler and drawing lines across it…

        Goddam scan lines…

      2. I kinda dug the scanlines, cause they reminded me of this sweet clip:

        I love this 4k of code… 3D fractals are the bomb.

  2. It’s 4kb of code on top of Windows 7, you meant to say. There might be a few million extra lines of code in *that*.

    I’d be truly impressed if it was 4kb of code running on an Apple ][.

  3. It’s 4kb of code on top of Windows 7, you meant to say. There might be a few million extra lines of code in *that*.

    I’d be truly impressed if it was 4kb of code running on an Apple ][.

      1.  Well, I could write a one line program that does this, if I convinced the library author to write a library call that creates a video.

        1. But then so could anyone else, so it wouldn’t impress too many people.
          On the other hand, the above video is quite impressive.  Because contrary to what you imply, it’s very hard to create something so detailed and beautiful within such tight constraints. 

          It requires both aesthetic and technical creativity, because the tools you’re using are not designed to do what you’re trying to do.  In that sense, it’s a kind of hacking.

  4. Correction: a 4K *executable* generated this amazing video. (I was disappointed not to find a 4K block of line-noise-like C code at the link.)

    1. Demoscene stuff like this is written in assembly, so the code is the executable.  Part of the art is creating machine code by hand that’s more elegant than any compiler could come up with.

      1.  The important part of this code is actually in GLSL (the C-like high level shader language).   The original code is actually larger than 4k, I think, but it’s preprocessed to e.g. shorten all the variable names to 1 letter.

        This shader code is compiled when the app runs, by the OpenGL driver.  In many cases this compiler can do a better job of optimising than most people (unless they’re really expert, and willing to spend a looong time on it). 

        Assembly language is mostly important in a demo for making the very small executable framework that initialises OpenGL etc. – not for performance reasons.

      2. Even assembly code is larger than the executable.

        MOV AL, 61h

        is 12 bytes (including the newline), but the assembler compiles it to something like B061, which is 4. In any case it’d still be cooler if you could see the code.

    1.  Hell yeah. The authors recently posted a post-mortem of it, including a horrible hack to get it under under the size limit. https://fgiesen.wordpress.com/2012/02/13/debris-opening-the-box/

  5. Amazing stuff, although I’m curious to know how small they could make it with just a boot disk i.e.  Here’s a floppy disk, get it to look like that but EVERYTHING has to fit on here.

    1.  It’s an interesting question.  The hardest bit would be driver code to make the video card work (this would be hardware-dependent and would require proprietary knowledge).

      What people seem to be missing is that this is really just a good old simple fractal-drawing app:  for each pixel, do some iterations of a function to find the value, and output a colour.

      You could actually port this to e.g. a BBC micro with maybe a thousand lines of basic – I estimate it would take a few months to render each frame.

      1.  That’s a contest I could get into! Back when I was a wee lad doing graphics, it was on machines that took a detectable amount of time to move every pixel. There was a real art to getting snappy graphics performance with limited hardware. These days, it’s too easy. A fractal program may only require 4k of code to work, but it takes trillions of GPU cycles to do its magic.

  6. I’ve noticed that some demos pull extra code or other assets in via http. Not sure about this one. I’d love to see the source code, if only to to hack it.

    1.  This one… wouldn’t really need to. If there were a cityscape with cars and flowers or the like, I might wonder. But here, as an author said, it’s a fractal. So they _could_ have done that, but…

  7. Normally I am not one to be tryptophobic – I love looking at 3D fractals – but wow, this demo made me start to understand here that fear is coming from.


  8. Challenge accepted!
    $ echo “main(){}” > test.c
    $ gcc test.c
    $ ls -l a.out
    -rwxrwxr-x 1 tadas tadas 8326 May 11 13:27 a.out


    (╯°□°)╯︵ ┻━┻

  9. Bloody lovely. Anyone else reminded of the old Atari Lynx game “Gates of Zendocon”? No? Anyone remember the Lynx? No? Righty-o, then, Martha!

Comments are closed.