From 087d8ec8dd53848960402eb79494ddeeae267b5d Mon Sep 17 00:00:00 2001 From: Laurent Le Brun Date: Sun, 23 Oct 2022 22:21:24 +0200 Subject: [PATCH] Version 1.3 Also update the README --- README.md | 34 +++++++++---------- src/options.fs | 2 +- tests/commands.txt | 1 + tests/real/chocolux.expected | 2 +- tests/real/disco.expected | 2 +- tests/real/elevated.hlsl.expected | 2 +- tests/real/heart.frag.expected | 12 +++---- tests/real/kinder_painter.expected | 3 +- tests/real/leizex.expected | 3 +- tests/real/lunaquatic.frag.expected | 2 +- tests/real/mandelbulb.expected | 2 +- tests/real/oscars_chair.frag.expected | 2 +- tests/real/sult.expected | 2 +- ...real_party_is_in_your_pocket.frag.expected | 2 +- tests/real/to_the_road_of_ribbon.expected | 2 +- .../real/yx_long_way_from_home.frag.expected | 2 +- tests/unit/blocks.expected | 2 +- tests/unit/externals.expected | 2 +- tests/unit/externals.preserved.expected | 2 +- tests/unit/float.frag.expected | 2 +- tests/unit/function_comma.expected | 2 +- tests/unit/function_overload.expected | 2 +- tests/unit/geometry.hlsl.expected | 2 +- tests/unit/inout.expected | 2 +- tests/unit/macros.expected | 2 +- tests/unit/many_variables.expected | 2 +- tests/unit/minus-zero.expected | 2 +- tests/unit/operators.expected | 2 +- tests/unit/qualifiers.expected | 2 +- 29 files changed, 49 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index dfacc4d0..a268720c 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,9 @@ shader is minified by hand by experienced demosceners, Shader Minifier is often able to optimize it further. See this [2010 report](https://www.ctrl-alt-test.fr/2010/glsl-minifier-smaller-and-smaller/). -If your application uses multiple shaders, use the `--preserve-externals` -option. Values such as the uniforms won't be renamed, which makes it easier to -use in your application (at the expense of a slightly bigger shader). +To be notified of new releases, use the watch feature of GitHub. + +Try the online version here: https://ctrl-alt-test.fr/minifier/ ## Features @@ -42,14 +42,14 @@ be the most compression-friendly. ## Example output ```c -/* File generated with Shader Minifier 1.1.6 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef HEART_FRAG_EXPECTED_ # define HEART_FRAG_EXPECTED_ -# define VAR_MOUSE "f" -# define VAR_RESOLUTION "y" -# define VAR_TIME "v" +# define VAR_mouse "f" +# define VAR_resolution "y" +# define VAR_time "v" const char *heart_frag = "uniform float v;" @@ -61,8 +61,8 @@ const char *heart_frag = "float r=mod(v,2.)/2.,a=pow(r,.2)*.5+.5;" "a-=a*.2*sin(r*6.2831*5.)*exp(-r*6.);" "f*=vec2(.5,1.5)+a*vec2(.5,-.5);" - "float m=atan(f.x,f.y)/3.14159,x=length(f),e=abs(m),o=(13.*e-22.*e*e+10.*e*e*e)/(6.-5.*e),l=step(x,o)*pow(1.-x/o,.25);" - "gl_FragColor=vec4(l,0.,0.,1.);" + "float m=atan(f.x,f.y)/3.141593,x=length(f),e=abs(m),o=(13.*e-22.*e*e+10.*e*e*e)/(6.-5.*e),n=step(x,o)*pow(1.-x/o,.25);" + "gl_FragColor=vec4(n,0.,0.,1.);" "}"; #endif // HEART_FRAG_EXPECTED_ @@ -156,7 +156,7 @@ If you desperately need to save a few bytes, try another value of The recommandation is to use: ``` -shader_minifier.exe --format c-array --preserve-externals *.frag -o shaders.h +shader_minifier.exe --format c-array *.frag -o shaders.h ``` Then, in your C or C++ code, include the file: @@ -167,8 +167,9 @@ const char* shaderSources[] = { }; ``` -Since the uniforms are not renamed, prefer shorter names when -possible. Hopefully a future version of Shader Minifier will improve this. +Note that uniforms will be renamed consistently across all the files. The +`#define` lines will tell you how they were renamed. To disable this renaming, +use `--preserve-externals`. ### Javascript @@ -337,10 +338,7 @@ Contributions are welcome. --------- -Slightly outdated user manual: - http://www.ctrl-alt-test.fr/?page_id=7 - -Created by Laurent Le Brun (LLB / Ctrl-Alt-Test). +Created by Laurent Le Brun (LLB / Ctrl-Alt-Test) and +[other contributors](https://github.com/laurentlb/Shader_Minifier/graphs/contributors). - http://laurent.le-brun.eu - http://ctrl-alt-test.fr + http://laurent.le-brun.eu -- http://ctrl-alt-test.fr diff --git a/src/options.fs b/src/options.fs index 9494d8b9..5d616ab4 100644 --- a/src/options.fs +++ b/src/options.fs @@ -3,7 +3,7 @@ open System.IO open Argu -let version = "1.2" // Shader Minifier version +let version = "1.3" // Shader Minifier version let debugMode = false type OutputFormat = diff --git a/tests/commands.txt b/tests/commands.txt index d8de2d69..2e3e8e05 100644 --- a/tests/commands.txt +++ b/tests/commands.txt @@ -51,6 +51,7 @@ -o tests/unit/macros.expected --no-inlining tests/unit/macros.frag --format indented -o tests/unit/switch.expected tests/unit/switch.frag --format indented -o tests/unit/forbidden.expected tests/unit/forbidden.frag +--format c-variables -o tests/real/heart.frag.expected tests/real/heart.frag # Optimization tests diff --git a/tests/real/chocolux.expected b/tests/real/chocolux.expected index fc1d2565..03cef3aa 100644 --- a/tests/real/chocolux.expected +++ b/tests/real/chocolux.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef CHOCOLUX_EXPECTED_ diff --git a/tests/real/disco.expected b/tests/real/disco.expected index b30a4de5..9882d2ef 100644 --- a/tests/real/disco.expected +++ b/tests/real/disco.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ diff --git a/tests/real/elevated.hlsl.expected b/tests/real/elevated.hlsl.expected index 510c6f30..9d81a27a 100644 --- a/tests/real/elevated.hlsl.expected +++ b/tests/real/elevated.hlsl.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef ELEVATED_HLSL_EXPECTED_ diff --git a/tests/real/heart.frag.expected b/tests/real/heart.frag.expected index 3d0b2d3d..725bbc55 100644 --- a/tests/real/heart.frag.expected +++ b/tests/real/heart.frag.expected @@ -1,11 +1,11 @@ -/* File generated with Shader Minifier 1.1.6 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef HEART_FRAG_EXPECTED_ # define HEART_FRAG_EXPECTED_ -# define VAR_MOUSE "f" -# define VAR_RESOLUTION "y" -# define VAR_TIME "v" +# define VAR_mouse "f" +# define VAR_resolution "y" +# define VAR_time "v" const char *heart_frag = "uniform float v;" @@ -17,8 +17,8 @@ const char *heart_frag = "float r=mod(v,2.)/2.,a=pow(r,.2)*.5+.5;" "a-=a*.2*sin(r*6.2831*5.)*exp(-r*6.);" "f*=vec2(.5,1.5)+a*vec2(.5,-.5);" - "float m=atan(f.x,f.y)/3.14159,x=length(f),e=abs(m),o=(13.*e-22.*e*e+10.*e*e*e)/(6.-5.*e),l=step(x,o)*pow(1.-x/o,.25);" - "gl_FragColor=vec4(l,0.,0.,1.);" + "float m=atan(f.x,f.y)/3.141593,x=length(f),e=abs(m),o=(13.*e-22.*e*e+10.*e*e*e)/(6.-5.*e),n=step(x,o)*pow(1.-x/o,.25);" + "gl_FragColor=vec4(n,0.,0.,1.);" "}"; #endif // HEART_FRAG_EXPECTED_ diff --git a/tests/real/kinder_painter.expected b/tests/real/kinder_painter.expected index a5297391..6f0f5a92 100644 --- a/tests/real/kinder_painter.expected +++ b/tests/real/kinder_painter.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ @@ -183,4 +183,3 @@ "col=mix(col,col2,.5-.5*ref.w);" "gl_FragColor=col;" "}", - diff --git a/tests/real/leizex.expected b/tests/real/leizex.expected index d9b1d374..803f84cb 100644 --- a/tests/real/leizex.expected +++ b/tests/real/leizex.expected @@ -1,4 +1,4 @@ -; File generated with Shader Minifier 1.2 +; File generated with Shader Minifier 1.3 ; http://www.ctrl-alt-test.fr _leizex_frag: @@ -105,4 +105,3 @@ _leizex_frag: db 'col*=.5+.5*(1.-p.x)*(1.+p.x);' db 'gl_FragColor=vec4(col,1.);' db '}', 0 - diff --git a/tests/real/lunaquatic.frag.expected b/tests/real/lunaquatic.frag.expected index 0a218190..68065cdd 100644 --- a/tests/real/lunaquatic.frag.expected +++ b/tests/real/lunaquatic.frag.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef LUNAQUATIC_FRAG_EXPECTED_ diff --git a/tests/real/mandelbulb.expected b/tests/real/mandelbulb.expected index 8df10d79..60ac59ae 100644 --- a/tests/real/mandelbulb.expected +++ b/tests/real/mandelbulb.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef MANDELBULB_EXPECTED_ diff --git a/tests/real/oscars_chair.frag.expected b/tests/real/oscars_chair.frag.expected index f0c60fba..aeb0e06f 100644 --- a/tests/real/oscars_chair.frag.expected +++ b/tests/real/oscars_chair.frag.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef OSCARS_CHAIR_FRAG_EXPECTED_ diff --git a/tests/real/sult.expected b/tests/real/sult.expected index ba2c047e..f0db069a 100644 --- a/tests/real/sult.expected +++ b/tests/real/sult.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef SULT_EXPECTED_ diff --git a/tests/real/the_real_party_is_in_your_pocket.frag.expected b/tests/real/the_real_party_is_in_your_pocket.frag.expected index 794a5c94..e649c9e5 100644 --- a/tests/real/the_real_party_is_in_your_pocket.frag.expected +++ b/tests/real/the_real_party_is_in_your_pocket.frag.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef THE_REAL_PARTY_IS_IN_YOUR_POCKET_FRAG_EXPECTED_ diff --git a/tests/real/to_the_road_of_ribbon.expected b/tests/real/to_the_road_of_ribbon.expected index cf78509a..25a69c5d 100644 --- a/tests/real/to_the_road_of_ribbon.expected +++ b/tests/real/to_the_road_of_ribbon.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef TO_THE_ROAD_OF_RIBBON_EXPECTED_ diff --git a/tests/real/yx_long_way_from_home.frag.expected b/tests/real/yx_long_way_from_home.frag.expected index 3c47c487..dcee6e68 100644 --- a/tests/real/yx_long_way_from_home.frag.expected +++ b/tests/real/yx_long_way_from_home.frag.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef YX_LONG_WAY_FROM_HOME_FRAG_EXPECTED_ diff --git a/tests/unit/blocks.expected b/tests/unit/blocks.expected index 1363302e..7fc42b8a 100644 --- a/tests/unit/blocks.expected +++ b/tests/unit/blocks.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef BLOCKS_EXPECTED_ diff --git a/tests/unit/externals.expected b/tests/unit/externals.expected index a95ab976..88532b01 100644 --- a/tests/unit/externals.expected +++ b/tests/unit/externals.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef EXTERNALS_EXPECTED_ diff --git a/tests/unit/externals.preserved.expected b/tests/unit/externals.preserved.expected index 880b7017..78249489 100644 --- a/tests/unit/externals.preserved.expected +++ b/tests/unit/externals.preserved.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef EXTERNALS_PRESERVED_EXPECTED_ diff --git a/tests/unit/float.frag.expected b/tests/unit/float.frag.expected index c4abbfc4..ffbe1644 100644 --- a/tests/unit/float.frag.expected +++ b/tests/unit/float.frag.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ diff --git a/tests/unit/function_comma.expected b/tests/unit/function_comma.expected index cb21106f..8a8b4d6a 100644 --- a/tests/unit/function_comma.expected +++ b/tests/unit/function_comma.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef FUNCTION_COMMA_EXPECTED_ diff --git a/tests/unit/function_overload.expected b/tests/unit/function_overload.expected index 93fb2bad..28395dd4 100644 --- a/tests/unit/function_overload.expected +++ b/tests/unit/function_overload.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef FUNCTION_OVERLOAD_EXPECTED_ diff --git a/tests/unit/geometry.hlsl.expected b/tests/unit/geometry.hlsl.expected index cabdf507..d00490fd 100644 --- a/tests/unit/geometry.hlsl.expected +++ b/tests/unit/geometry.hlsl.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef GEOMETRY_HLSL_EXPECTED_ diff --git a/tests/unit/inout.expected b/tests/unit/inout.expected index 7ee07a24..763655c5 100644 --- a/tests/unit/inout.expected +++ b/tests/unit/inout.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ # define VAR_ambientLight "m" diff --git a/tests/unit/macros.expected b/tests/unit/macros.expected index 51e05039..dbc36787 100644 --- a/tests/unit/macros.expected +++ b/tests/unit/macros.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef MACROS_EXPECTED_ diff --git a/tests/unit/many_variables.expected b/tests/unit/many_variables.expected index 0e712832..8baf7458 100644 --- a/tests/unit/many_variables.expected +++ b/tests/unit/many_variables.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ diff --git a/tests/unit/minus-zero.expected b/tests/unit/minus-zero.expected index 5daa84bc..faf1681c 100644 --- a/tests/unit/minus-zero.expected +++ b/tests/unit/minus-zero.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ diff --git a/tests/unit/operators.expected b/tests/unit/operators.expected index 26ff701d..ad01da30 100644 --- a/tests/unit/operators.expected +++ b/tests/unit/operators.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ diff --git a/tests/unit/qualifiers.expected b/tests/unit/qualifiers.expected index 5b5fda4c..c0d44b90 100644 --- a/tests/unit/qualifiers.expected +++ b/tests/unit/qualifiers.expected @@ -1,4 +1,4 @@ -/* File generated with Shader Minifier 1.2 +/* File generated with Shader Minifier 1.3 * http://www.ctrl-alt-test.fr */ #ifndef QUALIFIERS_EXPECTED_