Author Topic: Johnny Walker Fractal  (Read 4489 times)

0 Members and 1 Guest are viewing this topic.

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Johnny Walker Fractal
« on: January 04, 2007 »
Here's a lil something i thought up.. It's basically a random walker, however i'm doing it in a way i've never seen done before nor have i seen it beeing described anywhere else. The result look somewhat similar to perlin noise or a subdivision fractal and i can imagine it beeing used to generate random terrain, clouds, dirt etc.

What i do is, i create an array of X and Y displacement coordinates, something like this:
Code: [Select]
Const Dirtab : Array[0..8,0..1] of Shortint = ( (-001,-001),
                                                (+000,-001),
                                                (+001,-001),
                                                (-001,-000),     
                                                (+000,-000),
                                                (+001,-000),
                                                (-001,+001),
                                                (-000,+001),
                                                (+001,+001) );

Ok, so we got that down, now what we need is a Seed, 2 variables that are the amount of "walkers" and the distance they will travel, i will call them "walker" and "distance". Then i have the standard X and Y coordinates that i assign random values between 0-511(texturesize-1).

Now, it could be helpful to have 2 more variables that hold the random values needed to decide in what direction the pixels will travel, i will refer to them as "Xdirection" and... yes, you guess it... "Ydirection" :) and finally i will have a variable called "Brightness" used to color the whole thing.

So what we do is, loop through our walkers and distance, assigning X and Y random values, then we let them change direction by adding or subtracting 1 from their current position(using the Dirtab). Finally, when we have a new position on the grid we simply assign it a color by adding Brightness to the color already plotted in the current position, perform some range checking and plot a new pixel.

Now, our loops should look something like this:
Code: [Select]
For each walker do
  Begin
   X = Random(512)
   Y = Random(512)
    For each walkers distance do
     Begin
      Xdirection = Rand(9)
      Ydirection = Rand(9)
      X = (X + Dirtab[Xdirection,0])
      Y = (Y + Dirtab[Ydirection,1])
      Color = Brightness + Destination[X+Y*512]
      If Color > 255 Then Color = 255
      If Color < 000 Then Color = 000
      Destination[X+Y*512] = Color
     End
  End

And thats pretty much it.. The name of the "Fractal" is based on my surname, and since i was a lil buzzed out when i thought it up i decided to add "Walker"(and for those who dont get it, "Johnny Walker" is a whiskey brand :)). So, there you have it.

Screenshot and application is attached, as usual all feedback is appreciated.
« Last Edit: January 05, 2007 by mind »
Challenge Trophies Won:

Offline rdc

  • Pentium
  • *****
  • Posts: 1495
  • Karma: 140
  • Yes, it is me.
    • View Profile
    • Clark Productions
Re: Johnny Walker Fractal
« Reply #1 on: January 04, 2007 »
I saw something like this using Basic4GL a while back. It does produce some nice noise and the implementation is very simple too. Definitely a keeper.  :clap:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17426
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: Johnny Walker Fractal
« Reply #2 on: January 04, 2007 »
Nice texture generation Mind, the images that it makes could be used to make really neat height maps for landscapes too, also I could imagine it with a few anti-alias passes over the image being used to make some very good looking Marble textures.
Props for the explanation on how they are made too.  :cheers:
Shockwave ^ Codigos
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: Johnny Walker Fractal
« Reply #3 on: January 04, 2007 »
Texture-San,

I think optimus uses a similar technique for his fractal planet maths intro. Less controlled than yours but something similar. Also check out Langtons Ant which has states (directions) like yours and produces patterns not too far different though it has no randomness. Yeah I think you are right this is a cool technique and it would be great to see it as input to your CA progtram.

Nontheless

 :goodpost:

and wow another tool!
Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: Johnny Walker Fractal
« Reply #4 on: January 04, 2007 »
thanks for all the feedback..

shockie, i added an option to blur and updated the zipfile..

taj, yeah i know about langtons ant, i did some reading up on that a while ago.. somewhat inspired me to write this. and i know optimus used a random walk in his math compo contribution, i was gonna make a variant of his at first, but then i came up with my own way which tbh i like better :)

on another note, if you implement this, try using "If Random(2)=1 Then Color = Brightness + Destination[X+Y*512]" instead of the normal "Color = Brightness + Destination[X+Y*512]" for a nice scattered paint effect :)
Challenge Trophies Won: