Exemplo n.º 1
0
    public static Texture2D CreatePermutationTexture(Perlin perlin)
    {
        Int4[]  hashes = perlin.GetHashes2D();
        Color[] colors = new Color[Perlin.SIZE * Perlin.SIZE];
        for (int y = 0; y < Perlin.SIZE; y++)
        {
            for (int x = 0; x < Perlin.SIZE; x++)
            {
                colors[x + y * Perlin.SIZE] = hashes[x + y * Perlin.SIZE] / 255f;
            }
        }
        Texture2D texture = new Texture2D(Perlin.SIZE, Perlin.SIZE, TextureFormat.RGBA32, false, true);

        texture.filterMode = FilterMode.Point;
        texture.wrapMode   = TextureWrapMode.Repeat;
        texture.SetPixels(colors);
        texture.Apply();
        return(texture);
    }