Terrain for flight simulators

Started by
8 comments, last by Stainless 9 years, 8 months ago

I've been thinking about this for a while and I am kinda getting to the "code something and see if it bloody works" stage, but I want to have a chat about it with youguys first.

The problem I am trying to get my head around is the shear scale of things. I've written planetary terrain systems in the past, but they don't require that Buckingham Palace is recognisable and in the correct place.

Say I want to be able to have a theatre of operation that covers western Europe in the 1940's. Your are looking at about 1000 miles by a 1000 miles.

That's a big area. Using a 4K texture gives me a resolution of about 0.25 miles per pixel. Not very nice.

So I started thinking about using the texture pixel as the base height and adding in pseudo random noise for detail. In effect turning every pixel into a CLOD (well I'm leaning towards ROAM) patch.

Then I can have the resolution I want at the cost of a lot more processing, but at first glance it looks possible.

The next thing I thought about was visibility. If I was at ground level, then it's not too bad. Maybe an 8 by 8 set of patches would suffice.

However at 35,000 feet. The visible range is huge and I'm having to handle huge numbers of patches. Admittedly all of them would be reduced to a single quad, or at least most of them, but it's still a lot of patches.

So I started thinking about organising sets of patches into region patches, and groups of region patches into sector patches, and sector patches into country patches, and about that point I decided to go for a beer instead.

Has anyone had any expierience with a system like this?

Anyone got a better idea (Please have a better idea, pretty please with sugar on)

Advertisement

Create a quad tree for your terrain. Make each leaf contain a mesh fixed size such as 33x33 vertices (you can even use tesselation hardware for this). Subdive the quadtree nodes based on the distance from camera, for example : if camera distance to node bound is smaller than the bound size, subdivide (this may not be optimal algorithm).

WIth few hundred quad tree nodes you'll be able to simulate pretty huge terrains at variable resolution. Increasing the visible range gets cheaper and cheaper since bigger nodes cover bigger terrain areas. Of course you should try to keep the terrain triangles small enough so that the screen space error is small. This can be handled with a proper node subdivision algorithm.

In the best case you'll have a height texture or texture array which contains 33x33 blocks.With a 1K x 1K height texture, you can have around 900 nodes in the GPU memory in the same time. When the camera moves, you'll need to update the height texture from system ram, or hard disk, or use any random terrain algorithm you find suitable.

Just some ideas,

Cheers!


35,000 feet ... in the 1940's. Your are looking at about 1000 miles by a 1000 miles

35,000 feet? Spacecraft in the 40s? wink.png You might consider revising your parameters before you design everything. A P15 Mustang had a maximum altitude ~10,000 feet. So maybe more like 125x125 miles. You can limit that even further by adding haze (fog/clouds) as, at high altitudes there wouldn't be a real use for a pilot to see more than (maybe) 10 miles.

EDIT: Oops. Misread some info. This post is bogus. sad.png

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.


35,000 feet ... in the 1940's. Your are looking at about 1000 miles by a 1000 miles

35,000 feet? Spacecraft in the 40s? wink.png You might consider revising your parameters before you design everything. A P15 Mustang had a maximum altitude ~10,000 feet. So maybe more like 125x125 miles. You can limit that even further by adding haze (fog/clouds) as, at high altitudes there wouldn't be a real use for a pilot to see more than (maybe) 10 miles.

The Me-262 had a service ceiling of 37,565 ft, and the P51 Mustang had a service ceiling of 41,900 ft.... what are you talking about?

Something to think about, is that other flight sim games actually use a curved surface to represent the terrain, I'm spotty on the details but MS Flight did that.

Oh, this might help? http://www.microsoft.com/Products/Games/FSInsider/developers/Pages/GlobalTerrain.aspx

@Ameise: you're correct. I was wildly incorrect.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Thanks ferrous, that doc really has given me a few ideas.

I don't want the whole Earth. I want to be able to have theatre's of operation and expend more resources to make that much smaller area as high detail as I can.

Despite that , the techniques in the doc are very close to what I have bouncing around in my skull.

It's food for thought.

When I'm doing a whole planet I use six quadtrees arranged as a cube them deform them to a sphere in the vertex shader, I don't want to do that here.

I had to write something like this in my first job, it was about WinXP times, with ~128MB ram and GPUs with 4MB-32MB, artist drew a map of about 16384*12288+mips in DXT3 which was quite a chunk of a CD.

My pragmatic way to solve it was to divide the map into a simple Grid, every Grid entry with tiles of 256x256 which led to 64x48 for maintainance, which really isn't much to worry about (that's why I didn't go for quadtree or something). The grid entry was a struct, having the offset of the zipped texture in the archive, a 2d distance to the player and a pointer for the device texture.

depending on your hardware (or rather your settings), there were some 256x256 textures allocated, some 128x128, and most 64x64. On initialization, the distance to the player was calculated for every grid entry, then those 3k cells were sorted and initialized the textures by picking the highest available.

every frame the distance was re-evaluated and an iterator was increased, doing like a simple bubble-sort pass.
the iteration was interrupted for the frame either if the interator looped through all grid entries or if two entries with a different texture resolution needed to be swapped. in that case the pointers were swapped and the textures were uploaded (that way there was no dynamic allocation fragmenting the GPU mem and the framerate was quite stable as the amount of uploads was limited). At that time there was no multicore (maybe there was a Pentium D already, dunno), everything had to run single thread so there was no smart streaming going on. The map archive was installed on HDD, it was read only memorymapped by windows, but access could still stall and drop a frame or two.

Yet in general it was running quite smooth. I could imagin you could nowadays go to 4096x4096 tiles, if DXT+zip is not enough, even transcode those from jpg to have more space -> more tiles on disc. that would be 262144x196608 pixel ;)

(btw. I had no heightmap, just flat terrain, but you could get it working with CLOD terrain I if the border of your Grid entries meet, that would barely reduce the resolution.)

I suggest using quad tree for geometry management and procedural virtual texturing for texturing.

Lots of good information is here:

http://dice.se/publications/terrain-in-battlefield-3-a-modern-complete-and-scalable-system/

My implementation results:

I tested this approach to terrain sizes of 1000 km x 1000 km (with 10m elevations sampling span) and texture sizes

up to 256M x 256M pixels (this gives you denisty about 200 pixels per meter).

If you want to play with my implementation in realtime, you can grab it here (there is readme file, which

should help you get it running):

https://drive.google.com/file/d/0B1nsNgFzDF54SGx3alN5WEZHWjQ/edit?usp=sharing

This is slightly older build which does not support async streaming, but still should represent the potential of used

techniques :)

Cheers

P.

That looks really nice, I'll grab a copy and have a play. Thanks.

I will have to think about handling buildings etc as well.

This topic is closed to new replies.

Advertisement