Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using System.Collections.Generic;
using Unity.Mathematics;
using UnityEngine;
[Serializable]
public enum NoiseType
{
MathfPerlin,
MathematicsPerlin,
Simplex,
Celluar
}
[Serializable]
public struct Octave
{
public float amplitude;
public float frequency;
public NoiseType type;
public Vector2 offset;
public float Calculate(float2 position)
{
float addition;
position += new float2(offset);
switch (type)
{
default:
case NoiseType.MathfPerlin:
addition = Mathf.PerlinNoise(position.x, position.y);
break;
case NoiseType.MathematicsPerlin:
addition = noise.cnoise(position) / 2.3f + 0.5f;
break;
case NoiseType.Simplex:
addition = noise.snoise(position) / 4.6f + 0.5f;
break;
case NoiseType.Celluar:
addition = noise.cellular(position).x / 2.3f + 0.5f;
break;
}
return addition * amplitude;
}
}