Skip to content

Commit b8344cf

Browse files
Update terrain generation.py
1 parent e97e037 commit b8344cf

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/terrain generation.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
# Constants for the terrain
1616
WIDTH, HEIGHT = 1920, 1080
17-
GRID_SIZE = 750#1000 # Number of vertices along one side of the terrain
18-
SCALE = 0.25#0.5 # Distance between vertices in the grid
17+
GRID_SIZE = 3000#1000 # Number of vertices along one side of the terrain
18+
SCALE = 0.1#0.5 # Distance between vertices in the grid
1919
AMPLITUDE = 100#50 # Height amplitude for the noise
2020

2121
def load_texture(filepath, context):
@@ -28,7 +28,7 @@ def generate_perlin_noise(noise, grid_size, scale, amplitude):
2828

2929
for i in range(grid_size):
3030
for j in range(grid_size):
31-
y = noise.generate_2D_perlin_noise(i / 600.0, j / 600.0, new_range=[0, amplitude])
31+
y = noise.generate_2D_perlin_noise(i / 2500.0, j / 2500.0, new_range=[0, amplitude])
3232
noise_values[i * grid_size + j] = y
3333

3434
return noise_values
@@ -79,7 +79,7 @@ def generate_terrain(noise, grid_size, scale, amplitude):
7979
float radius = length(in_vert.xz);
8080
8181
// Determine the maximum radius for the animation based on the terrain size
82-
float max_radius = 250.0; // Adjust as necessary depending on the grid size
82+
float max_radius = 700.0; // Adjust as necessary depending on the grid size 250
8383
8484
float pi = 3.141592653589793238462643383279502884197169/2;
8585
@@ -88,7 +88,7 @@ def generate_terrain(noise, grid_size, scale, amplitude):
8888
8989
// Fade out effect for far away points
9090
float fade_start = 60; // 60
91-
float fade_end = 100; // 85
91+
float fade_end = 700; // 85
9292
float fade_factor = 1-smoothstep(fade_start, fade_end, radius);
9393
9494
// Apply the animation effect
@@ -211,6 +211,9 @@ def get_height_at_origin(vertices, grid_size):
211211
# Access the height (Y coordinate) at the origin
212212
height_at_origin = vertices[index_at_origin][1] # [1] for the Y component
213213

214+
if height_at_origin < 20:
215+
height_at_origin = 20
216+
214217
return height_at_origin
215218

216219
TAU = math.pi * 2

0 commit comments

Comments
 (0)