The new version of our tool is released! Here is the changelog:
- Allow forward declarations in the input code and remove them (functions are automatically reordered). Please use the syntax “int foo(int x)” and not “int foo(int)”.
- More intelligent renaming based on the context the variable is used.
- Allow structs in source code, fields are not renamed. Field names cannot look like vec fields (.rgb, .r…) because I haven’t written the typer yet.
- Remove the –macro-threshold option. Will be fixed in a future version.
- As usual, several bug fixes
The most important news is the improvement on the renaming strategy. In the 0.4 version, the Minifier tried to reuse the same variables again and again, and increased the frequency of a few characters. Now, it’s getting more complex: the name of a variable depends on how it is used.
For instance, if you often call functions “max” and “mix”, you’ll often have the “x(” pattern. Thus, GLSL Minifier will probably name your function x to increase of the frequency of this pattern. The same goes for each two-char pattern the tool will find.
Here are some statistics I’ve just made, using shaders from 4k intros. I’ve taken a short C file, inserted the shader as a string, compiled, and compressed using Crinkler (/COMPMODE:SLOW /ORDERTRIES:3000). So, it’s all about making the shader compress better. Numbers are the filesize in bytes:
- Original: 1462 (hand optimized)
- Minifier 0.4: 1429
- Minifier 0.5: 1421
- Original: 2240 (using old BluFlame minifier)
- Minifier 0.5: 2184
- Another theory
- Original: 1511 (hand optimized)
- Minifier 0.4: 1475
- Minifier 0.5: 1463
- Minifier 0.4: 2635
- Minifier 0.5: 2613
- Minifier 0.4: 1411
- Minifier 0.5: 1408
- Minifier 0.4: 2493
- Minifier 0.5: 2432
Conclusion: If you’re not using any tool to minify your GLSL shader, I bet you could save at least 20 bytes on your 4k intro. Try and see!