Example #1
0
    public static float[,] MergeNoise(int width, int height, int detailLevel, NoiseSettings noiseSettings_1, NoiseSettings noiseSettings_2, NoiseMergeType noiseMergeType, Vector2 center)
    {
        float[,] noise_1 = GenerateNoiseMap(width, height, detailLevel, noiseSettings_1, center);
        float[,] noise_2 = GenerateNoiseMap(width, height, detailLevel, noiseSettings_2, center);

        return(MergeNoise(width / detailLevel, height / detailLevel, noise_1, noise_2, noiseMergeType, center, noiseSettings_1.Mask && noiseSettings_2.Mask));
    }
Example #2
0
    private void Start()
    {
        if (photonView.IsMine)
        {
            _camera = Instantiate(CinemachineCameraPrefab);
            CinemachineVirtualCamera virtualCamera = _camera.GetComponent <CinemachineVirtualCamera>();

            virtualCamera.Follow = gameObject.transform;
            virtualCamera.m_Lens.Orthographic     = true;
            virtualCamera.m_Lens.OrthographicSize = 9;

            CinemachineConfiner confiner = virtualCamera.GetComponent <CinemachineConfiner>();
            GameObject          map      = GameObject.Find("Map");
            confiner.m_BoundingShape2D = map.GetComponent <MapManager>().GetMapCollider();
            virtualCamera.AddExtension(confiner);

            CinemachineBasicMultiChannelPerlin perlin =
                virtualCamera.AddCinemachineComponent <CinemachineBasicMultiChannelPerlin>();

            NoiseSettings shake = Resources.Load("6DShake") as NoiseSettings;
            perlin.m_NoiseProfile  = shake;
            perlin.m_AmplitudeGain = 0;

            playerScript = GetComponent <AbstractPlayerScript>();
            playerScript.SetCinemachineBasicMultiChannelPerlin(perlin);

            isGameStart = false;
        }

        if (SceneManager.GetActiveScene().name.Equals("Game"))
        {
            GameManager.playerManagers.Add(this);
            GameStart();
        }
    }
Example #3
0
            public void CopyFrom(NoiseSettings from)
            {
                NoiseType = from.NoiseType;
                Frequency = from.Frequency;

                FractalType             = from.FractalType;
                FractalOctaves          = from.FractalOctaves;
                FractalLacunarity       = from.FractalLacunarity;
                FractalGain             = from.FractalGain;
                FractalWeightedStrength = from.FractalWeightedStrength;
                FractalPingPongStrength = from.FractalPingPongStrength;


                CellularDistanceFunction = from.CellularDistanceFunction;
                CellularReturnType       = from.CellularReturnType;
                CellularJitter           = from.CellularJitter;

                DomainWarpType = from.DomainWarpType;
                DomainWarpAmp  = from.DomainWarpAmp;

                Invert = from.Invert;

                SmoothThresholdStart = from.SmoothThresholdStart;
                SmoothThresholdEnd   = from.SmoothThresholdEnd;

                Threshold = from.Threshold;

                RangeStart = from.RangeStart;
                RangeEnd   = from.RangeEnd;

                Opacity = from.Opacity;

                BlendMode = from.BlendMode;
            }
Example #4
0
        NoiseSettings CreateProfile(SerializedProperty property, string label, NoiseSettings copyFrom)
        {
            string path = GetObjectName(property) + " " + label;

            path = EditorUtility.SaveFilePanelInProject(
                "Create Noise Profile asset", path, "asset",
                "This asset will generate a procedural noise signal");
            if (!string.IsNullOrEmpty(path))
            {
                NoiseSettings profile = null;
                if (copyFrom != null)
                {
                    string fromPath = AssetDatabase.GetAssetPath(copyFrom);
                    if (AssetDatabase.CopyAsset(fromPath, path))
                    {
                        profile = AssetDatabase.LoadAssetAtPath(
                            path, typeof(NoiseSettings)) as NoiseSettings;
                    }
                }
                else
                {
                    profile = ScriptableObjectUtility.CreateAt(
                        typeof(NoiseSettings), path) as NoiseSettings;
                }
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
                return(profile);
            }
            return(null);
        }
        NoiseSettings CreateProfile(NoiseSettings copyFrom)
        {
            var path  = string.Empty;
            var scene = Target.gameObject.scene;

            if (string.IsNullOrEmpty(scene.path))
            {
                path = "Assets/";
            }
            else
            {
                var scenePath   = Path.GetDirectoryName(scene.path);
                var extPath     = scene.name + "_Profiles";
                var profilePath = scenePath + "/" + extPath;
                if (!AssetDatabase.IsValidFolder(profilePath))
                {
                    AssetDatabase.CreateFolder(scenePath, extPath);
                }
                path = profilePath + "/";
            }

            var profile = ScriptableObject.CreateInstance <NoiseSettings>();

            if (copyFrom != null)
            {
                profile.CopyFrom(copyFrom);
            }
            path += Target.VirtualCamera.Name + " Noise.asset";
            path  = AssetDatabase.GenerateUniqueAssetPath(path);
            AssetDatabase.CreateAsset(profile, path);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            return(profile);
        }
 // Use this for initialization
 void Start()
 {
     noise            = virtualCamera.GetCinemachineComponent <CinemachineBasicMultiChannelPerlin> ();
     defaultNoise     = noise.m_NoiseProfile;
     defaultAmplitude = noise.m_AmplitudeGain;
     defaultfrequency = noise.m_FrequencyGain;
 }
Example #7
0
        NoiseSettings CreateProfile(SerializedProperty property, string label, NoiseSettings copyFrom)
        {
            var path  = string.Empty;
            var scene = SceneManager.GetActiveScene();

            if (string.IsNullOrEmpty(scene.path))
            {
                path = "Assets/";
            }
            else
            {
                var scenePath   = Path.GetDirectoryName(scene.path);
                var extPath     = scene.name + "_Profiles";
                var profilePath = scenePath + "/" + extPath;
                if (!AssetDatabase.IsValidFolder(profilePath))
                {
                    AssetDatabase.CreateFolder(scenePath, extPath);
                }
                path = profilePath + "/";
            }

            var profile = ScriptableObject.CreateInstance <NoiseSettings>();

            if (copyFrom != null)
            {
                profile.CopyFrom(copyFrom);
            }
            path += GetObjectName(property) + " " + label + ".asset";
            path  = AssetDatabase.GenerateUniqueAssetPath(path);
            AssetDatabase.CreateAsset(profile, path);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
            return(profile);
        }
Example #8
0
    public static float[,] GenerateSimplexNoiseMap(int mapWidth, int mapHeight, NoiseSettings settings, Vector2 sampleCentre)
    {
        float[,] noiseMap = new float[mapWidth, mapHeight];
        OpenSimplex2F simplexNoise = new OpenSimplex2F(settings.seed);

        System.Random prng    = new System.Random(settings.seed);
        float         offsetX = prng.Next(-100000, 100000) + settings.offset.x + sampleCentre.x;
        float         offsetY = prng.Next(-100000, 100000) - settings.offset.y - sampleCentre.y;
        Vector2       offset  = new Vector2(offsetX, offsetY);

        float halfWidth = mapWidth / 2f;
        float halHeight = mapHeight / 2f;

        for (int y = 0; y < mapHeight; ++y)
        {
            for (int x = 0; x < mapWidth; ++x)
            {
                float sampleX = (x - halfWidth + offset.x) / (settings.scale * 10f);
                float sampleY = (y - halHeight + offset.y) / (settings.scale * 10f);

                float noiseHeight = (float)simplexNoise.Noise2(sampleX, sampleY) * 2 - 1;
                noiseMap[x, y] = noiseHeight;
            }
        }


        return(noiseMap);
    }
 void Load6DShakeIfNull()
 {
     if (m_h6DShake == null)
     {
         m_h6DShake = Resources.Load <NoiseSettings>("Noise_6DShake");
     }
 }
        private static float3 Vertex(float stepSize, int2 position, Vector2 offset, NoiseSettings noiseSettings)
        {
            var point      = Common.MiddlePosition(position.x, position.y, stepSize, offset);
            var noiseValue = Common.NoiseValue(point, noiseSettings);

            return(math.float3(position.x * stepSize - 0.5f, noiseValue, position.y * stepSize - 0.5f));
        }
