Little gpu terrain test

So… this is a humble progress of the project I’m implementing using BJS 5 until May 5th. For now it just shows a little section of a terrain patch, but the end result is a bit more ambitious than that…

https://imerso.github.io/babylon.js/ether01

Although still quite simple, I like it XR mode.

babylon_ether01

9 Likes

Already looking good!

2 Likes

So, progress is being slow as I already expected, because of daily work (I’m doing this in spare time only).

But here is something that with some imagination help resembles a planet from distance. =)


Edit: the above was bugged.

Here is how it should look at that point:

It is not just brute force displacement, it’s actually a quadtree and there is a lot going on already. I think that next update will come next week, when things will be way closer to something usable.

Quadtrees, huh? :eyes: I’m interested to see what’s going to come out!

Yeah, let’s see if I manage to build this properly in a short amount of time.

There are a few challenges there, as the scale is really big, so I won’t make too many promises, but I’ll try. =)

Edit: the full source will be published when it reaches a reasonable stage, even if not fully finished.

Could not make a release yet, but here is a teaser:

25 Likes

That definitely makes me want to see MORE! :star_struck:

2 Likes

that is class!

2 Likes

Amazing! I am very interested in the project/source.
Would be interested in:

  • How did you handle the scale? (precision and performance)
  • How did you solve the edge gaps between the different LOD sizes in the quadtree terrain?
  • What work were you able to offload to the GPU?
1 Like

Well, performance is obtained by doing all the generation inside the GPU. I generate 3D noise and then displace node vertices inside shaders. When I need to perform collision detection, I use transform feedback to get displaced vertices back to the CPU. But I only do that when very close to the ground, and only get for the closest nodes, not the entire planet.

Scale is solved in two ways: first, the use of floating-origin. Each node is handled separately. So, closer nodes have more precision, farther nodes have less precision. The second, I let it solve itself.

Think about it: when you’re very far from a planet, there is some imprecision because the quadtree nodes are huge (each one extending the diameter of the planet). But they’re very far and you don’t see that imprecision at all. When you’re very close to the ground, there is so much split already that the nodes are small enough to have close to full or even full floating-point precision.

My implementation is not able to split up to real-life ground resolution, though. I mean, at the highest split level (around 12 or 13), the resolution is more like 10 meters between triangles iirc. Ideal would be 1m or less per triangle. I would need to split to about level 20 to have full ground resolution – you know, as tesselated as normal ‘flat’ terrains – but after level 12 or so I start to see noise imprecision. I do have some ideas to solve that, but never got the time to implement them. The current resolution is sort of enough for my purposes.

I have implemented a few versions to solve the gaps. Currently I just use skirts to hide differences between nodes. Those differences almost all the time happen on distant nodes, so we don’t notice them.

5 Likes

This is so cool!!

Is there a link yet?

Not yet.

1 Like

Your demo really blew me away. You probably already know of this technique but if not you’ll probably love this:

The wave collapse function can definitely be used here.

Also, since you have the technical chops to do generation with the GPU (would LOVE to see more tutorials for beginners btw if you know of any good ones :smiley:) you should definitely have a look at what’s being done here:

2 Likes

I LOVE Inigo’s stuff :smiley: The Art of Code’s starting tutorials are super helpful to get on the mindset of drawing stuff with the GPU I think :slight_smile: (1) Shadertoy for absolute beginners - YouTube

2 Likes

I think @Cedric has been playing with wave function collapse too if ya’ll want to share ideas :smiley:

3 Likes

I finally get to say it…

Does he have a playground?? Would love to collaborate.

Btw, silly question, but how do you get updates for a thread when the replies aren’t @you, because I don’t seem to get any notifications for it.

Use the “Tracking” button at the end of the page of a thread to choose the level of notification you want:

3 Likes

Thanks!

Hi @imerso

Is Quadtree and its update is implemented on CPU side?

Split and join of nodes are on CPU, yes.

1 Like