Jump to content

Geo-Clipmapping Endless Terrain (contribution)


Dal
 Share

Recommended Posts

Hi all,

 

I've managed to implement a geo-clipmapping terrain for Babylon

 

screenshot.png

 

It is based on the awesome writings of Florian Bösch (https://github.com/pyalot/webgl-lacr), and Jasmine Kent (who uses Florian's method and explains it nicely here:

http://www.gamasutra.com/blogs/JasmineKent/20130904/199521/WebGL_Terrain_Rendering_in_Trigger_Rally__Part_1.php

 

In theory this kind of terrain is really good for WebGL, because it puts most of the work onto the GPU and it allows very large terrains.

 

My implementation isn't quite right at the moment though and I hit a few snags trying to implement it in Babylon:

 

1) Florian's implementation uses non-indexed meshes and triangles. I figured out how to create the same shapes needed using Babylon mesh functions, but I am sending waaaaay more data to the GPU than Florian does. 

2) I also struggled with other issues like how to give the different meshes their own materials/settings without creating a lot of duplication.

3) I'm not sure I am using all the settings correctly... I'm finding it hard to get good looking results.

4) The mip levels really don't seem to be working properly

5) The detailing is definitely not right either :)

 

 

I think I've come about as far with it as I can with my understanding of Babylon... but I am hoping some smart people in this community can help me fix it / finish it :)

 

Source code is at: https://github.com/darrylryan/BabylonTerrain

Live demo is here

 

Link to comment
Share on other sites

Wow, excellent, it's a feature you want embed in babylon. That would be really great.

It is impressive as the terrain is great.

 

Yep, it's already open source and can be used. 

It needs some fixing up though. I hope you guys can help :)

Link to comment
Share on other sites

Setting checkCollisions to true on the camera, scene and the center mesh didn't seem to do much.. 

 

What shader are you using? 

 

Its a custom shader... the magic to how the whole thing works is in the shader. Take a look in the source code :)

Link to comment
Share on other sites

It would be intersting to drasticaly increase camera.maxZ value to better see the infinite landscape.

 

Increasing the camera size won't help because the terrain size is fixed... it doesn't actually draw infinite land, it works by drawing a single square of land and then a number of concentric rings around that, with lower LOD levels.

It only actually makes one "square" of terrain in effect... the height and texture data is then pulled over it. The mesh doesn't actually get translated. The GPU moves the vertices around based on the image data, so it's lighter on the CPU.

Think of it as though you're standing still and the mountains are moving :)

 

It looks like this:

 

terrain-diagram4.png

 

In the parameters you can increase the number of levels of rings drawn, the grid resolution and the grid scale.  The way to get a really mega view distance is to increase the number of levels.

I haven't figured out how to get the scaling quite right yet though - feel free to have a play!  Keep in mind I may have made some mistakes in the implementation though, so perhaps tweaks are needed in the shader to get awesome results ;)

Link to comment
Share on other sites

Here's how it looks with a huge view distance... gridLevel of 16.

 

 

terrainfar.PNG

 

Really to get it to look really great though I need you guys to help me by studying/tweaking the code a bit.. I don't think just changing the numbers is going to give us a great result, we need to tweak the implementation and shader to work better with babylon. Those of you that know what you're doing, perhaps take a look at the original and see what I did right/wrong or misunderstood? :D

I made a start, but we need more work on it to make it really useful.

Link to comment
Share on other sites

Ah ah, just travel at max speed through landscape as close to the ground as possible and you'll feel like a pod racer ! We juste need to raise a little more up the high mountains (and maybe add collisions) to enhance the sensation.

 

Actually I did have the exact same feeling... we could make a really good pod-racer game with this hehe :)

In fact, increasing the mountain height is a good community challenge. I bet if you figure out how to increase the height, you will also run across where I made mistakes in the implementation and maybe you can fix them? ;)

Link to comment
Share on other sites

Do you want to create an official extension for Babylon.js with this great work?

 

Sure, that would be cool.  I think it does need some more attention from core devs to be useful though... its bugged right now and I am not sure if I can fix it alone :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...