2021-10-01 00:54:13 +02:00
|
|
|
tool
|
2021-10-04 11:54:52 +02:00
|
|
|
extends MMNode
|
2021-10-01 00:54:13 +02:00
|
|
|
|
2021-10-02 18:45:29 +02:00
|
|
|
var NoisePerlin = preload("res://addons/mat_maker_gd/nodes/common/noise_perlin.gd")
|
2021-10-01 23:07:05 +02:00
|
|
|
|
2021-10-01 00:54:13 +02:00
|
|
|
var image : Image
|
|
|
|
var tex : ImageTexture
|
|
|
|
|
2021-10-04 13:15:18 +02:00
|
|
|
export(Vector2) var scale : Vector2 = Vector2(4, 4)
|
|
|
|
export(int) var iterations : int = 3
|
|
|
|
export(float) var persistence : float = 0.5
|
2021-10-01 00:54:13 +02:00
|
|
|
|
2021-10-09 13:33:59 +02:00
|
|
|
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
2021-10-04 13:15:18 +02:00
|
|
|
return NoisePerlin.perlinc(uv, scale, iterations, persistence, pseed)
|
2021-10-01 00:54:13 +02:00
|
|
|
|
2021-10-06 10:30:22 +02:00
|
|
|
func _register_methods(mm_graph_node) -> void:
|
2021-10-09 13:33:59 +02:00
|
|
|
mm_graph_node.add_slot_texture(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE, "render_image", "")
|
2021-10-06 09:15:48 +02:00
|
|
|
mm_graph_node.add_slot_int(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, "get_iterations", "set_iterations", "iterations")#, Vector2(1, 10))
|
|
|
|
mm_graph_node.add_slot_float(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, "get_persistence", "set_persistence", "persistence", 0.05)#, Vector2(0, 1))
|
|
|
|
mm_graph_node.add_slot_vector2(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, "get_scale", "set_scale", "scale", 1)#, Vector2(1, 32))
|
2021-10-01 00:54:13 +02:00
|
|
|
|
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()
|
|
|
|
|
2021-10-04 18:29:11 +02:00
|
|
|
func get_scale() -> Vector2:
|
|
|
|
return scale
|
2021-10-04 14:58:15 +02:00
|
|
|
|
2021-10-04 18:29:11 +02:00
|
|
|
func set_scale(val : Vector2) -> void:
|
|
|
|
scale = val
|
2021-10-04 14:58:15 +02:00
|
|
|
|
|
|
|
emit_changed()
|