broken_seals/game/addons/mat_maker_gd/nodes/noise/perlin.gd

54 lines
1.6 KiB
GDScript3
Raw Normal View History

tool
extends MMNode
var NoisePerlin = preload("res://addons/mat_maker_gd/nodes/common/noise_perlin.gd")
2021-10-01 23:07:05 +02:00
var image : Image
var tex : ImageTexture
export(Vector2) var scale : Vector2 = Vector2(4, 4)
export(int) var iterations : int = 3
export(float) var persistence : float = 0.5
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:
2021-10-04 13:28:00 +02:00
mm_graph_node.add_slot_texture(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_IMAGE, "recalculate_image", "")
2021-10-04 14:58:15 +02:00
mm_graph_node.add_slot_int(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_iterations", "set_iterations", "iterations")
mm_graph_node.add_slot_float(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_persistence", "set_persistence", "persistence")
mm_graph_node.add_slot_float(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_scale_x", "set_scale_x", "scale")
mm_graph_node.add_slot_float(SlotTypes.SLOT_TYPE_NONE, SlotTypes.SLOT_TYPE_NONE, "get_scale_y", "set_scale_y", "")
2021-10-04 14:58:15 +02:00
func get_iterations() -> int:
return iterations
func set_iterations(val : int) -> void:
iterations = val
emit_changed()
func get_persistence() -> float:
return persistence
func set_persistence(val : float) -> void:
persistence = val
emit_changed()
func get_scale_x() -> float:
return scale.x
func set_scale_x(val : float) -> void:
scale.x = val
emit_changed()
func get_scale_y() -> float:
return scale.y
func set_scale_y(val : float) -> void:
scale.y = val
emit_changed()