Advertisement
s1ay3r44

Untitled

Apr 24th, 2014
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. for (var y = 0.0; y < noiseTex.height; y++) {
  2. for (var x = 0.0; x < noiseTex.width; x++) {
  3. // Get a sample from the corresponding position in the noise plane
  4. // and create a greyscale pixel from it.
  5.  
  6. //X coord from map
  7. var xCoord = xOrg + x / noiseTex.width * scale;
  8. //Y coord from map
  9. var yCoord = yOrg + y / noiseTex.height * scale;
  10. //Gets the perlin noise value for a given (x,y) coordinate
  11. var sample = Mathf.PerlinNoise(xCoord, yCoord);
  12. //Fills a pixel array with data generated by the perlin noise
  13. pix[y * noiseTex.width + x] = new Color(sample, sample, sample);
  14. }
  15. }
  16.  
  17. //For your use:
  18.  
  19. for (var y = 0.0; y < map.height; y++) {
  20. for (var x = 0.0; x < map.width; x++) {
  21. //Gets the perlin noise value for a given (x,y) coordinate
  22. var sample = Mathf.PerlinNoise(x, y);
  23. //Fills a pixel array with data generated by the perlin noise
  24. mapArray[y*map.width + x] = sample;
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement