Liberty BASIC Community Forum
« perlin noise 1d 2d 3d »

Welcome Guest. Please Login or Register.
Dec 12th, 2017, 08:09am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: perlin noise 1d 2d 3d  (Read 63 times)
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 928
xx perlin noise 1d 2d 3d
« Thread started on: Nov 30th, 2017, 1:10pm »

error :
LB reports a syntaks error
but tels not where
verry anoing

@ carl :
can you fix that ?

Code:


WindowWidth = DisplatWidth
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight

blue = rgb( 0 , 0 , 255 )
white = rgb( 255 , 255 , 255 )

nomainwin

open "perlin noise demo" for graphics as #m
  #m "trapclose [quit]"
  for x = 0 to 100
    for y = 0 to 100
      scan
      d = turbulence2d( x , y , 32 )
      kl = mix( blue , d , white )
      call setpixel x , y , kl
    next y
  next x
wait
[quit]
  close #m
end

end

function mix( a , f , b )
  a.r = int( a ) and 255
  a.g = int( a / 256 ) and 255
  a.b = int( a / 256 ^ 2 ) and 255
  b.r = int( b ) and 255
  b.g = int( b / 256 ) and 255
  b.b = int( b / 256 ^ 2 ) and 255
  r = a.r + ( b.r - a.r ) * f
  g = a.g + ( b.g - a.g ) * f
  b = a.b + ( b.b - a.b ) * f
  mix = rgb( r , g , b )
end function

sub setpixel x , y , kl
  r = int( kl ) and 255
  g = int( kl / 256 ) and 255
  b = int( kl / 256 ^ 2 ) and 255
  #m "color ";r;" ";g;" ";b
  #m "goto ";x;" ";y
  #m "down"
  #m "set ";x;" ";y
  #m "up"
end sub

function rgb( r , g , b )
  rgb = r + g * 256 + b * 256 * 256
end function

function noise( x , y , z )
  randomize x + 1000 * y + 1e6 * z
  noise = rnd
end function

function smoothNoise1d( x )
  x = abs( x )
  iX1 = int( x )
  iX2 = ix1 + 1
  tx = x - iX1

''  iX1 and= NOIZESIZE
''  iX2 and= NOIZESIZE

  l = noise( iX1 , 0 , 0 )
  r = noise( iX2 , 0 , 0 )
  v = l + ( r - l ) * tx
  smoothnoise1d = v
end function

function smoothNoise2d( x , y )
  x = abs( x )
  y = abs( y )
  iX1 = int( x )
  iY1 = int( y )
  iX2 = ix1 + 1
  iY2 = iy1 + 1
  tx = x - iX1
  ty = y - iY1

''  iX1 and= NOIZESIZE
''  iX2 and= NOIZESIZE
''  iY1 and= NOIZESIZE
''  iY2 and= NOIZESIZE

  lt = noise( iX1 , iY1 , 0 )
  rt = noise( iX2 , iY1 , 0 )
  rb = noise( iX2 , iY2 , 0 )
  lb = noise( iX1 , iY2 , 0 )

  sxt = lt + ( rt - lt ) * tx
  sxb = lb + ( rb - lb ) * tx

  v = sxt + ( sxb - sxt ) * ty
  smoothnoise2d = v
end function

function smoothNoise3d(x as double, y as double, z as double) as double
  x = abs( x )
  y = abs( y )
  z = abs( z )
  iX1 = int( x )
  iY1 = int( y )
  iZ1 = int( z )
  iX2 = ix1 + 1
  iY2 = iy1 + 1
  iZ2 = iz1 + 1
  tx = x - iX1
  ty = y - iY1
  tz = z - iZ1

''  iX1 and= NOIZESIZE
''  iX2 and= NOIZESIZE
''  iY1 and= NOIZESIZE
''  iY2 and= NOIZESIZE
''  iZ1 and= NOIZESIZE
''  iZ2 and= NOIZESIZE

  ltf = noise( iX1 , iY1 , iZ1 )
  rtf = noise( iX2 , iY1 , iZ1 )
  rbf = noise( iX2 , iY2 , iZ1 )
  lbf = noise( iX1 , iY2 , iZ1 )
  sxtf = ltf + ( rtf - ltf ) * tx
  sxbf = lbf + ( rbf - lbf ) * tx

  ltb = noise( iX1 , iY1 , iZ2 )
  rtb = noise( iX2 , iY1 , iZ2 )
  rbb = noise( iX2 , iY2 , iZ2)
  lbb = noise( iX1 , iY2 , iZ2)
  sxtb = ltb + ( rtb - ltb ) * tx
  sxbb = lbb + ( rbb - lbb ) * tx

  vf = sxtf + ( sxbf - sxtf ) * ty
  vb = sxtb + ( sxbb - sxtb ) * ty
  v = vf + ( vb - vf ) * tz

  smoothnoise3d = v
