So it has been some time since I have created a post on 64D but I am back. Last night I decided that I wanted to start creating a world that I have never seen, dreamt or even thought about. I want to create a game from this world that also I did not design. This sounds a lot harder in concept then it really is. The first thing that came to mind is that to have a game world you need some ground to walk on which isn’t that hard to do using Perlin Noise I should be able to create variations in the terrain to my liking. So I needed to get a basic understanding of how Perlin Noise works.
Subdivide the height map into x chunks generate a random number from 0.0 to 1.0 for each creating a new height map (Keep doing this until your chunks are the size of a pixel). Stack the images together by finding the average value across all images for each pixel. Blur the stacked image height map values until there is a smooth transition between each value on the height map. Expand all values on the height map so the lowest value is 0.0 and the highest value is 1.0.So in a nut shell my process is:1. Subdivide2. Stack3. Smooth4. ExpandThis is just sudo code my cross of VB and Crap[:)]Width = 256
Height = 256
Scale = 2
NoiseImages() As Image
'Create noise layers
For Each Image In NoiseImages
RecWidth = Width / Scale
RecHeight = Height / Scale
For X = 0 To Scale
For Y = 0 To Scale
RecX = X * RecWidth
RecY = Y * RecHeight
Image.DrawRectangle(RecX, RecY, RecWidth, RecHeight, Random)
Next
Next
Image = CreateNoise(Width, Height, Scale)
Scale = Scale * 2
Loop
'Create a average value noise map
For X = 0 To Width
For Y = 0 To Height
Value = 0
Count = 0
For Each Image In NoiseImages
Value = Value + Image.GetPixcle(X, Y)
Count = Count + 1
Loop
LayeredNoiseImage.SetPixcel(X, Y, Value / Count)
Next
Next
'Get the min and max of the average value noise map
MaxValue = 0
MinValue = 1
For X = 0 To Width
For Y = 0 To Height
Value = LayeredNoiseImage.GetPixcle(X, Y)
If Value > MaxValue Then MaxValue = Value
If Value < MinValue Then MinValue = Value
Next
Next
'Set the average value noise map to extend from min to max
For X = 0 To Width
For Y = 0 To Height
Value = LayeredNoiseImage.GetPixcle(X, Y)
Value = (Value - MinValue) * (1 / (MaxValue - MinValue))
LayeredNoiseImage.SetPixcel(X, Y, Value)
Next
Next
'Create a smooth value noise map
For Count = 0 To 16
For X = 0 To Width
For Y = 0 To Height
'Centre
Value = LayeredNoiseImage.GetPixcle(X, Y)
'North
Value = Value + LayeredNoiseImage.GetPixcle(X - 1, Y)
'South
Value = Value + LayeredNoiseImage.GetPixcle(X + 1, Y)
'West
Value = Value + LayeredNoiseImage.GetPixcle(X, Y - 1)
'East
Value = Value + LayeredNoiseImage.GetPixcle(X, Y + 1)
'North West
Value = Value + LayeredNoiseImage.GetPixcle(X - 1, Y - 1)
'North East
Value = Value + LayeredNoiseImage.GetPixcle(X - 1, Y + 1)
'South West
Value = Value + LayeredNoiseImage.GetPixcle(X + 1, Y - 1)
'South East
Value = Value + LayeredNoiseImage.GetPixcle(X + 1, Y + 1)
smoothNoiseImage.SetPixcel(X, Y, Value / 9)
Next
Next
Next
For some reason, this makes me think about Fallout New Vegas.
Those VB titlecase keywords make me uncomfortable.
WE MUST NEVER GO BACK
I love perlin noise so much
you should use bilinear/trilinear imterpolation on those noise octaves before you merge them together