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:
- Retrospection
- Original: 1462 (hand optimized)
- Minifier 0.4: 1429
- Minifier 0.5: 1421
- Valleyball
- Original: 2240 (using old BluFlame minifier)
- Minifier 0.5: 2184
- Another theory
- Original: 1511 (hand optimized)
- Minifier 0.4: 1475
- Minifier 0.5: 1463
- Lunaquatic
- Minifier 0.4: 2635
- Minifier 0.5: 2613
- Sult
- Minifier 0.4: 1411
- Minifier 0.5: 1408
- Slicesix
- 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!
Keep on the great work. I´am impressed :)
Source please! …or at least a binary for OS X.
Something went wrong in the last release, but Mono-comptibility will be fixed for the next release (to make it work on Linux and Mac). In the meantime, you can try the limited online version: http://www.ctrl-alt-test.fr/minifier/
The following code works with the online minifier but produces a parse error using the .net executable:
uniform mat4 uModelviewPrjMatrix44;
uniform vec4 uUniColor;
attribute vec3 aVertexPos;
varying vec4 vPointColor;
void main(void) {
vPointColor = uUniColor;
gl_Position = uModelviewPrjMatrix44 * vec4(aVertexPos, 1.0); // parse error in this line.
}