Also pass the seed to get_value for, and cleaned up perlin.gd.

This commit is contained in:
Relintai 2021-10-04 13:15:18 +02:00
parent 0943dc32f8
commit a13908fcec
2 changed files with 7 additions and 13 deletions

View File

@ -21,7 +21,7 @@ func recalculate_image(material, slot_idx : int) -> ImageTexture:
for y in range(image.get_height()): for y in range(image.get_height()):
var v : Vector2 = Vector2(x / w, y / h) 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) image.set_pixel(x, y, col)
@ -31,7 +31,7 @@ func recalculate_image(material, slot_idx : int) -> ImageTexture:
return tex 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() return Color()
func register_methods(mm_graph_node) -> void: func register_methods(mm_graph_node) -> void:

View File

@ -6,18 +6,12 @@ var NoisePerlin = preload("res://addons/mat_maker_gd/nodes/common/noise_perlin.g
var image : Image var image : Image
var tex : ImageTexture var tex : ImageTexture
export(Vector2) var bmin : Vector2 = Vector2(0.1, 0.1) export(Vector2) var scale : Vector2 = Vector2(4, 4)
export(Vector2) var bmax : Vector2 = Vector2(1, 1) export(int) var iterations : int = 3
export(float) var persistence : float = 0.5
var seed_o12297 = -26656; func get_value_for(uv : Vector2, slot_idx : int, pseed : int) -> Color:
var p_o12297_scale_x = 4.000000000; return NoisePerlin.perlinc(uv, scale, iterations, persistence, pseed)
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 register_methods(mm_graph_node) -> void: func register_methods(mm_graph_node) -> void:
mm_graph_node.add_slot_texture(0, 0, "recalculate_image", "") mm_graph_node.add_slot_texture(0, 0, "recalculate_image", "")