• Welcome to Dark Bit Factory & Gravity.
 

Table based demo effects?

Started by va!n, June 17, 2007

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

va!n

i am very interested in how to code all those well known table-based demo effects from the 90th, like tunnel, sphere, bumpmap and all the other great table-based demo effects...

sadly i dont remember the real name of this technique... it was known as table based demo effects but this isnt the right defination of those effects... if someone know the real name of this technique and maybe how to create the tables for some of this great effects (psydo basic please ^^) i would be very very happy !!! :)

Btw, would be nice to know, how all the table-based effects are called too... like tunnel, bump... and so on...



Here are some screenshots of table based effects afaik. (i still miss the great old amiga days)









- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Shockwave

Most software rendered stuff has "tables" :)

For all intents and purposes on the PC it is an array that has it's data manipulated in some way. Those effects are classic ones, to start off I will pick the delerium effect;



Typically a coder will have a set of concentric rings precalculated into an array. This is blitted in place in a buffer, and then blitted again on top of it offset with some movement and then finally the created data table is used to make a screen display using some pre-calculated colour palette.

Here's one I made earlier in Freebasic..


'
'
'
'

'--------------------------------------------------------------------------

            OPTION STATIC
            OPTION EXPLICIT
            Print "PRECALCULATING"
'-------------------------------------------------------------------------
'Please ditch the defs below, they are for the shit fps counter.
'Benchmark reading when nothing is happening is;
'
'-------------------------------------------------------------------------
        declare sub millisecs()
        DIM SHARED AS DOUBLE oldtime,newtime
        dim shared ticks,t as integer
       
'-------------------------------------------------------------------------
' The stuff below is needed to set up the circles;
'-------------------------------------------------------------------------
       
        declare sub dcircle(BYVAL CX AS INTEGER , BYVAL CY AS INTEGER , BYVAL R AS INTEGER, BYVAL CLR AS INTEGER)
        declare sub generate()       
        Dim Shared As uInteger Buffer( 640 * 480 ):  ' Screen Buffer. (or your texture buffer)
        Dim Shared As ubyte C_Buffer( 1280 * 1280 ):' Circles Buffer.
        dim shared as Uinteger C_Palette(512): ' Circles Palette.
       
        declare sub Make_circle_palette()
        declare sub render_delerium1(BYVAL XCX AS uINTEGER , BYVAL XCY AS uINTEGER)
        declare sub render_delerium2(BYVAL XCX AS uINTEGER , BYVAL XCY AS uINTEGER)
        dim shared cwobble as integer
        MAKE_CIRCLE_PALETTE()
        GENERATE()

'-------------------------------------------------------------------------
' Includes.
'-------------------------------------------------------------------------
            '#define PTC_WIN
            #Include Once "tinyptc.bi"

'-------------------------------------------------------------------------
' Open Screen;
'-------------------------------------------------------------------------

        If( ptc_open( "FAST DELERIUM", 640, 480 ) = 0 ) Then
        End -1
        End If
   
'-------------------------------------------------------------------------
' Main Loop;
'-------------------------------------------------------------------------

DIM SHARED GADD AS INTEGER

    DO
       
        'WAIT &H3DA,8
       
       
    gadd=gadd+1
   
    render_delerium1(320+200*sin(gadd/33),420+200*sin(gadd/63))
    render_delerium2(320+200*sin(gadd/43),420+200*sin(gadd/53))
   
   
    millisecs()
    ptc_update@buffer(0)   
    ticks=ticks+1 :' <-- Ditch this (FPS Counter)
   
    LOOP UNTIL INKEY$ = CHR$(27)


'-------------------------------------------------------------------------
' Make some nice colours!.
'-------------------------------------------------------------------------

sub make_circle_palette()
    dim as integer A,RD,GR,BL
    RD=0
    GR=0
    BL=0   
    FOR A=1 TO 250
       
        If A<125 and RD<250 then RD=RD+3
        if A<125 AND GR<250 then GR=GR+2
        if A<125 and BL<250 then BL=BL+1       

        If A>125 and RD>5 then RD=RD-1
        if A>125 AND GR>5 then GR=GR-2
        if A>125 and BL>5 then BL=BL-3       
       
        C_palette(A) = RGB (int(RD),int(GR),int(BL))
    NEXT

