Noise viewer
The six FastNoiseLite types side by side, same seed and no fractal, so the character of each one shows.
The editor above is running this project. Change a line and it reloads.
Godot classes used
FastNoiseLiteNoiseTexture2DTextureRect
The code
scripts/main.gd
extends Node
const TILE: float = 250.0
const GAP: float = 44.0
const COLUMNS: int = 3
const ROWS: int = 2
const SEED: int = 20260814
const TYPES: Array = [
{name = 'SIMPLEX', type = FastNoiseLite.TYPE_SIMPLEX, frequency = 0.03},
{name = 'SIMPLEX_SMOOTH', type = FastNoiseLite.TYPE_SIMPLEX_SMOOTH, frequency = 0.03},
{name = 'PERLIN', type = FastNoiseLite.TYPE_PERLIN, frequency = 0.03},
{name = 'VALUE', type = FastNoiseLite.TYPE_VALUE, frequency = 0.05},
{name = 'VALUE_CUBIC', type = FastNoiseLite.TYPE_VALUE_CUBIC, frequency = 0.05},
{name = 'CELLULAR', type = FastNoiseLite.TYPE_CELLULAR, frequency = 0.04},
]
func _ready() -> void:
_add_background()
var view: Vector2 = get_viewport().get_visible_rect().size
var origin: Vector2 = Vector2(
(view.x - COLUMNS * TILE - (COLUMNS - 1) * GAP) * 0.5,
(view.y - ROWS * TILE - (ROWS - 1) * GAP) * 0.5 + 18.0
)
for row in ROWS:
for column in COLUMNS:
var entry: Dictionary = TYPES[row * COLUMNS + column]
var at: Vector2 = origin + Vector2(column * (TILE + GAP), row * (TILE + GAP))
var tile: TextureRect = TextureRect.new()
tile.texture = _make_noise(entry.type, entry.frequency)
tile.position = at
tile.size = Vector2(TILE, TILE)
tile.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
tile.stretch_mode = TextureRect.STRETCH_SCALE
add_child(tile)
_add_label(entry.name, at + Vector2(0, -26))
print('six FastNoiseLite types with the same seed, change SEED for another set')
func _make_noise(type: FastNoiseLite.NoiseType, frequency: float) -> NoiseTexture2D:
var noise: FastNoiseLite = FastNoiseLite.new()
noise.noise_type = type
noise.frequency = frequency
noise.seed = SEED
# the default FBM fractal blurs the types into the same cloud
noise.fractal_type = FastNoiseLite.FRACTAL_NONE
var texture: NoiseTexture2D = NoiseTexture2D.new()
texture.noise = noise
texture.color_ramp = _make_ramp()
texture.width = 256
texture.height = 256
return texture
func _make_ramp() -> Gradient:
var ramp: Gradient = Gradient.new()
ramp.set_color(0, Color('#12141a'))
ramp.set_color(1, Color('#8da5f3'))
return ramp
func _add_label(text: String, at: Vector2) -> void:
var label: Label = Label.new()
label.text = text
label.position = at
label.add_theme_color_override('font_color', Color('#999999'))
add_child(label)
func _add_background() -> void:
var background: ColorRect = ColorRect.new()
background.color = Color('#12141a')
add_child(background)
background.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)