#Randomly Generated World --> Randomly Generated Island

6 messages · Page 1 of 1 (latest)

red sparrow
#

Hello, everybody.
I were trying to make a procedurally generated island, and after doing some work, I ended up with a random mesh that I made out of perlin noise. I need to kinda wrap it around the edges, and make it island like. If any of you know how to do that, please help.

Here's my script:

extends StaticBody3D

@export var world_size_huge = 50
@export var world_size_regural = 30
@export var world_size_small = 10

@export var world_size_selector = world_size_small

@export var size = 264 * world_size_selector
@export var subdivide = 63 * world_size_selector
@export var amplitude = 20
@export var noise = FastNoiseLite.new()

func _ready():
    generate_mesh()

func generate_mesh():
    print("Generating Mesh...")
    var plane_mesh = PlaneMesh.new()
    plane_mesh.size = Vector2(size,size)
    plane_mesh.subdivide_depth = subdivide
    plane_mesh.subdivide_width = subdivide
    
    var surface_tool = SurfaceTool.new()
    surface_tool.create_from(plane_mesh,0)
    var data = surface_tool.commit_to_arrays()
    var vertices = data[ArrayMesh.ARRAY_VERTEX]
    
    
    
    for i in vertices.size():
        var vertex = vertices[i]
        vertices[i].y = noise.get_noise_2d(vertex.x,vertex.z) * amplitude
    data[ArrayMesh.ARRAY_VERTEX] = vertices
        
    var array_mesh = ArrayMesh.new()
    array_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES,data)
    
    surface_tool.create_from(array_mesh,0)
    surface_tool.generate_normals()

    $MeshInstance3D.mesh = surface_tool.commit()
    $CollisionShape3D.shape = array_mesh.create_trimesh_shape()

Would really appreciate some help, thanks.

#

Just realized, that it's hard to see the randomness of the mesh on the picture... I should pump up the amplitude just a little bit I think.

slim furnace
#

apply a circlular gradient to the noise

red sparrow
#

Problem Solved.

slim furnace