From a13908fcecdb78d7e1a29b3ed741dfe2910be210 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 4 Oct 2021 13:15:18 +0200 Subject: [PATCH] Also pass the seed to get_value for, and cleaned up perlin.gd. --- game/addons/mat_maker_gd/nodes/mm_node.gd | 4 ++-- game/addons/mat_maker_gd/nodes/noise/perlin.gd | 16 +++++----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/game/addons/mat_maker_gd/nodes/mm_node.gd b/game/addons/mat_maker_gd/nodes/mm_node.gd index fcec253e..4fb44853 100644 --- a/game/addons/mat_maker_gd/nodes/mm_node.gd +++ b/game/addons/mat_maker_gd/nodes/mm_node.gd @@ -21,7 +21,7 @@ func recalculate_image(material, slot_idx : int) -> ImageTexture: for y in range(image.get_height()): var v : Vector2 = Vector2(x / w, y / h) - var col : Color = get_value_for(v, slot_idx) + var col : Color = get_value_for(v, slot_idx, pseed) image.set_pixel(x, y, col) @@ -31,7 +31,7 @@ func recalculate_image(material, slot_idx : int) -> ImageTexture: return tex -func get_value_for(uv : Vector2, slot_idx : int) -> Color: +func get_value_for(uv : Vector2, slot_idx : int, pseed : int) -> Color: return Color() func register_methods(mm_graph_node) -> void: diff --git a/game/addons/mat_maker_gd/nodes/noise/perlin.gd b/game/addons/mat_maker_gd/nodes/noise/perlin.gd index 02f42348..0be1b4d5 100644 --- a/game/addons/mat_maker_gd/nodes/noise/perlin.gd +++ b/game/addons/mat_maker_gd/nodes/noise/perlin.gd @@ -6,18 +6,12 @@ var NoisePerlin = preload("res://addons/mat_maker_gd/nodes/common/noise_perlin.g var image : Image var tex : ImageTexture -export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) -export(Vector2) var bmax : Vector2 = Vector2(1, 1) +export(Vector2) var scale : Vector2 = Vector2(4, 4) +export(int) var iterations : int = 3 +export(float) var persistence : float = 0.5 -var seed_o12297 = -26656; -var p_o12297_scale_x = 4.000000000; -var p_o12297_scale_y = 4.000000000; -var p_o12297_iterations = 3.000000000; -var p_o12297_persistence = 0.500000000; - -func get_value_for(uv : Vector2, slot_idx : int) -> Color: - var a = NoisePerlin.perlinc(uv, Vector2(p_o12297_scale_x, p_o12297_scale_y), int(p_o12297_iterations), p_o12297_persistence, seed_o12297) - return a +func get_value_for(uv : Vector2, slot_idx : int, pseed : int) -> Color: + return NoisePerlin.perlinc(uv, scale, iterations, persistence, pseed) func register_methods(mm_graph_node) -> void: mm_graph_node.add_slot_texture(0, 0, "recalculate_image", "")