All those old school hacks are forgotten for the younger generation I learnt all those float to int tricks from Chris Hecker's articles years ago. Converting float to fixed point numbers was essential for software texture mapping on the pentium chips (those float to fix point hacks were miles quicker) - do all the calculations in floats all away to the draw span code, set off a floating point divide and use the integer pipeline to interpolate the spans... and best of all the time the span gets drawn the divide had finished calculating. Those were the days of creative programming.
I'm failry sure I found out about the IEEE hacking stuff from Chris Hecker, or maybe Mike Abrash's articles. Certainly from Quake related stuff. I could however out-juggle him with those original xbox branded bouncy balls though
Very nice.. and in your case it will definitely make a difference. Incidentally, I'm working with a 2K x 2K height map.. but no more than 20-40 elements animated at once. Thanks for the explanation 8)
I have to be able to handling up to 1/32 of my map every frame so very different requirements. Cool video on your site (Fractal Combat), is that doing any LOD?
Thanks ! Yes it's a regular grid kind of LOD. The closest patch is a 64x64, and the resolution halves with the distance.. while mending the edges between patches with different resolutions. It's a 2K x 2K height field and color texture with baked lighting (baked at run-time, when a new world gets generated). The shader gets dynamic X,Y,Z and static UVs modulated by an offset fed to the vertex shader, per-patch. I could send only Ys.. but that's a potential speed up for the future (fill rate is usually my main problem anyway). No special low level hacks, but definitely another case for C/C++. I do use this one a lot though (one compare to clamp to [0, 255]): Code: //===================================== inline static U8 ClampInt( int val ) { if ( (U32)val > 255 ) return (U8)(~(val >> (sizeof(int)*8-1)) & 255); else return (U8)val; } //===================================== color( const Float3 &rgb, float a=1.f ) { rgba[0] = ClampInt( (int)(rgb[0]*255) ); rgba[1] = ClampInt( (int)(rgb[1]*255) ); rgba[2] = ClampInt( (int)(rgb[2]*255) ); rgba[3] = ClampInt( (int)(a*255) ); }
Sounds kind of like the LOD in Ground Effect, though that was 1.1 and done without shaders. I like the single compare clamp though, seems obvious but I'd never seen it before.
I don't remember where I got the 8 bit clamp trick.. but it's from many moons ago 8) It's especially handy for image processing. Regular grid LODs are all very similar I guess. Mine should work with 1.1 as well, using the texture matrix. The custom shaders just make the optimization more obvious, as I can skip the full texure matrix multiply. Another benefit of custom shaders is better fog. I rely on that a lot, and the one provided with ES 1.1 was just not enough (seems to work on Z depth rather than actual distance from the viewer).
For those interested in floating point hacking, here's a link to Chris Hecker's site. http://chrishecker.com/Miscellaneous_Technical_Articles#Floating_Point