Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (var y = 0.0; y < noiseTex.height; y++) {
- for (var x = 0.0; x < noiseTex.width; x++) {
- // Get a sample from the corresponding position in the noise plane
- // and create a greyscale pixel from it.
- //X coord from map
- var xCoord = xOrg + x / noiseTex.width * scale;
- //Y coord from map
- var yCoord = yOrg + y / noiseTex.height * scale;
- //Gets the perlin noise value for a given (x,y) coordinate
- var sample = Mathf.PerlinNoise(xCoord, yCoord);
- //Fills a pixel array with data generated by the perlin noise
- pix[y * noiseTex.width + x] = new Color(sample, sample, sample);
- }
- }
- //For your use:
- for (var y = 0.0; y < map.height; y++) {
- for (var x = 0.0; x < map.width; x++) {
- //Gets the perlin noise value for a given (x,y) coordinate
- var sample = Mathf.PerlinNoise(x, y);
- //Fills a pixel array with data generated by the perlin noise
- mapArray[y*map.width + x] = sample;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement