jerome

Dynamic or infinite terrain experiment

Recommended Posts

54 minutes ago, jerome said:

Maybe I was too optimistic by saying I could finish by the end of this week :( I just can't have a working function getHeightAt(x ,z)

Keep at it!

Terrain is a tricky topic but you're smart so I'm sure you will get it :D

Could you make an example with the terrain view distance of about 1km? I'd love to see how this performs on larger scenes.


 

Share this post


Link to post
Share on other sites

What would a terrain be without some collision detection features ?

Here's the first working prototype of terrain.getHeightFromMap(x ,z) in action : http://jerome.bousquie.fr/BJS/test/terrain.html

Not yet documented (*), but already working : https://github.com/BabylonJS/Extensions/tree/master/DynamicTerrain/dist

 

(*) Actually all the methods are documented in code comments, so if you generate a doc from the code, you can already get the API documentation.

Share this post


Link to post
Share on other sites

Hi guys, 

Today's extension repo update is a complete reimplementation of the internal geometry update, faster than the standard ribbon update because it deals only with low level float32 arrays directly instead of BJS objects (vectors3, colors4, etc) and it embbeds within the same loop the terrain computation, the mesh geometry computation and its bounding box computation.

So one loop instead of three.

The legacy ribbon object, provided in the BJS core, was also a bit improved to morph quickly, GC and optimizer-wise.

Well, I still need to add two or three more little and useful methods for the user, like returning the terrain normal at the coordinates (x, z) or a boolean to check if the world coordinates (x, z) are currently also in the terrain (both almost done), before starting to write some documentation and code some examples.

The toy will be released very soon ;)

Share this post


Link to post
Share on other sites

Cool!
I started experimenting with this, but I think I still not get LODLimits.

I would like a terrain like this:

- near, lod 0, 128x128 meters, 0.5m/texel (the resolution of the heightmap, and the material splatmap. 256x256 quads)
- far, lod 1 1024x1024 meters, 4m/texel (this is like 1/8 resolution. 256x256 quads)
- environment (mountains), lod 2 10240x10240 meters, 20m/texel (1/40 resolution. 512x512 quads) Edit: It can be 1/32 resolution, it does not matter really.


How can I do this?

Share this post


Link to post
Share on other sites

the full height map would be 20480x20480, and that's about 3.4G in memory (just the heightmap), so that's impossible to download and have in memory.
I'm thinking of some kind of patch loading.
Now I'm using two groundheightmaps, one is 10kmx10km 512x512, one is 1280x1280m 256x256.

Share this post


Link to post
Share on other sites

I'm off this next week, I'll tell you when I'm back

The main idea is this one :

the initial LOD is the factor between the terrain quads and the map quads => 1 (default) means 1 terrain quad matches 1 map quad

2 means 1 terrain quad matches 2 map quads on X axis and 2 map quads on Z axis, so 4 map quads

3 means 1 terrain quad matches 9 (3 x 3) map quads, 

and so on

When you set a LODLimit, this means that the terrain quads under this limit around the terrain perimeter have their LOD factor incremented

LODLimits = [2]   => consider the 2 rows and columns of quads around the terrain... they have their LOD factor equal incremented from the initial one.

If the initial LOD is 1 (default), their LOD factor is 2... In this case, the central terrain quads match each 1 map quad and the perimetric terrain quad (under 2 rows/columns) match each 4 (2 x 2) map quads.

Maybe this picture can help to understand :

terrainLOD.png

In this example, the LODLimits is visibly [6, 4]. Have a look only at the squared quads from one terrain corner.

6 quads  from the edge in totla have a LOD factor higher than the central ones

and from these 6, 4 have again a LOD higher

The terrain doesn't know any measurement but only map quads. It can fit 1, 4, 9, 16, etc map quads (for the squared quads, the others are automatically computed)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.