Texturing is essential to improve the visual appearance of object. When texturing, the 3D position on the surface of object is transformed to a 2D uv coordinate for sampling. In heightmap-based terrain, this could be easily done by one planar projection. However, due to the topological complexity of voxel terrain, single planar projection would cause distortion along different direction.
To avoid distortion, we instead uses an elegant technique named triplanar texturing, also suggested by GPU Gem. Triplanar texturing literally performs three planar projections respectively on xy-plane, yz-plane, and xz-plane. Triplanar texture then performs a weighted sum of three values, where the weight is the outward normal vector. For example, if the outward normal vector points mostly in x direction, the value of yz-plane would be the main component. Here let’s have a look at the effect of triplanar texturing (of course with bump mapping):
Indeed, there is no distortion. However, we can easily notice repeated tiling of the texture. The tiling artifact remains a dilemma in texturing large areas like terrains. If the texture scale is small, tilling artifact becomes obvious in a distant view; If the texture scale is large, the detail of terrain becomes blurry. In this project, we try to reduce the artifact by employing several techniques.
The first technique is called Multi-UV mixing, which is described on https://udn.epicgames.com/Three/TerrainAdvancedTextures.html. Multi-UV mixing is a low-cost method for improving terrain textures and decreasing apparent tiling by mixing one texture at two different UV scales. The advantage of using the same texture twice is that it does not require additional resources. For example, given a UV coordinate (u,v), the texture is sampled both at (u, v) and (0.25*u, 0.25*v). The latter value serves as a low frequency component to be modulated (multiplied) by the former value which serves as a high frequency component. The repeating period thus gets a 4x increase. Let’s see what the terrain looks like after applying the technique. After mixing different UV scale, the repeatedness is reduced remarkably.
The second technique is coherent noise. Coherent noise is the “ultimate weapon” against repeatedness. A noise function can be considered as an infinitely large texture with infinite preciseness. Coherent noise also generates natural or visually appealing pattern which is easy to blend into other patterns. To further break the repeatedness, here we add an extra macro layer of noise to adjust the color of the terrain:
Noise blended in
Note that the brightness and the color of terrain is more variant now.
Finally, terrain texturing should support multiple textures for more diverse look. To control the distribution of multiple textures, an extra volumetric splatmap is introduced. Here, the four channels of a splatmap could be used to control four terrain textures. The terrain starts to become cool, and even more awesome with some lights and a skybox!!
Here is some more zoomed-in screenshots. We can see the terrain has pretty rich details and variation: