TerrainLayerColor terrain,layer[,red#][,green#][,blue#]
Parameters
|
terrain - terrain entity created with CreateTerrain or LoadTerrain layer - which of the four ground layers to tint, 0 to 3 red (optional) - red component of the tint, 0 to 255; 255 (default) green (optional) - green component of the tint, 0 to 255; 255 (default) blue (optional) - blue component of the tint, 0 to 255; 255 (default) |
Description
|
Tints one of the terrain's four ground layers. The tint multiplies the layer's texture, exactly like EntityColor does for a mesh. Leaving all three components at 255 means "no tint", which is what a layer starts with. It saves you making texture variants. One grey rock tile can become warm sandstone on one map and cold granite on another; one grass tile can be tinted olive for a summer level and straw yellow for an autumn one. It is also the cheapest way to build a terrain material at all - set four layers with no textures and four different tints, and you get flat coloured ground blended by the splat map, which is perfect for blocking a level out before any art exists. Because it is a per-layer setting rather than a whole-terrain one, you can drift a single layer over time - fading the snow layer up towards white as a storm rolls in, or reddening the dirt layer as lava approaches - without touching the other three. Gotcha: the layer index must be 0 to 3 or you get "Terrain layer must be from 0 to 3". Calling this switches the terrain onto the built-in layered material even if you have not set any textures yet, so a terrain that was using EntityTexture will change appearance. ClearTerrainMaterial throws the tints away along with everything else, so re-apply them if you rebuild the material. See also: TerrainLayer, TerrainSplatMap, TerrainNormalMap, ClearTerrainMaterial, EntityColor. |
Example
; TerrainLayerColor Example ; ------------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,6,-40 CameraClsColor camera,110,150,200 light=CreateLight(1) RotateEntity light,50,-30,0 ; Rolling hills built from a sine-wave height field terrain=CreateTerrain(128) For z=0 To 127 For x=0 To 127 ModifyTerrain terrain,x,z,0.2+Sin(x*10)*Cos(z*10)*0.12 Next Next ScaleEntity terrain,0.5,20,0.5 PositionEntity terrain,-32,-5,-32 TerrainShading terrain,True TerrainDetail terrain,8000,True ; A pale texture on layer 0 so the tint colour shows clearly pale=CreateTexture(8,8,1+8) SetBuffer TextureBuffer(pale) : ClsColor 220,220,220 : Cls : SetBuffer BackBuffer() TerrainLayer terrain,0,pale,0.2 angle#=0 paused=0 While Not KeyDown(1) ; Space pauses the colour cycle If KeyHit(57) Then paused=1-paused If paused=0 Then angle=angle+1 ; Cycle the tint of terrain material layer 0 red#=155+Sin(angle)*100 green#=155+Sin(angle+120)*100 blue#=155+Sin(angle+240)*100 TerrainLayerColor terrain,0,red,green,blue ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 RenderWorld Text 0,0,"Arrow keys: move camera Space: pause colours Esc: exit" Text 0,20,"TerrainLayerColor terrain,0,"+Int(red)+","+Int(green)+","+Int(blue) Flip Wend End
Index