Thanks GG,
It would just make it easier because after I changed the Tiling, the grass looked better, but the cliff looked noticeably tiled...
If your virtual memory is too low, change the size of the terrain. At the moment, the code makes a 10000,10000,400,400 matrix, splits it into 10x10 pieces and then makes 100 memblocks. Try making the terrain smaller to start with, and Ill post a edited version of the code in a minute...
About shdaerdata.dll, I dont have darkshader, so I dont know where that came from...
I'll also have a browse to see if I can find your original shaders on the forum, and post a link if I find anything =)
Edit:
GG, could you try this code? Its similar to before but the original matrix is 100 times smaller ( only 1000,1000,40,40) and it only makes one memblock not 100, so that should work for you now .
set display mode 1024,768,32
sync on
sync rate 0
set camera range 0,1,10000
t = timer()
randomize 6018045`timer()`5742813
v = make vector4(1)
v = make vector4(2)
load effect "GG Blended Bump Mapping Shader v4.fx",1,0
load image "grass1.bmp", 301
load image "rocky_cliff_t.png", 302
load image "sand1.png", 303
load image "gravel1.png", 304
load image "RoadMap.png", 305
load image "sandstone.png", 306
dim tilex(256)
dim tilez(256)
dim tilesizex#(512)
dim tilesizez#(512)
dim texture(512)
dim xpart#(128)
dim ypart#(128)
dim object(512)
time=timer()
fase#=0.00
splitx = 10
splity = 10
oldsizex = 5000
oldsizey = 5000
oldnox = 400
oldnoy = 400
newnox = (oldsizex/splitx)/12
newnoy = (oldsizey/splity)/12
dim mat(splitx*splity+1,4)
dim oldheight#(oldnox,oldnoy)
dim midpoint(splitx*splity+1,2)
mat = 1
makenorm(mat,oldsizex,oldsizey,oldnox,oldnoy,35,800)
splitmatrix(mat,splitx,splity,oldsizex,oldsizey,oldnox,oldnoy)
memblock(500,500,10,10)
do
control camera using arrowkeys 0,15,3
text 0,0,str$(t)
text 0,10,str$(screen fps())
sync
loop
end
function gaussian_function(x as float,z as float,centerx as float,centerz as float,spread as float,intensity as float)
xterm#=((x-centerx)/spread)^2
zterm#=((z-centerz)/spread)^2
height#=intensity*EXP(0-(xterm#+zterm#)) ` # signs added as well
endfunction height#
function makenorm(matno,matx,matz,sizex,sizez,spread,intensity)
rem make a matrix
make matrix matno,matx,matz,sizex,sizez
`position matrix matno, matx*matno,0,matz
hillno = 20
dim hill(hillno,3) `0 = cntx 1= cntz 2= sprd 3 = int
dim height#(hillno)
for h = 1 to hillno
hill(h,0) = rnd(sizex-100)+50
hill(h,1) = rnd(sizez-100)+50
hill(h,2) = rnd(spread-10)+10
hill(h,3) = rnd(intensity/3) + intensity/2
next h
cumulheight# = 0
rem make the gaussian hill
for x=0 to sizex `maximum matrix width
for z=0 to sizez `maximum matrix height
cumulheight# = 0
x# = x
z# = z
for hill = 1 to hillno
height#(hill) = gaussian_function(x#,z#,hill(hill,0),hill(hill,1),hill(hill,2),hill(hill,3))
cumulheight# = cumulheight# + height#(hill)
next hill
set matrix height matno,x,z,cumulheight#`height#(1) + height#(2) + height#(3) + height#(4) + height#(5) + height#(6) + height#(7) + height#(8) + height#(9) + height#(10)
next y
next x
update matrix matno
endfunction
function splitmatrix(mat,splitx,splity,oldsizex,oldsizey,oldnox,oldnoy) `split value is how many new smaller matrices you want
newsizex = oldsizex / splitx `1000
newsizey = oldsizey / splity `1000
newnox = newsizex / 25 `40
newnoy = newsizey / 25 `40
for x = 0 to oldnox
for y = 0 to oldnoy
oldheight#(x,y) = get matrix height(mat,x,y)
next y
next x
x = 0
y = 0
for m = 2 to splitx*splity+1
make matrix m, newsizex,newsizey,newnox,newnoy
position matrix m, x*newsizex,0,y*newsizey
`mat(m,1) = matrix position x(m)
`mat(m,2) = matrix position z(m)
`mat(m,3) = newsizex
`mat(m,4) = newsizey
for hx = 0 to newnox
for hy = 0 to newnoy
newheight# = oldheight#((x*newnox)+hx,(y*newnoy)+hy)
set matrix height m, hx,hy,newheight#
next hy
next hx
inc y
if y = splity
x = x + 1
y = 0
endif
update matrix m
next m
`setlodmatrices(2,5,5,mat(2,3),mat(2,4))
delete matrix 1
endfunction 1
function memblock(nsx,nsy,splitx,splity)
dim matrixheight#(splitx*splity,nsx,nsy)
for mem = 2 to splitx*splity+1
makematrix(mem,500,500,20,20)
for x = 0 to 20`tilex(mem)
for z = 0 to 20`tilez(mem)
matrixheight#(mem,x,z) = get matrix height(mem,x,z)
setmatrixheight(mem,x,z,matrixheight#(mem,x,z))
`if matrixheight#(mem,x,z)>=30 and matrixheight#(mem,x,z)<60 then color=rgb(255,255,149)`int(200-((matrixheight#(mem,x,z)-200)*1.50)),int(150+((matrixheight#(mem,x,z)-200)*1.00)),50)
`if matrixheight#(mem,x,z)>=60 and matrixheight#(mem,x,z)<600 then color=rgb(0,91,0)`int(50+((matrixheight#(mem,x,z)-3)*1.00)),int(250-((matrixheight#(mem,x,z)-3)*1.00)),int(50+((matrixheight#(mem,x,z)-3)*1.00)))
`if matrixheight#(mem,x,z)<600 then color=rgb(0,91,0)
`if matrixheight#(mem,x,z)>=600 then color=rgb(250,250,250)
`if matrixheight#(mem,x,z)<30 then color=rgb(0,0,255)
`setmatrixcolor(mem,x,z,color)
next z
next
normalizematrix(mem,0,0,tilex(1),tilez(1))
positionmatrix(mem,matrix position x(mem),matrix position y(mem),matrix position z(mem))
updatematrix(mem)
delete matrix mem
texture object mem+50, 0, 301 ` first detail map
texture object mem+50, 1, 302 ` second detail map
texture object mem+50, 2, 303 ` third detail map
texture object mem+50, 3, 304 ` fourth detail map
`texture object mem+50 4, tex_grid ` road map
texture object mem+50, 5, 306 ` road texture
SET OBJECT NORMALS mem+50
set object effect mem+50, 1
` sc_setupobject mem+50, 1, 0
next mem
contrast# = 10.0
vertScale# = 0.014
set effect constant float 1, "contrast", contrast#
set effect constant float 1, "vertScale", vertScale#
set vector4 1, 0.1, 0.1, 1, 1
set effect constant vector 1, "UVTiling", 1
endfunction
function makematrix(mem,x#,z#,tilex,tilez)
tilex(mem)=tilex
tilez(mem)=tilez
tilesizex#(mem)=x#/tilex(mem)
tilesizez#(mem)=z#/tilez(mem)
polys=2*tilex*tilez
size=(polys*36*3)+12
make memblock mem,size
write memblock dword mem,0,338
write memblock dword mem,4,36
write memblock dword mem,8,polys*3
Position=12
for x=1 to tilex(mem)
for z=1 to tilez(mem)
writevectordata(mem,Position,(x-1.0)*tilesizex#(mem),0.000,(z-1.0)*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),0.000,1.000)
writevectordata(mem,Position+36,x*tilesizex#(mem),0.000,z*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),1.000,0.000)
writevectordata(mem,Position+72,x*tilesizex#(mem),0.000,(z-1.0)*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),1.000,1.000)
writevectordata(mem,Position+108,(x-1.0)*tilesizex#(mem),0.000,(z-1.0)*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),0.000,1.000)
writevectordata(mem,Position+144,(x-1.0)*tilesizex#(mem),0.000,z*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),0.000,0.000)
writevectordata(mem,Position+180,x*tilesizex#(mem),0.000,z*tilesizez#(mem),0.000,1.000,0.000,rgb(255,255,255),1.000,0.000)
Position=Position+216
next z
next x
object(mem)=mem+50`000
make mesh from memblock object(mem),mem
make object object(mem),object(mem),0
endfunction
function writevectordata(mem,Position,X# as float,Y# as float,Z# as float,NX# as float,NY# as float,NZ# as float,color as dword,TU# as float,TV# as float)
write memblock float mem,Position,X#
write memblock float mem,Position+4,Y#
write memblock float mem,Position+8,Z#
write memblock float mem,Position+12,NX#
write memblock float mem,Position+16,NY#
write memblock float mem,Position+20,NZ#
write memblock dword mem,Position+24,color
write memblock float mem,Position+28,TU#
write memblock float mem,Position+32,TV#
endfunction
function setmatrixheight(mem,x,z,y#)
if x-1>=0 and z-1>=0
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+40,y#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+184,y#
endif
if x-1>=0 and z<tilez(mem)
write memblock float mem,12+(216*(((x-1)*tilez(mem))+z))+76,y#
endif
if x<tilex(mem) and z-1>=0
write memblock float mem,12+(216*((x*tilez(mem))+(z-1)))+148,y#
endif
if x<tilex(mem) and z<tilez(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+4,y#
write memblock float mem,12+(216*((x*tilez(mem))+z))+112,y#
endif
endfunction
function setmatrixcolor(mem,x,z,color)
if x-1>=0 and z-1>=0
write memblock dword mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+60,color
write memblock dword mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+204,color
endif
if x-1>=0 and z<tilez(mem)
write memblock dword mem,12+(216*(((x-1)*tilez(mem))+z))+96,color
endif
if x<tilex(mem) and z-1>=0
write memblock dword mem,12+(216*((x*tilez(mem))+(z-1)))+168,color
endif
if x<tilex(mem) and z<tilez(mem)
write memblock dword mem,12+(216*((x*tilez(mem))+z))+24,color
write memblock dword mem,12+(216*((x*tilez(mem))+z))+132,color
endif
endfunction
function setmatrixnormal(mem,x,z,nx#,ny#,nz#)
if x-1>=0 and z-1>=0
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+48,nx#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+52,ny#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+56,nz#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+192,nx#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+196,ny#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+200,nz#
endif
if x-1>=0 and z<tilez(mem)
write memblock float mem,12+(216*(((x-1)*tilez(mem))+z))+84,nx#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+z))+88,ny#
write memblock float mem,12+(216*(((x-1)*tilez(mem))+z))+92,nz#
endif
if x<tilex(mem) and z-1>=0
write memblock float mem,12+(216*((x*tilez(mem))+(z-1)))+156,nx#
write memblock float mem,12+(216*((x*tilez(mem))+(z-1)))+160,ny#
write memblock float mem,12+(216*((x*tilez(mem))+(z-1)))+164,nz#
endif
if x<tilex(mem) and z<tilez(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+12,nx#
write memblock float mem,12+(216*((x*tilez(mem))+z))+16,ny#
write memblock float mem,12+(216*((x*tilez(mem))+z))+20,nz#
write memblock float mem,12+(216*((x*tilez(mem))+z))+120,nx#
write memblock float mem,12+(216*((x*tilez(mem))+z))+124,ny#
write memblock float mem,12+(216*((x*tilez(mem))+z))+128,nz#
endif
endfunction
function getmatrixheight(mem,x,z)
if x-1>=0 and z-1>=0
height#=memblock float(mem,12+(216*(((x-1)*tilez(mem))+(z-1)))+40)
else
if x<tilex(mem) and z<tilez(mem)
height#=memblock float(mem,12+(216*((x*tilez(mem))+z))+4)
else
height#=memblock float(mem,12+(216*(((x-1)*tilez(mem))+z))+76)
endif
endif
endfunction height#
function normalizematrix(mem,bx,bz,ex,ez)
if bx<=0 then bx=1
if bz<=0 then bz=1
if ex>=tilex(mem) then ex=tilex(mem)-1
if ez>=tilez(mem) then ez=tilez(mem)-1
rem Use matrix normals to make it smooth
for z=bz to ez
for x=bx to ex
rem Get matrix heights
h8#=getmatrixheight(mem,x,z-1)
h4#=getmatrixheight(mem,x-1,z)
h#=getmatrixheight(mem,x,z)
h2#=getmatrixheight(mem,x,z)
rem Calculate projected angle X using heights
x1#=(x-1)*25.0 : y1#=h#
x2#=(x+0)*25.0 : y2#=h4#
dx#=x2#-x1#
dy#=y2#-y1#
ax#=atanfull(dx#,dy#)
ax#=wrapvalue(90-ax#)
rem Calculate projected angle Z using heights
z1#=(z-1)*25.0 : y1#=h2#
z2#=(z+0)*25.0 : y2#=h8#
dz#=z2#-z1#
dy#=y2#-y1#
az#=atanfull(dz#,dy#)
az#=wrapvalue(90-az#)
rem Make normal from projected angle
nx#=sin(ax#)
ny#=cos(ax#)
nz#=sin(az#)
rem Setting matrix normal for smoothness
setmatrixnormal(1,x,z,nx#,ny#,nz#)
next x
next z
endfunction
function updatematrix(mem)
change mesh from memblock object(mem),mem
change mesh object(mem),0,object(mem)
texture object object(mem),texture(mem)
endfunction
function getgroundheight(mem,x#,z#)
if x#>=0 and z#>=0 and x#<tilex(mem)*tilesizex#(mem) and z#<tilez(mem)*tilesizez#(mem)
xt=int(x#/tilesizex#(mem))
zt=int(z#/tilesizez#(mem))
if (((xt+1)*tilesizex#(mem))-x#)+(z#-(zt*tilesizez#(mem)))<=tilesizex#(mem)
dx#=getmatrixheight(mem,xt+1,zt)-getmatrixheight(mem,xt,zt)
dz#=getmatrixheight(mem,xt+1,zt+1)-getmatrixheight(mem,xt+1,zt)
else
dx#=getmatrixheight(mem,xt+1,zt+1)-getmatrixheight(mem,xt,zt+1)
dz#=getmatrixheight(mem,xt,zt+1)-getmatrixheight(mem,xt,zt)
endif
height#=(((x#-(xt*tilesizex#(mem)))/tilesizex#(mem))*dx#)+(((z#-(zt*tilesizez#(mem)))/tilesizez#(mem))*dz#)+getmatrixheight(mem,xt,zt)
endif
endfunction height#
function setmatrixtile(mem,x,z,xtex,ytex)
write memblock float mem,12+(216*((x*tilez(mem))+z))+28,(xtex-1)*xpart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+32,ytex*ypart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+64,xtex*xpart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+68,(ytex-1)*ypart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+100,xtex*xpart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+104,ytex*ypart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+136,(xtex-1)*xpart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+140,ytex*ypart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+172,(xtex-1)*xpart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+176,(ytex-1)*ypart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+208,xtex*xpart#(mem)
write memblock float mem,12+(216*((x*tilez(mem))+z))+212,(ytex-1)*ypart#(mem)
endfunction
function Positionmatrix(mem,x#,y#,z#)
Position object object(mem),x#,y#,z#
endfunction
function ghostmatrix(mem,ghost)
ghost object on object(mem),ghost
endfunction