Example #11
0
 public RequestedChunk(ChunkIndex chunkIndex, NoiseSettings noiseSettings, Action <ChunkIndex, Chunk> onInstantiateCallback, bool perlin)
 {
     this.chunkIndex       = chunkIndex;
     this.noiseSettings    = noiseSettings;
     OnInstantiateCallback = onInstantiateCallback;
     this.perlin           = perlin;
 }
        private static NoiseSettings GenerateBiomeMapSettings(BiomeSettings[] biomes, GlobalBiomeSettings worldBiomeSettings, float totalFrequency)
        {
            NoiseSettings biomeMapSettings = ScriptableObject.CreateInstance <NoiseSettings>();

            biomeMapSettings.noiseLayers = new NoiseLayer[]
            {
                new NoiseLayer
                {
                    enabled       = true,
                    layerOperator = NoiseLayer.LayerOperator.Set,
                    settings      = new FilterSettings
                    {
                        filterType       = FilterSettings.FilterType.CellularStep,
                        cellularSettings = new FilterSettings.CellularStep
                        {
                            seed             = worldBiomeSettings.seed,
                            frequency        = worldBiomeSettings.frequency,
                            distanceFunction = worldBiomeSettings.distanceFunction,
                            cellTypes        = new Gradient
                            {
                                mode      = GradientMode.Fixed,
                                colorKeys = CalculateBiomeGradientKeys(biomes, totalFrequency)
                            }
                        }
                    }
                }
            };
            return(biomeMapSettings);
        }
Example #13
0
    public static float[,,] Calc3D(int width, int height, int length, int seed, NoiseSettings noiseSettings, Vector3 offset)
    {
        Seed = seed;
        var values = new float[width, height, length];

        for (var i = 0; i < width; i++)
        {
            for (var j = 0; j < height; j++)
            {
                for (var k = 0; k < length; k++)
                {
                    float currentSample = 0;
                    for (int l = 0; l < noiseSettings.octaves; l++)
                    {
                        float sampleX = (i + offset.x) / noiseSettings.scale * noiseSettings.frequencyTable[l];
                        float sampleY = (j + offset.y) / noiseSettings.scale * noiseSettings.frequencyTable[l];
                        float sampleZ = (k + offset.z) / noiseSettings.scale * noiseSettings.frequencyTable[l];
                        currentSample += Generate(sampleX, sampleY, sampleZ) * noiseSettings.amplitudeTable[l];
                    }
                    values[i, j, k] = currentSample;
                }
            }
        }
        return(values);
    }
