コード例 #1
0
    Texture2D GetNoiseTexture(NoiseMap noiseMap) //move this?
    {
        Texture2D texture = (Texture2D)material.mainTexture;

        if (texture == null || texture.width != textureResolution)
        {
            texture = new Texture2D(textureResolution, textureResolution);
        }

        for (int y = 0; y < textureResolution; y++)
        {
            for (int x = 0; x < textureResolution; x++)
            {
                float t = Mathf.InverseLerp(noiseMap.minValue, noiseMap.maxValue, noiseMap.GetNoiseValue(x, y));
                texture.SetPixel(x, y, Color.Lerp(Color.black, Color.white, t));
            }
        }
        //texture.filterMode = FilterMode.Trilinear;
        texture.Apply();
        return(texture);
    }