This is more for RiiDii, but anyone is welcome to use it as well. RiiDii has contributed to the opensource mmorpg project greatly. His recent thread
here. inspired me to make an automatic fractal like terrain color application thing. It's not the most eficient tool yet, but with some work I think it could be added to anyones toolset.
Here's the full source.
Sync on : sync rate 60
set display mode 1024,768,32
`load heightmap here
load image "...HeightMapmap.bmp",1
Make(1,2,0.0,0,70,0,60,130,0,130,205,0,230,250,0,240,245,0)
Make(1,3,0.25,0,70,0,60,130,0,130,205,0,230,250,0,240,245,0)
Make(1,4,0.25,0,70,45,60,130,45,130,205,40,230,250,45,240,245,5)
Make(1,5,0.25,0,100,0,80,110,10,100,130,0,130,240,-60,230,240,4)
Make(1,6,0.25,0,0,4,0,90,51,0,200,40,0,0,0,0,0,0)
position camera 0,5,0
Do
paste image 1,0,0
paste image 2,image width(2),0
paste image 3,image width(3)+image width(3),0
paste image 4,image width(4)+image width(4)+image width(4),0
paste image 5,0,image height(5)
paste image 6,image width(6),image height(6)
control camera using arrowkeys 0,1,1
Sync
Loop
function Make(image,output,filter#,w1,w2,wamp,b1,b2,bamp,g1,g2,gamp,gr1,gr2,gramp,wh1,wh2,whamp)
cls rgb(0,0,0)
if image exist(image)
width = image width(image)
height = image height(image)
dim Original(width,height) as dword
dim Color(width,height) as dword
dim Blue(width,height) as dword
Dim Brown(width,height) as dword
Dim Gray(width,height) as dword
Dim Green(width,height) as dword
cls
paste image image,0,0
lock pixels
for x = 0 to width
for y = 0 to height
Color(x,y) = point(x,y)
Blue(x,y) = point(x,y)
Brown(x,y) = point(x,y)
Gray(x,y) = point(x,y)
Green(x,y) = point(x,y)
Original(x,y) = point(x,y)
Gray(x,y) =Original(x,y)
````````````````````White operations`````````````````````
for z = wh1 to wh2 step 1
if Gray(x,y) < rgb(z,z,z) and Gray(x,y) > rgb(z-10,z-10,z-10)
random1=z+rnd(10)+whamp
random2=z+rnd(10)+whamp
random3=z+rnd(10)+whamp
Gray(x,y) = rgb(random1,random2,random3)
_gr1 = rgbr(Gray(x,y))
_gr2 = rgbg(Gray(x,y))
_gr3 = rgbb(Gray(x,y))
Color(x,y) = rgb(_gr1 - rnd(_gr1)*filter#, _gr2 - rnd(_gr2)*filter# , _gr3 - rnd(_gr3)*filter#)
endif
next z
````````````````````White operations`````````````````````
Gray(x,y) = Original(x,y)
````````````````````Gray operations`````````````````````
for z = gr1 to gr2 step 1
if Gray(x,y) < rgb(z,z,z) and Gray(x,y) > rgb(z-10,z-10,z-10)
random1=z+rnd(10)+gramp
random2=z+rnd(10)+gramp
random3=z+rnd(10)+gramp
Gray(x,y) = rgb(random1,random2,random3)
_gr1 = rgbr(Gray(x,y))
_gr2 = rgbg(Gray(x,y))
_gr3 = rgbb(Gray(x,y))
Color(x,y) = rgb(_gr1 - rnd(_gr1)*filter#, _gr2 - rnd(_gr2)*filter# , _gr3 - rnd(_gr3)*filter#)
endif
next z
````````````````````Gray operations`````````````````````
Green(x,y) = Original(x,y)
````````````````````Green operations`````````````````````
for z = g1 to g2 step 1
if Green(x,y) < rgb(z,z,z) and Green(x,y) > rgb(z-10,z-10,z-10)
Green(x,y) = rgb(0,z+rnd(10)+gamp,0)
green = rgbg(Color(x,y))
Color(x,y) = rgb(0,green - rnd(green)*filter# ,0)
endif
next z
````````````````````Green operations`````````````````````
Brown(x,y) = Original(x,y)
````````````````````Brown operations`````````````````````
for z = b1 to b2 step 1
if Brown(x,y) < rgb(z,z,z) and Brown(x,y) > rgb(z-10,z-10,z-10)
random=z+rnd(10)+bamp
Brown(x,y) = rgb(random,random,0)
_b1 = rgbr(brown(x,y))
_b2 = rgbg(brown(x,y))
Color(x,y) = rgb(_b1 - rnd(_b1)*filter#,_b2 - rnd(_b2)*filter# , 0)
endif
next z
````````````````````Brown operations`````````````````````
Blue(x,y) = Original(x,y)
````````````````````Blue operations`````````````````````
for z = w1 to w2 step 1
if Blue(x,y) < rgb(z,z,z) and Blue(x,y) > rgb(z-10,z-10,z-10)
random=z+rnd(10)+wamp
Blue(x,y) = rgb(random,random,random)
blue = rgbb(blue(x,y))
Color(x,y) = rgb(0,0 ,blue - rnd(blue)*filter#)
endif
next z
````````````````````Blue operations`````````````````````
if Color(x,y) <= rgb(0,0,0)
Color(x,y) = rgb(rnd(0),rnd(0),rnd(0))
endif
if Color(x,y) <= rgb(255,255,255) and Color(x,y) >= rgb(254,254,254)
Color(x,y) = rgb(254,254,254)
endif
next x
next y
unlock pixels
cls
lock pixels
for x = 0 to width
for y = 0 to height
dot x,y,Color(x,y)
next x
next y
unlock pixels
get image output,0,0,width,height
undim Color(0)
undim Color(0)
undim Blue(0)
undim Brown(0)
undim Gray(0)
endif
endfunction
It's a little buggy, in that you still might get white patches. Here's how it works.
The function will get the color attributes of each pixel and than plot a different pixel if it is within that color range.
For example, w1 and w2 represent the blue(water) ranges. So if we specify 20-90, any rgb color between rgb(20,20,20) and rgb(90,90,90) will be colored a random value of blue. This random value gives a nice sort of grainy look to the landscape.
This random value is controlled by the 'wamp' variable, meaning Water Amplitude.
To make things short and sweet, here's an image of some automatically colored terrains.
Hope this inspires others to create a better version, or even myself to finish it off later. It just wasn't doing any good sitting around, so I've released it here once and for all.
A book? I hate book. Book is stupid.
(Formerly Yellow)