Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
1  
You will not get the exact same results with 2 different floating point units on CPU and GPU –  Maik Semder Aug 7 '11 at 21:14
1  
possible duplicate of Perlin noise - copying the algorithm on the CPU? –  user744 Aug 7 '11 at 21:25
3  
@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. –  user744 Aug 7 '11 at 21:26
    
@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. –  user744 Aug 7 '11 at 21:28
    
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 –  Maik Semder Aug 7 '11 at 22:02

1 Answer 1

up vote 7 down vote accepted

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.

share|improve this answer
    
The thing is, I want this world to be ever-expanding. Minecraft uses the same technique as I am. –  Mathias Lykkegaard Lorenzen Aug 7 '11 at 21:05
1  
@Mathias: No, it doesn't. –  user744 Aug 7 '11 at 21:13
    
Yes. Minecraft uses the Perlin Noise algorithm for terrain generation. –  Mathias Lykkegaard Lorenzen Aug 7 '11 at 21:14
    
"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. –  Raptormeat Aug 7 '11 at 21:18
4  
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. –  user744 Aug 7 '11 at 21:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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