Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit/AppGameKit Studio Showcase / Real world terrain streaming

Author
Message
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 1st Jul 2020 11:16 Edited at: 1st Jul 2020 11:17
Hey there,

recently I started some work on a real world terrain streaming project. The idea is to have the entire earth (or any other height data map in any size) streamed using AGK. As you can imagine there is no way to have that as meshes in memory so what I do is to use a global positioning system (using longitude and latitude) and just build the terrain chunks on the fly around the camera position. First results are very promising, it's already possible to move over the entire earth, while new chunks are created on the fly:


(click here for a larger version)

What you can see here is the area south of japan with some huge tailrace channel in front, plus the mount Fuji a bit to the right behind the "sphere" - the player's position.. In Google maps this region looks like:



The chunk size is configurable, currently I use 48x48 grid points (vertices) per chunk which is an area of about 48x48km. I'm using freely available GTOPO30 data which has just a resolution of ~1km per point in long/lat even though the height is correct to about 1 meter.

Next steps will be to refine the grid, enhance the resolution by adding more grid points in between, interpolating them and to add Perlin noise on top of it to let it look natural without destroying the real world.

Completely missing is currently the shader part, I'm using just the standard terrain shader atm, want to address the completeness of the mesh creation first.
Scribble
7
Years of Service
User Offline
Joined: 2nd Apr 2017
Location:
Posted: 1st Jul 2020 15:18 Edited at: 5th Nov 2021 12:34
Looking forward to your progress.
PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 1st Jul 2020 15:24
This is already looking very nice.
Good job Xaron!

PSY


PSY LABS Games
Coders don't die, they just gosub without return
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 1st Jul 2020 22:22
looking very nice.
How do you do the textures?
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 2nd Jul 2020 07:41
Thank you guys!

Quote: "How do you do the textures?"


Currently I just use the stock terrain shader with one texture. Plan is to put in a real one, maybe splat mapping or at least a height based shader with different textures for each height/slope which blend nicely together.
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 2nd Jul 2020 13:18
Added interpolation to the terrain. So it's possible to add "resolution" to the terrain by adding extra grid points between the original data points and add Perlin noise on top. Looks like that:

First, the original height data, the resolution is given with about 1km per grid point (height is exact to the meter):

(higher res image)

Then I add additional points between the original grid points. Here are 5 additional one used, still without interpolation you get something like:

(higher res image)

After that some bilinear interpolation is done to smooth it:

(higher res image)

And finally some Perlin noise is applied to add some natural look to that artificial higher resolution:

(higher res image)

You might see the effect better using that animated gif:

xtremi
5
Years of Service
User Offline
Joined: 26th Aug 2018
Location:
Posted: 2nd Jul 2020 19:50
Really cool stuff there!
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 2nd Jul 2020 20:48 Edited at: 2nd Jul 2020 20:50
Do you need additional vertices for collision or something else ? cause this is verry much predistined to be done in shaders for a visual only result.
But If you want to zoom in on the surface then you probably want to stay with extra vertices.
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 3rd Jul 2020 06:53
@janbo: Well the original data has just a resolution of 1km, so I'm adding a bit as I want to move bit closer. Sure I could use tesselation but I don't know if that would add even extra "information" like is added with Perlin noise. So yes I want to zoom in a bit.
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 3rd Jul 2020 08:07
Actually, tesselation is not possible in AppGameKit except for a plugin maybe.
I refer to normalmapping using perlin noise...
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 3rd Jul 2020 08:17
Ah, so you say you could apply that kind of Perlin noise on the shader side using normal maps to "fake" additional structures so to say which looks similar if you don't zoom in too much?
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 3rd Jul 2020 11:59 Edited at: 3rd Jul 2020 11:59
Ok, got the threaded loading working. Unfortunately the AppGameKit commands themself are not thread safe so the mesh creation (from memblock) must be done in the main thread, but still - it's fast enough:



