Jump to content
  • Advertisement
Sign in to follow this  
Aramil04

OpenGL Scrolling Terrain Problem

This topic is 3069 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!