Hacker News new | past | comments | ask | show | jobs | submit login
Source code for 4kb demoscene production “Elevated” released (2016) (scene.org)
169 points by ddtaylor on June 6, 2022 | hide | past | favorite | 74 comments




This demo marks the beginning of the SDF era in the demo scene. If you watch most demos from 2009 they still use solid geometry. elevated showed the superiority of just using fragment shaders for everything. By 2009 the GPUs where fast enough to do SDF and people had come up with the idea of ray marching.


"Elevated" does not use a SDF, it is based on a grid mesh displaced with a vertex shader.

Iq, the main author of "Elevated" is indeed best known for popularizing SDFs in the demoscene, but for that particular intro, the SDF raymarching trend had already started and he wanted to do something different.

https://iquilezles.org/articles/function2009/function2009.pd...


Well, not really, even its readme file mentions previous work. Look no further than iq's previous demos, for example. Also, anyone who is interested knows when the phrase “zero polys and shaders” was sung.

However, “Elevated” had great visuals, great music, captivated people, and at the same time was a 4 kilobyte demo. It became a milestone instantly, as told by cheering on live video. And it became natural for 4K demos to implement everything in a shader to eliminate the rest of the code and be competitive on the new level of visual performance.


Using SDFs and other pure maths to build these kinds of demos makes me wonder why we don't just build a whole game this way.

Why not go one step further and just skip the geometry pipeline altogether? Most of the stuff I see on shadertoy has absolutely nothing to do with triangles.


Claybook[0] uses SDF throughout. I don't think any of the game is conventional poly-based geometry.

Having built with both SDF and conventional geometry, it's much easier to find excellent 3D modellers than it is to find people who can build with SDF though.

[0] https://ubm-twvideo01.s3.amazonaws.com/o1/vault/gdc2018/pres...


> it's much easier to find excellent 3D modellers than it is to find people who can build with SDF though.

Maybe we simply need to develop a more intuitive domain-specific language for artists to work at this level of abstraction? The benefits of working this way are incredible to me... Just in that one presentation you find quotes like:

  > Runtime performance not dependent on brush count
  > O(1) particle<->SDF collision detection
  > Perfect LOD


I'm curious, was the music included in that 4kb demo?


Yes. It's generated in realtime along with the visuals.


From what I understood it should be. If you look at the source code there is music.asm with what seems to be tables of data describing the music data and synth.asm with synthesizer interpreting it.


4k intro available only in 1080p


4k as in a limit of 4096 bytes of data for the whole demo. It’s a standard demoscene category: https://www.pouet.net/prodlist.php?type%5B%5D=4k&page=1


The size of the actual code is a small fraction of a single frame of the video stream it generates.


ahhh 4KB...


Crinkler, the compressing linker, is really interesting. This link inadvertently shows the file_id.diz for Crinkler rather than anything relevant to the rest of Elevated; but honestly I always found the Crinkler stuff to be fascinating.

The project lives on today: https://github.com/runestubbe/Crinkler and http://crinkler.net/


It is a very impressive pice of technology. The crazy part is the decompressor. It is ~200 bytes of handwritten x86 assembler, tuned for code smallness over 15 years. If you go to the release page, you see every time the shaved one or two bytes of of it. It’s also interesting how compression is done. They do only care about output size, not compression time. So it is possible that you just wrote a couple of KB of GLSL and the compressor takes 12 hours to squeeze that into your 4k demo.


Do you know if anyone has a good write up of some of the advanced techniques crinkler uses? I started reading the manual.txt file but it's pretty big!


This is a write up.

https://in4k.github.io/wiki/crinkler

And some more info from 2005 seminars. (search for crinkler)

https://files.scene.org/browse/parties/2005/assembly05/semin...


Source code can also be viewed online via https://madethisthing.com/iq/Elevated , which is a platform made by one of the demo developers to share code.



Man that little "downloads in the past 30 days" tracker is cool. (HN made it a hockey stick.) It'd be cool if every indie/amateur website had that in lieu of the old "webcounter".


I think Source Forge used to have that sort of a graph.


Maybe the universe is a demo written by the gods in <4kb


The Mandelbrot set comes to mind.

It has a many aspects one would want from a good universe.

Infinite detail. But not "boring". The digits of PI have infinite detail too, but when you don't know the algorithm itself, they probably look just random. Which would be boring. But the Mandelbrot set exhibits many nice patterns one can learn and reason about.

The algorithm that creates the Mandelbrot set can probably be implemented in less than 400 bytes.


I can do you a 276 byte version using `dc`?

2k64sw32sh7sz[.]0:p[,]1:p[:]2:p[o]3:p[]4:p[O]5:p[@]6:p[ ]lz:p5lw/si4 lh/sj0 2-dsxsu0 2-dsysv[0 2-dsxsu[luSalvSblzdsnSq[lqSn0Sq]Sm[laddSoSs LoLslb2* SoSsLoLslbd-lu+Salv+Sbcladlbd+4<mlqd1-Sq0<g]sglgxladlbd* +4 0sr[1sr]st>tLrln;pPlilu+ Sulu2>h]sh lhx[]pljlv+Svlv2>f]sflfx