end function

function turbulence1d( x , size )
  if size < 1 then size = 1
  initialSize = size
  while size >= 1
    value = value _
    + smoothNoise1d( x / size ) * size
    size = size / 2.0
  wend
  value =  value * 0.5
  turbulence1d = value / initialSize
end function

function turbulence2d( x , y , size )
  if size < 1 then size = 1
  initialSize = size
  while size >= 1
    value = value _
    + smoothNoise2d( x / size , y / size ) * size
    size = size / 2.0
  wend
  value = value * 0.5
  return value / ( initialSize - 1 )
end function

function turbulence3d( x , y , z , size )
  if size < 1 then size = 1
  initialSize = size
  while size >= 1
    value = value _
    + smoothNoise3d( x / size _
    , y / size , z / size ) * size
    size = size / 2.0
  wend
  value = value * 0.5
  turbulence3d = value / ( initialSize - 1 )
end function



 

User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 928
xx Re: perlin noise 1d 2d 3d
« Reply #1 on: Nov 30th, 2017, 1:27pm »

update :
fount and removed some error's

error :
division zero : where ?
Code:


WindowWidth = DisplatWidth
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight

blue = rgb( 0 , 0 , 255 )
white = rgb( 255 , 255 , 255 )

nomainwin

open "perlin noise demo" for graphics as #m
  #m "trapclose [quit]"
  for x = 0 to 100
    for y = 0 to 100
      scan
      d = turbulence2d( x , y , 32 )
      kl = mix( blue , d , white )
      call setpixel x , y , kl
    next y
  next x
wait
[quit]
  close #m
end

end

function mix( a , f , b )
  a.r = int( a ) and 255
  a.g = int( a / 256 ) and 255
  a.b = int( a / 256 ^ 2 ) and 255
  b.r = int( b ) and 255
  b.g = int( b / 256 ) and 255
  b.b = int( b / 256 ^ 2 ) and 255
  r = a.r + ( b.r - a.r ) * f
  g = a.g + ( b.g - a.g ) * f
  b = a.b + ( b.b - a.b ) * f
  mix = rgb( r , g , b )
end function

sub setpixel x , y , kl
  r = int( kl ) and 255
  g = int( kl / 256 ) and 255
  b = int( kl / 256 ^ 2 ) and 255
  #m "color ";r;" ";g;" ";b
  #m "goto ";x;" ";y
  #m "down"
  #m "set ";x;" ";y
  #m "up"
end sub

function rgb( r , g , b )
  rgb = r + g * 256 + b * 256 * 256
end function

function noise( x , y , z )
  randomize x + 1000 * y + 1e6 * z
  noise = rnd
end function

function smoothnoise1d( x )
  x = abs( x )
  iX1 = int( x )
  iX2 = iX1 + 1
  tx = x - iX1

''  iX1 and= NOIZESIZE
''  iX2 and= NOIZESIZE

  l = noise( iX1 , 0 , 0 )
  r = noise( iX2 , 0 , 0 )
  v = l + ( r - l ) * tx
  smoothnoise1d = v
end function

function smoothnoise2d( x , y )
  x = abs( x )
  y = abs( y )
  iX1 = int( x )
  iY1 = int( y )
  iX2 = iX1 + 1
  iY2 = iY1 + 1
  tx = x - iX1
  ty = y - iY1

''  iX1 and= NOIZESIZE
''  iX2 and= NOIZESIZE
''  iY1 and= NOIZESIZE
''  iY2 and= NOIZESIZE

  lt = noise( iX1 , iY1 , 0 )
  rt = noise( iX2 , iY1 , 0 )
  rb = noise( iX2 , iY2 , 0 )
  lb = noise( iX1 , iY2 , 0 )

  sxt = lt + ( rt - lt ) * tx
  sxb = lb + ( rb - lb ) * tx

  v = sxt + ( sxb - sxt ) * ty
  smoothnoise2d = v
