4kb of code generated this amazing video

Discuss

38 Responses to “4kb of code generated this amazing video”

  1. Kevin Pierce says:

    Nice work.  To me, it says a lot about the current state of graphics acceleration.

    • John Radi says:

      Can you explain that briefly for a techie non-programmer?

      • 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.

        • Glen Able says:

           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.

          • 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.

      • DooBie says:

        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.

  2. Cowicide says:

    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.

  3. good to know the demo scene is still kicking.

  4. nixiebunny says:

    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 ][.

  5. nixiebunny says:

    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 ][.

    • If it’s in the black box, it’s free.

      • nixiebunny says:

         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.

        • ZikZak says:

          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.

  6. Nathaniel says:

    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.)

    • ZikZak says:

      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.

      • Glen Able says:

         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.

      • Nathaniel says:

        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.

  7. FrodeSvendsen says:

    Anyone remember this one? http://en.wikipedia.org/wiki/.kkrieger 1st person game with stellar graphics in 96K..

    • jlargentaye says:

       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/

  8. 10xor01 says:

    I’m truly humbled.  Back to my mindless corporate data mulching…

  9. Ben Carlsen says:

    4kb of code also produced this:

    http://www.youtube.com/watch?v=jB0vBmiTr6o

    EDIT: Oh, and 1kb of code produced this:

    http://youtu.be/qQNIKOD6WnY

  10. rarrr says:

    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.

    • Glen Able says:

       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.

      • nixiebunny says:

         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.

  11. Dan Century says:

    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.

    • metamaterial says:

       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…

    • Eric Rucker says:

      And some demo parties actually explicitly ban using network resources for just that reason.

  12. Egypt Urnash says:

    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.

    Lovely but THERE’S NOTHING BUT HOLES and WHAT’S ON THE OTHER SIDE.

  13. thermoplasticity says:

    It reminds me of Orphid nets and Beezies.

  14. 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

    8k..

    (╯°□°)╯︵ ┻━┻

  15. License Farm says:

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

Leave a Reply