• by laurentlb on 5/13/2025, 6:34:50 AM

    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.

  • by monokai_nl on 5/13/2025, 5:40:56 AM

    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

  • by pjmlp on 5/13/2025, 6:24:10 AM

    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.

  • by sagacity on 5/13/2025, 7:20:01 AM

    This is an awesome tool, thanks Laurent! Currently using it for my next 64k intro which will probably ship sometime in 2047 :)

  • by slimbuck on 5/13/2025, 7:33:27 AM

    Have you tested the shader's runtime performance penalty after minification?

    Also wondering how you handle named uniforms?

  • by akomtu on 5/13/2025, 6:06:43 AM

    With recursive #defines it would be possible to do LZW compression.

  • by zombot on 5/13/2025, 5:00:35 AM

    >

      #define R return
    
    OK, that was not what I thought of when reading "shader minification".

  • by gitroom on 5/13/2025, 9:39:47 AM

    Man, 15 years grinding on this is hardcore - big respect, love this kinda craft.