Example #14
0
        static public void ApplyNoiseToSphere(SurfaceMap sphereLayer, Vector3Int center)
        {
            foreach (int contourPoint in sphereLayer.contour3D)
            {
                Vector3Int contourStartPoint = new Vector3Int(contourPoint % sphereLayer.resolution,
                                                              (contourPoint / sphereLayer.resolution) % sphereLayer.resolution,
                                                              contourPoint / sphereLayer.resolution2);
                Vector3 direction = contourStartPoint - center;
                direction = direction.normalized;

                Vector3    contourEndPointF = (contourStartPoint + direction * NoiseSettings.noiseMethod(contourStartPoint, NoiseSettings.frequency) * NoiseSettings.gain);
                Vector3Int contourEndPoint  = new Vector3Int(Mathf.RoundToInt(contourEndPointF.x),
                                                             Mathf.RoundToInt(contourEndPointF.y),
                                                             Mathf.RoundToInt(contourEndPointF.z));

                Cylinder(sphereLayer, contourStartPoint, contourEndPoint, 1,
                         sphereLayer.ReadMaterial(contourStartPoint.x, contourStartPoint.y, contourStartPoint.z));
            }
            Vector3Int point = new Vector3Int(sphereLayer.contour3D[0] % sphereLayer.resolution,
                                              (sphereLayer.contour3D[0] / sphereLayer.resolution) % sphereLayer.resolution,
                                              sphereLayer.contour3D[0] / sphereLayer.resolution2);

            Sphere(sphereLayer, center,
                   (int)((point - center).magnitude),
                   (int)((point - center).magnitude + 1),
                   /*sphereLayer.ReadMaterial(point.x, point.y, point.z)*/ 1,
                   false);
        }
 public MeshData(int size, Vector2 offset, NoiseSettings noiseSettings)
 {
     Size          = size;
     StepSize      = 1f / size;
     Offset        = offset;
     NoiseSettings = noiseSettings;
 }
Example #16
0
 public HeightMapSettings(AnimationCurve heightCurve, float heightMultiplier, bool useFalloff, NoiseSettings noiseSettings)
 {
     this.heightCurve      = heightCurve;
     this.heightMultiplier = heightMultiplier;
     this.useFalloff       = useFalloff;
     this.noiseSettings    = noiseSettings;
 }
Example #17
0
    public void GenerateChunkNonThreaded(Chunk chunk, ChunkIndex chunkIndex, NoiseSettings noiseSettings, bool perlin)
    {
        var generated = GenerateNew(chunk, chunkIndex, noiseSettings);

        chunk.ApplyBlocks(generated.blocks);
        chunk.ApplyMesh(generated.vertices, generated.uvs, generated.triangles);
    }
Example #18
0
 public ShapeGenerator(NoiseSettings noiseSettings, float radius)
 {
     this.radius        = radius;
     noiseFilter        = new NoiseFilter();
     elevationMinMax    = new MinMax();
     this.noiseSettings = noiseSettings;
 }
    private NoiseMapData GenerateNoiseMap(int width, int height, NoiseSettings noiseSettings)
    {
        float[,] noiseValues = new float[width, height];

        float maxValue = float.MinValue;
        float minValue = float.MaxValue;

        for (int i = 0; i < width; i++)
        {
            for (int j = 0; j < height; j++)
            {
                Vector3 p = new Vector3();
                p.x = i / (float)width;
                p.y = j / (float)height;
                float noiseValue = Evaluate(p, noiseSettings) / 2 + 0.5f;
                noiseValues[i, j] = noiseValue;

                maxValue = Mathf.Max(maxValue, noiseValue);
                minValue = Mathf.Min(minValue, noiseValue);
            }
        }

        NoiseMapData noiseMapData = new NoiseMapData();

        noiseMapData.noiseValues = noiseValues;
        noiseMapData.minValue    = minValue;
        noiseMapData.maxValue    = maxValue;

        return(noiseMapData);
    }
Example #20
0
 public void Play(NoiseSettings settings, float duration, AnimationCurve gain, Vector3 modulation)
 {
     if (settings && duration > 0f && !_isShaking && isActiveAndEnabled)
     {
         StartCoroutine(Shaking(settings, duration, gain, modulation));
     }
 }
Example #21
0
    public static float[,] computeNoiseMap(NoiseSettings settings, int seed, int mapSize, int layer)
    {
        float[,] noiseMap = new float[mapSize, mapSize];

        System.Random prng = new System.Random(seed);

        Vector2[] octaveOffsets = new Vector2[settings.octaves];
        for (int i = 0; i < settings.octaves; i++)
        {
            float offsetX = prng.Next(-100000, 100000) + (layer * 1000);
            float offsetY = prng.Next(-100000, 100000) + (layer * 1000);
            octaveOffsets[i] = new Vector2(offsetX, offsetY);
        }

        float maxNoiseHeight = float.MinValue;
        float minNoiseHeight = float.MaxValue;

        for (int x = 0; x < mapSize; x++)
        {
            for (int y = 0; y < mapSize; y++)
            {
                float amplitude   = 1;
                float frequency   = 1;
                float noiseHeight = 0;

                for (int i = 0; i < settings.octaves; i++)
                {
                    float sampleX = x / settings.scale * frequency + octaveOffsets[i].x;
                    float sampleY = y / settings.scale * frequency + octaveOffsets[i].y;

                    float perlinValue = Mathf.PerlinNoise(sampleX, sampleY);// * 2 - 1;
                    noiseHeight += perlinValue * amplitude;

                    amplitude *= settings.persistance;
                    frequency *= settings.lacunarity;
                }

                if (noiseHeight > maxNoiseHeight)
                {
                    maxNoiseHeight = noiseHeight;
                }
                else if (noiseHeight < minNoiseHeight)
                {
                    minNoiseHeight = noiseHeight;
                }
                noiseMap[x, y] = noiseHeight;
            }
        }

        // Normalize the values.
        for (int y = 0; y < mapSize; y++)
        {
            for (int x = 0; x < mapSize; x++)
            {
                noiseMap[x, y] = Mathf.InverseLerp(minNoiseHeight, maxNoiseHeight, noiseMap[x, y]);
            }
        }

        return(noiseMap);
    }
Example #22
0
    public OreChunk(Vector2 position, NoiseSettings noiseSettings, OreType[] oreTypes, float oreSpawnThreshold)
    {
        this.position      = position;
        this.noiseSettings = noiseSettings;
        this.oreTypes      = oreTypes;
        //this.threshold = threshold;


        float[,] noise = Noise.GenerateNoiseMap(100, 100, noiseSettings, position * 100); // generates noise map based on worldgrid

        float totalFrequency = 0;

        foreach (OreType ore in oreTypes)
        {
            totalFrequency += ore.frequency;
        }
        foreach (OreType ore in oreTypes)
        {
            ore.relFrequency = ore.frequency / totalFrequency;
        }

        oreRanges = new float[oreTypes.Length];
        float workingSum = 0;

        for (int i = 0; i < oreTypes.Length; i++)
        {
            workingSum  += oreTypes[i].relFrequency;
            oreRanges[i] = workingSum;
            Debug.Log(oreRanges[i]);
        }

        Dictionary <Vector2, float> aboveThreshold = new Dictionary <Vector2, float>();

        for (int i = 0; i < 100; i++)
        {
            for (int j = 0; j < 100; j++)
            {
                if (noise[i, j] > threshold)
                {
                    aboveThreshold.Add(new Vector2(position.x * 100 - 50 + i, position.y * 100 - 50 + j), noise[i, j]);
                }
            }
        }
        int loopCount = 0;

        while (aboveThreshold.Count > 0)
        {
            Vector2[] keys = new Vector2[aboveThreshold.Keys.Count];
            aboveThreshold.Keys.CopyTo(keys, 0);
            localVeins.Add(GenerateOreVeinsHelper(keys[0], aboveThreshold, new OreVein(new List <OreSpace>(), null), RandomOreType()));
            loopCount++;
            if (loopCount > 10000)
            {
                Debug.Log("too many loops");
                break;
            }
        }

        //Debug.Log("localveins: " + localVeins.Count);
    }
    public void UpdateNoise(NoiseSettings settings = null)
    {
        settings = settings == null ? activeSettings : settings;

        if (updateNoise && noiseCompute && settings != null)
        {
            RenderTexture texture = GetTexture(settings.type);
            updateNoise = false;
            buffers     = new List <ComputeBuffer>();

            noiseCompute.SetFloat("layerMix", settings.mix);
            noiseCompute.SetInt("resolution", TEXTURE_SIZE[settings.type]);
            noiseCompute.SetVector("channelMask", ChannelMask((NoiseChannel)settings.channel));
            noiseCompute.SetTexture(0, "result", texture);
            var limitsBuffer = SetBuffer(new int[] { int.MaxValue, 0 }, sizeof(int), "limits");
            UpdateProperties(settings);

            int threads = Mathf.CeilToInt(TEXTURE_SIZE[settings.type] / 8.0f);

            noiseCompute.Dispatch(0, threads, threads, threads);

            noiseCompute.SetBuffer(1, "limits", limitsBuffer);
            noiseCompute.SetTexture(1, "result", texture);
            noiseCompute.Dispatch(1, threads, threads, threads);

            foreach (var buffer in buffers)
            {
                buffer.Release();
            }
        }
    }
