My terrain engine (will it ever get finished) has evolved, I now have a base heightmap that gives the general layout of the island the scale is massive, each individual pixel represents 1km^2. The engine then generates a procedural texture from this and neighboring pixel heights to get twice the detail. I repeat this several times till I get a 10x10cm resolution per pixel.
The end result is quite satisfying and the undelying mesh is scrolled with the player, View distance is quite far and detail is high plus there is only a slight delay (hardly noticable) when the procedural edges get redrawn when the player moves a set distance.
I have the Mesh, Player Movement, Procedural update all working at the moment, still trying to get my procedural function to generate suitable terrain results then I'll focus on the shader aspect. I'll probably look into modifying GG's shader to support my requirements.
Here is some code to help explain...
`*** LOD Terrain test
`***
`*** Setup Display
Set Display Mode 800,600,32
Create_Texture() `<- Default Grass Texture
Hide Mouse : Sync Rate 0 : Sync On : Sync
Color Backdrop RGB(128,192,255)
Fog On : Fog Color RGB(128,192,255) :Fog Distance 800*(600.0/800.0) `<- Screen Aspect Ratio
`*** Create Matrices
Make Matrix 1,1600,1600,40,40 :Position Matrix 1,-800,0,-800
Prepare Matrix Texture 1,1,1,1 :`<- This should have an accross & Down of .01 to maintain scale.
Set Matrix Texture 1,0,1
Make Matrix 2,400,400,20,20 :Position Matrix 2,-200,.01,-200
Prepare Matrix Texture 2,1,1,1 :`<- This should have an accross & Down of .1 to maintain scale.
Set Matrix Texture 2,0,1
Make Matrix 3,100,100,10,10 :Position Matrix 3,-50,.02,-50
Prepare Matrix Texture 3,1,1,1
Set Matrix Texture 3,0,1
`*** Main Loop
#Constant TC = (128<<24)||(0<<16)||(0<<8)||(128)
Position Camera 0,0,5,0
Do
Control Camera Using ArrowKeys 0,.5,.5
CX=Camera Position X()
CZ=Camera Position Z()
If Abs(CX-NX)>=10 or Abs(CZ-NZ)>=10
If Abs(CX-MX)>=20 or Abs(CZ-MZ)>=20
If Abs(CX-FX)>=40 or Abs(CZ-FZ)>=40
`*** Update Far-Range ***
If Abs(CX-FX)>=40 then FX=CX
If Abs(CZ-FZ)>=40 then FZ=CZ
`Procedural(1,FX,FZ,40)
Position Matrix 1,-800+FX,0,-800+FZ
EndIf
`*** Update Mid-Range ***
If Abs(CX-MX)>=20 then MX=CX
If Abs(CZ-MZ)>=20 then MZ=CZ
`Procedural(2,MX,MZ,20)
Position Matrix 2,-200+MX,.01,-200+MZ
EndIf
`*** Update Near-Range ***
If Abs(CX-NX)>=10 then NX=CX
If Abs(CZ-NZ)>=10 then NZ=CZ
`Procedural(3,NX,NZ,10)
Position Matrix 3,-50+NX,.02,-50+NZ
EndIf
Status()
Loop
End
`*** Create Texture
Function Create_Texture()
For X=1 to 128
For Y=1 to 128
Dot X,Y,RGB(Rnd(64),RND(64)+128,RND(128))
Next
Next
Get Image 1,0,0,128,128,0
EndFunction
`***
Function Status()
Box 0,0,100,32,TC,TC,TC,TC
T$=" "+Str$(Screen FPS())+" FPS"
Text 95-Text Width(T$),0,T$
T$=" "+Str$(Statistic(1))+" Polys"
Text 95-Text Width(T$),16,T$
Sync
EndFunction
Go Create...
Cyberspace was becoming overcrowded and slummy so I decided to move. These nice chaps gave me a lift.