use this code.
Function NormaliseLandScape(Matno, Detail)
`================================================ This Code Is By Lee Bamber, Taken From The Dark Basic Classic Example Code.
For Z = 1 To (Detail - 1)
For X = 1 To (Detail - 1)
rem Get matrix heights
H8# = Get Matrix Height(MatNo, X, Z - 1)
H4# = Get Matrix Height(MatNo, X - 1, Z)
H# = Get Matrix Height(MatNo, X, Z)
H2# = Get Matrix Height(MatNo, 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
Set Matrix Normal MatNo, X, Z, Nx#, Ny#, Nz#
Next X
Next Z
Update Matrix MatNo
EndFunction
Where:
MatNo is the matrix number
Detail is the X/Z tile amount
1800+ XP - GeforceFX 5600 - 256MbDDR - 60Gb Hdd - XP Pro (SP2)