# GetAlphamaps(int, int, int, int)

> Returns the alpha map at a position x, y given a width and height.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.TerrainModule

```csharp
public float[,,] GetAlphamaps(int x, int y, int width, int height)
```

### Parameters

**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The x offset to read from.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The y offset to read from.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The width of the alpha map area to read.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The height of the alpha map area to read.

### Returns

| Type                                                                | Description                                                                                                         |
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| [float\[,,\]](https://learn.microsoft.com/dotnet/api/system.single) | A 3D array of floats, where the 3rd dimension represents the mixing weight of each splatmap at each x,y coordinate. |

### Remarks

The returned array is three-dimensional - the first two dimensions represent y and x coordinates on the map, while the third denotes the splatmap texture to which the alphamap is applied.

### Examples

```csharp
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    // Add some random "noise" to the alphamaps.
    void AddAlphaNoise(Terrain t, float noiseScale)
    {
        float[,,] maps = t.terrainData.GetAlphamaps(0, 0, t.terrainData.alphamapWidth, t.terrainData.alphamapHeight);

        for (int y = 0; y < t.terrainData.alphamapHeight; y++)
        {
            for (int x = 0; x < t.terrainData.alphamapWidth; x++)
            {
                float a0 = maps[y, x, 0];
                float a1 = maps[y, x, 1];

                a0 += Random.value * noiseScale;
                a1 += Random.value * noiseScale;

                float total = a0 + a1;

                maps[y, x, 0] = a0 / total;
                maps[y, x, 1] = a1 / total;
            }
        }

        t.terrainData.SetAlphamaps(0, 0, maps);
    }
}
```
