Archived
Private
Public Access
1
0
This repository has been archived on 2026-02-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ProjectBackup/Unity/Landmass Generation/Assets/Scripts/MapDisplay.cs
2023-07-31 21:20:56 +02:00

29 lines
883 B
C#

using UnityEngine;
namespace LandmassGeneration {
public class MapDisplay : MonoBehaviour {
public Renderer textureRenderer;
public void DrawNoiseMap(float[,] noiseMap) {
var width = noiseMap.GetLength(0);
var height = noiseMap.GetLength(1);
var texture = new Texture2D(width, height);
var colorMap = new Color[width * height];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
colorMap[y * width + x] = Color.Lerp(Color.black, Color.white, noiseMap[x, y]);
}
}
texture.SetPixels(colorMap);
texture.Apply();
textureRenderer.sharedMaterial.mainTexture = texture;
textureRenderer.transform.localScale = new Vector3(width, 1, height);
}
}
}