Josh in Josh's Dev Blog
A new update is available for beta testers. This adds a new LOD system to the terrain system, fixes the terrain normals, and adds some new features. The terrain example has been updated ans shows how to apply multiple material layers and save the data.
Terrain in LE4 uses a system of tiles. The tiles are rendered at a different resolution based on distance. This works great for medium sized terrains, but problems arise when we have very large view distances. This is why it is okay to use a 4096x4096 terrain in LE4, but your camera range should only show a portion of the terrain at once. A terrain that size will use 1024 separate tiles, and having them all onscreen at once can cause slowdown just because of the number of objects. That have to be culled and drawn.
Another approach is to progressively divide the terrain up into quadrants starting from the top and working down to the lowest level. When a box is created that is a certain distance from the camera, the algorithm stops subdividing it and draws a tile. The same resolution tile is drawn over and over, but it is stretched to cover different sized areas.
This approach is much better suited to cover very large areas. At the furthest distance, the entire terrain will be drawn with just one single 32x32 patch. Here it is in action with a 2048x2048 terrain, the same size as The Zone:
This example shows how to load a heightmap, add some layers to it, and save the data, or load the data we previously saved:
local terrain = CreateTerrain(world,2048,32)
--Add base layer
local mtl = LoadMaterial("Materials/Dirt/dirt01.mat")
local layerID = terrain:AddLayer(mtl)
--Add rock layer
mtl = LoadMaterial("Materials/Rough-rockface1.json")
rockLayerID = terrain:AddLayer(mtl)
terrain:SetLayerSlopeConstraints(rockLayerID, 35, 90, 25)
--Add snow layer
mtl = LoadMaterial("Materials/Snow/snow01.mat")
snowLayerID = terrain:AddLayer(mtl)
terrain:SetLayerHeightConstraints(snowLayerID, 50, 1000, 8)
terrain:SetLayerSlopeConstraints(snowLayerID, 0, 35, 10)
if FileType("Terrain/2048/2048_N.raw") == 0 then
if FileType("Terrain/2048/2048_L.raw") == 0 or FileType("Terrain/2048/2048_A.raw") == 0 then
The x86 build configurations have also been removed from the game template project. This is available now in the beta tester forum.