how to decrease size of 4kb intro
category: code [glöplog]
Hi all,
I have been coding a 4kb intro. After compression size of the intro is 4295 bytes. I am using Visual Studio for conding and Crinkler for compression. How to decrease size of intro? Any Visual Studio or Crinkler tricks and tips? Is there something I need to change/set-up in VS?
Cheers
I have been coding a 4kb intro. After compression size of the intro is 4295 bytes. I am using Visual Studio for conding and Crinkler for compression. How to decrease size of intro? Any Visual Studio or Crinkler tricks and tips? Is there something I need to change/set-up in VS?
Cheers
hallo?
um... i know this sounds trivial but have you tried optimizing your code? :)
what I did not dare to say, but Gargaj said
just cut off the end bit with a pair of scissors
Gargaj: code is optimized
Maali: I used an axe to cut 4kb from 64kb:)
Maali: I used an axe to cut 4kb from 64kb:)
Quote:
Then it is no 4k.Gargaj: code is optimized
Quote:
Then it is a 60k.Maali: I used an axe to cut 4kb from 64kb:)
tip: read here for inspiration.
littlejerome: have you tried looking through the crinkler report to see which functions / data blobs are bigger than they should be?
Taking a hint from iq, save yourself some bytes and use magical floats instead!
[url text="\:D/"]http://tmd.freeshell.org/floats.h[/url]
[url text="\:D/"]http://tmd.freeshell.org/floats.h[/url]
whatever, the link is in there
also, assuming you have triple checked all the compile options (/QIfist, /Gs, /Os, /Oi, etc etc) and that you have also gone thru in4k and that you have cross checked your code with all the 4k source codes and frameworks out there for ensuring you have a minimal setupcode, then the rest is optimizing the code.
Are you using DX, or OpenGL? Is your code using extensive (ab)use of shaders like in most recent intros? Are you using a softhsynth or gm.dls?
It's difficult without looking to the code. Also, how long did you try to remove those 200 bytes? I think two weeks going thru the code everyday for few hours removing byte by byte is what might you need?
Are you using DX, or OpenGL? Is your code using extensive (ab)use of shaders like in most recent intros? Are you using a softhsynth or gm.dls?
It's difficult without looking to the code. Also, how long did you try to remove those 200 bytes? I think two weeks going thru the code everyday for few hours removing byte by byte is what might you need?
oh, I can share a trick for shaders. On top of the usual offuscation (like calling all the variables a, b, c, etc, removing the spaces, the unnecessary { }, and so on), you should try to make the code repetitive. In Elevated there are quite a lot of smoothstep(a,b,x) calls, and we replaced them all with smoothstep(0.0,1.0,(x-a)/(b-a)) so that a longer string "smoothstep(0.0,1.0," was repeated over the code (often the "/(b-a)" becomes a constant tho, like "*0.25"). In the same idea, don't mix writing conventions like "2.", "3" and "4.0"; instead choose one (whatever) and consistently use it. So, the advice is that prior to offuscation make sure you have consistent and repeatable code. Part can be done automatically by simple offuscation tools, but other things like the smoothstep require some more advanced parser, so do them by hand. Speaking of what, nobody ready to make a serius stable and advanced offuscator and release it as demotool (a good one I mean which does tricks like the smoothstep one)?
all: thanks for hints
iq: I am using opengl (no shaders) and a softh synth.
iq: I am using opengl (no shaders) and a softh synth.
iq: i guess the problem is that it wouldnt be obfuscation, but instead optimization for context modelling, and i'm not sure if you can automate that easily...
littlejerome, give us size-updates and let us know when it's 4k or under
iq: I did a basic glsl parser/ofuscator/text2h for my latest 4k, it should evolve onto a full brute force shader permutator to obtain somewhat more compressible shaders automagically in the near/far future. Not sure if it'll released publicly any time soon, but it's something I'm going to work for the next 4k after the experience gained on our latest 4k. Not sure if this is helpful at all, I'm tired and asleep.
littlejerome: what crinkler settings are you using? which compiler settings?
Some mixed tricks that helped on Linux at least: try different compiler options - compressed code is rather unpredictable, define local arrays as static, inline subroutines that are called only once, use as little different external functions as possible (for example don't import both glVertex2f and glVertex3f), use float versions of math functions instead of doubles. As a last resort to get some precious bytes you might even change the order of some lines of code where appropriate to see if it compresses better :)
you could also find some tricks here
iq: like shash, we also have an own glsl obfuscator, but is not that sophisticated, it'd need a major rewrite and some inspiration to do automatic code optimization (function inlining, elimination of dead code, etc.), to be release-worthy :)
it would be interesting to see how well such a tool would perform.
but i guess manual tweaking of the shader source with the help of crinkler reports will still be unmatched.
but i guess manual tweaking of the shader source with the help of crinkler reports will still be unmatched.
All: Thank you for all tips. Some VS tricks made life easy:) The size of the intro is less than 4096 bytes.