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
49
50
51
52
53
54
55
56
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BiomeMaster : MonoBehaviour
{
public List<BiomeParameter> parameters;
[Header("Debug")]
public bool updateDebug;
public int debugSize = 500;
public float debugFrequency = 0.1f;
#region On Validate
private void OnValidate()
{
if (updateDebug)
{
updateDebug = false;
for (int i = -debugSize; i < debugSize; i++)
{
for (int j = -debugSize; j < debugSize; j++)
{
float x = i * debugFrequency;
float y = j * debugFrequency;
float h = 0;
Color colorBlend = new();
foreach (var parameter in parameters)
{
foreach (var octave in parameter.map)
{
float strength = octave.Calculate(new(x, y));
h += strength;
if (octave.amplitude > 0)
colorBlend += parameter.debugColor * (strength / octave.amplitude)
/ parameters.Count;
}
}
colorBlend.a = 1;
Vector3 start = new(x, 0, y);
Vector3 end = new(x, h, y);
Debug.DrawLine(start, end, colorBlend, 10);
}
}
}
}
#endregion
}