end function

function smoothnoise3d( x , y , z )
  x = abs( x )
  y = abs( y )
  z = abs( z )
  iX1 = int( x )
  iY1 = int( y )
  iZ1 = int( z )
  iX2 = iX1 + 1
  iY2 = iY1 + 1
  iZ2 = iZ1 + 1
  tx = x - iX1
  ty = y - iY1
  tz = z - iZ1

''  iX1 and= NOIZESIZE
''  iX2 and= NOIZESIZE
''  iY1 and= NOIZESIZE
''  iY2 and= NOIZESIZE
''  iZ1 and= NOIZESIZE
''  iZ2 and= NOIZESIZE

  ltf = noise( iX1 , iY1 , iZ1 )
  rtf = noise( iX2 , iY1 , iZ1 )
  rbf = noise( iX2 , iY2 , iZ1 )
  lbf = noise( iX1 , iY2 , iZ1 )
  sxtf = ltf + ( rtf - ltf ) * tx
  sxbf = lbf + ( rbf - lbf ) * tx

  ltb = noise( iX1 , iY1 , iZ2 )
  rtb = noise( iX2 , iY1 , iZ2 )
  rbb = noise( iX2 , iY2 , iZ2)
  lbb = noise( iX1 , iY2 , iZ2)
  sxtb = ltb + ( rtb - ltb ) * tx
  sxbb = lbb + ( rbb - lbb ) * tx

  vf = sxtf + ( sxbf - sxtf ) * ty
  vb = sxtb + ( sxbb - sxtb ) * ty
  v = vf + ( vb - vf ) * tz

  smoothnoise3d = v
end function

function turbulence1d( x , size )
  if size < 2 then size = 2
  initialSize = size
  while size >= 2
    value = value _
    + smoothnoise1d( x / size ) * size
    size = size / 2.0
  wend
  value =  value * 0.5
  turbulence1d = value / ( initialSize - 1 )
end function

function turbulence2d( x , y , size )
  if size < 2 then size = 2
  initialSize = size
  while size >= 2
    value = value _
    + smoothnoise2d( x / size , y / size ) * size
    size = size / 2.0
  wend
  value = value * 0.5
  turbulence2d = value / ( initialSize - 1 )
end function

function turbulence3d( x , y , z , size )
  if size < 2 then size = 2
  initialSize = size
  while size >= 2
    value = value _
    + smoothnoise3d( x / size _
    , y / size , z / size ) * size
    size = size / 2.0
  wend
  value = value * 0.5
  turbulence3d = value / ( initialSize - 1 )
end function



 

User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1708
xx Re: perlin noise 1d 2d 3d
« Reply #2 on: Nov 30th, 2017, 2:00pm »

Quote:
error :
division zero : where ?

Run it with debugger. It 'll stop on offending line

namely
Code:
randomize x + 1000 * y + 1e6 * z 

because
randomize 0
produces "division zero" error.
User IP Logged

damned Dog in the Manger
tsh73
Board Moderator

member is offline

Avatar

Anatoly (real name)


PM

Gender: Male
Posts: 1708
xx Re: perlin noise 1d 2d 3d
« Reply #3 on: Nov 30th, 2017, 2:03pm »

Also, "mix" functiom needs some INT
or fractional "g" makes really weird change in "r"
Code:
function mix( a , f , b )
  a.r = int( a ) and 255
  a.g = int( a / 256 ) and 255
  a.b = int( a / 256 ^ 2 ) and 255
  b.r = int( b ) and 255
  b.g = int( b / 256 ) and 255
  b.b = int( b / 256 ^ 2 ) and 255
  r = int(a.r + ( b.r - a.r ) * f)
  g = int(a.g + ( b.g - a.g ) * f)
  b = int(a.b + ( b.b - a.b ) * f)
  mix = rgb( r , g , b )
end function 
User IP Logged

damned Dog in the Manger
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 928
xx Re: perlin noise 1d 2d 3d
« Reply #4 on: Dec 1st, 2017, 02:14am »

@ tsh73 :
thanks for help

update :
changed noise()
i added int() in rgb()
i added multycolor

it does not look exiting

i was expexting a earth like texture

? :
can this be done whit 1 turbulece function ?
for example :
Code:
  d = turbulence3d( x , y , 0 , 100 )
 


