Example #1
0
    private SurfaceGenerator.Vertex withNoise(Vector3 vertexPos, float x, float y)
    {
        float sample = FBMNoise.valueAt(vertexPos / noiseScale + noiseOffset, octaves, lacunarity, persistance);

        SurfaceGenerator.Vertex vert;

        vert.position = radius * vertexPos * (1 + sample * noiseMagnitude);
        vert.uv       = new Vector2(x, y);
        vert.color    = Color.white;
        vert.normal   = Vector3.zero;

        return(vert);
    }
Example #2
0
    void UpdateNoise()
    {
        time += timeStep;
        Color[] colors = new Color[width * height];
        int     index  = 0;
        float   s      = 1f / scale;

        for (int y = 0; y < height; ++y)
        {
            for (int x = 0; x < width; ++x, ++index)
            {
                colors[index] = Color.Lerp(Color.black, Color.white, FBMNoise.valueAt(x * s + offsetX, y * s + offsetY, time, octaves, lacunarity, persistance) * 0.5f + 0.5f);
            }
        }

        tex.SetPixels(colors);
        tex.Apply();
        GetComponent <Renderer>().material.mainTexture = tex;
    }