Hi there
As the tittle says, what about making the texture for our terrain on the fly?. Lately, has been mentioned a seamless textures for terrains like Green Gandalf's one that I like it. Time ago, I made a little trick (as usual) to give my terrains a better appearance. Example attached .
ink rgb(255,255,255),0
set cursor 250,200:print "PLEASE WAIT "
SYNC
autocam off:hide mouse
color backdrop rgb(0,170,255)
sync on
set camera range 0.5, 30000
gosub Make_texture
` detail texture
load image "detail.tga", 2
make object terrain 1
set terrain heightmap 1, "heightmap.jpg"
set terrain scale 1, 5, 0.6, 5
set terrain split 1, 16
set terrain tiling 1, 8
set terrain light 1, 1, -0.25, 0, 1, 1, 1 , 0.5 ` luz - dirX, dirY, dirZ, red, green, blue, intensity
set terrain texture 1, 1, 2
build terrain 1
position camera x,23,z
veloc#=0.07 `camera speed
a#=170 `initial camera angle y
`initial camera position
x#=300
z#=550
do
set cursor 0,0
ink rgb(255,255,255)
if spacekey() then paste image 1,0,0
rem print x#
rem print y#
rem print z#
print "Press spacekey to see texture"
print "fps = " + str$ ( screen fps ( ) )
if upkey()=1 THEN x#=NEWXVALUE(x#,a#,veloc#):z#=NEWZVALUE(z#,a#,veloc#)
if downkey()=1 THEN x#=NEWXVALUE(x#,a#,-veloc#):z#=NEWZVALUE(z#,a#,-veloc#)
a#=wrapvalue(a#+mousemovex()/2)
cam#=wrapvalue(cam#+mousemovey()/2)
rotate camera cam#,a#,0
y#=get terrain ground height(1,x#,z#)
`TERRAIN COLLISION
`HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
xd#=get terrain ground height(1,x#+5,z#)
xi#=get terrain ground height(1,x#-5,z#)
zf#=get terrain ground height(1,x#,z#+5)
zb#=get terrain ground height(1,x#,z#-5)
if xd#>y#+3 then dec x#,veloc#
if xi#>y#+3 then inc x#,veloc#
if zf#>y#+3 then dec z#,veloc#
if zb#>y#+3 then inc z#,veloc#
`HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
position camera x#,y#+4,z#
sync
loop
Make_texture:
ink rgb(100,50,50),0
box 0,0,120,50
get image 100,0,0,120,50
load image "heightmap.jpg",1
paste image 1,0,0
ink rgb(50,100,50),0
box image width(1),0,image width(1)*2,image height(1)
`WE CAN CHANGE WHATEVER COLOUR VALUES WE NEED
for x= 1 to image width(1)
for y= 1 to image height(1)
col=rgbr(point(x,y))
col2=rgbr(point(x+1,y))
col3=rgbr(point(x-1,y))
col4=rgbr(point(x,y+1))
col5=rgbr(point(x,y-1))
if col<40 and rnd(2)=1 then ink rgb(25,75,25),0:dot x+image width(1),y
if col<120 and col>70 and rnd(2)=1 then ink rgb(75,125,75),0:dot x+image width(1),y
`mud colour
if col>col2+3 then ink rgb(100+rnd(30),80+rnd(30),50+rnd(30)),0:dot image width(1)+x+1,y
if col>col3+3 then ink rgb(100+rnd(30),80+rnd(30),50+rnd(30)),0:dot image width(1)+x-1,y
if col>col4+3 then ink rgb(100+rnd(30),80+rnd(30),50+rnd(30)),0:dot image width(1)+x,y+1
if col>col5+3 then ink rgb(100+rnd(30),80+rnd(30),50+rnd(30)),0:dot image width(1)+x,y-1
`rocks
if col>col2+6 then ink rgb(20+rnd(30),20+rnd(30),20+rnd(30)),0:dot image width(1)+x+1,y
if col>col3+6 then ink rgb(20+rnd(30),20+rnd(30),20+rnd(30)),0:dot image width(1)+x-1,y
if col>col4+6 then ink rgb(20+rnd(30),20+rnd(30),20+rnd(30)),0:dot image width(1)+x,y+1
if col>col5+6 then ink rgb(20+rnd(30),20+rnd(30),20+rnd(30)),0:dot image width(1)+x,y-1
snow=210+rnd(45)
`snow height
if col>160-rnd(5) then ink rgb(snow,snow,snow),0:dot x+image width(1),y
next y
next x
get image 1,image width(1)+1,0,image width(1)*2,image height(1)
return
I'm not a grumpy grandpa