Code:
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , clrmax
winx = WindowWidth
winy = WindowHeight
dim clr( 10 )
global black , red , green , yellow
global blue , magenta , cyan , white
global pink , gray , orange
black   = 0
red     = rgb( 255 , 000 , 000 )
green   = rgb( 000 , 255 , 000 )
yellow  = rgb( 255 , 255 , 000 )
blue    = rgb( 000 , 000 , 255 )
magenta = rgb( 255 , 000 , 255 )
cyan    = rgb( 000 , 255 , 255 )
white   = rgb( 255 , 255 , 255 )
pink    = rgb( 255 , 127 , 127 )
gray    = rgb( 127 , 127 , 127 )
orange  = rgb( 255 , 127 , 000 )
clr( 0 ) = black
clr( 1 ) = blue
clr( 2 ) = yellow
clr( 3 ) = green
clr( 4 ) = orange
clr( 5 ) = gray
clr( 6 ) = white
clr( 7 ) = 0
clr( 8 ) = 0
clr( 9 ) = 0
clrmax = 6

nomainwin

open "perlin noise demo" for graphics as #m
  #m "trapclose [quit]"
  for x = 0 to 100
    for y = 0 to 100
      scan
      d = turbulence2d( x , y , 100 )
      '' kl = mix( black , d , white )
      kl = color( d )
      call setpixel x , y , kl
    next y
  next x
  notice "ready !!"
wait
[quit]
  close #m
end

function color( f )
  f2 = f * clrmax
  while not( done )
    if t < f2 and f2 < t + 1 then
      uit = mix( clr( t ) , f , clr( t + 1 ) )
      done = 1
    end if
    t = t + 1
  wend
  color = uit
end function

function mix( a , f , b )
  a.r = int( a ) and 255
  a.g = int( a / 256 ) and 255
  a.b = int( a / 256 ^ 2 ) and 255
  b.r = int( b ) and 255
  b.g = int( b / 256 ) and 255
  b.b = int( b / 256 ^ 2 ) and 255
  r = a.r + ( b.r - a.r ) * f
  g = a.g + ( b.g - a.g ) * f
  b = a.b + ( b.b - a.b ) * f
  mix = rgb( r , g , b )
end function

sub setpixel x , y , kl
  r = int( kl ) and 255
  g = int( kl / 256 ) and 255
  b = int( kl / 256 ^ 2 ) and 255
  #m "color ";r;" ";g;" ";b
  #m "goto ";x;" ";y
  #m "down"
  #m "set ";x;" ";y
  #m "up"
end sub

function rgb( r , g , b )
  r = int( r ) and 255
  g = int( g ) and 255
  b = int( b ) and 255
  rgb = r + g * 256 + b * 256 * 256
end function

function noise( x , y , z )
  randomize 1 + x + 1000 * y + 1e6 * z
  noise = rnd( 0 )
end function

function smoothnoise1d( x )

  x = abs( x )
  iX1 = int( x )
  iX2 = iX1 + 1
  tx = x - iX1

''  iX1 and= NOIZESIZE
''  iX2 and= NOIZESIZE

  l = noise( iX1 , 0 , 0 )
  r = noise( iX2 , 0 , 0 )
  v = l + ( r - l ) * tx
  smoothnoise1d = v
end function

function smoothnoise2d( x , y )
  x = abs( x )
  y = abs( y )
  iX1 = int( x )
  iY1 = int( y )
  iX2 = iX1 + 1
  iY2 = iY1 + 1
  tx = x - iX1
  ty = y - iY1

''  iX1 and= NOIZESIZE
''  iX2 and= NOIZESIZE
''  iY1 and= NOIZESIZE
''  iY2 and= NOIZESIZE

  lt = noise( iX1 , iY1 , 0 )
  rt = noise( iX2 , iY1 , 0 )
  rb = noise( iX2 , iY2 , 0 )
  lb = noise( iX1 , iY2 , 0 )

  sxt = lt + ( rt - lt ) * tx
  sxb = lb + ( rb - lb ) * tx

  v = sxt + ( sxb - sxt ) * ty
  smoothnoise2d = v
end function

function smoothnoise3d( x , y , z )
  x = abs( x )
  y = abs( y )
  z = abs( z )
  iX1 = int( x )
  iY1 = int( y )
  iZ1 = int( z )
  iX2 = iX1 + 1
  iY2 = iY1 + 1
  iZ2 = iZ1 + 1
  tx = x - iX1
  ty = y - iY1
  tz = z - iZ1

''  iX1 and= NOIZESIZE
''  iX2 and= NOIZESIZE
''  iY1 and= NOIZESIZE
''  iY2 and= NOIZESIZE
''  iZ1 and= NOIZESIZE
''  iZ2 and= NOIZESIZE

  ltf = noise( iX1 , iY1 , iZ1 )
  rtf = noise( iX2 , iY1 , iZ1 )
  rbf = noise( iX2 , iY2 , iZ1 )
  lbf = noise( iX1 , iY2 , iZ1 )
  sxtf = ltf + ( rtf - ltf ) * tx
  sxbf = lbf + ( rbf - lbf ) * tx

  ltb = noise( iX1 , iY1 , iZ2 )
  rtb = noise( iX2 , iY1 , iZ2 )
  rbb = noise( iX2 , iY2 , iZ2)
  lbb = noise( iX1 , iY2 , iZ2)
  sxtb = ltb + ( rtb - ltb ) * tx
  sxbb = lbb + ( rbb - lbb ) * tx

  vf = sxtf + ( sxbf - sxtf ) * ty
  vb = sxtb + ( sxbb - sxtb ) * ty
  v = vf + ( vb - vf ) * tz

  smoothnoise3d = v
end function

function turbulence1d( x , size )
  if size < 1 then size = 1
  initialSize = size
  while size >= 1
    value = value _
    + smoothnoise1d( x / size ) * size
    size = size / 2.0
  wend
  value =  value * 0.5
  turbulence1d = value / ( initialSize - 1 )
end function

function turbulence2d( x , y , size )
  if size < 1 then size = 1
  initialSize = size
  while size >= 1
    value = value _
    + smoothnoise2d( x / size , y / size ) * size
    size = size / 2.0
  wend
  value = value * 0.5
  turbulence2d = value / ( initialSize - 1 )
end function

function turbulence3d( x , y , z , size )
  if size < 1 then size = 1
  initialSize = size
  while size >= 1
    value = value _
    + smoothnoise3d( x / size _
    , y / size , z / size ) * size
    size = size / 2.0
  wend
  value = value * 0.5
  turbulence3d = value / ( initialSize - 1 )
end function
 

User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
bluatigro
Guru
ImageImageImageImageImage


member is offline

Avatar

cxiu diversas el tio respondas cxiu samvaloras [ thats esperanto for : we are al different therefore we are al equal ]


PM

Gender: Male
Posts: 928
xx Re: perlin noise 1d 2d 3d
« Reply #5 on: Dec 1st, 2017, 03:20am »

update :
removed trubulence1d1d an turbulence2d
it stil works
whit les code
added trub() , marble() and wood() colorfunctions

i don't like the resilts

Code:


WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy , clrmax
winx = WindowWidth
winy = WindowHeight
dim clr( 10 )
global black , red , green , yellow
global blue , magenta , cyan , white
global pink , gray , orange
black   = 0
red     = rgb( 255 , 000 , 000 )
green   = rgb( 000 , 255 , 000 )
yellow  = rgb( 255 , 255 , 000 )
blue    = rgb( 000 , 000 , 255 )
magenta = rgb( 255 , 000 , 255 )
cyan    = rgb( 000 , 255 , 255 )
white   = rgb( 255 , 255 , 255 )
pink    = rgb( 255 , 127 , 127 )
gray    = rgb( 127 , 127 , 127 )
orange  = rgb( 255 , 127 , 000 )
clr( 0 ) = black
clr( 1 ) = blue
clr( 2 ) = yellow
clr( 3 ) = green
clr( 4 ) = orange
clr( 5 ) = gray
clr( 6 ) = white
clr( 7 ) = 0
clr( 8 ) = 0
clr( 9 ) = 0
clrmax = 6

nomainwin

open "perlin noise demo" for graphics as #m
  #m "trapclose [quit]"
  for x = 0 to 100
    for y = 0 to 100
      scan
      ''kl = turb(x,y,z,size,scale)
      ''kl = wood(x,y,z,size,scale,t)
      ''kl = marble(x,y,z,size,scale,t)
      kl = marble( x , y , 0 , 127 , 10 , 1000 )
      call setpixel x , y , kl
    next y
  next x
  notice "ready !!"
