Author Topic: [PROCEDURAL] Wood  (Read 5761 times)

0 Members and 1 Guest are viewing this topic.

Offline Deleter

  • C= 64
  • **
  • Posts: 73
  • Karma: 11
    • View Profile
    • Deleter's Rants
[PROCEDURAL] Wood
« on: April 30, 2008 »
Well this is a start to my entry. Right now its obviously not very flexible but I'm planning on expanding these calculations to accept parameters such as grain density, knot freqency, knot size, texture size, wood scale, and color. I'm not using any specific algorithm, just messing around and seeing what I can come up with.

Code: [Select]
screenres 512,512,32

dim as uinteger seed=&h02D8FAAE

dim as integer offset

randomize seed

dim as integer grain(63)
dim as integer ny(63)
dim as integer lastx(63)
dim as integer xstep
for streak as integer = 0 to 10
    for streakpart as integer = 0 to 5'-int(rnd*3)
        xstep=streak*5+streakpart
        offset = int(rnd*5)-2
        grain(xstep)=streak*50+streakpart*7'xstep*10+offset
        lastx(xstep)=grain(xstep)
        ny(xstep)=0
        '&hC58340
    next
next

const maxdisps=3

dim as integer dispx(maxdisps)
dim as integer dispy(maxdisps)
dim as integer dispm(maxdisps)

dispx(0)=256
dispy(0)=256
dispm(0)=35

dispx(1)=75
dispy(1)=400
dispm(1)=15

dispx(2)=125
dispy(2)=40
dispm(2)=15


dispx(2)=435
dispy(2)=80
dispm(2)=20


const maxd = 512^2 + 512^2

dim as integer tx,ty,td

paint(0,0),&hff00ff
for ystep as integer = 0 to 512
    for xstep as integer = 0 to 51
        if ny(xstep)=ystep then
            offset=int(rnd*3)-1
            lastx(xstep)=offset+grain(xstep)
            ny(xstep)=int(rnd*4)+ystep+2
        end if
        tx=lastx(xstep)
        ty=ystep
       
        for tmp as integer = 0 to ubound(dispx)
            td= (tx-dispx(tmp))^2 + (ty-dispy(tmp))^2
            tx += (1-(td/maxd))^19  *dispm(tmp) * sgn(tx-dispx(tmp))
        next
       
        pset (tx,ty),&h905219'&hC58430
    next
next

dim as any ptr img = imagecreate(512,512,&hff00ff)
dim as any ptr back = imagecreate(512,512,0)
dim as any ptr buffer = imagecreate(512,1,&hff00ff)

get (0,0)-(511,511),img
cls
'paint (0,0),&h956420
for x as integer = 0 to 511
    for y as integer = 0 to 511
        dim as integer c=rgb(&hAC+int(rnd*20),&h65+int(rnd*15),&h17+int(rnd*5))
        for tmpy as integer = -int(rnd*3)-1 to int(rnd*3)+1
        pset back, (x,y+tmpy),c
        next
    next
next
'sleep
for pass as integer = 1 to 10
    for tmpy as integer = 0 to 512
        get back,(0,tmpy)-(511,tmpy),buffer
        put (0,tmpy),buffer,pset'alpha,int(rnd*32)+64
        put (0,tmpy+1),buffer,alpha,int(rnd*32)+64
        put (0,tmpy+2),buffer,alpha,int(rnd*32)+64
        put (0,tmpy+3),buffer,alpha,int(rnd*32)+64
    next
next


line buffer,(0,0)-(511,0),0
for pass as integer = 1 to 10
    for tmpy as integer = 0 to 512
        dim as integer xoff=int(rnd*3)-1
        dim as integer yoff=int(rnd*5)-1
        'get back,(0,tmpy)-(511,tmpy),buffer
        'put (0,tmpy),buffer,pset
        'line buffer,(0,0)-(511,0),0
        get img, (xoff,tmpy+yoff)-(511,tmpy+yoff),buffer
        put (0,tmpy),buffer,alpha,int(rnd*32)+64
    next
next
sleep
for tmp as integer = 1 to 1
    get (0,0)-(511,511),img
    put (int(rnd*10),int(rnd*15)),img,alpha,int(rnd(80))+60
next

imagedestroy back
imagedestroy img
imagedestroy buffer
sleep

result so far:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: [PROCEDURAL] Wood
« Reply #1 on: April 30, 2008 »
Really nice looking wood texture :)

Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: [PROCEDURAL] Wood
« Reply #2 on: April 30, 2008 »
What Shocky says!
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Dr_D

  • Atari ST
  • ***
  • Posts: 151
  • Karma: 29
    • View Profile
Re: [PROCEDURAL] Wood
« Reply #3 on: April 30, 2008 »
That's a good start man. I bet you could make some really detailed stuff with a bit of tweaking. :)
The Dr. is INsane!!!

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: [PROCEDURAL] Wood
« Reply #4 on: April 30, 2008 »
 definaley wood grain lotsa variety coming in for this compo :D

Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: [PROCEDURAL] Wood
« Reply #5 on: May 01, 2008 »
Welldone Deleter :)
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2456
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
Re: [PROCEDURAL] Wood
« Reply #6 on: May 02, 2008 »
Nice texture, I like it.
Challenge Trophies Won:

Offline Deleter

  • C= 64
  • **
  • Posts: 73
  • Karma: 11
    • View Profile
    • Deleter's Rants
Re: [PROCEDURAL] Wood
« Reply #7 on: May 02, 2008 »
Little number tweaks:



(still have to make the knot position "random")

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: [PROCEDURAL] Wood
« Reply #8 on: May 02, 2008 »
Thats cool, it looks almost Sketched!
Shockwave ^ Codigos
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: [PROCEDURAL] Wood
« Reply #9 on: May 02, 2008 »
I really like that, hope you keep working on it!
It's not so far away from what the pros do...
Challenge Trophies Won:

Offline Pixel_Outlaw

  • Pentium
  • *****
  • Posts: 1382
  • Karma: 83
    • View Profile
Re: [PROCEDURAL] Wood
« Reply #10 on: May 12, 2008 »
I really like the notion of using math to create forms that mimic organic structures. Very nice.
Challenge Trophies Won: