Terrain splatting is a new terrain feature in 6.5 that allows you to use tiled high-resolution textures rather than one large texture over the whole terrain. It uses alpha maps to determine where each texture layer will be visible.
Texture splatting is very easy to set up once you know how it works, and this tutorial should help you to understand it perfectly. All of the media discussed is included in the sample project.
First, we must declare the terrain variable.
Public Terrain As TVLandscape
Next, the three textures to be used for the terrain, the base, the first layer, and the first layer’s alphamap, are loaded into the engine.
Dim iGrassTex, iDirtTex, iAlphaMap As Integer iGrassTex = TextureFactory.LoadTexture(Application.StartupPath & "\grass.jpg", "grass") iDirtTex = TextureFactory.LoadTexture(Application.StartupPath & "\RockyEarth.dds", "Dirt") iAlphaMap = TextureFactory.LoadTexture(Application.StartupPath & "\AlphaMap.dds", "alpha1")
We now have the necessary textures, so we set up the terrain with some terrain data and a texture, and specify the base texture’s scale.
Terrain = Scene.CreateLandscape("Terrain1") Terrain.LoadTerrainData(Application.StartupPath & "\Terrain1.tvm") Terrain.SetTexture(iGrassTex) Terrain.SetTextureScale(4, 4)
Finally, here’s where the splatting comes in. Before starting with splatting, we must enable it using SetSplattingEnable. Then, for each splatting layer you want to add, you call AddSplattingLayer with a priority of 0, ExpandSplattingLayer with your alphamap, and SetSplattingTextureProperties with the texture scale you want. After you finish adding all layers, call OptimizeSplatting to make it run faster. If you ever want to remove all splatting stuff and start over, use ClearAllSplattingLayers and then RemoveAllSplattingLayers.
Terrain.SetSplattingEnable(True) Terrain.AddSplattingTexture(iDirtTex, 0) Terrain.ExpandSplattingTexture(iAlphaMap, iDirtTex) Terrain.SetSplattingTextureProperties(iDirtTex, New TV_3DVECTOR(0, 1, 0), 0, 4, 4) Terrain.OptimizeSplatting()
As always, remember to render your terrain between Tv.Clear and Tv.RenderToScreen.
Splatting Sample Project: http://pizzayoyo.smithbower.com/other/SplattingSample.rar Don’t forget to add your beta key to the project, and put the latest MTV3D65.dll in the bin\x86\release folder!