Example #24
0
    public TerrainChunk
    (
        Vector2 coord,
        HeightMapSettings heightMapSettings,
        MeshSettings meshSettings,
        LODInfo[] detailLevels,
        int colliderLODIndex,
        Transform parent,
        Transform viewer,
        GameManager gameManager,
        Material material,
        NoiseSettings oreNoiseSettings,         //last 3 are ore related
        OreType[] oreTypes,
        float oreSpawnThreshold
    )
    {
        this.coord             = coord;
        this.detailLevels      = detailLevels;
        this.colliderLODIndex  = colliderLODIndex;
        this.heightMapSettings = heightMapSettings;
        this.meshSettings      = meshSettings;
        this.viewer            = viewer;
        chunkOres = new ChunkOres(oreTypes, oreSpawnThreshold);



        sampleCentre = coord * meshSettings.meshWorldSize / meshSettings.meshScale;
        Vector2 position = coord * meshSettings.meshWorldSize;

        bounds = new Bounds(position, Vector2.one * meshSettings.meshWorldSize);



        meshObject            = new GameObject("Terrain Chunk " + coord);
        meshRenderer          = meshObject.AddComponent <MeshRenderer>();
        meshFilter            = meshObject.AddComponent <MeshFilter>();
        meshCollider          = meshObject.AddComponent <MeshCollider>();
        meshObject.layer      = 6;
        meshRenderer.material = material;

        meshObject.transform.position = new Vector3(position.x, 0, position.y);
        meshObject.transform.parent   = parent;
        SetVisible(false);

        lodMeshes = new LODMesh[detailLevels.Length];
        for (int i = 0; i < detailLevels.Length; i++)
        {
            lodMeshes[i] = new LODMesh(detailLevels[i].lod);
            lodMeshes[i].updateCallback += UpdateTerrainChunk;
            if (i == colliderLODIndex)
            {
                lodMeshes[i].updateCallback += UpdateCollisionMesh;
            }
        }

        maxViewDst = detailLevels [detailLevels.Length - 1].visibleDstThreshold;
        chunkOres.GenerateOres(coord, meshSettings.meshWorldSize, meshSettings.meshScale, oreNoiseSettings);
        gameManager.RunCoroutine(GenerateOreMeshes());
    }
 public NoiseSettingsEditor()
 {
     if (noiseSettings == null)
     {
         noiseSettings    = new NoiseSettings[1];
         noiseSettings[0] = new NoiseSettings();
     }
 }
Example #26
0
 /// <summary>
 /// Creates a new simplex noise generator with the given noise settings.
 /// </summary>
 /// <param name="settings">
 /// The settings for fractal noise generation.
 /// </param>
 public SimplexNoise(NoiseSettings settings)
 {
     this.settings = settings;
     if (settings.scale <= 0.0f)
     {
         settings.scale = 0.0001f;
     }
 }
