Scrolling Terrain Problem

Started by
1 comment, last by Aramil04 14 years, 1 month ago
Hi-ya folks, I'm currently working on a sort of endless terrain that 'scrolls' it's height values to give the impression of movement. The entire terrain is implemented using VBOs. Right now, the scrolling is somewhat inefficient: I pass an array of height values into the proper 'shifting' function that performs a couple of memmoves() that scroll the heights. The inefficient part is that after this function completes, I have to update the vertex data of the entire terrain such that the vertex y coordinates match the height values I have just scrolled/calculated. This requires an iteration through about 65,000 vertices, which is what I'm trying to avoid. I'm trying to look for a more efficient solution (more specifically, something where I can avoid that expensive traversal), but without success. I gave some thought to storing the vertex data in a different form: (xxxyyyzzz) rather than the usual (xyzxyzxyz), which would allow me to store each set of coordinates (x, y and z) as parallel arrays. From then, I could just perform the memmove() shifts on the y-array and then simply update the vertex buffer object's chunk of y-coords through a call to glBufferSubData(). However, OpenGL expects all vertex data to be in the form (xyzxyzxyz), which renders my idea useless. Is there a way around this? So, is there a more efficient way to handle the terrain scrolling that doesn't involve updating every single vertex? Thanks.
Advertisement
Pass the terrain in as a (static) flat mesh, then use a vertex shader to change the vertices individually. You can use a procedural function with changing uniform inputs to update the vertices or a scrolling heightmap texture.

65,536 (I assume 256 squared?) vertices may be a lot for the CPU to update, but it's nothing for the GPU, especially when it's in-line with rasterization.

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

Okay, thanks a lot. I'll look into that.

This topic is closed to new replies.

Advertisement