Largest Heightmap/Terrain possible?

Blitz3D Forums/Blitz3D Programming/Largest Heightmap/Terrain possible?

Imperium(Posted 2014) [#1]
So far I'm very impressed with the sheer size of a terrain you can create with Blitz3d. It may prove to serve me well in a simulation I'm developing.

Before I push Blitz3d even more has anyone reached any limits or problems I may not be aware of? I know 3ds models have a vertex limit but no one should be using that format anyway.

The goal with my upcoming project is to simulate an entire planet in real time. Obviously the entire planet isn't rendered at once but is the only limiting factor the hardware Blitz is running on itself? I still need to crunch the numbers to figure how the exact size of the height map needed. In my design docs the planet is roughly 1/3 the size of the Earth so you will have a lot to explore.

I love the idea of a randomly generated planet but for now just filling a static world of that size is enough of a challenge. Any ideas of what my best approach would be? Should I split up the terrains into sections and only load them if the player is close enough to active them? Can Blitz3d support multiple terrains loading at once? I finally have a fair amount of art assets completed so I'm readying to start coding again.

My only complaint so far is my terrain doesn't look that great. Sculpting things manually I can make nice terrain in Maya and Mudbox but height map I generated (which I had high hopes for) doesn't look nearly as detailed as it should.

*image here* Upload not working hold on. >:(
If you want to try the height map for yourself you will need to convert it back to 1024x1024 and change the format.

Edit:
Okay so I tried 5 different uploading sites and nothing works. They just endlessly display UPLOADING. I'm so sick of troubleshooting things I'm having one of those days where nothing works like it should.


RemiD(Posted 2014) [#2]
From my tests, if you want to use a very large terrain made of several small terrains which tile, the only challenge is to load them, build them, and then save them, destroy them, without the player noticing it.
It can be done by attributing a few milliseconds for this task in the mainloop.
You can't store an unlimited amount of terrain datas in ram.

The other problem you will encounter is how to save all this height datas on disk.
To be able to store more terrain datas, you can reduce the relief precision, for example, have a vertex each 10 units instead of each 1 unit.


Rick Nasher(Posted 2014) [#3]
Yup Blitz does support multiple terrains at once afaik, on forrum there was once mentioning off a way to create a cave like that I believe.
Largest I got to work OK is in code below:



This gives me a nice huge island type setting:



For images tinypic.com seems to work ok last time I used it(see above).

For Planetary terrains, if you're interested check the following Irrlicht Wrapper example(4th picture):

65_Example_Sphere_Terrain.bb << for use in Blitz3D.

From the description:
;; Example 65 : Spherical Terrain
;; This example creates a spherical terrain by attaching six terrain objects
;; together in a cube and then applying a spherical distortion to the terrains.
;; the six textures applied to the terrain sphere need to be carefully
;; constructed so that they are properly applied.

Hope it's of some use to you.


Imperium(Posted 2014) [#4]
Interestingly enough after I removed google Chrome and all the registry hacks it leaves behind everything started working as normal. This time I also have the IP logs to prove that Chrome functions like a virus which I will save for a new post. So Chrome is a lightweight application because of the non-existent security.? Wonderful... The Globally enforced proxy setting is really pathetic. No one should be using Chrome if they care about security.

Here is my height map:


Blitz Terrains:

How do I increase the relief precision? Wouldn't that make the mountains/terrain look better instead of reducing it? I tried lowering the height at which the terrain is drawn from 800 to 400 and it helped minimally. The terrain is still very jagged despite the high resolution of the height map.

@Rick
I tried out TerrainShading terr,True on my test project and I don't notice any difference in the graphics. The Blitz book doesn't really elaborate much on what this is other than it may affect the LOD pop in. Does this effect the rendering or lighting of the terrain?

I'm very interested in those planetary terrains. This could be exactly what I need! THANKS!


RemiD(Posted 2014) [#5]
You "heightmap" does not seem to be a heightmap but rather a shadowmap


Imperium(Posted 2014) [#6]
You're right I extracted the wrong layer from the terrain generator I used. (L3DT Professional from Bundysoft) After applying a simple Blur the terrain came out much smoother but it is still lacking the detail I'm aiming for. Looks like I need to spend more time with L3DT.


RemiD(Posted 2014) [#7]
You may be interested in this post : http://www.blitzbasic.com/Community/posts.php?topic=99410


Rick Nasher(Posted 2014) [#8]
I think maximum terrain heightvalue in a heightmap is 256 meaning your source heightmap has to be ..x..x256 which then can then be scaled, but that won't get you smoother slopes, only the length of polygons will increase(anybody pls correct me if I'm wrong).


Imperium(Posted 2014) [#9]
Thanks for that link RemiD. Did you ever get any farther than that?

@Rick Nasher
So it would seem Blitz3d is not capable of highly detailed terrain. I would have to rely heavily on textures instead of polygons to achieve the desired effect. That's not a huge issue but I was hoping to for a little more geometry on the terrain.

A year or so ago I had an example that someone was able to match a height map over a texture perfectly. It may have been a scan of the surface of mars. It was impressive because it accurately recreated every little crater and correctly mapped the texture to each surface.

That project of yours Nasher looks very interesting. I saw it in another post what became of it? I'd like to know more about the strange creature standing in the water.


Guy Fawkes(Posted 2014) [#10]
I would like to see the source example so I can build huge terrains o.o


RemiD(Posted 2014) [#11]
NostalgicAlgorithms>>
I am curious about how you plan to have at the same time :
a game world which is "is roughly 1/3 the size of the Earth"
and
"highly detailed terrain"

From my understanding, this is not possible, except if you use a procedurally generated terrain and you don't need to store each height.
Because even if you store only the heights of each terrain with a byte for each height, if the game world is that big, this will take too much bytes on the hard disk.

Consider a 10km*10km game world, with a height each 1unit =
10000*10000*1=100000000Bytes or 100MB
This is only the space taken to store the heights of the terrains...
You also need to store the colormap
10000*10000*3=300000000Bytes or 300MB
already you need 400MB to store the heights and the RGB values for those terrains...

The other issue is how fast your characters/vehicles can move, the faster they can move the less free time there will be to load and build the others terrains in the mainloop.

Daggerfall had a huge game world because the terrains had low details, probably scaled by 10, that is one vertex each 10units
Morrowind had a smaller game world but the terrains had high details, and sometimes there was a loading screen when the player was moving too fast from one tile to the other.

So a possibility to have a larger game world would be to decrease the details of the terrain (a vertex only each 10units) and thus allow to store a larger but less detailed game world. This is what Rick shows by scaling the terrain width and depth by 8. But this is not acceptable for all kinds of games. For my game i was planning to be able to modify the terrain height so i needed to have a height each 1unit.

Good luck.


Rick Nasher(Posted 2014) [#12]
I only recently picked back up my little project again cos I´m having some eye troubles, but if it´s cleaned up(it's very very messy) I´ll post some code for anyone interested.

For the character models: they're not my work, just dumped them in to test the capabilities. But I do intent to create similar odd looking beasts lol.
The one used here is Balchak.b3d and from an ealier post I see that according to Naughty Alien it's a model from P.A. Phann. Don't ask me where I got it from though(can't remember), but it certainly looks marvelous.


Guy Fawkes(Posted 2014) [#13]
I'm interested =)


Imperium(Posted 2014) [#14]
I was way off with that 1/3 Earth remark. Previously I had all the calculations worked out with my former programing instructor but I lost the data when I shut off my Facebook page. Which won't be active again for quite some time.

The size of the planet went something like this:

Dimensions 513.2×502.8×496.6
Mean radius 252.1 ± 0.2 km (0.0395 Earths)

The original idea was to store a series of height-maps in a large array. The game then would randomize the placement of each onto the 3d grid of the actual world. I was manually designing each height map so they tiled or fit together with each other. The entire game world is not rendered at once so entities unseen to the player would also not be involved in collisions but still be moving. When I said "highly detailed terrain" I feel like it should look at least as good as Unreal 2. Scaling back the graphics a few eras behind what is considered modern should allow me to make a larger game.

I know you can have multiple height-maps but what about just one giant height-map that folders over onto itself? My graphics card has a limit of 8192 for texture size but has plenty of memory and processing power. Since Blitz3d runs only on one core I will need to optimize whatever I can. I doubt I will ever learn how to create multithreaded code.

Take a look at this game. It's terrible in every way but the concept is amazing:
https://en.wikipedia.org/wiki/Universal_Combat

Video:
https://www.youtube.com/watch?v=xbgMxUd4_s0
In the real game it doesn't fade out when you break the atmosphere of a planet. Everything happens in real time.

Watch out because it comes with a nasty forum of Starforce or Securom hidden in it. So don't buy it unless you are cool with removing things from your registry.

I haven't played any Derek Smart games in years because they are often extremely buggy and crash prone. Universal Combat like all his other games simulates entire universes, planets, and the terrain of each. Most of it is procedurally generated I'm sure but I know things can happen in the game whether or not you are present to see the event. Similar to how the original Radiant AI before it was removed from Oblivion functioned. I remember the devs kept finding every shop keeper dead. Basically the inhabitants of Oblivion after considering the easiest way to reach their goals found it easier to just kill for what they wanted. CREEPY!

Anyways what I really what for my game is a completely seamless experience. You never leave the 1st person perspective. The vastness of the terrain will help ensure the experience is unique each time you play. Basically you land on a planet with a mission and all the tools needed to survive. Ultimately success is up to you based upon your ability to command the team of terraformers.

I hoped that the placement of the enemy force could also be randomized. That way you may play the game for quite a awhile before encountering any hostilities. It could be a few hours of even a week before you discover any threats. This might be beneficial because you will be well established by then. When not in combat their will be plenty to do trust me. However keep in mind that the enemy has also had equal time to expand. The main focus of the game is to Terraform the planet but also defend it from any alien threat.


I found this information about the Elder Scrolls games:

Skyrim's heightmap is rectangular and uses 119 x 94 = 11186 in-game "cells". The engine uses the same cell size as in Oblivion, Fallout 3 and Fallout: New Vegas - 57.6 metres (63 yards) to the side, 3317.76 m² (3 969 square yards) of area. The full map thus has an area of about 37.1 km² (14.3 square miles). Around a quarter of this is not playable, stuck behind invisible borders.

The playable area is roughly the same as the one in Morrowind and Oblivion and less than one thousandths of Daggerfall's size.

In addition, the game features a good part of the surrounding area of Tamriel as low-quality "fake" terrain meshes.

For comparison, the heightmaps of Skyrim (upper left corner), Morrowind (upper right corner) and Oblivion (lower left corner) look as follows, to scale (courtesy of Lightwave from Bethesda's forums).




(THINK HERE HE IS TALKING ABOUT MORROWIND)

According to the wiki, your running speed is 17.3 f/s. That means you run at about 11 mph. If the total area of the map was 14.3 miles, you'd be able to get from any point to any point in less than two game hours. You don't. It's a ten hour trip from Windhelm to Whiterun, for example. (Providing of course you play with the default time scale, of course)

If it were a real map, or everyone had the same size screen and resolution, it would be easy enough to eyeball the distance between the above mentioned cities, and call that 110 miles. Although your results may vary, I can guestimate that the longitudal distance of Skyrim is about 400-600 miles, and the latitudinal distance about 800-1000 miles. So, just as a rough estimate, the province would be somewhere between 320,000 miles, squared and 600,000 miles, squared.

For comparison, if we split it in the middle, Skyrim is about the size of Alaska.


Rroff(Posted 2014) [#15]
Scale isn't the problem - blitz can do coordinates upto large enough (without special casing) to model the solar system at a scale of 1 unit = 1km so plenty to work with and its not that hard to create a system that has effectively limitless scale.

The bigger issue is that you will get horrid issues with rounding bugs when trying to move and render around that unless your using some technique of either moving the world around or resetting the player around 0,0,0.

Getting terrain with good enough detail at smaller resolutions requires moving beyond the native b3d terrain commands and creating your own system but its not crazily hard stuff - even spherical terrain to create planets is trivial vector maths though a bit harder to deal with zoning LOD and physics.


RemiD(Posted 2014) [#16]
What i meant is that if the terrain has a lot of details (many heights each xunits), the total size of the game area must be smaller because it will take more space on the harddisk to store the terrains datas. And the amount of bytes you can use is limited by what the target machine is, and by what the user is willing to download...

The details of the terrains (how many heights each xunits) and the total size of the game area of Daggerfall compared to those of Morrowind illustrate what i mean.


Imperium(Posted 2014) [#17]
Found these posts and thought they were worth mentioning:

http://www.blitzbasic.com/codearcs/codearcs.php?code=1609
http://www.blitzbasic.com/Community/posts.php?topic=70565

I started sculpting terrain manually before switching back to a height map otherwise I will never finish my game. Maybe I will only do this for special areas of interest.

To address any concerns about performance the camera is set to only 3000 rendering distant terrain. With the fog effect it hides the LOD popping perfectly and still gives the player a long visual range. If you need to engage targets any farther than that you will have to rely on your radar system to pinpoint the enemy.

Update: 1/14/14
The other night I tested a huge terrain that took me 15 minutes to reach the other side moving at very high speed. When I tried to do this with the UDK it took a dump and crashed. The longer I work with Blitz the more I love it.

The only minor issue I have is sometimes I fall through the terrain? What is the best way to make a terrain solid? Later on I will also have to code a maximum slope a player can traverse. Unlike in Morrowind and Skyrim in which you can walk up nearly any mountain.


RemiD(Posted 2015) [#18]
I have just thought about another approach to be able to have a large world (with large terrains) and to take less space to store the heights : store only the approximate relief (heights) of the terrain (for example one height each 10x10z unit) and use a routine to add small reliefs to the terrain (for example one height each 1x1 unit) by taking into account the approximate relief (like adding noise). This could work and allow to create larger world with larger terrains. However creating the seams between terrains could take more mstime in this case...


Matty(Posted 2015) [#19]
Basically you are suggesting the equivalent of a base diffuse texture and an overlaid greyscale detail texture for detail except these are height maps not colour maps. Similar principle.


RemiD(Posted 2015) [#20]
Yes but instead of storing a smaller heightmap with less heights, it may be more precise to store a low lod version of a heithmap, and store only the important heights at x,z.

Or another approach would be to have always the same routine generate the terrain relief which should produce always the same result, but i think this is too slow to do this in real time... But it may be usable if a small region is precreated during the loading of the game. Especially if the generated terrain are low lod versions... It could be fast and take only space in ram.


Rroff(Posted 2015) [#21]
Seems a bit pointless in this day and age - even "old" PCs these days generally have multiple CPU cores, GBs of RAM, etc.

Greyscale images are trivial to attain 90% or better compression ratios as well I think the biggest limit is people's imaginations rather than the ability to handle huge scales even in B3D.

Few images from various stages of a prototype system I built in B3D:

http://www.aten-hosted.com/images/cldtest2.jpg

http://www.aten-hosted.com/images/trees.jpg

http://www.aten-hosted.com/images/road1.jpg

http://www.aten-hosted.com/images/roadtest2.jpg

In the end could handle terrain upto approx the size of Europe detailed as per the trees image with a terrain detail resolution down to a few feet.

EDIT: Oh and yes those are (sort of) volumetric clouds and not a pre-rendered background.

EDIT2: B3D had quite a few limitations though (none the least handling large coordinates) in turning that into a useful gameplay experience rather than something just to fly around in freelook mode.


RustyKristi(Posted 2015) [#22]
Hey Roff, off topic question: What tool did you use to make those roads? Is this a single diffuse texture on terrain?


Rroff(Posted 2015) [#23]
I'm not using an external/3rd party tool.

Getting roads to work properly was a pain - traditional single diffuse texture systems and vertex alpha, etc. didn't let me get even close to the quality I wanted, massive alpha maps/masks or techniques similar to far cry, etc. quickly ran into z fighting/flickering and related issues.

I ended up with separate terrain and road meshes and then rendering in realtime via an overhead view camera (flattening everything out) to generate high quality tiles (basically splatting) for terrain cells close to the camera and using a similar technique to pre-render a low quality single diffuse texture for distant cells. (The road images are a bit unrealistic for actual use - the trees image which shows the editor view is more realistic of the quality level - if you look closely at the nearest bit of road you can see some pixelation).

Few issues with seams and terrain grids with a high level of verticality but nothing that I couldn't have worked around if I'd continued with it. Performance wise works pretty well but swallows a chunk of VRAM so only really applicable to modern PCs (it also solved a whole load of mip mapping issues I was having especially with DXT textures with complex alpha).


RustyKristi(Posted 2015) [#24]

I ended up with separate terrain and road meshes and then rendering in realtime via an overhead view camera (flattening everything out) to generate high quality tiles (basically splatting) for terrain cells close to the camera and using a similar technique to pre-render a low quality single diffuse texture for distant cells.



Thanks. So how did you generate those road meshes? Did you do the overhead tile texture generation in blitz/bmx as well?

sorry for the many questions but I'm quite interested in getting good roads on terrain. :)


Rroff(Posted 2015) [#25]
Everything pretty much was done in B3D with liberal use of fastext libraries (especially render to texture).

Road meshes were created by placing a chain of linked nodes kind of like in the far cry 2 editor which would then build the appropriate number of segments, end caps, etc.


RustyKristi(Posted 2015) [#26]
Hey Rroff,

Just remembered and reading this topic again as I would like to know the process or achieve something similar. Where did you create those linked nodes and did you use some sort of editor? It would be hard doing those manually, right?


Rroff(Posted 2015) [#27]
I wrote my own editor in B3D - unfortunately don't have an uptodate version of it to hand that has the road tool functional but basically looked like this:

http://i.imgur.com/G2lzf5c.png

Paths/roads were created in a similar way with a chain of points like the red selected ones (didn't need to match the terrain exactly).


RustyKristi(Posted 2015) [#28]
Thanks Rroff for the info. I'm searching for other alternatives.. can you recommend some?


Guy Fawkes(Posted 2015) [#29]
L3DT :D


RustyKristi(Posted 2015) [#30]
Thanks Guy, I'm looking into that tutorial now. :-)


Guy Fawkes(Posted 2015) [#31]
no problem :)