Thomas Blood
Thomas Blood

Reputation: 11

How to make a 2d simplex noise map that loops in both directions? Godot 3.6

So I've followed a few tutorials to try and do this but I'm not getting anywhere. What I'm trying to do is make a 2D noise map that loops in all directions (I'm making a game map you can walk around and loop), and so I'm using 4D simplex noise and making 2 circles that I'm looping through, but the entire thing is coming out as if it's a perfect grid of low points with high points in the center of each grid.

Here is the generator code and the outcome:

extends Node

onready var tilemap_grass = get_node("/root/manager_global/manager_tile/tilemap_grass")
var map = {"0,0": 0}
var noise = OpenSimplexNoise.new()
var map_size = Vector2(90, 90)

func _ready():
    noise.seed = 14756107829
    for x in map_size.x:
        for y in map_size.y:
            var label = str(x)
            label += ","
            label += str(y)
            var r = 1
            map[label] = noise.get_noise_4d(r + cos(x * 4), r + sin(x * 4), r + cos(y * 4), r + sin(y * 4))
            
            if map[label] < 0:
                tilemap_grass.set_cell(x, y, 0)
    
    
    print(map)
    tilemap_grass.update_bitmask_region(Vector2(0, 0), Vector2(map_size.x, map_size.y))

Photo of result here

When I shrink the loop from 360 to 90, and so I cycle through every 4 degrees instead of everyone, instead of a grid I get weird high point dashes in a grid with everything around it being low points. I've also tried changing the octaves, and frequency, but none of them are getting rid of this grid.

Upvotes: 1

Views: 45

Answers (0)

Related Questions