In this video I use a chunk size of 12x12 (which is about 12x12km per tile) which is then refined with additional 4 grid points in between, interpolated and Perlin noise on top. You see pretty nicely how the chunks are loaded without blocking the main thread. When you move too fast, you can see that the loading takes a while.
Speaking of fast moving, I move about 5 tiles per second there which is approximately 60km per second, so that should cover almost everything.
haliop787
4
Years of Service
User Offline
Joined: 22nd Mar 2020
Playing: With reality.
Posted: 3rd Jul 2020 12:33 Edited at: 3rd Jul 2020 12:37
Well if it's not as fast as you would like, why not generating bigger tiles, in much lower res, then when you get close you fake tesselation with :

Tween3D

So,

First you have the min res tiles, when you get closer
You tween3dAlpha them down, and tween3DAlpha up the higer res ones.
Edit: these 2 tweens need to start and end together for the effect to take place.

This could be done quite easily and you can get huge amount of correct landscape that way.

Just dont forget to setobjectvisible(lowTerr,0)
So you actually get the same draw calls.

And also use a distance fog shader, which will eliminate all the basic looking min res terrain "errors" , meaning the lower res just wont be noticeable as lower res.
Nadav "Haliop" Rosenberg
Lets make the world great forever.
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 3rd Jul 2020 13:10
Bigger tiles comes with some cost. Unfortunately I cannot get around to call the AppGameKit stuff in the main thread, so while all is going smooth those calls are blocking ones. What works best is to create smaller but more tiles. I really want to avoid having several sets of tiles for the same place - even though I could think off a simple LOD.

Of course there's still lot of stuff missing, e.g. fog, unloading of chunks out of sight, real textures and a real shader.

GarBenjamin
AGK Developer
7
Years of Service
User Offline
Joined: 30th Nov 2016
Location: USA
Posted: 4th Jul 2020 05:44
Looks very good and seemed very fast to me. While watching I was thinking in actual gameplay I would guess the player would be moving much slower than you are in the video unless they are flying a jet or something. I noticed you later mentioned the speed was 60 km per SECOND so yeah I cannot imagine speed being an issue. lol
MikeHart
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 4th Jul 2020 11:25
Xaron? Ehm, I am confused. Not working on your Unity game anymore?
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 4th Jul 2020 16:38
@Mike: I'm still doing my Unity game full time but wanted to port the terrain part over to AGK. Just as kind of a challenge. Plus I need to keep my C++ skills alive.
MikeHart
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 4th Jul 2020 17:05
That is always a good reason. So agk studio supports Tier2? Similar to classic?
Xaron
9
Years of Service
User Offline
Joined: 3rd May 2014
Location: Germany
Posted: 5th Jul 2020 07:31
I think it's just the same as with classic. So yes it's possible to use tier 2 with studio.
MikeHart
AGK Bronze Backer
20
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 5th Jul 2020 08:46
Mmh, that means the target builder in CX should work with it too. Thanks for the info.
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 9th Jul 2020 16:27
Quote: "First results are very promising, it's already possible to move over the entire earth, while new chunks are created on the fly:"

Awesome!

IMO.. Low res on the details are fine, and nothing to slow it down like shaders at first to see how fast it can go. (add normal/bump map after basic optimization)

Quote: "The idea is to have the entire earth (or any other height data map in any size) streamed using AGK."


With a LOD of just a world map to scale on a grid of planes for a base ground layer and the terrain being built for the visible radius of XTBD, this would be fantastic for any typpe of flight simulation.

Don't forget the lunar lander, and Mars' rovers.

Quote: "Ok, got the threaded loading working. Unfortunately the AppGameKit commands themself are not thread safe so the mesh creation (from memblock) must be done in the main thread, but still - it's fast enough:
"

You have it looking great.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2024-04-19 19:20:03
Your offset time is: 2024-04-19 19:20:03