-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoffline_hfield_generator.py
More file actions
36 lines (22 loc) · 939 Bytes
/
offline_hfield_generator.py
File metadata and controls
36 lines (22 loc) · 939 Bytes
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
import time
import tqdm
import os
import numpy as np
from perlin_noise import PerlinNoise
if __name__ == '__main__':
os.makedirs('hfields', exist_ok=True)
while True:
print('Regenerating hfields...')
for itr in tqdm.tqdm(range(100)):
hfield = np.zeros((600, 600), dtype=np.float32)
perlin_fn = PerlinNoise(octaves=np.random.uniform(5, 10), seed=np.random.randint(10000))
for i in range(int(600 * 600)):
ix, iy = i // 600, i % 600
x = ix * 0.05 - 30 / 2
y = iy * 0.05 - 30 / 2
dist = np.linalg.norm((x, y))
falloff = np.clip((dist - 2) / 2, 0, 1.5)
z_size = perlin_fn((ix / 600, iy / 600)) * falloff
hfield[iy, ix] = z_size
hfield = (hfield - np.min(hfield)) / (np.ptp(hfield) + 1e-6)
np.save(f'hfields/hfield_{itr}.npy', hfield)