Shader Minifier by Ctrl-Alt-Test [web] | ||||||||
---|---|---|---|---|---|---|---|---|
|
||||||||
|
popularity : 70% |
|||||||
alltime top: #1670 |
|
|||||||
|
||||||||
added on the 2010-06-15 23:26:07 by LLB |
popularity helper
comments
hell yes !!
woo
The name alone is worth a thumb. ;)
I wonder how such tool fits in the workflow of a demo coder.
Wouldn't it be nice have such tool in JS ? It would to work online and offline, be smaller, not require .NET or Mono. I doubt there would be any noticeable speed difference. Idealy this could be combined with something à la ShaderToy to see the result right away and be able to tweak the original shader, minify it, compare sizes and results.
Wouldn't it be nice have such tool in JS ? It would to work online and offline, be smaller, not require .NET or Mono. I doubt there would be any noticeable speed difference. Idealy this could be combined with something à la ShaderToy to see the result right away and be able to tweak the original shader, minify it, compare sizes and results.
really cool LLB, I did once a ShaderStrip equivalent handling vertex and fragment shader uniform problem... but I was not enough motivated to integrate a full parser! ;) Nice job!
I read that you have used F# and FParsec for the lexer/grammar... I'm not a huge fan of functionnal programming, but I have to admit that when it comes to lexer/parser, the syntax is extremely close to what we would write in a lex/yacc... without the pain of a more complex build chain and integration into the host language...
@p01, well shader obfuscation is mainly used when you are coding a 4k in c/c++/asm, checking compression ratio against crinkler, so I don't really see benefit of a cooperative usage with shadertoy... and It's indeed nice to have such a tool integrated in an intro build process.
I read that you have used F# and FParsec for the lexer/grammar... I'm not a huge fan of functionnal programming, but I have to admit that when it comes to lexer/parser, the syntax is extremely close to what we would write in a lex/yacc... without the pain of a more complex build chain and integration into the host language...
@p01, well shader obfuscation is mainly used when you are coding a 4k in c/c++/asm, checking compression ratio against crinkler, so I don't really see benefit of a cooperative usage with shadertoy... and It's indeed nice to have such a tool integrated in an intro build process.
Nice!
(hehe, LLB, from your resume, I understand now why you are using F#... :D )
great!
it makes it smaller, no doubt, but does it make it compress better? :)
ace
Nice idea, nice execution :)
But somehow I'm still more into the idea of murdering myself by writing obfuscated, ugly code from the start haha
But somehow I'm still more into the idea of murdering myself by writing obfuscated, ugly code from the start haha
Oh, and nice name <3
Can someone bother to recompress some intro using it to see what happens?
Anyway nice useful tool.
Anyway nice useful tool.
good job!
with em defines for globals its absolutely working.
i prefer to do the job by hand tho, more control of bytes ;)
with em defines for globals its absolutely working.
i prefer to do the job by hand tho, more control of bytes ;)
koryuken
nice one could use later on D:
r0x0r, very very nice !
Melikes ++
Melikes ++
i've been waiting for that. cool!
Basically great, but it doesn't support forward declaration of functions, which our 4ks need:
Code:
Parse error: Error in src\shader.fs: Ln: 12 Col: 19
vec4 traceRay(vec3, vec3, int);
^
Expecting: Ascii letter, digit, identifier, whitespace or '_'
LLB & @lx: I know the main use case of that tool is for 4K intros. The impact of the obfuscation/minification on the compression ratio slipped my mind :p
My idea of having such tool written in JS and integrated with shader preview was to be able to spot the eventual errors and glitches introduced by the minifier and to reduce the turn around time ( no need to re-compile ). To allow for more tweaking.
But yeah shaders optimization belong in the intro build process, regardless of the language.
My idea of having such tool written in JS and integrated with shader preview was to be able to spot the eventual errors and glitches introduced by the minifier and to reduce the turn around time ( no need to re-compile ). To allow for more tweaking.
But yeah shaders optimization belong in the intro build process, regardless of the language.
Awesome !
God is French it turns out.
Nice tool.
Nice stuff! Have anyone tried how much space it gives after compression?
One question: why does it always leave leading zeros before negatives?
I mean transformation "-.3 -> -0.3".
One question: why does it always leave leading zeros before negatives?
I mean transformation "-.3 -> -0.3".
yep, remove that zeroes !
also i might add that no software ever was able to replace any human being !
4ks are humans prods made by humans and stripped down to few of bytes by humans !
DONNOT rely on software if you wanna obtain full control of what is going on ! ;)
also i might add that no software ever was able to replace any human being !
4ks are humans prods made by humans and stripped down to few of bytes by humans !
DONNOT rely on software if you wanna obtain full control of what is going on ! ;)
what i wanted to say is:
making 4ks is fun for coders, so dont spoil any fun by using any software, just do it by hand !
its worth the effort ! :D ( also you´ll teach yourself how to code your next 4k in a better way everytime you go through any stripdown-phase ! )
if you do 4ks you are seriously doing major-demoscenish stuff so dont cut yourself by taking the easy road !
making 4ks is fun for coders, so dont spoil any fun by using any software, just do it by hand !
its worth the effort ! :D ( also you´ll teach yourself how to code your next 4k in a better way everytime you go through any stripdown-phase ! )
if you do 4ks you are seriously doing major-demoscenish stuff so dont cut yourself by taking the easy road !
hardy, that depends on you being as efficient as the program at stripping :)
Quote:
4ks are humans prods made by humans and stripped down to few of bytes by humans !
DONNOT rely on software if you wanna obtain full control of what is going on ! ;)
Even software made by humans? ;-)
hArDy, just out of curiosity, do you use Crinkler? ;-)
Seriously, this tool doesn't prevent you from working to the last byte on a 4k. But it will do some nasty job for you, like the statistical analysis for naming.
More importantly in my opinion, it allows to work on a human readable code. The time you don't waste concentrating on obfuscated code can be wisely spent on content and size optimization. :-)
And no doubt you will still have plenty of low level work to do.
Seriously, this tool doesn't prevent you from working to the last byte on a 4k. But it will do some nasty job for you, like the statistical analysis for naming.
More importantly in my opinion, it allows to work on a human readable code. The time you don't waste concentrating on obfuscated code can be wisely spent on content and size optimization. :-)
And no doubt you will still have plenty of low level work to do.
exactly what i said !
so why asking ?
i wouldnt want to have some rewritten code and need to find out first what got renamed to what instead of renaming it all by myself and still having the control of what is what !
ofcoz if you think its worth it, use that tool and youll be fine ! i wont !
so why asking ?
i wouldnt want to have some rewritten code and need to find out first what got renamed to what instead of renaming it all by myself and still having the control of what is what !
ofcoz if you think its worth it, use that tool and youll be fine ! i wont !
Yep, I've read your discussion in the forum just now.
Sounds like a perl job. Implementation on .NET -- why-oh-why???
Quote:
Sounds like a perl job. Implementation on .NET -- why-oh-why???
Nah mate, this is a perl-job.
awesome tool!!! thank you :)
Awesome tool, but macros have compatibility problems:
- variables/functions can't be named like keywords on ATI:
- variables/functions can't be named like keywords on ATI:
Code:
- redefinions in the same scope:#define t vec3
t t=t(0,1,2);
Code:
#define s scale;
uniform float s;
const vec3 s=vec3(0,1,2);
Code:
for(int c=0;c<9;c++){float c = 1.;}
Is there any alternative for HLSL? Anyone knows? :)
Wow how come I missed this, really sweet idea. Thanks a lot for taking that extra step and doing something most of us were talking about for a long time but didn't do because we're too lazy. :)
@merry: little after GLSL Minifier, someone started TinyHLSL. Though, seeing the code, so far the tool is way more basic.
thx for sharing
Thumbs for this. Keep working on it, please!
you might have more feedback in your BBS topic
gotta try this out sometime
Awesome work!
I'm using this tool for my 8k intro.
And I have some suggestions.
My program is using 'glBindAttribLocation' and 'glTransformFeedbackVaryings'.
These functions take input and output vertex attribute's names in vertex shader.
So 'in' and 'out' variables in vertex shader needs to be '#define' like uniform variables by GLSL minifier.
And my program using multiple shaders and they share same name uniform variables.
So I want GLSL minifier write #define names which have shader file name.
e.g.
glsl_minifier.exe foo_vertex_shader.vs -o foo_vertex_shader.vs.h
foo_vertex_shader.vs
in vec3 in_normal;
in vec3 in_texcoord;
out vec3 out_normal;
out vec3 out_texcoord;
uniform samplerBuffer positions;
void main()
...
foo_vertex_shader.vs.h
#ifndef FOO_VERTEX_SHADER.VS_H_
# define FOO_VERTEX_SHADER.VS_H_
# define FOO_VERTEX_SHADER_I_IN_NORMAL "n"
# define FOO_VERTEX_SHADER_I_IN_TEXCOORD "t"
# define FOO_VERTEX_SHADER_O_OUT_NORMAL "o"
# define FOO_VERTEX_SHADER_O_OUT_TEXCOORD "u"
# define FOO_VERTEX_SHADER_U_POSITIONS "p"
const char *foo_vertex_shader_vs = ""
"in vec3 n,t;"
"out vec3 o,u;"
"uniform samplerBuffer p;"
"void main()"
...
Thank you.
I'm using this tool for my 8k intro.
And I have some suggestions.
My program is using 'glBindAttribLocation' and 'glTransformFeedbackVaryings'.
These functions take input and output vertex attribute's names in vertex shader.
So 'in' and 'out' variables in vertex shader needs to be '#define' like uniform variables by GLSL minifier.
And my program using multiple shaders and they share same name uniform variables.
So I want GLSL minifier write #define names which have shader file name.
e.g.
glsl_minifier.exe foo_vertex_shader.vs -o foo_vertex_shader.vs.h
foo_vertex_shader.vs
in vec3 in_normal;
in vec3 in_texcoord;
out vec3 out_normal;
out vec3 out_texcoord;
uniform samplerBuffer positions;
void main()
...
foo_vertex_shader.vs.h
#ifndef FOO_VERTEX_SHADER.VS_H_
# define FOO_VERTEX_SHADER.VS_H_
# define FOO_VERTEX_SHADER_I_IN_NORMAL "n"
# define FOO_VERTEX_SHADER_I_IN_TEXCOORD "t"
# define FOO_VERTEX_SHADER_O_OUT_NORMAL "o"
# define FOO_VERTEX_SHADER_O_OUT_TEXCOORD "u"
# define FOO_VERTEX_SHADER_U_POSITIONS "p"
const char *foo_vertex_shader_vs = ""
"in vec3 n,t;"
"out vec3 o,u;"
"uniform samplerBuffer p;"
"void main()"
...
Thank you.
.
I'd like to have a command line argument so that it won't rename in and out variables, I'm generating direct shader output, no C header, and need the variables as designed.
That's great! thanks :)
.
Cool. Thanks!
Second thumb up to make it working with HLSL! Welcome to ShaderMinifier!
haven't really used it yet, but im sure it will be very useful
instant thumb!
instant thumb!
This is a great tool! I'm using this tool when I make prod for revision.
But I found some bugs.
It show Parse error if "#if 0 ~ #endif" is used inside function definition.
And it also show Parse error with unsigned int constant.
e.g.
uint c = 123u;
If I change unsigned int constant for signed, GLSL compiler generate errors or warnings.
I can avoid this error by replacing all uint with int.
But I would like to use uint type rather than int in my shader.
Thank you in advance.
But I found some bugs.
It show Parse error if "#if 0 ~ #endif" is used inside function definition.
And it also show Parse error with unsigned int constant.
e.g.
uint c = 123u;
If I change unsigned int constant for signed, GLSL compiler generate errors or warnings.
I can avoid this error by replacing all uint with int.
But I would like to use uint type rather than int in my shader.
Thank you in advance.
Doesn't seem to like "gl_FragData[0]", is this an error?
Just something you should be aware of..
Just something you should be aware of..
Thanks for awesome tool.
I typed like below.
>>shader_minifier test.fx --hlsl
but caused error.
>>Error: Parse error: Error in test.fx: Ln: 2 Col: 20
>>cbuffer cbPerFrame : register( b0 )
>>Expecting: '('
test.fx is like this.
/* test.fx */
cbuffer cbPerFrame : register( b0 )
{
column_major float4x4 viewProj;
column_major float4x4 view;
column_major float4x4 proj;
};
(EOF)
Shader Minifier doesn't allow this style?
thanks.
I typed like below.
>>shader_minifier test.fx --hlsl
but caused error.
>>Error: Parse error: Error in test.fx: Ln: 2 Col: 20
>>cbuffer cbPerFrame : register( b0 )
>>Expecting: '('
test.fx is like this.
/* test.fx */
cbuffer cbPerFrame : register( b0 )
{
column_major float4x4 viewProj;
column_major float4x4 view;
column_major float4x4 proj;
};
(EOF)
Shader Minifier doesn't allow this style?
thanks.
and I long for "not rename function" option.
I've found a bug.
Sevaral functions are renamed to same name with HLSL that has a lot of functions.
Please fix this.
thanks.
Sevaral functions are renamed to same name with HLSL that has a lot of functions.
Please fix this.
thanks.
Very very cool.
Unfortunately, the HLSL feature doesn't seem to support DX10-style "Texture2D <float4> tex"-statements or state blocks (ala "BlendState blend { BlendEnable[0] = FALSE; };")
Unfortunately, the HLSL feature doesn't seem to support DX10-style "Texture2D <float4> tex"-statements or state blocks (ala "BlendState blend { BlendEnable[0] = FALSE; };")
It also seems support for attributes (like "maxvertexcount(12)]" and "[unroll]") as well as Geometry Shader input types aren't supported either.
That should have been "[maxvertexcount(12)]", of course.
handy!
LLB: any news on the fix (2011-06-21 00:06:22)? The minifier generates several functions with the same name, one of those should be the entry point of my shader... It'd be cool if you could at least provide an option to prevent any function to be given a name that appears in the "no-renaming-list". That way I can tell the minifier in the "no-renaming-list" which functions are my entry points.
.
very cool stuff! :) thanks for the source release!
thank you for the source <3
cool too, much appreciated
Of course!
First time I tried it. Can produce code that doesn't compile, but after finding the problem, it ruled how it obfurscates my code :)
Fantastic tool. Thank you for this.
!
+
Thank you for this, works great!
Inexcusably, I somehow never thumbed this one up. Thanks for this tool!
Modern 4k scene would not be possible without this tool!
submit changes
if this prod is a fake, some info is false or the download link is broken,
do not post about it in the comments, it will get lost.
instead, click here !
.NET or Mono, it should work on Windows, Linux, Mac, BSD. I hope it will help you make great intros. :)
Please check our website for complete description and examples. Feel free to send me features requests and optimizations ideas!
http://www.ctrl-alt-test.fr/?page_id=7