Posts: 566
Threads: 86
Joined: Feb 2003
Antoni Gual saying to Jark "it's really fast"... Must be a kind of Spanish virus that crossed the Pyrenean moutains :wink:
hink Global, Make Symp' All ! ®
Posts: 566
Threads: 86
Joined: Feb 2003
Antoni, this virus is dangerous...
Code:
DIM Cloud%(129, 129)
RANDOMIZE TIMER
T0 = TIMER
' Init the corners
Cloud%(1, 1) = 128
Cloud%(1, 129) = 128
Cloud%(129, 1) = 128
Cloud%(129, 129) = 128
' Init the edges
FOR Rank% = 1 TO 7
Grid% = 2 ^ (7 - Rank% + 1)
nStep% = 2 ^ (Rank% - 1) + 1
FOR kx% = 1 TO nStep% - 1
x% = (kx% - 1) * Grid% + 1: y% = 1
Alt% = (Cloud%(x%, y%) + Cloud%(x% + Grid%, y%)) / 2
zNew% = INT(Alt% * (1 + (RND - .5) / (2 ^ Rank%)))
Cloud%(x% + Grid% / 2, 1) = zNew%
Cloud%(x% + Grid% / 2, 129) = zNew%
NEXT kx%
FOR ky% = 1 TO nStep% - 1
x% = 1: y% = (ky% - 1) * Grid% + 1
Alt% = (Cloud%(x%, y%) + Cloud%(x%, y% + Grid%)) / 2
zNew% = INT(Alt% * (1 + (RND - .5) / (2 ^ Rank%)))
Cloud%(1, y% + Grid% / 2) = zNew%
Cloud%(129, y% + Grid% / 2) = zNew%
NEXT ky%
NEXT Rank%
' Fill the clouds
FOR Rank% = 1 TO 7
Grid% = 2 ^ (7 - Rank% + 1)
nStep% = 2 ^ (Rank% - 1) + 1
FOR kx% = 1 TO nStep% - 1
x% = (kx% - 1) * Grid% + 1
FOR ky% = 1 TO nStep% - 1
y% = (ky% - 1) * Grid% + 1
Alt% = (Cloud%(x%, y%) + Cloud%(x% + Grid%, y%) + Cloud%(x%, y% + Grid%) + Cloud%(x% + Grid%, y% + Grid%)) / 4
Cloud%(x% + Grid% / 2, y% + Grid% / 2) = INT(Alt% * (1 + (RND - .5) / (2 ^ Rank%)))
Alt% = (Cloud%(x%, y%) + Cloud%(x% + Grid%, y%)) / 2
IF y% <> 1 THEN Cloud%(x% + Grid% / 2, y%) = INT(Alt% * (1 + (RND - .5) / (2 ^ Rank%)))
Alt% = (Cloud%(x%, y%) + Cloud%(x%, y% + Grid%)) / 2
IF x% <> 1 THEN Cloud%(x%, y% + Grid% / 2) = INT(Alt% * (1 + (RND - .5) / (2 ^ Rank%)))
Alt% = (Cloud%(x% + Grid%, y%) + Cloud%(x% + Grid%, y% + Grid%)) / 2
IF (x% + Grid%) <> 129 THEN Cloud%(x% + Grid%, y% + Grid% / 2) = INT(Alt% * (1 + (RND - .5) / (2 ^ Rank%)))
Alt% = (Cloud%(x%, y% + Grid%) + Cloud%(x% + Grid%, y% + Grid%)) / 2
IF (y% + Grid%) <> 129 THEN Cloud%(x% + Grid% / 2, y% + Grid%) = INT(Alt% * (1 + (RND - .5) / (2 ^ Rank%)))
NEXT ky%
NEXT kx%
NEXT Rank%
dt = TIMER - T0
CLS
PRINT dt
hink Global, Make Symp' All ! ®
Posts: 1,407
Threads: 117
Joined: Dec 2002
You could also change all
Code:
result= INT(anything/something)
to
Code:
result=anything\something
Integer division is faster...
Also you could precalculate an array of powers of 2...
Antoni
Posts: 566
Threads: 86
Joined: Feb 2003
It's only a sphere, and I don't control everything yet, but that's a beginning...
hink Global, Make Symp' All ! ®
Posts: 566
Threads: 86
Joined: Feb 2003
I seriously need to develop an regular antialiasing routine... my smoothering filter only handles black spots.
hink Global, Make Symp' All ! ®
Posts: 1,407
Threads: 117
Joined: Dec 2002
:o :o :o :o :o :o :o :o :o :o :o :o :o
Antoni
Posts: 3,288
Threads: 167
Joined: Nov 2001