Skip to main content
GameDev.net gamedev.net
🔒 Locked

Dynamic heightmap creation

Started by Matt Aufderheide Mar 23, 2009 at 1:38 PM 2 replies 1.7k views
Original Post
Matt Aufderheide
Matt Aufderheide
In my D3D large-terrain renderer, I have a terrain geometry similar to the clipmap system--a series of toroidal rings--and I use a floating-point heightmap to displace vertices in the vertex shader. Currently I use two heightmaps; one is for the nearest few rings, one for the farthest. I update the heightmaps using render-to-texture methods. I render a large flat plane with some noise functions, centered on the viewing position, then project that onto the real terrain in the vertex shader. This gives the ability to create normal maps as well, with essentially limitless procedural terrain. The problem is this: to get a good resolution and area coverage i have to use 4096*4096 floating-point textures--even when updating only every 500 or a thousand frames or so, i get a noticeable lag whenever i render the hieghtmaps out. This lag goes away when i use lower-res textures but so does the quality. Obviously rendering the large textures is very slow even on a strong video card, too slow even for occasional updates. Even when I stagger the rendering of each heightmap there is a lag. Does my method sound like it's simply flawed? Should i be using some other method of creating heightmaps that can be done without the one-frame super lag?
harveypekar
harveypekar
Maybe you are updating a too large rectangle each frame? Consider this: if you move 1 meter to the left, only a one meter wide region needs to be updated. Of course, in a naive implementation, all the other regions need to be moved one meter to the right too. AFAIK the clipmap implementations get around this by modular adressing (<a href="www.cs.virginia.edu/~gfx/Courses/2002/BigData/papers/Texturing/Clipmap.pdf> Section 3.2.4 from The Clipmap: A Virtual Mipmap).
ndhb
ndhb
How large an area can you render before the frame lag becomes intolerable? Is 4k by 4k the size of the update area, or the whole heightmap, or the clip size? On each update, you're re-using the same texture I guess?

When I did something similar to what you describe, I decided on doing the updates on the CPU side and stream any modified texels to the GPU as needed. I thought it was more flexible, and in any case, evaluating the noise functions could be threaded to take advantage of multiple cores.
Matt Aufderheide
Matt Aufderheide
My implementation is very naive then, as I hadn't tried updating smaller regions, but of course this seems like an obviously good idea now that you mention it. Thanks, I will try something like this.

Currently I'm updating two regions: one is 4096*4096 in size, the other is 16384. Both use a 4096 texture, so i was rendering the whole thing every update.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.