Show HN: Bitwise Liminal – A Short Film in 256 Bytes of Code (killedbyapixel.github.io)

450 points by KilledByAPixel ↗ HN
A Short Film in 256 Bytes of Code

Programmed by KilledByAPixel Presented at Lovebyte Party 2024

...

I found an old VHS tape at a yard sale. It was labeled "Bitwise Liminal" in sharpie. But when I watched the video it was only static.

Then I started having vivid and... unsettling dreams. Also I couldn't stop thinking about that weird VHS tape. After researching I learned it was a digital backup. Using some special software I recovered the data. To my shock, it was a 256 byte program...

With trembling hands I opened it in a web browser. Strange. This reminds me of the dreams I've been having. Now I don't need to sleep anymore. I just keep watching.

...

l ɐ u ᴉ ɯ ᴉ ⅂ ǝ s ᴉ ʍ ʇ ᴉ ᗺ

  <canvas id=c><svg onload=setInterval("for(t+=.1,R=T=C=Math.cos,c.width=w=128,i=9986,V=t/9&3;Y=i--/w;c.getContext`2d`.fillRect(X,Y,(C(t/6)*T^V*i/1e4*T+t)%20?(R=T++,1):(T=9,19/R),5/Z))for(Z=5,X=i%w+4/R;0<(V*95+C(t/3)+Z*X/64-Z^Z|(60-Y)*Z/58)%13;Z+=.2);",t=9)>

68 comments

[ 2.7 ms ] story [ 127 ms ] thread
(comment deleted)
What the fuck. How?
Ray marching, most likely.
Yes, this raymarching, though the vhs effect was really the trickiest part.
A minor note: this is the first time I've seen an svg embedded in a canvas purely for it's onload event. Within this context the canvas is referred to by its (bare) id. How strange and wonderful!
I noticed and thought the same! Pretty cool.
Why is that allowed? I didn’t realize one could do that in js.
If you nest any valid elements inside an unknown element like <asdf>...</asdf>, browsers just ignore the invalid wrapper element but still display the nested children. This fact is exploited by spec authors when introducing new tags to allow backwards compatibility: elements like canvas, video and audio all specifically allow optional children that are automatically hidden - but they won't be hidden in older browsers that don't know about the new elements. This allows you to easily define arbitrary fallback content for older browsers that don't support the new elements, just by nesting children in them.
It turns out that packing it into an svg onload is a tiny bit smaller then using a script tag!

It is possible to save a little more space by putting it in the canvas onclick event.

(comment deleted)
I can't stress enough how much I admire that it is true 256 bytes, instead of usual 1k game jams, where submissions are presented as zipped, gzipped, and postfixed, and not including assets to fit the criteria.

Hats off.

Is "import gameassets" allowed in those competitions?

On a side note "import GOTO" works in python :)

> On a side note "import GOTO" works in python :)

Never heard of this, and it doesn't work on my interpreter (tested with both 2.7 and 3.11). Are you sure it's not a third party package?

thank you! it is a crazy challenge that is just shy of being impossible that seems like magic when it actually works.
> [...] where submissions are presented as zipped, gzipped, and postfixed, [...]

Well, you can always include a decompressor in your entry. PNG bootstrap has been popular enough in the JS demoscene for a long time and it starts to be effective for 1K or larger demos. There are other alternatives for smaller sizes, and 256B demos just happen to be too small to put any kind of decompressor in general.

> [...] and not including assets to fit the criteria.

I do agree on this aspect though.

Fantastic.

Also this would be perfect as an SCP.

Their work is always jaw-dropping. Here is some explanation of the tools they use: https://frankforce.com/tools/

And here's their work on the micro animation blog Dwitter: https://www.dwitter.net/u/KilledByAPixel

Youtube explanation: https://www.youtube.com/watch?v=HV7Dmo277Rs

That “YouTube explanation” doesn't actually explain how any of the Dweets work. Don't get me wrong, his work is amazing, I loved seeing it and I'm excited to listen to him show it off; I'm just saying that anyone looking for a detailed walkthrough of how any of it works, that video will disappoint.
TIL that elements with ids are exposed as global variables in JS.
I've also noticed this a few years ago, but where is this documented? Was it already the case in IE6 for example? Have you found any definitive source, which states this behaviour?
Stuff like this makes me believe that the entirety of life really could be encoded in DNA. I've read that if you gzipped the human genome, the file would be about 4MB, which intuitively seems too small to represent a human. But if this behavior can emerge from 256 bytes, then clearly my intuition is off.
Is a misconception that DNA is enough by itself to replicate a living being, there are biological bases in the embryon that need to be pass down from the parent as biological infraestructure for the new being to form.
You're absolutely correct, just as you'd be correct to observe that these 256 bytes require a fairly complex software platform running on fairly complex hardware.

And all these things, including us, operate within the fabric of the universe, whose complexity is only beginning to be understood.

But in theory, would it be possible to genetically engineer a simple life form, like a bacteria, to eventually produce a human, in a process similar to the kind of metamorphosis you see in insects. Of course, this the bootstrapping code would take quite some space, but if we could do that (at least in theory), it essentially means that all you need to make practically any living being is a single generic cell and a few megabytes worth of data encoded as DNA.

I mean, when we get infected by a virus, our cells are able to produce a completely different life form (if you consider viruses life forms), so why not going from a bacteria (which can also be infected by viruses) to a mammal. It will obviously take a lot more code, and evolution can't get us there, but the idea is similar.

It could be a 4 megabyte-long seed for a random generator.
4MB are enough to discriminate between 2^(3.2 * 10^7) possible states. Suppose you have a decompressor that can interpret a percent of a percent of a percent of a percent of those states as functional lifeforms. There are about a trillion species on the planet[1]; let's say there are a trillion times as many potential species that don't currently exist and a trillion variations within each. And then let's multiply by another trillion for good measure. Wolfram Alpha tells me[2] we've left a margin of error of roughly* ten to the ten million.

[1]https://www.nsf.gov/news/news_summ.jsp?cntn_id=138446

[2]https://www.wolframalpha.com/input?i2d=true&i=Divide%5BPower...

*'roughly' in the sense that a mountain range is roughly coarse sandpaper, but too round not to round to

Even a SHA-256 hash would leave 10^31 margin of error. The "percent of a percent of a percent of a percent" part is sweeping a lot under the proverbial rug here ;)
Life generated from DNA in a vacuum would probably be pretty boring. The entirety of life requires some surroundings to interact with, and as it stands there is but one of those, and singular things don't compress well.

Also, have a look at the Mandelbrot set again. There's quite a lot of information in, arguably, a very modest process.

And finally, to suggest that these 256 bytes are less impressive than they are, consider what hardware and software is needed to support it. These 256 bytes would not lead to the same illusion on a C64.

> There's quite a lot of information in, arguably, a very modest process.

But quite low in Kolmogorov complexity.

You can add image-rendering: pixelated on the canvas element to remove the blurring. Mind you, that may be an intentional effect.
(comment deleted)
Is there an annotated version breaking down each part of this for us lesser mortals?
I've had a stab at decompressing the code by hand, adding comments and meaningful var names where possible. I still don't understand the maths in it...

https://github.com/callumlocke/bitwise-liminal-expanded

Just a guess, the speedup is probably due to you caching the 2d context.
Looks like the maths is a kind of raymarching loop if you want to read up on it.
This made my 5560U ramp it's sysfan up 100%. :-)
Love seeing demoscene on HN. Excellent work.
This is impressive and actually looks like a real movie scene. And to think this only fits in 256 bytes makes you rethink how bloated the things we are using everyday are and also how powerful current browsers are.

I am however more impressed by the 8K demos such as "the Sheep and the Flower" [1] which was shared on HN recently or "One of those days" [2] which is a remake of an actual Youtube video [3] (granted not exactly the same video by the second but the style is immediately recognizable). They are way bigger than this 256 bytes movie but convey a lot more graphics and story.

[1]: https://news.ycombinator.com/item?id=39121101

[2]: https://www.pouet.net/prod.php?which=75790 and YouTube video: https://youtu.be/8T_Um-cw0Wc

[3]: https://www.youtube.com/watch?v=R1NagZN2kjY