This thread is quite interesting, if the universe is that simple does that imply a complex runtime? Because DC itself should probably be taken as part of the universe here as well as the OS and the hardware it all runs on.

So then the question becomes what is the absolute minimal hardware and software configuration that you could use to generate a mandelbrot?


> if the universe is that simple does that imply a complex runtime?

There is a tradeoff to be made between (algorithmic) information specified as a program/software versus an interpreter/hardware http://www.hutter1.net/publ/ctoex.pdf

However, all we really need is a Turing-complete runtime, which can be very simple, e.g. https://en.wikipedia.org/wiki/Rule_110 https://beza1e1.tuxen.de/articles/accidentally_turing_comple...

One easy way to make our universe is to run all possible programs (even if you don't think our universe is computable, we would still end up running simulations which are indistinguishable to arbitrary precision). We can even apply an anthropic argument to this: that the vast majority of programs are not universes conducive to containing life, but we must necessarily find ourselves in one which is.

https://www.kurzweilai.net/in-the-beginning-was-the-code


My feeling is that there is no such thing as a "minimal configuration" when it comes to universes.

Because there is no way to evaluate how "minimal" a configuration is.

No matter which elementary property you assume the universe to have, one would have to ask "Is that a complex thing?". Is gravity complex? Is an electron complex?


This reminds me of all the episodes of Closer to Truth[1] about the question "Why is there something rather than nothing?" He's absolutely relentless with that question, over two decades now, asking every single famous philosopher, mathematician and scientist he can find. Here's one from around Season 3 around 2009[2], another from season 12[3] a few years ago and so on.

1. https://www.youtube.com/c/CloserToTruthTV

2. https://youtu.be/cfmewf2DoKU

3. https://youtu.be/YkB-phz_2cA


This question is maybe the deepest of them all. What a great project, can't wait to check these videos out.

My understanding of an answer I've heard is along these lines:

If there is truly nothing then that means there are also no bounds/limits/rules, which means there is nothing stopping everything from being. Out of nothing comes the boundless cornucopia of existence, from complete lack of constraints that is nothingness.


That got a bit mangled - proper version here[1].

[1] https://rjp.is/dcmando.txt


I think that was one of the theories roughly suggested by NKS https://en.wikipedia.org/wiki/A_New_Kind_of_Science though the work seems to have fizzled out.


Not what I really believe (I would rather have some data for that kind of thought/belief), given all the wierdness of reality, I tend to joke more and more often that we live in a simulation. This one (demo) is a beauty - always on the lookout for some exceptional demos. ^^


I like to imagine the outside universe has no computational limits. When you write code there, you can init an array of 10*1000 elements and have a loop that does heavy math over every pair of them, but it still runs instantly.


Elevated is one of the most atmospheric, cinematic demos I've ever seen, and the fact that it takes only a fraction of the disk space of the icon used to represent it in the file-manager is ridiculous.


Demos of this caliber are like F1 cars from 60 years ago: a single genius, or small team, creating something totally beyond the reasonable expectations of everyone who is familiar with the technology in question.

I really hope it continues to be possible for this art form to exist.


The most impressive one for me will always be fr-08, the .product, released in 2000:

https://www.youtube.com/watch?v=1dcrV_7JpXQ

Pouet link if you want the binary: https://www.pouet.net/prod.php?which=1221

It blew my mind when I first came across it in 2003, and it's still highly impressive even now.


The most impressive for me, in a slightly different way, is A Mind is Born, because it manages to do some simple but impactful sound and video in 256 bytes, on a Commodore 64:

https://news.ycombinator.com/item?id=26511266


I still listen to that song just by itself. It's such an amazing demo.


I was at a film festival, and saw a short film about AI or something. The film used just the music for the end credits! I told the director i appreciated the reference, and he was amazed someone recognised it.


His other work is great too: https://www.youtube.com/watch?v=sNCqrylNY-0


My most favourite demo of 2000 was "Heaven 7" by Exceed [0]. That someone could do smooth raytracing (of course with many tricks, but still...) was mindblowing for me.

[0] https://www.pouet.net/prod.php?which=5


Ah man you just took me back to middle school. The 90s and the 2000s were such happy times in my life. Everything Farbrausch produced evokes such happy memories.

For whatever reason I became obsessed with this lesser known demo called g-cube and watched it a lot in 2011.

Just wanted to share(anyone remember it?): https://www.youtube.com/watch?v=fc0gh5wnItw


When I watched the '.the .product', my perspective about the computers have shifted dramatically and permanently. I became an high performance programming (not in HPC sense) enthusiast, and decided that performance and optimization matters.

That path brought me to HPC, efficient and high performance programming and showed me how thinking about writing efficient code made a difference.

Yes, you can't arrive to demoscene level wizardy in every application/tool you write, but optimizing the obvious and then some changes things a lot.

Thinking about it again, possibly coming from C64 and early x86 hardware already primed me to "do more with less" mindset already, but '.the .product' get the things rolling.


How would one even learn how to do something like this?

I feel like I have a high level understanding of most parts of the stack, but graphics programming has eluded me thus far.

Would writing a ray tracer be a good starter project? I know I've seen it recommended by several people before.


Thankfully for the graphics the very person who did the graphics in this Elevated demo is very generous with their time. Inigo Quilez has many instructional videos on his channel in how to code procedural graphics from the very beginner to the advanced. I link a couple of examples. You can watch the more advanced video even as a beginner but trying yourself is easier at the beginner level.

Beginner. https://youtu.be/0ifChJ0nJfM

Advanced. https://youtu.be/BFld4EBO2RE

Website. https://iquilezles.org/


Indeed his videos are amazing. My recommendation though would be to start with the "beginner" video -- which is completely 2D but at least gets some ideas across. Then watch https://www.youtube.com/watch?v=PGtv-dBi2wE which isn't his but introduces how you get 3D out of fragment shaders. Finally just drink from the firehose -- https://www.youtube.com/watch?v=Cfe5UQ-1L9Q is fantastic, yes it's five hours but worth it. (Definitely come into that familiar with the idea of raymarching though... the first few minutes start off super basic but it goes to eleven real quick.)


great! Thanks for your course!


For basic 3d graphics rasterization concepts and implementation check out 500 lines C++ TinyRenderer and its wiki here: https://github.com/ssloy/tinyrenderer and the 100 lines Python version (only numpy dependency) here: https://github.com/rougier/tiny-renderer

Raytracing in a weekend is also useful: https://raytracing.github.io/



I appreciate the recommendation to start with JS, I'm actually trying to avoid targeting the browser as much as possible with my projects, with the exception of things actually returning hypertext or that I get for free via wasm or something else.

The Book of Shaders looks quite interesting however, thank you for the link!


I'd encourage you to reconsider that. Using WebGL lets you skip over a lot of tedious initialization. Or, even better, using a platform like shadertoy.net lets you skip all the JS as well and just write shaders.

Using these tools doesn't mean your final project has to be JS-based as well. It just happens to be a convenient way to focus on specific aspects of the project.


A good starterpoint would be any old 8 bit machine with bitmapped memory and a copy of Newman and Sproull.


And finally 'Elevated' commented in Shadertoy with links to the techniques on his blog.

https://www.shadertoy.com/view/MdX3Rr


Specific to this demo, Inigo Quilez did a breakdown back in 2009 called 'behind elevated' for Function 2009 but I can't find it on his site today. Maybe it's there. But here's the archive link to the pdf.

https://web.archive.org/web/20120119015415if_/http://www.iqu...


> Would writing a ray tracer be a good starter project?

Yes!


I fell the synth is overlooked. There's a lot going on there in a tiny amount of code.


Definitely true! I've played around with audio a little bit before, and am a little more comfortable there (though by no means proficient).


>I really hope it continues to be possible for this art form to exist.

Hopefully AI doesn't one day ruin the demoscene as well. Seems like a Pandora's box for cheating and/or asymmetric resource advantages.


The same may have been said about most other technologies introduced. The fact that a Windows .exe can do a lot more because it has access to DirectX doesn't invalidate the effort made in a demo of the same size made for the C64. There simply are different categories.

I don't think they'll be much ruining going on. The people who make these demos use everything they can get their hands on, as long as it helps with cool visuals, a great soundtrack, and sandal executable size. In terms of how they get there everything seems to be allowed and even expected. And if one of those things is a trained network, so be it. Many groups have their own custom tools or even one-offs for only one demo.


Well put, I think you're correct.


Sorcery. This is not possible by mere mortals to do in 4kb.


It's a little more possible now that iq has spent years teaching us all how to do it though


kB, not kb.


The creator's homepage is a treasure trove https://iquilezles.org/


According to the intro description it was made in 2009.


The intro was made in 2009. The code was released in 2016.


Any idea how large the source code was before minification and Crinkler? In curious how much Crinkler actually compresses it. 25% ? 50% ?


that kind of careful developer is becoming rare nowadays, sadly..

all about slowing down the computer nowadays, including build time cough like rust cough


Imagine if this beast did a “No Man’s Sky”-style game


If with "this beast" you mean Inigo Quilez, he worked at Pixar for a while, made shadertoy, and teaches the world maths via shadertoy, his own website and his yt channel. So he's doing pretty well I'd say

[0] https://www.shadertoy.com/

[1] https://iquilezles.org/

[2] https://www.youtube.com/c/InigoQuilez/videos


Just in case you're interested, there's an FPS made with similar techniques, called .kkrieger. The game itself if <96kB, and won the team a competition in 2004.

https://en.wikipedia.org/wiki/.kkrieger


Astonishing. Thank you.


just wanted to share: dwitter.net




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: