In my engine I create infinite terrain with usage of Perlin noise alghoritm computed on CPU.

Creation of terrain goes like this:

  • If camera is near unloaded patch, create it
  • Compute 513x513 noise array with given boundaries
  • Compute normals, tangent, binormal, indices
  • Pass data to vbo


  • Only needs to be rendered when needed
  • Easy to make collision


  • Slow 64 513x513 patches are created in 3,1s(one thread). For each tile ~20ms noise creation, ~25ms vertices, normals, tangent, bitangent, indices. When camera moves fast, user can notice tiles loading.
  • memory consuming???

Now I was wondering how to speed this up by generating terrain completely on GPU But there are some doubts:

  • If shaders run every frame, isn't this computation power waste to compute noise over and over? This can be avoided by writing result into RBGA texture and used later in vertex shader for displacement, but increase memory usage. From the other hand if the creation would be super fast, only visible tiles should stay in memory. However detaching buffer causes gpu-cpu sync which may slow down the app (am I right?)
  • If the terrain is just a flat grid displaced by vertex shader, the same work needs to be done on CPU to compute height and normal at given point for collision.
  • This is just a concept, but to speed everything up I was thinking about projecting grid on viewport so only minimal amount of vertices is used. Do you think this would work?

My final question is:

What the best/fastest/broadly used technique to create infinite terrain on GPU?

  • 8
    \$\begingroup\$ Just note that creating terrain on the GPU will make it difficult to do collision detection, picking detection or pretty much any kind of interaction with the terrain. \$\endgroup\$
    – House
    Jul 17, 2013 at 14:25
  • 1
    \$\begingroup\$ A compute shader (DX10 or 11) may be used to generate the terrain on the GPU. But as Byte56 stated, you will need to pull the values back out of the GPU in order to interact with it. msdn.microsoft.com/en-us/library/windows/desktop/… \$\endgroup\$ Jul 17, 2013 at 17:16
  • \$\begingroup\$ creating terrain on a GPU kind of sounds like a bad idea to me. It might work but I figure it would probably work a bit better if you just generate the terrain on the CPU side and send the standard drawing stuff to the GPU. \$\endgroup\$ Jul 17, 2013 at 17:17
  • \$\begingroup\$ Just my experience; I actually did just this with aparapi and actually got the damn thing to work; but it actually ended up being slower than just having the cpu do the work. I think because of the overhead of sending data to/from the gpu. If I recall correctly gpu only really works if the calculation is large compared to the size of the data (and also large in absolute terms) \$\endgroup\$ Sep 2, 2013 at 23:12
  • \$\begingroup\$ This article might give you some ideas http.developer.nvidia.com/GPUGems3/gpugems3_ch01.html \$\endgroup\$ Jun 9, 2015 at 18:50

1 Answer 1


Well if I was to try to use the GPU for such a thing, I think I would go for compute/opencl/cuda.

However regardless of using the GPU or CPU (which is what I actually do), I would do it in an asynchronous manner, deciding you need some new terrain for the current frame is likely too late (e.g. consider 1000ms / 60 = 16.666ms, and the entire frame wants to fit into that).

Start generating (or loading from compressed files) terrain on a worker thread, and make it available to the rest of the game and rendering once that worker has finished, generally this will be the next frame, or perhaps the frame after that, so the user won't really notice the difference there, but it makes things smoother.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .