Warning: Undefined array key "translationlc" in /usr/www/users/fabook/_diggets/doc/v2/lib/plugins/translation/action.php on line 237

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/fabook/_diggets/doc/v2/lib/plugins/translation/action.php:237) in /usr/www/users/fabook/_diggets/doc/v2/inc/Action/Export.php on line 104

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/fabook/_diggets/doc/v2/lib/plugins/translation/action.php:237) in /usr/www/users/fabook/_diggets/doc/v2/inc/Action/Export.php on line 104

Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/fabook/_diggets/doc/v2/lib/plugins/translation/action.php:237) in /usr/www/users/fabook/_diggets/doc/v2/inc/Action/Export.php on line 104
====== Terrain Material (TGorillaTerrainMaterialSource) ====== The **TGorillaTerrainMaterialSource** is inherited from the TGorillaDefaultMaterialSource, supports multiple lights and enables texturing by height information: **GORILLA_GLSL_DEFINE_TERRAINMAP** {{ ::terrain-example.png?nolink&600 |}} {{youtube>fFNIXRQZOHk?medium}} It works by defining a height range and which texture to use. To allow texture overlapping, you can configure transition for each level. The material provides a texture bitmap pool (TCollection) where you can simply add your height levels and the texture to be used. We create a height level by Bitmaps.Add() function and retrieve a new **TGorillaTerrainBitmap** instance with a few properties to be set: ^ Property ^Notice ^ | DisplayName | A required texture name. | | MinHeight | The lower limit value, depending on the __untransformed__ mesh vertex position. | | MaxHeight | The upper limit value, depending on the __untransformed__ mesh vertex position. | | LowTransition | A transition value at the lower limit for blending transitions between textures. | | HighTransition | A transition value at the upper limit for blending transitions between textures. | | Tiling | A texture tiling for multiplying the specific texture. | | Bitmap | Loading the texture data itself. | var LTerrMat : TGorillaTerrainMaterialSource; LTerrBmp : TGorillaTerrainBitmap; [...] LTerrMat := TGorillaTerrainMaterialSource.Create(fTerrain); LTerrMat.Parent := FTerrain; with LTerrMat do begin // height level 1 LTerrBmp := Bitmaps.Add() as TGorillaTerrainBitmap; LTerrBmp.DisplayName := 'TerrainTexture0'; LTerrBmp.MinHeight := +0.1; LTerrBmp.MaxHeight := -0.5; LTerrBmp.LowTransition := 0.25; LTerrBmp.HighTransition := 0.25; LTerrBmp.Tiling := TPointF.Create(32, 32); LTerrBmp.Bitmap.LoadFromFile('terrain-1.jpg'); // height level 2 LTerrBmp:= Bitmaps.Add() as TGorillaTerrainBitmap; LTerrBmp.DisplayName := 'TerrainTexture1'; LTerrBmp.MinHeight := -0.5; LTerrBmp.MaxHeight := -1.0; LTerrBmp.LowTransition := 0.25; LTerrBmp.HighTransition := 0.25; LTerrBmp.Tiling := TPointF.Create(32, 32); LTerrBmp.Bitmap.LoadFromFile('terrain-2.jpg'); // height level 3 LTerrBmp:= Bitmaps.Add() as TGorillaTerrainBitmap; LTerrBmp.DisplayName := 'TerrainTexture2'; LTerrBmp.MinHeight := -1.0; LTerrBmp.MaxHeight := -2.0; LTerrBmp.LowTransition := 0.25; LTerrBmp.HighTransition := 0.25; LTerrBmp.Tiling := TPointF.Create(32, 32); LTerrBmp.Bitmap.LoadFromFile('terrain-3.jpg'); // height level 4 LTerrBmp:= Bitmaps.Add() as TGorillaTerrainBitmap; LTerrBmp.DisplayName := 'TerrainTexture3'; LTerrBmp.MinHeight := -2.0; LTerrBmp.MaxHeight := -FTerrain.HeightScale - 0.1; LTerrBmp.LowTransition := 0.25; LTerrBmp.HighTransition := 0.25; LTerrBmp.Tiling := TPointF.Create(32, 32); LTerrBmp.Bitmap.LoadFromFile('terrain-4.jpg'); end; ==== Lower and upper limits ==== The texture selection in the material shader depends on the untransformed mesh vertex position on y-axis (GLSL: "vars.v_VertPos.y"). So MinHeight and MaxHeight values should range between 0.0 and -FTerrain.HeightScale including a tolerance of +/-0.1. For example: 1) Dividing a terrain in __3 equal height-levels__ at a __terrain height scale of 1.0__ means: ^ Level ^ MinHeight ^ MaxHeight ^ | Level 1 | 0.0 [+ 0.1] | -0.33 | | Level 2 | -0.33 | -0.66 | | Level 3 | -0.66 | -1.0 [-0.1] | 2) Dividing a terrain in __3 equal height-levels__ at a __terrain height scale of 2.0__ means: ^ Level ^ MinHeight ^ MaxHeight ^ | Level 1 | 0.0 [+ 0.1] | -0.66 | | Level 2 | -0.66 | -1.33 | | Level 3 | -1.33 | -2.0 [-0.1] | ==== Lower and upper transition ==== Transition values are useful for overlapping / blending textures to simulate a more realistic terrain texture. Like the lower and upper limit values, transitions also depend on the untransformed mesh vertex position. So LowTransition and HighTransition values should range between 0.0 and -FTerrain.HeightScale, too.