Compute shader terraining

So, it’s been a while since I’ve updated about the terrain utility I’d been working on. I haven’t done a lot on it, but I’ve ironed out a few annoying bugs, and figured I may as well do an update.

So, here’s a screenshot from the tool:

And here’s the output mesh in Modo:

So, not particularly exciting at the moment.

I have changed things a little since the last post, though. For a start, I’m generating the slope image on the GPU using compute shaders, and also reducing the image to get the min / max slope on the GPU too.
It’s all pretty simple changes on top of the HDRToneMapping example from the DX Sdk.
There is a compute shader that uses parallel reduction to accumulate luminance values. So I nabbed that.

So. Basically, if I run the application on a heightmap of 1024 * 1024 or greater, the computer shader is about 5 times quicker than calculating the slope map on CPU. No doubt, when I move more of the calculations onto the GPU, and actually have a slightly more complicated algorithm, this gap will grow.
Still not entirely sure if I’ll stick with using compute shaders for this. The code is harder to maintain, harder to optimise, harder to debug, etc.

As far as the current code goes, the selection of where to create vertices is not very good at the moment. I’m just using the slope of the heightmap, which is not very exciting. There’s lots of re-meshing algorithms out there, so I need to have a look into it more, but I’ve got some ideas about that.

So, all in all, I have some code for taking an image, creating a bunch of badly placed vertices, and joining them up. Well, it’s something 😉 We’ll see how much further I get with it, but plenty of work before it even gets near touching the great terrain tools I worked with back in the day on Heatseeker.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s