Developing in C++

Discussion in 'Public Game Developers Forum' started by jlauener, Jul 21, 2011.

  1. NinthNinja

    NinthNinja Well-Known Member

    Jan 31, 2011
    441
    0
    0
    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.
     
  2. Pamx

    Pamx Well-Known Member

    Oct 9, 2009
    303
    0
    0
    UK
    Not sure who taught who, but here's a picture of Glenn & Chris Hecker from a few years back. ;)
     
  3. GlennX

    GlennX Well-Known Member

    May 10, 2009
    761
    0
    0
    UK
    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 :)
     
  4. naythan

    naythan Well-Known Member

    Jun 5, 2009
    328
    0
    0
    winner
    noooooo! monica!!!!
     
  5. TheCrib

    TheCrib Well-Known Member

    Aug 11, 2010
    273
    0
    0
    Programmer
    Tokyo, Japan
    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)
     
  6. GlennX

    GlennX Well-Known Member

    May 10, 2009
    761
    0
    0
    UK
    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?
     
  7. TheCrib

    TheCrib Well-Known Member

    Aug 11, 2010
    273
    0
    0
    Programmer
    Tokyo, Japan
    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) );
    }
    
     
  8. GlennX

    GlennX Well-Known Member

    May 10, 2009
    761
    0
    0
    UK
    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.
     
  9. TheCrib

    TheCrib Well-Known Member

    Aug 11, 2010
    273
    0
    0
    Programmer
    Tokyo, Japan
    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).
     
  10. NinthNinja

    NinthNinja Well-Known Member

    Jan 31, 2011
    441
    0
    0

Share This Page