wait
[quit]
  close #m
end

function color( f )
  f2 = f * clrmax
  while not( done )
    if t < f2 and f2 < t + 1 then
      uit = mix( clr( t ) , f , clr( t + 1 ) )
      done = 1
    end if
    t = t + 1
  wend
  color = uit
end function

function mix( a , f , b )
  a.r = int( a ) and 255
  a.g = int( a / 256 ) and 255
  a.b = int( a / 256 ^ 2 ) and 255
  b.r = int( b ) and 255
  b.g = int( b / 256 ) and 255
  b.b = int( b / 256 ^ 2 ) and 255
  r = a.r + ( b.r - a.r ) * f
  g = a.g + ( b.g - a.g ) * f
  b = a.b + ( b.b - a.b ) * f
  mix = rgb( r , g , b )
end function

sub setpixel x , y , kl
  r = int( kl ) and 255
  g = int( kl / 256 ) and 255
  b = int( kl / 256 ^ 2 ) and 255
  #m "color ";r;" ";g;" ";b
  #m "goto ";x;" ";y
  #m "down"
  #m "set ";x;" ";y
  #m "up"
end sub

function rgb( r , g , b )
  r = int( r ) and 255
  g = int( g ) and 255
  b = int( b ) and 255
  rgb = r + g * 256 + b * 256 * 256
end function

function noise( x , y , z )
  randomize 1 + x + 1000 * y + 1e6 * z
  noise = rnd( 0 )
end function

function smoothnoise( x , y , z )
  x = abs( x )
  y = abs( y )
  z = abs( z )
  iX1 = int( x )
  iY1 = int( y )
  iZ1 = int( z )
  iX2 = iX1 + 1
  iY2 = iY1 + 1
  iZ2 = iZ1 + 1
  tx = x - iX1
  ty = y - iY1
  tz = z - iZ1

''  iX1 and= NOIZESIZE
''  iX2 and= NOIZESIZE
''  iY1 and= NOIZESIZE
''  iY2 and= NOIZESIZE
''  iZ1 and= NOIZESIZE
''  iZ2 and= NOIZESIZE

  ltf = noise( iX1 , iY1 , iZ1 )
  rtf = noise( iX2 , iY1 , iZ1 )
  rbf = noise( iX2 , iY2 , iZ1 )
  lbf = noise( iX1 , iY2 , iZ1 )
  sxtf = ltf + ( rtf - ltf ) * tx
  sxbf = lbf + ( rbf - lbf ) * tx

  ltb = noise( iX1 , iY1 , iZ2 )
  rtb = noise( iX2 , iY1 , iZ2 )
  rbb = noise( iX2 , iY2 , iZ2)
  lbb = noise( iX1 , iY2 , iZ2)
  sxtb = ltb + ( rtb - ltb ) * tx
  sxbb = lbb + ( rbb - lbb ) * tx

  vf = sxtf + ( sxbf - sxtf ) * ty
  vb = sxtb + ( sxbb - sxtb ) * ty
  v = vf + ( vb - vf ) * tz

  smoothnoise = v
end function

function turbulence( x , y , z , size )
  if size < 1 then size = 1
  initialSize = size
  while size >= 1
    value = value _
    + smoothnoise( x / size _
    , y / size , z / size ) * size
    size = size / 2.0
  wend
  value = value * 0.5
  turbulence = value / ( initialSize - 1 )
end function

function turb( x , y , z , size , scale )
  x = x / scale
  y = y / scale
  z = z / scale
  d = turbulence(x,y,z,size)
  turb = color( d )
end function

function marble( x , y , z , size , scale , t )
  x = x / scale
  y = y / scale
  z = z / scale
  d = sin( y _
  + turbulence(x,y,z,size) * t ) / 2 + .5
  marble = color( d )
end function

function wood( x , y , z , size , scale , t )
  x = x / scale
  y = y / scale
  z = z / scale
  d = sin( sqr( x*x+y*y ) _
  + turbulence(x,y,z,size) * t ) / 2 + .5
  wood = color( d )
end function

 

User IP Logged

basic's : C64 Simons C128 Amiga Amos quick4.5 Visual5 Visual6 Visual2005 Visual2008 just and last but not least liberty
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls