private static int CalculateHeight(Vector2 xz, float frequency, float persistence)
        {
            float noise               = OpenSimplexSlim.GetSimplex(GenerationConstants.Seed, frequency, xz);
            float noiseHeight         = noise.Unlerp(-1f, 1f) * GenerationConstants.WORLD_HEIGHT;
            float modifiedNoiseHeight = noiseHeight + (((GenerationConstants.WORLD_HEIGHT / 2f) - (noiseHeight * 1.25f)) * persistence);

            return((int)modifiedNoiseHeight);
        }
Beispiel #2
0
        private int GetHeightByGlobalPosition(int2 globalPosition)
        {
            float noise = OpenSimplexSlim.GetSimplex(WorldController.Current.Seed, _Frequency, globalPosition);
            float noiseAsWorldHeight        = math.unlerp(-1f, 1f, noise) * WorldController.WORLD_HEIGHT;
            float noisePersistedWorldHeight =
                noiseAsWorldHeight + (((WorldController.WORLD_HEIGHT / 2f) - (noiseAsWorldHeight * 1.25f)) * _Persistence);

            return((int)math.floor(noisePersistedWorldHeight));
        }
Beispiel #3
0
        private float GetCaveNoiseByGlobalPosition(int3 globalPosition)
        {
            float currentHeight  = (globalPosition.y + (((WorldController.WORLD_HEIGHT / 4f) - (globalPosition.y * 1.25f)) * _Persistence)) * 0.85f;
            float heightDampener = math.unlerp(0f, WorldController.WORLD_HEIGHT, currentHeight);
            float noiseA         = OpenSimplexSlim.GetSimplex(_NoiseSeedA, 0.01f, globalPosition) * heightDampener;
            float noiseB         = OpenSimplexSlim.GetSimplex(_NoiseSeedB, 0.01f, globalPosition) * heightDampener;
            float noiseAPow2     = math.pow(noiseA, 2f);
            float noiseBPow2     = math.pow(noiseB, 2f);

            return((noiseAPow2 + noiseBPow2) / 2f);
        }
        private static float CalculateCaveNoise(Vector3i global, IGenerationStep.Parameters parameters)
        {
            float currentHeight  = (global.Y + (((GenerationConstants.WORLD_HEIGHT / 4f) - (global.Y * 1.25f)) * parameters.Persistence)) * 0.85f;
            float heightDampener = currentHeight.Unlerp(0f, GenerationConstants.WORLD_HEIGHT);

            float sampleA = OpenSimplexSlim.GetSimplex(parameters.Seed ^ 2, parameters.Frequency, global) * heightDampener;
            float sampleB = OpenSimplexSlim.GetSimplex(parameters.Seed ^ 3, parameters.Frequency, global) * heightDampener;

            sampleA *= sampleA;
            sampleB *= sampleB;

            return((sampleA + sampleB) * 0.5f);
        }
 public float ReadOnlyArray() => OpenSimplexSlim.GetSimplex(_Seed, 0.001f, _Coordinates);