Example #27
0
 /// <summary>
 /// Spawns a new chunk, populates it with blocks and adds its mesh
 /// </summary>
 /// <param name="chunkIndex">Chunk index.</param>
 /// <param name="noiseSettings">Noise settings.</param>
 public void RequestChunkGeneration(ChunkIndex chunkIndex, NoiseSettings noiseSettings, Action <ChunkIndex, Chunk> callback, bool perlin)
 {
     lock (Loading)
     {
         Loading.Add(chunkIndex);
     }
     requestedChunks.Enqueue(new RequestedChunk(chunkIndex, MainNoiseSettings, callback, perlin));
 }
 // Start is called before the first frame update
 void Start()
 {
     planet              = GetComponent <Planet>();
     shapeSettings       = planet.shapeSettings;
     colorSettings       = planet.colorSettings;
     simpleNoiseSettings = shapeSettings.noiseLayers[0].noiseSettings;
     rigidNoiseSettings  = shapeSettings.noiseLayers[1].noiseSettings;
 }
Example #29
0
 public static INoiseFilter CreateNoiseFilter(NoiseSettings settings)
 {
     return(settings.filterType switch
     {
         NoiseSettings.FilterType.Simple => new SimpleNoiseFilter(settings.simpleNoiseSettings),
         NoiseSettings.FilterType.Rigid => new RigidNoiseFilter(settings.rigidNoiseSettings),
         _ => null,
     });
        public void SetCameraNoice(NoiseSettings preset, float amp, float freq, float time)
        {
            noise.m_NoiseProfile  = preset;
            noise.m_AmplitudeGain = amp;
            noise.m_FrequencyGain = freq;

            StartCoroutine(StartResetCamInSeconds(time));
        }
	public void GeneratePreview (NoiseSettings script)
	{
		script.debugPreviewGrid = new float[previewSize,previewSize];
		for (int x = 0; x < previewSize; x++)
		{
			for (int y = 0; y < previewSize; y++)
			{
				if (script.passOperationType == NoiseSettings.PassOperation.ADD)
				{
					script.debugPreviewGrid[x, y] = -script.outputCurve.minOutputValue;
				}
				else if (script.passOperationType == NoiseSettings.PassOperation.MULTIPLY)
				{
					script.debugPreviewGrid[x, y] = 1f;
				}
			}
		}
		script.ModifyGrid(ref script.debugPreviewGrid, 1f, previewSeed);
	}
	public void UpdateCheck(NoiseSettings script)
	{
		float valueHash = GetPropertyValueHash(script);
		if (valueHash != lastValueHash)
		{
			lastValueHash = valueHash;
			GeneratePreview(script);
		}
	}
	//not sure how to best check for updates at the moment
	private float GetPropertyValueHash (NoiseSettings script)
	{
		float hash = (float)script.frequency * 1.1123f;
		hash += (float)script.lacunarity * 2.4123f;
		hash += (float)script.noisePassType * 1.53234f;
		hash += (float)script.octaves * 3.53434f;
		hash += (float)script.persistence * 2.1347f;
		hash += (float)script.quality * 4.1237f;
		if (script.turbulenceSettings.isActive)
		{
			hash += (float)script.turbulenceSettings.frequency * 5.2627f;
			hash += (float)script.turbulenceSettings.power * 2.68287f;
			hash += (float)script.turbulenceSettings.roughness * 1.682234f;
		}
		hash += (float)script.outputCurve.maxInputValue * 2.62347f;
		hash += (float)script.outputCurve.minInputValue * 5.62123f;
		hash += (float)script.outputCurve.curve.GetHashCode() * .0000052342f;

		return hash;
	}
	public PassSettingsAndActive(bool _isActive, NoiseSettings _noiseSettings)
	{
		isActive = _isActive;
		noiseSettings = _noiseSettings;
	}
	public void Initialize (NoiseSettings newNoiseSettings, int newSeed)
	{
		noiseSettings = newNoiseSettings;
		seed = newSeed;
		GenerateNoise();
	}
	public IEnumerator CheckForUpdates (NoiseSettings script)
	{
		while (Selection.activeObject == target || !DisplayPreview)
		{
			UpdateCheck(script);
			yield return 2f;
		}
	}