Terrain or big mesh

Blitz3D Forums/Blitz3D Programming/Terrain or big mesh

PeachJay(Posted 2004) [#1]
I have been messing around with a zoom-style Flight-simulation.

If I use a big terrain, it works, but I can only give it one texture.

But if I create a big mesh with different surfaces, I have trouble with the memory.

How many vertices can Biltz3d handle maximum???

I have a grid of about 2200 x 3000. I would like to zoom out so that I can see the whole terrain/grid, and then zoom at every single position and gently increase the resolution.
Then of course have different textures for trees, water, grass, snow, steep mountains etc.

Has anybody got an idea?


jfk EO-11110(Posted 2004) [#2]
Directx has that 64k Vertices Maximum. Use a Terrain whenever possible since the LOD Optimation is perfect for Flight sims. that said - terrains seems to have some compatibility problems with a number of radeon Cards/drivers, see bug report, ati terrain bug thread.

Let's assume this will be solved soon - I vote for terrains, even if you need to do some tricks for the texturing. There are several things you can do: Multitexturing with soft transitions using alpha-transparency with a blended texture (eg: the higher the mountains, the more rock shines through).
Or, even easier:
Use Multiple Terrains and stretch a single Texture across each Terrain, so there is no repetition. You can combine this with a second texture (multitexturing) that will add a fine structure pattern.


poopla(Posted 2004) [#3]
Terrains are hellu slow on older systems. But seeing as you probably arent looking to play you're game onn old systems if you're using large land areas, they could do the job.


PeachJay(Posted 2004) [#4]
Hi JFK

"Multitexturing with soft transitions using alpha-transparency with a blended texture (eg: the higher the mountains, the more rock shines through). "

Do you mean using a brush with 3 Textures
1st Groundtexture
2nd Rocktexture
3rd "How much Rock" alpha - Texture
And then using brushblend and paintentity ???

"Or, even easier:
Use Multiple Terrains and stretch a single Texture across each Terrain, so there is no repetition. You can combine this with a second texture (multitexturing) that will add a fine structure pattern. "

I guess here, I just draw several Terrains over each other and use ENTITYFX terrain2,32 For Alpa-Blending ???

I hope this is what you meant. It took quite a while for me to get into Multitexturing and I'm desperately looking for some guidance.


jfk EO-11110(Posted 2004) [#5]
The Problem is I never tried this myself :) but I think I remember some other people did it. You can set a flag whtn you laod a texture. So set the flag 2 for Alpha. Now, if oyu load a BMP, it will simply use the pixels brightness to set its transparency: the darker, the more transparent.

But there is also the TGA format. It uses 32 Bit: RGB plus an Alpha Channel that can be edited seperatly, so you can set the transparency of each pixel completely individually.

Now you would copy the heightmap to the alpha-channel of the Rock Texture. You might need to fiddle a bit with the order of the blended textures (first normal, second alpha) to make it work.

BTW there are several Painting Apps which can deal with 32 Bit TGAs (I prefere Photoshop - not that cheap), plus there is a TGA save soucecode in the codearchives, if you want to mix a texture with a heightmap yourself.


PeachJay(Posted 2004) [#6]
Hi jfk,

I've been playing around with the "Fonts + multi-texturing (B3D)" Turtorial in the forum.

It is real sad. I can only use one texture as an alpha map and then have an overlying texture.
Unfortunately I can't have a second or third overlyingtexture with alpha info.

This means, for every different Rock or Tree etc style I need a seperate Terrain with an alpha map texture(how strong should the trees look (compared to the heigt of the mountain)) and then a second terrain with small scale "black" trees but the rest of this texture has to be transperent.

Now that creates a big problem.
If I could only use a third overlay with the "leaves" texture, but no. I loose all the alpha transperency.

Any Ideas???


jfk EO-11110(Posted 2004) [#7]
I think you should not use Terrains for trees. I'd use terrains only for the ground. Today I think the best solution would be to use a high number of little terrains and use them as a grid byside eachother, eg. 10*10 Terrains, and each of these Terrains uses it's own texture that is stretched across the complete terrain. SOu you would have 100 Textures, which can be highly detailed.

If I was you, I would do the following: Create a HUGE Heightmap, maybe 640*640 Pixels. Then slice it to 10*10 parts, each 64*64 Pixels and store them as heightmaps, bitmaps or whatever you like. Then write an application in Blitz which will load each heightmap and create a 512*512 pixel texture for it. Depending on height (=brightness) of each pixel it will draw parts of some textures, grass, rock, seaground, sand, mud, whatever. You can also use transitions to mix textures, and add a random factor to make it look interesting.

However, this way you can store a texture for each part of the Heightmap Grid. SInce Terrains are using LOD (Level of detail optimation), distant Terrains are automaticly reduced to a small number of Polygons and the framerate could remain pretty high, compared to the usage of meshbased big terrains.


PeachJay(Posted 2004) [#8]
Well to tell you the truth,

I am tying to make an overview over a real existing country.

Mark Sibly's home country New Zealand.

So I have a heightmap of about 2900 x 2100 Pixels.

Splitting everything up in little units is a very good idea.

And then calculating textures for every unit is a perfect idea.

I'll have to try that out and have a look how many MBytes of Texture I will create and if it all fits well together.
I must admit, I havn't really found out how to stich the terrains togehter properly.

It would have been a great deal easier just to have several big texture layers with alpha- and texture- data.

At the moment I have the heightmap and just a big coloured terture map, that I stretch across the whole terrain. It's just color now with no texture-differences.


Matty(Posted 2004) [#9]
There is another alternative. You could generate rectangular meshes, texture them with black transparent, then conform each of the vertices of the rectangular mesh to the height of the terrain at that vertex's X and Z coordinates. Basically it is like painting the terrain with lots of quads or with a rectangular mesh made up with a lot of quads.


jfk EO-11110(Posted 2004) [#10]
@Matty - but wouldn't that mean there wold be a very big lot of Quads? 2900*2100= about 12 Million Tris - good to see you brought us some graphiccards from the year 2020 using your timemachine ;)

2900 * 2100 is really big! Do you have a bearable framerate with that?

However, you could load this Heightmap as an image, then create the Terrain-patches manually with CreateTerrain and ModifyTerrain.

something like
for y=0 to 2099 step 256
for x=0 to 2899 step 256

create terrain patch
for y2=0 to 255
for x2=0 to 255
set heights using pixels (x+x2,y+y2) brightness
next
next
position patch based on x and y
scale terrain patch so it fits in the grid

next
next


;Maybe you need to round up the size of 2900*2100 to numbers which can be divided trough 256
If you have once made this working, you can decide if this method can be used at all (speed!) I really don't know if this is going to be an overkill.

For the texture sizes you can calculate: 512*512Texels= 1 Megabyte, 256*256=250kB (well, not shure if mipmaping will require even a bit more). So 10*10 textures of 512*512 Size would require at least 128 Megabytes Videoram. YOU must decide what minimum hardware requirement makes sense.