Ejemplo n.º 1
0
        public static void ApplyNoiseToMapTexture(Texture2D mapTexture, PerlinNoiseSettings settings,
                                                  float noiseOffsetFactor)
        {
            var noiseTexture =
                NoiseTextureHelper.PerlinNoise(mapTexture.width, settings);

            var mapColors   = mapTexture.GetPixels();
            var noiseColors = noiseTexture.GetPixels();

            Debug.Assert(mapColors.Length == noiseColors.Length,
                         "Cannot use textures with different resolutions!");

            for (var i = 0; i < mapColors.Length; ++i)
            {
                mapColors[i].r -= noiseColors[i].r * noiseOffsetFactor;
            }

            mapTexture.SetPixels(mapColors);
            mapTexture.Apply();
        }
Ejemplo n.º 2
0
    public void FillTexture()
    {
        var texture = NoiseTextureHelper.PerlinNoise(resolution, settings);

        GetComponent <MeshRenderer>().sharedMaterial.mainTexture = texture;
    }