I’ve been stuck on this problem for a while now, and I’m really sure how to fix it. I’m trying to take a height map (Texture2D) and make a script that will turn the texture into a Vector 3 Array that I can use to deform vertices on a mesh. (context: I’m creating a map of the world that is flat but has raised mountains and hills kind of like in HIO4).
You could get the colors of each pixel in the texture, and put it into a Color[] using myTexture2D.GetPixels().
Then, you’ll need to create a new float array (of the same length), and fill it up with the heights of each pixel. The height may be determined by how white the pixel is, which can be done with myColor.grayscale.
Finally, with this new float array (representing the heightmap), you can generate a plane mesh and elevate the vertices. This is detailed in this video: Procedural mesh generation: Sebastian Lague