15 Years of Shader Minification
8 comments
·May 10, 2025monokai_nl
Thank you for making this tool. I'm calling it in a custom webpack plugin so it transforms GLSL code into a single minified string on every build / watch event. I used this setup for my latest artwork: https://monokai.com/work/origin
pjmlp
The pain of GL shaders, only because they don't embrace modern programming like modules and bytecode delivery.
That is how one ends up with shader minification.
And this is still quite actual as pain point, given how shaders work in 3D Web APIs.
akomtu
With recursive #defines it would be possible to do LZW compression.
zombot
>
#define R return
OK, that was not what I thought of when reading "shader minification".pests
Thankfully that’s not what the article is about, three paragraphs later it is noticed this has no savings after compression.
keyle
The author is referencing the demo scene, where they often have to meet very tight budgets in terms of space, so everyone is on an equal footing and it makes for very interesting wow moments.
null
I wrote this article mainly for the people in the demoscene. If anything is unclear or missing for the Hackernews audience, I'm happy to answer questions here.
If anyone wants to try it, I've made a web build: https://ctrl-alt-test.fr/minifier/
I might write a more general article later on writing code minifiers, e.g. how it compares to writing a code formatter, how to implement the transformations, etc.
On the tech side, the code is written in F#. The web build uses Bolero (Blazor for F#). So maybe I'll write later about my experience writing an open source project with F# and evolving it.