FOR A=251 TO 500
       
        If A<375 and RD<250 then RD=RD+1
        if A<375 AND GR<250 then GR=GR+1
        if A<375 and BL<250 then BL=BL+1       

        If A>375 and RD>5 then RD=RD-1
        if A>375 AND GR>5 then GR=GR-1
        if A>375 and BL>5 then BL=BL-1       
       
        C_palette(A) = RGB (int(RD),int(GR),int(BL))
    NEXT

end sub


'-------------------------------------------------------------------------
' Render 1st circle set, clearing the buffer as we go.
'-------------------------------------------------------------------------

sub render_delerium1(BYVAL XCX AS uINTEGER , BYVAL XCY AS uINTEGER)
    dim as uinteger x,y,xrs,yrs,bpos,ppos,yppre1,yppre2
   
   cwobble=cwobble+3
    ' 573
    for y=0 to 479       
        yppre1 = 640*y
        yppre2 = (1280*(y+XCY))+(61+59*sin((y+cwobble))/23)
    for x=0 to 639
        bpos=yppre1+x
        ppos=yppre2+(x+XCX)
        buffer(bpos) = C_buffer(ppos)       
    next
    next
       
end sub

'-------------------------------------------------------------------------
' Render 2nd circle set and convert buffer to colours
'-------------------------------------------------------------------------

sub render_delerium2(BYVAL XCX AS uINTEGER , BYVAL XCY AS uINTEGER)
    dim as uinteger x,y,xrs,yrs,bpos,ppos,yppre1,yppre2
   
   
   
    for y=0 to 479       
        yppre1 = 640*y
        yppre2 = (1280*(y+XCY))+(69+68*sin((y+cwobble)/25))
    for x=0 to 639
        bpos=YPPRE1+x
        ppos=YPPRE2+(x+XCX)
        buffer(bpos) = C_PALETTE(buffer(bpos) + C_buffer(ppos))
    next
    next
       
end sub

'-------------------------------------------------------------------------
' Circle routine;
'-------------------------------------------------------------------------

SUB dCIRCLE(BYVAL CX AS INTEGER , BYVAL CY AS INTEGER , BYVAL R AS INTEGER, BYVAL CLR AS INTEGER)
DIM  as integer r2,cc,loopy,ww,l
r2=r*r
cc=-r
for loopy = cc to r       
        ww = Sqr(r2-loopy*loopy)
        for l = CX-ww to CX+ww                   
                       C_buffer((1280*(loopy+CY))+l)=CLR                   
        next   
       
next
END SUB

'-------------------------------------------------------------------------
' Create circle pattern
'-------------------------------------------------------------------------

sub GENERATE()
    dim rr,lame,ccl as integer
    lame=0
        ccl=0
        for rr=639 to 1 step-1
        dcircle (640,640,rr,ccl)
        if lame = 0 then ccl = ccl+2
        if lame = 1 then ccl = ccl-2
        if ccl>=250 then lame=1
        if ccl<=3 then lame=0
        next
END SUB

'-------------------------------------------------------------------------
' Shit FPS Counter, discard.
'-------------------------------------------------------------------------

SUB Millisecs()
    dim as double t   
    t=timer
if  t-oldtime >=1 then
    newtime = ticks
    ticks=0
    oldtime=timer
    print str( (newtime) )               
end if   
end sub


The effect looks a little different, but the technique used to generate is the same.
exe is attached btw.

Lots of these so called table based effects can be obtained really efficiently using pixel shaders and in some cases, hardware accelerated graphics api's like opengl are great for them, but take the fun out of them and leave the routine feeling "clinical" (just my own opinion).
Shockwave ^ Codigos
Challenge Trophies Won:

mind

#2
i coded a pretty sweet displacement water effect a few years ago and i guess it could be considered a table-effect, i'll try to find the source tomorrow as im not at home at the moment, and post it here.
Challenge Trophies Won: