Shader Minifier 1.1

I’ve just released Shader Minifier 1.1. You can download the binary at the usual place.

Changes

  • New output options: use --format js to generate a Javascript file, and --format c-array to get a comma-separated list of strings (to be included in a C array).
  • Use the new option --no-renaming-list if there are identifiers you don’t want to get renamed (e.g. entry point functions in HLSL)
  • If you have #define macros, Shader Minifier will now avoid conflicts between macros and identifier renaming.
  • If your code has conditions with compile-time known values, they will get simplified (e.g. if (false), or int i_tag = 2; if (i_tag < 4) ...).
  • If there are many identifiers in your code (this probably won’t happen in a 4k intro), Minifier will now use 2-letter names if needed. This is not correctly optimized, but some people use this tool for obfuscation, instead of size-optimization.
  • The option --preserve-all-globals won’t rename any global variable or any function. This is useful if your shader is split between multiple files.
  • You can now tell the Minifier not to parse some block of code. Put your code between //[ and //] and it won’t be parsed, identifiers won’t be renamed, but spaces and comments will still be removed. This is very useful if you want to use features not yet supported in the tool (e.g. forward declarations, or layouts).
  • Other fixes in the parser (macros can be used in a function block, numbers can have suffixes, etc.)
  • Unix support. Use this zip file instead of the standard release, install a recent version of Mono (at least 2.10) and run mono shader_minifier.exe. This should work.
  • Online Minifier. You can use shader minifier online, but only one shader at a time.

Who is using it?

During the last year, many great intros have used it with great success.

  • Another Theory, by FRequency (#1 at Main 2010)
  • white one by Never (#1 at the Ultimate Meeting 2010)
  • anglerfish by Cubicle (#1 at Assembly 2011)
  • RED by BluFlame (#1 at Evoke 2011)
  • akiko by flopi (#2 at Riverwash 2011)
  • fr-071: sunr4y by farbrausch (#1 at Sunrise 2011)

4 thoughts on “Shader Minifier 1.1

  1. Witek

    Program has problems with parsing some key features of HLSL syntax.
    For instance: “RWTexture2D g_OutBuff;”. It doesn’t expect “<" symbol after type identifier.
    Another example: "cbuffer g_GlobalParams : register (b0)". Colon symbol is here unexpected.
    It would be great if this bugs were solved.

  2. LLB Post author

    As a workaround, you can probably use the //[ … //] syntax.
    Full HLSL support is definitely on my TODO-list (I think it’s the most asked feature), but I have no idea when I will implement it.

  3. gormio

    Awesome, Unix support \o/

    I have a problem, though.

    The minifier might produce GLSL code similar to this:


    vec3 m(vec3 m) {
    }

    vec3 n(vec3 m) {
    return m(m);
    }

    This fails to compile. If I understand it correctly inside the function n the name m refers to the variable passed as an argument and hides the function name m. Hence the function m can’t be called from function n. I think another name needs to be used for the argument passed to function n in order for this to compile successfully.

    On another occasion I saw code that looked similar to this:


    vec3 m(vec3 m) {
    }

    vec3 n() {
    vec3 m = vec3();
    return m(m);
    }

    A similar problem: inside n the local variable m hides the function name m but n still tries to call it. Doesn’t compile.

Leave a Reply

Your email address will not be published. Required fields are marked *