Posts: 1,774
Threads: 62
Joined: Aug 2003
Quote: Heh, its 1 PSET, if I clear, it wouln't look half as pretty..
I'm embarking on 3D, so I havn't got to lookup tables, what are they BTW, you on TYPEs or something? :???:
This is a lut for sin/cos...
Code:
Dim tSin(359) as SINGLE, tCos(359) as SINGLE
For i = 0 to 359
tSin(i) = SIN(i*(Pi/180))
tCos(i) = COS(i*(Pi/180))
Next
'rx! = ax * 3.14/180
'ry! = ay * 3.14/180
'rz! = az * 3.14/180
'totally eliminate that code...
' Just use it this way...
cx! = tCos(ax)
sx! = tSin(ax)
cy! = tCos(ay)
sy! = tSin(ay)
cz! = tCos(az)
sz! = tSin(az)
Posts: 602
Threads: 27
Joined: Oct 2004
correct me if i'm wrong, but lookuptables for cos and sinus on nowadays machines is a waste of time/space. no need for those as the fpu sin and cos should be faasst enough. somebody correct me
quote="NecrosIhsan"]
[/quote]
Posts: 2,404
Threads: 153
Joined: Jan 2005
right, okay, I see what you mean, heh, thats simple.. :wink:
Kevin (
x.t.r.GRAPHICS)
Posts: 149
Threads: 32
Joined: Feb 2005
Quote:correct me if i'm wrong, but lookuptables for cos and sinus on nowadays machines is a waste of time/space. no need for those as the fpu sin and cos should be faasst enough. somebody correct me
Yes, for most mortal applications.... BUT.... if you are trying for every last possible bit of speed they can't be beat.
(So that's why we keep all those old programming books :-) )
Posts: 320
Threads: 24
Joined: Feb 2005
As far as I know, the majority of commercial games use lookup tables. Carmack probably used them in Doom 3.
.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Posts: 2,404
Threads: 153
Joined: Jan 2005
Yeah, makes since, load all the numbers into that table, in it just grabs 'em insted of pausing to generate the number,. I get the point, yep, and I plan to use it to
...
Kevin (
x.t.r.GRAPHICS)
Posts: 336
Threads: 4
Joined: Nov 2004
moderday flaoitng calulation are up there with interger calulation i can't see it effect speed all that much.
Posts: 1,774
Threads: 62
Joined: Aug 2003
It does though. Check it out. I modified his demo to use the lut and it got a boost of about 300,000 "fps"... :lol:
Code:
SCREEN 19, 32, 2' ,-1 I can't run gfxlib in full screen :(
'mangleberry pie :D
#DEFINE Pi 3.14 '15926535897932
x! = 150
y! = 150
z! = 150
Dim tSin(360) as Single, tCos(360) as Single
For i = 0 to 360
tSin(i) = SIN(i * (Pi/180))
tCos(i) = COS(i * (Pi/180))
Next
centx = 400
centy = 300
LENS = 256 ' centz
ax = 0
ay = 0
az = 0
T! = TIMER
DO
press$ = INKEY$
cx! = tCos(ax)
sx! = tSin(ax)
cy! = tCos(ay)
sy! = tSin(ay)
cz! = tCos(az)
sz! = tSin(az)
ny! = (y! * cx!)-(z! * sx!)
nz! = (z! * cx!)+(y! * sx!)
y! = ny!
z! = nz!
nz! = (z! * cy!)-(x! * sy!)
nx! = (x! * cy!)+(z! * sy!)
x! = nx!
nx! = (x! * cz!)-(y! * sz!)
ny! = (y! * cz!)+(x! * sz!)
ax += 1
If ax > 360 then ax -= 360
ay += 1
If ay > 360 then ay -= 360
az += 1
If az > 360 then az -= 360
PSET (centx + nx!, centy - ny!), RGB(z!, z!, z! )
F += 1
LOOP UNTIL press$ = CHR$(27)
PRINT "Average FPS:"; F / (TIMER - T!)
SLEEP
Posts: 2,404
Threads: 153
Joined: Jan 2005
:o AH!!!!
It ran at 150,000 FPS on mine, 109,000 FPS faster!!!!!!!111 :o (Numbers are rounded)
:wink: Cool!!
Kevin (
x.t.r.GRAPHICS)
Posts: 3,288
Threads: 167
Joined: Nov 2001
Cool!!!!
Try to play with colors. Like adding thge color you want plus the color on screen limiting the RGB components to 255, and you'd get roughly a swirling hazy effect. :*)