switch (renderflag) { case 0 : { for(int i=1; i < resy-1 ; i ++ ) { for(int j=1; j < resx-1 ; j ++ ) { buf1 [ j ] [ i ] = (( ( buf2 [ j + 1 ] [ i ] + buf2 [ j - 1 ] [ i ] + buf2 [ j ] [ i - 1 ] + buf2 [ j ] [ i + 1 ] ) >> 1 ) - buf1 [ j ] [ i ] ); buf1 [ j ] [ i ] -= buf1 [ j ] [ i ] >> 7 ; offsetx = buf1 [ j ] [ i ] - buf1 [ j + 1 ] [ i ] ; offsety = buf1 [ j ] [ i ] - buf1 [ j ] [ i + 1 ] ; _putpixel( water, j , i ,( 128 - offsetx )& 255 ); offsetx >>= 8 ; offsety >>= 8 ; indexu = offsetx + j ; indexv = offsety + i ; if ( indexu >= resx ) indexu -= resx ; else if ( indexu < 0 ) indexu += resx ; if ( indexv >= resy ) indexv -= resy ; else if ( indexv < 0 ) indexv += resy ; _putpixel( vscreen , j , i ,(( _getpixel( backdrop , indexu , indexv ) << 8 )+ _getpixel( water, j , i )) >> 8 ); }}} break ; case 1 :{ for(int i=1; i < resy-1 ; i ++ ) { for(int j=1; j < resx-1 ; j ++ ) { buf2 [ j ] [ i ] = (( ( buf1 [ j + 1 ] [ i ] + buf1 [ j - 1 ] [ i ] + buf1 [ j ] [ i - 1 ] + buf1 [ j ] [ i + 1 ] ) >> 1 ) - buf2 [ j ] [ i ] ); buf2 [ j ] [ i ] -= buf2 [ j ] [ i ] >> 7 ; offsetx = buf2 [ j ] [ i ] - buf2 [ j + 1 ] [ i ] ; offsety = buf2 [ j ] [ i ] - buf2 [ j ] [ i + 1 ] ; _putpixel( water, j , i ,( 128 - offsetx )& 255 ); offsetx >>= 8 ; offsety >>= 8 ; indexu = offsetx + j ; indexv = offsety + i ; if ( indexu >= resx ) indexu -= resx ; else if ( indexu < 0 ) indexu += resx ; if ( indexv >= resy ) indexv -= resy ; else if ( indexv < 0 ) indexv += resy ; _putpixel( vscreen , j , i ,(( _getpixel( backdrop , indexu , indexv ) << 8 )+ _getpixel( water, j , i )) >> 8 ); }}} break ; default: break; }
Showing posts with label demo. Show all posts
Showing posts with label demo. Show all posts
6/14/11
Coding: Pixel ripple effect
Obfuscated C code! This is the inner core loop of a water rippling effect, though I spent some time rearranging the code, because it looked cool for some reason. Do you get what is going on here ? :p
Subscribe to:
Posts (Atom)