heightmap textures
Blitz3D Forums/Blitz3D Programming/heightmap textures
| ||
Is there a way to texture an entire terrain instead of tiling the same texture over every face? |
| ||
2 ways: 1 with a mesh terrain (ie not standard blitz terrain entity) - uvmap the mesh so that the texture covers the entire mesh, usually with a planar mapping in the xz plane. other way: with a blitz terrain entity - scale the texture an appropriate amount relative to the size of the terrain. So if you have a 256x256 texture map for the heightmap then you either scale the diffuse map for the texture by 256 or 1/256 - it is one of those I can't remember offhand whether you scale it up or down. |
| ||
umm.... I'm still kind of new to programming, could you explain what a diffuse map is and how to scale it up/down? |
| ||
Sorry Eviltoes I'll see if I can explain it a bit better. I assume you have a heightmap (bitmap) you are using for the terrain using the loadterrain("heightmap.bmp") command. The diffuse map is simply your colored,textured bitmap that you want to apply to the terrain. For the purposes of this exercise you could use any bitmap you want. To scale the texture use the 'scaletexture' command. Here is some sample code to test it with: Graphics3D 800,600,32,2 camera=CreateCamera() MoveEntity camera,0,100,0 terrain=LoadTerrain("heightmap.bmp") ;image you want for heightmap tex=LoadTexture("colormap.bmp") ;image you want for texture EntityTexture terrain,tex ScaleTexture tex,256,256 ;assumes image for texture is 256pixels by 256pixels. You may need to use the texturewidth(),textureheight() commands for arbitrary texture sizes Repeat If KeyDown(200) Then MoveEntity camera,0,0,1 If KeyDown(208) Then MoveEntity camera,0,0,-1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 UpdateWorld RenderWorld Flip Until KeyDown(1) End |
| ||
Thanks very much. |
| ||
terrains and textures are kind of limited. There are some tricks: eg: use multitexturing.(Edit: seems I was wrong with some info about alpha layers, so removed). Some people tried to frag terrains, so they would me made of individual pieces that can be mapped individually. But as far as I remember this didn't work because it wasn't possible to completely hide the seams between the pieces. Today most people use Mesh terrains instead. It's a technic named "alpha splatting". Have a look at the FLE open source project as seen in the toolbox of this site. Other tools (FLE commercial, TED, ALE) are using the same method. I would however suggest to implement your own LOD system for these meshes (Level Of Detail: depending on the distance camera to the terrain mesh, a version with reducted polygon count will be used, there may be a couple of versions where only one of them is not hidden at a time). Although I have to say, Alpha Splatting involves Alpha and you will need to fix "Z-fighting" artefacts when you use it. As long as you don't need more than 2 textures, you may try the multitexturing approach instead. |