I am looking for an example site with a Perlin Noise implementation in both CPU and GPU, that generates somewhat the same results in those two places.

I see many CPU implementations of Perlin Noise, but they don't match up with the GPU implementations that I found.

The reason I need this is for physics. The map is generated with Perlin Noise on the GPU in 2D, but this also means that to do physics, I must have a CPU version of the algorithm that generates the same results.

  • 1
    \$\begingroup\$ You will not get the exact same results with 2 different floating point units on CPU and GPU \$\endgroup\$ – Maik Semder Aug 7 '11 at 21:14
  • 1
    \$\begingroup\$ possible duplicate of Perlin noise - copying the algorithm on the CPU? \$\endgroup\$ – user744 Aug 7 '11 at 21:25
  • 3
    \$\begingroup\$ @Mathias: You really should read through the papers and algorithms concerning noise I linked in your first question about terrain generation, and invest effort in understanding them, not simply gather together miscellaneous "Perlin noise" code from the Internet and expect sane results. \$\endgroup\$ – user744 Aug 7 '11 at 21:26
  • \$\begingroup\$ @Maik: That is technically true, but unless you need ridiculous accuracy, you can make them more than close enough if you implement the algorithms correctly. \$\endgroup\$ – user744 Aug 7 '11 at 21:28
  • \$\begingroup\$ Even small differences during the calculation can end up as big differences when using floor() and co, not sure if thats the case here however @Joe \$\endgroup\$ – Maik Semder Aug 7 '11 at 22:02

I don't know if the answer you are looking for exists, but personally I don't like the idea of independently generating values that you hope will end up identical.

I'm assuming that the map data is something you only generate once in the beginning of the scene. If so, much better to generate the data once, and use it twice. You should either generate the data on the CPU, and pass it to the GPU as a texture, or generate it on the GPU and write it to a texture, then give it back to the CPU.

  • \$\begingroup\$ The thing is, I want this world to be ever-expanding. Minecraft uses the same technique as I am. \$\endgroup\$ – Mathias Lykkegaard Lorenzen Aug 7 '11 at 21:05
  • 1
    \$\begingroup\$ @Mathias: No, it doesn't. \$\endgroup\$ – user744 Aug 7 '11 at 21:13
  • \$\begingroup\$ Yes. Minecraft uses the Perlin Noise algorithm for terrain generation. \$\endgroup\$ – Mathias Lykkegaard Lorenzen Aug 7 '11 at 21:14
  • \$\begingroup\$ "I want this world to be ever-expanding" - Sure, that makes sense. But you probably will still generate it in "chunks" that could be easily be done as I described. Every time you want more terrain, just generate another chunk. \$\endgroup\$ – Raptormeat Aug 7 '11 at 21:18
  • 4
    \$\begingroup\$ Minecraft uses Perlin noise for terrain generation; it does not do it in a manner that requires separate but equivalent evaluation on the GPU and CPU; the code samples you have shared elsewhere cast doubt that you are using Perlin noise at all. \$\endgroup\$ – user744 Aug 7 '11 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.