mirror of
https://github.com/Relintai/broken_seals_2d.git
synced 2024-11-11 20:35:10 +01:00
Removed mat_maker_gd.
This commit is contained in:
parent
538e5a7017
commit
4808456515
@ -1,22 +0,0 @@
|
||||
# MIT License
|
||||
|
||||
Copyright (c) 2020 Péter Magyar
|
||||
Copyright (c) 2018-2020 Rodolphe Suescun and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -1,22 +0,0 @@
|
||||
# mat_maker_gd
|
||||
|
||||
My goal with this project is to take Material Maker's ( https://github.com/RodZill4/material-maker ) code,
|
||||
and make it an in-godot texture/image generator.
|
||||
|
||||
If it turns out well I'll probably turn it into a c++ engine module eventually.
|
||||
|
||||
Multi threading uses my threadpool engine module for now.
|
||||
|
||||
## Status:
|
||||
|
||||
Missing ~ 60 nodes from ~ 195.
|
||||
|
||||
## TODOS
|
||||
|
||||
- [ ] Go through the current MaterialMaker and add the code from all the new nodes.
|
||||
- [ ] Go through the current MaterialMaker and update any old code.
|
||||
- [ ] Add note to all files that has code from MaterialMaker.
|
||||
- [ ] Proper readme.md.
|
||||
- [ ] Per node seed like in the original.
|
||||
- [ ] Port all the nodes. Missing ~ 60 from ~ 195
|
||||
- [ ] Somehow get ctrl-s to always just save the edited material, instead of having to double click it (for the inspector to update), and then clicking the save icon and selecting save.
|
@ -1,65 +0,0 @@
|
||||
tool
|
||||
extends ConfirmationDialog
|
||||
|
||||
signal ok_pressed
|
||||
|
||||
export(NodePath) var line_edit_path : NodePath
|
||||
export(NodePath) var tree_path : NodePath
|
||||
|
||||
export(PoolStringArray) var type_folders : PoolStringArray
|
||||
|
||||
var _resource_type : String = "MMNode"
|
||||
|
||||
var _line_edit : LineEdit
|
||||
var _tree : Tree
|
||||
|
||||
func _ready():
|
||||
_line_edit = get_node(line_edit_path) as LineEdit
|
||||
_tree = get_node(tree_path) as Tree
|
||||
|
||||
connect("confirmed", self, "_on_OK_pressed")
|
||||
connect("about_to_show", self, "about_to_show")
|
||||
|
||||
func set_resource_type(resource_type : String) -> void:
|
||||
_resource_type = resource_type
|
||||
|
||||
func about_to_show():
|
||||
_tree.clear()
|
||||
|
||||
var root : TreeItem = _tree.create_item()
|
||||
|
||||
for s in type_folders:
|
||||
evaluate_folder(s, root)
|
||||
|
||||
func evaluate_folder(folder : String, root : TreeItem) -> void:
|
||||
var ti : TreeItem = _tree.create_item(root)
|
||||
ti.set_text(0, folder.substr(folder.find_last("/") + 1))
|
||||
|
||||
var dir = Directory.new()
|
||||
if dir.open(folder) == OK:
|
||||
dir.list_dir_begin()
|
||||
var file_name = dir.get_next()
|
||||
while file_name != "":
|
||||
if !dir.current_is_dir():
|
||||
print("Found file: " + file_name)
|
||||
var e : TreeItem = _tree.create_item(ti)
|
||||
|
||||
e.set_text(0, file_name.get_file())
|
||||
e.set_meta("file", folder + "/" + file_name)
|
||||
|
||||
file_name = dir.get_next()
|
||||
else:
|
||||
print("An error occurred when trying to access the path.")
|
||||
|
||||
func _on_OK_pressed():
|
||||
var selected : TreeItem = _tree.get_selected()
|
||||
|
||||
if selected:
|
||||
if !selected.has_meta("file"):
|
||||
hide()
|
||||
return
|
||||
|
||||
var file_name : String = selected.get_meta("file")
|
||||
emit_signal("ok_pressed", file_name)
|
||||
|
||||
hide()
|
@ -1,61 +0,0 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/editor/CreateNamePopup.gd" type="Script" id=1]
|
||||
|
||||
[node name="CreateNamePopup" type="ConfirmationDialog"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -245.5
|
||||
margin_top = -220.0
|
||||
margin_right = 245.5
|
||||
margin_bottom = 220.0
|
||||
window_title = "Create New Resource"
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
line_edit_path = NodePath("VBoxContainer/LineEdit")
|
||||
tree_path = NodePath("VBoxContainer/Tree")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
margin_left = 8.0
|
||||
margin_top = 8.0
|
||||
margin_right = 483.0
|
||||
margin_bottom = 404.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label2" type="Label" parent="VBoxContainer"]
|
||||
margin_right = 475.0
|
||||
margin_bottom = 14.0
|
||||
size_flags_horizontal = 3
|
||||
text = "Type"
|
||||
|
||||
[node name="Tree" type="Tree" parent="VBoxContainer"]
|
||||
margin_top = 18.0
|
||||
margin_right = 475.0
|
||||
margin_bottom = 350.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
hide_root = true
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer"]
|
||||
visible = false
|
||||
margin_top = 354.0
|
||||
margin_right = 475.0
|
||||
margin_bottom = 368.0
|
||||
size_flags_horizontal = 3
|
||||
text = "Name"
|
||||
|
||||
[node name="LineEdit" type="LineEdit" parent="VBoxContainer"]
|
||||
visible = false
|
||||
margin_top = 372.0
|
||||
margin_right = 475.0
|
||||
margin_bottom = 396.0
|
||||
size_flags_horizontal = 3
|
||||
caret_blink = true
|
@ -1,218 +0,0 @@
|
||||
tool
|
||||
extends MarginContainer
|
||||
|
||||
var MMGraphNode = preload("res://addons/mat_maker_gd/editor/mm_graph_node.gd")
|
||||
|
||||
export(NodePath) var graph_edit_path : NodePath = "VBoxContainer/GraphEdit"
|
||||
export(NodePath) var add_popup_path : NodePath = "Popups/AddPopup"
|
||||
|
||||
var _graph_edit : GraphEdit = null
|
||||
|
||||
var _material : MMMaterial
|
||||
var _ignore_material_change_event : int = 0
|
||||
var _recreation_in_progress : bool = false
|
||||
|
||||
var _plugin : EditorPlugin = null
|
||||
var _undo_redo : UndoRedo = null
|
||||
|
||||
func _enter_tree():
|
||||
ensure_objs()
|
||||
|
||||
func set_plugin(plugin : EditorPlugin) -> void:
|
||||
_plugin = plugin
|
||||
_undo_redo = plugin.get_undo_redo()
|
||||
|
||||
func get_undo_redo() -> UndoRedo:
|
||||
return _undo_redo
|
||||
|
||||
func ensure_objs() -> void:
|
||||
if !_graph_edit:
|
||||
_graph_edit = get_node(graph_edit_path)
|
||||
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_IMAGE, MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_INT, MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_FLOAT, MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_VECTOR2, MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_VECTOR3, MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_COLOR, MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL)
|
||||
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SLOT_TYPE_IMAGE)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SLOT_TYPE_INT)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SLOT_TYPE_FLOAT)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SLOT_TYPE_VECTOR2)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SLOT_TYPE_VECTOR3)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SLOT_TYPE_COLOR)
|
||||
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL)
|
||||
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_IMAGE, MMNodeUniversalProperty.SLOT_TYPE_IMAGE)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_INT, MMNodeUniversalProperty.SLOT_TYPE_INT)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_FLOAT, MMNodeUniversalProperty.SLOT_TYPE_FLOAT)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_VECTOR2, MMNodeUniversalProperty.SLOT_TYPE_VECTOR2)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_VECTOR3, MMNodeUniversalProperty.SLOT_TYPE_VECTOR3)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SLOT_TYPE_COLOR, MMNodeUniversalProperty.SLOT_TYPE_COLOR)
|
||||
|
||||
_graph_edit.connect("connection_request", self, "on_graph_edit_connection_request")
|
||||
_graph_edit.connect("disconnection_request", self, "on_graph_edit_disconnection_request")
|
||||
|
||||
func recreate() -> void:
|
||||
ignore_changes(true)
|
||||
|
||||
if _recreation_in_progress:
|
||||
return
|
||||
|
||||
_recreation_in_progress = true
|
||||
|
||||
ensure_objs()
|
||||
|
||||
_graph_edit.clear_connections()
|
||||
|
||||
for c in _graph_edit.get_children():
|
||||
if c is GraphNode:
|
||||
_graph_edit.remove_child(c)
|
||||
c.queue_free()
|
||||
|
||||
if !_material:
|
||||
return
|
||||
|
||||
_material.cancel_render_and_wait()
|
||||
|
||||
for n in _material.nodes:
|
||||
var gn : GraphNode = MMGraphNode.new()
|
||||
gn.set_editor(self)
|
||||
gn.set_node(_material, n)
|
||||
_graph_edit.add_child(gn)
|
||||
|
||||
#connect them
|
||||
for n in _material.nodes:
|
||||
if n:
|
||||
for ip in n.input_properties:
|
||||
if ip.input_property:
|
||||
var input_node : Node = find_graph_node_for(n)
|
||||
var output_node : Node = find_graph_node_for(ip.input_property.owner)
|
||||
|
||||
var to_slot : int = input_node.get_input_property_graph_node_slot_index(ip)
|
||||
var from_slot : int = output_node.get_output_property_graph_node_slot_index(ip.input_property)
|
||||
|
||||
_graph_edit.connect_node(output_node.name, from_slot, input_node.name, to_slot)
|
||||
|
||||
_material.render()
|
||||
|
||||
_recreation_in_progress = false
|
||||
|
||||
ignore_changes(false)
|
||||
|
||||
func find_graph_node_for(nnode) -> Node:
|
||||
for c in _graph_edit.get_children():
|
||||
if c is GraphNode:
|
||||
if c.has_method("get_material_node"):
|
||||
var n = c.get_material_node()
|
||||
|
||||
if n == nnode:
|
||||
return c
|
||||
|
||||
return null
|
||||
|
||||
func set_mmmaterial(object : MMMaterial):
|
||||
if _material:
|
||||
_material.disconnect("changed", self, "on_material_changed")
|
||||
|
||||
_material = object
|
||||
|
||||
recreate()
|
||||
|
||||
if _material:
|
||||
_material.connect("changed", self, "on_material_changed")
|
||||
|
||||
func on_material_changed() -> void:
|
||||
if _ignore_material_change_event > 0:
|
||||
return
|
||||
|
||||
if _recreation_in_progress:
|
||||
return
|
||||
|
||||
call_deferred("recreate")
|
||||
|
||||
func ignore_changes(val : bool) -> void:
|
||||
if val:
|
||||
_ignore_material_change_event += 1
|
||||
else:
|
||||
_ignore_material_change_event -= 1
|
||||
|
||||
func on_graph_edit_connection_request(from: String, from_slot: int, to: String, to_slot: int):
|
||||
var from_node : GraphNode = _graph_edit.get_node(from)
|
||||
var to_node : GraphNode = _graph_edit.get_node(to)
|
||||
|
||||
ignore_changes(true)
|
||||
|
||||
_material.cancel_render_and_wait()
|
||||
|
||||
if from_node.connect_slot(from_slot, to_node, to_slot):
|
||||
_graph_edit.connect_node(from, from_slot, to, to_slot)
|
||||
|
||||
ignore_changes(false)
|
||||
|
||||
func on_graph_edit_disconnection_request(from: String, from_slot: int, to: String, to_slot: int):
|
||||
var from_node : GraphNode = _graph_edit.get_node(from)
|
||||
var to_node : GraphNode = _graph_edit.get_node(to)
|
||||
|
||||
ignore_changes(true)
|
||||
|
||||
_material.cancel_render_and_wait()
|
||||
|
||||
if from_node.disconnect_slot(from_slot, to_node, to_slot):
|
||||
_graph_edit.disconnect_node(from, from_slot, to, to_slot)
|
||||
|
||||
ignore_changes(false)
|
||||
|
||||
func on_graph_node_close_request(node : GraphNode) -> void:
|
||||
if _material:
|
||||
ignore_changes(true)
|
||||
|
||||
_material.cancel_render_and_wait()
|
||||
|
||||
#_material.remove_node(node._node)
|
||||
|
||||
_undo_redo.create_action("MMGD: Remove Node")
|
||||
_undo_redo.add_do_method(_material, "remove_node", node._node)
|
||||
_undo_redo.add_undo_method(_material, "add_node", node._node)
|
||||
_undo_redo.commit_action()
|
||||
|
||||
recreate()
|
||||
|
||||
ignore_changes(false)
|
||||
|
||||
func _on_AddButton_pressed():
|
||||
get_node(add_popup_path).popup_centered()
|
||||
|
||||
func _on_AddPopup_ok_pressed(script_path : String):
|
||||
if !_material:
|
||||
return
|
||||
|
||||
ensure_objs()
|
||||
|
||||
_material.cancel_render_and_wait()
|
||||
|
||||
var sc = load(script_path)
|
||||
var nnode : MMNode = sc.new()
|
||||
|
||||
if !nnode:
|
||||
print("_on_AddPopup_ok_pressed: Error !nnode! script: " + script_path)
|
||||
return
|
||||
|
||||
ignore_changes(true)
|
||||
|
||||
#_material.add_node(nnode)
|
||||
|
||||
_undo_redo.create_action("MMGD: Add Node")
|
||||
_undo_redo.add_do_method(_material, "add_node", nnode)
|
||||
_undo_redo.add_undo_method(_material, "remove_node", nnode)
|
||||
_undo_redo.commit_action()
|
||||
|
||||
var gn : GraphNode = MMGraphNode.new()
|
||||
gn.set_editor(self)
|
||||
gn.set_node(_material, nnode)
|
||||
_graph_edit.add_child(gn)
|
||||
|
||||
ignore_changes(false)
|
||||
|
@ -1,51 +0,0 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/editor/MatMakerGDEditor.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/editor/CreateNamePopup.tscn" type="PackedScene" id=2]
|
||||
|
||||
[node name="MatMakerGDEditor" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_min_size = Vector2( 0, 200 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 34.0
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer/PanelContainer"]
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 1017.0
|
||||
margin_bottom = 27.0
|
||||
|
||||
[node name="AddButton" type="Button" parent="VBoxContainer/PanelContainer/HBoxContainer"]
|
||||
margin_right = 37.0
|
||||
margin_bottom = 20.0
|
||||
text = "Add"
|
||||
|
||||
[node name="GraphEdit" type="GraphEdit" parent="VBoxContainer"]
|
||||
margin_top = 38.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
right_disconnects = true
|
||||
scroll_offset = Vector2( 0, -20 )
|
||||
|
||||
[node name="Popups" type="Control" parent="."]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="AddPopup" parent="Popups" instance=ExtResource( 2 )]
|
||||
type_folders = PoolStringArray( "res://addons/mat_maker_gd/nodes/uniform", "res://addons/mat_maker_gd/nodes/noise", "res://addons/mat_maker_gd/nodes/filter", "res://addons/mat_maker_gd/nodes/gradient", "res://addons/mat_maker_gd/nodes/pattern", "res://addons/mat_maker_gd/nodes/sdf2d", "res://addons/mat_maker_gd/nodes/sdf3d", "res://addons/mat_maker_gd/nodes/transform", "res://addons/mat_maker_gd/nodes/simple", "res://addons/mat_maker_gd/nodes/other" )
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/PanelContainer/HBoxContainer/AddButton" to="." method="_on_AddButton_pressed"]
|
||||
[connection signal="ok_pressed" from="Popups/AddPopup" to="." method="_on_AddPopup_ok_pressed"]
|
@ -1,742 +0,0 @@
|
||||
tool
|
||||
extends GraphNode
|
||||
|
||||
var gradient_editor_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/gradient_editor/gradient_editor.tscn")
|
||||
var polygon_edit_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/polygon_edit/polygon_edit.tscn")
|
||||
var curve_edit_scene : PackedScene = preload("res://addons/mat_maker_gd/widgets/curve_edit/curve_edit.tscn")
|
||||
|
||||
var _material : MMMaterial = null
|
||||
var _node : MMNode = null
|
||||
var properties : Array = Array()
|
||||
|
||||
var _editor_node
|
||||
var _undo_redo : UndoRedo = null
|
||||
var _ignore_change_event : bool = false
|
||||
|
||||
func _init():
|
||||
show_close = true
|
||||
connect("dragged", self, "on_dragged")
|
||||
connect("close_request", self, "on_close_request")
|
||||
|
||||
func set_editor(editor_node) -> void:
|
||||
_editor_node = editor_node
|
||||
|
||||
_undo_redo = _editor_node.get_undo_redo()
|
||||
|
||||
func ignore_changes(val : bool) -> void:
|
||||
_ignore_change_event = val
|
||||
_editor_node.ignore_changes(val)
|
||||
|
||||
func add_slot_texture(getter : String, setter : String) -> int:
|
||||
var t : TextureRect = TextureRect.new()
|
||||
t.rect_min_size = Vector2(128, 128)
|
||||
t.expand = true
|
||||
t.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, getter, setter, t)
|
||||
|
||||
t.texture = _node.call(getter, _material, slot_idx)
|
||||
properties[slot_idx].append(t.texture)
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_texture_universal(property : MMNodeUniversalProperty) -> int:
|
||||
var t : TextureRect = TextureRect.new()
|
||||
t.rect_min_size = Vector2(128, 128)
|
||||
t.expand = true
|
||||
t.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
|
||||
|
||||
var slot_idx : int = add_slot(property.input_slot_type, property.output_slot_type, "", "", t)
|
||||
|
||||
var img : Image = property.get_active_image()
|
||||
|
||||
var tex : ImageTexture = ImageTexture.new()
|
||||
|
||||
if img:
|
||||
tex.create_from_image(img, 0)
|
||||
|
||||
t.texture = tex
|
||||
|
||||
properties[slot_idx].append(property)
|
||||
|
||||
property.connect("changed", self, "on_universal_texture_changed", [ slot_idx ])
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_image_path_universal(property : MMNodeUniversalProperty, getter : String, setter : String) -> int:
|
||||
var t : TextureButton = load("res://addons/mat_maker_gd/widgets/image_picker_button/image_picker_button.tscn").instance()
|
||||
|
||||
var slot_idx : int = add_slot(property.input_slot_type, property.output_slot_type, "", "", t)
|
||||
|
||||
properties[slot_idx].append(property)
|
||||
properties[slot_idx].append(getter)
|
||||
properties[slot_idx].append(setter)
|
||||
|
||||
property.connect("changed", self, "on_universal_texture_changed_image_picker", [ slot_idx ])
|
||||
|
||||
t.connect("on_file_selected", self, "on_universal_image_path_changed", [ slot_idx ])
|
||||
|
||||
t.call_deferred("do_set_image_path", _node.call(getter))
|
||||
|
||||
return slot_idx
|
||||
|
||||
|
||||
func add_slot_gradient() -> int:
|
||||
var ge : Control = gradient_editor_scene.instance()
|
||||
ge.graph_node = self
|
||||
ge.set_undo_redo(_undo_redo)
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, "", "", ge)
|
||||
|
||||
ge.set_value(_node)
|
||||
#ge.texture = _node.call(getter, _material, slot_idx)
|
||||
#properties[slot_idx].append(ge.texture)
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_polygon() -> int:
|
||||
var ge : Control = polygon_edit_scene.instance()
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, "", "", ge)
|
||||
|
||||
ge.set_value(_node)
|
||||
#ge.texture = _node.call(getter, _material, slot_idx)
|
||||
#properties[slot_idx].append(ge.texture)
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_curve() -> int:
|
||||
var ge : Control = curve_edit_scene.instance()
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, "", "", ge)
|
||||
|
||||
ge.set_value(_node)
|
||||
#ge.texture = _node.call(getter, _material, slot_idx)
|
||||
#properties[slot_idx].append(ge.texture)
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_color(getter : String, setter : String) -> int:
|
||||
var cp : ColorPickerButton = ColorPickerButton.new()
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, getter, setter, cp)
|
||||
|
||||
cp.color = _node.call(getter)
|
||||
|
||||
cp.connect("color_changed", _node, setter)
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_color_universal(property : MMNodeUniversalProperty) -> int:
|
||||
var cp : ColorPickerButton = ColorPickerButton.new()
|
||||
|
||||
var slot_idx : int = add_slot(property.input_slot_type, property.output_slot_type, "", "", cp)
|
||||
|
||||
cp.color = property.get_default_value()
|
||||
|
||||
properties[slot_idx].append(property)
|
||||
|
||||
cp.connect("color_changed", self, "on_universal_color_changed", [ slot_idx ])
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_label(getter : String, setter : String, slot_name : String) -> int:
|
||||
var l : Label = Label.new()
|
||||
|
||||
l.text = slot_name
|
||||
|
||||
return add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, getter, setter, l)
|
||||
|
||||
func add_slot_line_edit(getter : String, setter : String, slot_name : String, placeholder : String = "") -> int:
|
||||
var bc : VBoxContainer = VBoxContainer.new()
|
||||
|
||||
var l : Label = Label.new()
|
||||
l.text = slot_name
|
||||
bc.add_child(l)
|
||||
|
||||
var le : LineEdit = LineEdit.new()
|
||||
le.placeholder_text = placeholder
|
||||
bc.add_child(le)
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, getter, setter, bc)
|
||||
|
||||
le.text = _node.call(getter)
|
||||
|
||||
le.connect("text_entered", self, "on_slot_line_edit_text_entered", [ slot_idx ])
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_enum(getter : String, setter : String, slot_name : String, values : Array) -> int:
|
||||
var bc : VBoxContainer = VBoxContainer.new()
|
||||
|
||||
if slot_name:
|
||||
var l : Label = Label.new()
|
||||
l.text = slot_name
|
||||
bc.add_child(l)
|
||||
|
||||
var mb : OptionButton = OptionButton.new()
|
||||
|
||||
for v in values:
|
||||
mb.add_item(v)
|
||||
|
||||
bc.add_child(mb)
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, getter, setter, bc)
|
||||
|
||||
mb.selected = _node.call(getter)
|
||||
|
||||
mb.connect("item_selected", self, "on_slot_enum_item_selected", [ slot_idx ])
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_int(getter : String, setter : String, slot_name : String, prange : Vector2 = Vector2(-1000, 1000)) -> int:
|
||||
var bc : VBoxContainer = VBoxContainer.new()
|
||||
|
||||
var l : Label = Label.new()
|
||||
l.text = slot_name
|
||||
bc.add_child(l)
|
||||
|
||||
var sb : SpinBox = SpinBox.new()
|
||||
sb.rounded = true
|
||||
sb.min_value = prange.x
|
||||
sb.max_value = prange.y
|
||||
bc.add_child(sb)
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, getter, setter, bc)
|
||||
|
||||
sb.value = _node.call(getter)
|
||||
|
||||
sb.connect("value_changed", self, "on_int_spinbox_value_changed", [ slot_idx ])
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_bool(getter : String, setter : String, slot_name : String) -> int:
|
||||
var cb : CheckBox = CheckBox.new()
|
||||
cb.text = slot_name
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, getter, setter, cb)
|
||||
|
||||
cb.pressed = _node.call(getter)
|
||||
|
||||
cb.connect("toggled", _node, setter)
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_label_universal(property : MMNodeUniversalProperty) -> int:
|
||||
var l : Label = Label.new()
|
||||
l.text = property.slot_name
|
||||
|
||||
var slot_idx : int = add_slot(property.input_slot_type, property.output_slot_type, "", "", l)
|
||||
|
||||
properties[slot_idx].append(property)
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_int_universal(property : MMNodeUniversalProperty) -> int:
|
||||
var bc : VBoxContainer = VBoxContainer.new()
|
||||
|
||||
var l : Label = Label.new()
|
||||
l.text = property.slot_name
|
||||
bc.add_child(l)
|
||||
|
||||
var sb : SpinBox = SpinBox.new()
|
||||
sb.rounded = true
|
||||
sb.min_value = property.value_range.x
|
||||
sb.max_value = property.value_range.y
|
||||
bc.add_child(sb)
|
||||
|
||||
var slot_idx : int = add_slot(property.input_slot_type, property.output_slot_type, "", "", bc)
|
||||
|
||||
sb.value = property.get_default_value()
|
||||
|
||||
sb.connect("value_changed", self, "on_int_universal_spinbox_value_changed", [ slot_idx ])
|
||||
|
||||
properties[slot_idx].append(property)
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_float(getter : String, setter : String, slot_name : String, step : float = 0.1, prange : Vector2 = Vector2(-1000, 1000)) -> int:
|
||||
var bc : VBoxContainer = VBoxContainer.new()
|
||||
|
||||
var l : Label = Label.new()
|
||||
l.text = slot_name
|
||||
bc.add_child(l)
|
||||
|
||||
var sb : SpinBox = SpinBox.new()
|
||||
bc.add_child(sb)
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, getter, setter, bc)
|
||||
sb.rounded = false
|
||||
sb.step = step
|
||||
sb.min_value = prange.x
|
||||
sb.max_value = prange.y
|
||||
sb.value = _node.call(getter)
|
||||
|
||||
sb.connect("value_changed", self, "on_float_spinbox_value_changed", [ slot_idx ])
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_float_universal(property : MMNodeUniversalProperty) -> int:
|
||||
var bc : VBoxContainer = VBoxContainer.new()
|
||||
|
||||
var l : Label = Label.new()
|
||||
l.text = property.slot_name
|
||||
bc.add_child(l)
|
||||
|
||||
var sb : SpinBox = SpinBox.new()
|
||||
bc.add_child(sb)
|
||||
|
||||
var slot_idx : int = add_slot(property.input_slot_type, property.output_slot_type, "", "", bc)
|
||||
sb.rounded = false
|
||||
sb.step = property.value_step
|
||||
sb.min_value = property.value_range.x
|
||||
sb.max_value = property.value_range.y
|
||||
sb.value = property.get_default_value()
|
||||
|
||||
properties[slot_idx].append(property)
|
||||
|
||||
sb.connect("value_changed", self, "on_float_universal_spinbox_value_changed", [ slot_idx ])
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_vector2(getter : String, setter : String, slot_name : String, step : float = 0.1, prange : Vector2 = Vector2(-1000, 1000)) -> int:
|
||||
var bc : VBoxContainer = VBoxContainer.new()
|
||||
|
||||
var l : Label = Label.new()
|
||||
l.text = slot_name
|
||||
bc.add_child(l)
|
||||
|
||||
var sbx : SpinBox = SpinBox.new()
|
||||
bc.add_child(sbx)
|
||||
|
||||
var sby : SpinBox = SpinBox.new()
|
||||
bc.add_child(sby)
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, getter, setter, bc)
|
||||
sbx.rounded = false
|
||||
sby.rounded = false
|
||||
sbx.step = step
|
||||
sby.step = step
|
||||
sbx.min_value = prange.x
|
||||
sbx.max_value = prange.y
|
||||
sby.min_value = prange.x
|
||||
sby.max_value = prange.y
|
||||
|
||||
var val : Vector2 = _node.call(getter)
|
||||
|
||||
sbx.value = val.x
|
||||
sby.value = val.y
|
||||
|
||||
sbx.connect("value_changed", self, "on_vector2_spinbox_value_changed", [ slot_idx, sbx, sby ])
|
||||
sby.connect("value_changed", self, "on_vector2_spinbox_value_changed", [ slot_idx, sbx, sby ])
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_vector3(getter : String, setter : String, slot_name : String, step : float = 0.1, prange : Vector2 = Vector2(-1000, 1000)) -> int:
|
||||
var bc : VBoxContainer = VBoxContainer.new()
|
||||
|
||||
var l : Label = Label.new()
|
||||
l.text = slot_name
|
||||
bc.add_child(l)
|
||||
|
||||
var sbx : SpinBox = SpinBox.new()
|
||||
bc.add_child(sbx)
|
||||
|
||||
var sby : SpinBox = SpinBox.new()
|
||||
bc.add_child(sby)
|
||||
|
||||
var sbz : SpinBox = SpinBox.new()
|
||||
bc.add_child(sbz)
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SLOT_TYPE_NONE, MMNodeUniversalProperty.SLOT_TYPE_NONE, getter, setter, bc)
|
||||
sbx.rounded = false
|
||||
sby.rounded = false
|
||||
sbz.rounded = false
|
||||
sbx.step = step
|
||||
sby.step = step
|
||||
sbz.step = step
|
||||
sbx.min_value = prange.x
|
||||
sbx.max_value = prange.y
|
||||
sby.min_value = prange.x
|
||||
sby.max_value = prange.y
|
||||
sbz.min_value = prange.x
|
||||
sbz.max_value = prange.y
|
||||
|
||||
var val : Vector3 = _node.call(getter)
|
||||
|
||||
sbx.value = val.x
|
||||
sby.value = val.y
|
||||
sbz.value = val.z
|
||||
|
||||
sbx.connect("value_changed", self, "on_vector3_spinbox_value_changed", [ slot_idx, sbx, sby, sbz ])
|
||||
sby.connect("value_changed", self, "on_vector3_spinbox_value_changed", [ slot_idx, sbx, sby, sbz ])
|
||||
sbz.connect("value_changed", self, "on_vector3_spinbox_value_changed", [ slot_idx, sbx, sby, sbz ])
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot_vector2_universal(property : MMNodeUniversalProperty) -> int:
|
||||
var bc : VBoxContainer = VBoxContainer.new()
|
||||
|
||||
var l : Label = Label.new()
|
||||
l.text = property.slot_name
|
||||
bc.add_child(l)
|
||||
|
||||
var sbx : SpinBox = SpinBox.new()
|
||||
bc.add_child(sbx)
|
||||
|
||||
var sby : SpinBox = SpinBox.new()
|
||||
bc.add_child(sby)
|
||||
|
||||
var slot_idx : int = add_slot(property.input_slot_type, property.output_slot_type, "", "", bc)
|
||||
sbx.rounded = false
|
||||
sby.rounded = false
|
||||
sbx.step = property.value_step
|
||||
sby.step = property.value_step
|
||||
sbx.min_value = property.value_range.x
|
||||
sbx.max_value = property.value_range.y
|
||||
sby.min_value = property.value_range.x
|
||||
sby.max_value = property.value_range.y
|
||||
|
||||
var val : Vector2 = property.get_default_value()
|
||||
|
||||
sbx.value = val.x
|
||||
sby.value = val.y
|
||||
|
||||
properties[slot_idx].append(property)
|
||||
|
||||
sbx.connect("value_changed", self, "on_vector2_universal_spinbox_value_changed", [ slot_idx, sbx, sby ])
|
||||
sby.connect("value_changed", self, "on_vector2_universal_spinbox_value_changed", [ slot_idx, sbx, sby ])
|
||||
|
||||
return slot_idx
|
||||
|
||||
func add_slot(input_type : int, output_type : int, getter : String, setter : String, control : Control) -> int:
|
||||
add_child(control)
|
||||
var slot_idx : int = get_child_count() - 1
|
||||
|
||||
var arr : Array = Array()
|
||||
|
||||
arr.append(slot_idx)
|
||||
arr.append(input_type)
|
||||
arr.append(output_type)
|
||||
arr.append(getter)
|
||||
arr.append(setter)
|
||||
arr.append(control)
|
||||
|
||||
properties.append(arr)
|
||||
|
||||
set_slot_enabled_left(slot_idx, input_type != -1)
|
||||
set_slot_enabled_right(slot_idx, output_type != -1)
|
||||
|
||||
if input_type != -1:
|
||||
set_slot_type_left(slot_idx, input_type)
|
||||
set_slot_color_left(slot_idx, get_slot_color(input_type))
|
||||
|
||||
if output_type != -1:
|
||||
set_slot_type_left(slot_idx, output_type)
|
||||
set_slot_color_right(slot_idx, get_slot_color(output_type))
|
||||
|
||||
return slot_idx
|
||||
|
||||
func connect_slot(slot_idx : int, to_node : Node, to_slot_idx : int) -> bool:
|
||||
var from_property_index : int = -1
|
||||
var to_property_index : int = -1
|
||||
|
||||
for i in range(properties.size()):
|
||||
if properties[i][2] != -1:
|
||||
from_property_index += 1
|
||||
|
||||
if from_property_index == slot_idx:
|
||||
from_property_index = i
|
||||
break
|
||||
|
||||
for i in range(to_node.properties.size()):
|
||||
if to_node.properties[i][1] != -1:
|
||||
to_property_index += 1
|
||||
|
||||
if to_property_index == to_slot_idx:
|
||||
to_property_index = i
|
||||
break
|
||||
|
||||
#to_node.properties[to_property_index][6].set_input_property(properties[from_property_index][6])
|
||||
|
||||
_undo_redo.create_action("MMGD: connect_slot")
|
||||
_undo_redo.add_do_method(to_node.properties[to_property_index][6], "set_input_property", properties[from_property_index][6])
|
||||
_undo_redo.add_undo_method(to_node.properties[to_property_index][6], "set_input_property", to_node.properties[to_property_index][6].input_property)
|
||||
_undo_redo.commit_action()
|
||||
|
||||
return true
|
||||
|
||||
func disconnect_slot(slot_idx : int, to_node : Node, to_slot_idx : int) -> bool:
|
||||
var from_property_index : int = -1
|
||||
var to_property_index : int = -1
|
||||
|
||||
for i in range(properties.size()):
|
||||
if properties[i][2] != -1:
|
||||
from_property_index += 1
|
||||
|
||||
if from_property_index == slot_idx:
|
||||
from_property_index = i
|
||||
break
|
||||
|
||||
for i in range(to_node.properties.size()):
|
||||
if to_node.properties[i][1] != -1:
|
||||
to_property_index += 1
|
||||
|
||||
if to_property_index == to_slot_idx:
|
||||
to_property_index = i
|
||||
break
|
||||
|
||||
#to_node.properties[to_property_index][6].set_input_property(null)
|
||||
|
||||
_undo_redo.create_action("MMGD: disconnect_slot")
|
||||
_undo_redo.add_do_method(to_node.properties[to_property_index][6], "unset_input_property")
|
||||
_undo_redo.add_undo_method(to_node.properties[to_property_index][6], "set_input_property", to_node.properties[to_property_index][6].input_property)
|
||||
_undo_redo.commit_action()
|
||||
|
||||
return true
|
||||
|
||||
func get_input_property_graph_node_slot_index(property) -> int:
|
||||
var property_index : int = -1
|
||||
|
||||
for i in range(properties.size()):
|
||||
if properties[i][1] != -1:
|
||||
property_index += 1
|
||||
|
||||
if properties[i][6] == property:
|
||||
break
|
||||
|
||||
return property_index
|
||||
|
||||
func get_output_property_graph_node_slot_index(property) -> int:
|
||||
var property_index : int = -1
|
||||
|
||||
for i in range(properties.size()):
|
||||
if properties[i][2] != -1:
|
||||
property_index += 1
|
||||
|
||||
if properties[i][6] == property:
|
||||
break
|
||||
|
||||
return property_index
|
||||
|
||||
func get_property_control(slot_idx : int) -> Node:
|
||||
return properties[slot_idx][5]
|
||||
|
||||
func set_node(material : MMMaterial, node : MMNode) -> void:
|
||||
_node = node
|
||||
_material = material
|
||||
|
||||
if !_node:
|
||||
return
|
||||
|
||||
title = _node.get_class()
|
||||
|
||||
if _node.get_script():
|
||||
title = _node.get_script().resource_path.get_file().get_basename()
|
||||
|
||||
_node.register_methods(self)
|
||||
|
||||
offset = _node.get_graph_position()
|
||||
|
||||
#_node.connect("changed", self, "on_node_changed")
|
||||
|
||||
func propagate_node_change() -> void:
|
||||
pass
|
||||
|
||||
func on_dragged(from : Vector2, to : Vector2):
|
||||
if _node:
|
||||
ignore_changes(true)
|
||||
#_node.set_graph_position(offset)
|
||||
|
||||
_undo_redo.create_action("MMGD: value changed")
|
||||
_undo_redo.add_do_method(_node, "set_graph_position", to)
|
||||
_undo_redo.add_undo_method(_node, "set_graph_position", from)
|
||||
_undo_redo.commit_action()
|
||||
|
||||
ignore_changes(false)
|
||||
|
||||
#func on_node_changed():
|
||||
# if _ignore_change_event:
|
||||
# return
|
||||
#
|
||||
# _ignore_change_event = true
|
||||
# propagate_node_change()
|
||||
# _ignore_change_event = false
|
||||
|
||||
func on_int_spinbox_value_changed(val : float, slot_idx) -> void:
|
||||
#_node.call(properties[slot_idx][4], int(val))
|
||||
|
||||
ignore_changes(true)
|
||||
_undo_redo.create_action("MMGD: value changed")
|
||||
_undo_redo.add_do_method(_node, properties[slot_idx][4], int(val))
|
||||
_undo_redo.add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]))
|
||||
_undo_redo.commit_action()
|
||||
ignore_changes(false)
|
||||
|
||||
func on_float_spinbox_value_changed(val : float, slot_idx) -> void:
|
||||
#_node.call(properties[slot_idx][4], val)
|
||||
|
||||
ignore_changes(true)
|
||||
_undo_redo.create_action("MMGD: value changed")
|
||||
_undo_redo.add_do_method(_node, properties[slot_idx][4], val)
|
||||
_undo_redo.add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]))
|
||||
_undo_redo.commit_action()
|
||||
ignore_changes(false)
|
||||
|
||||
func on_vector2_spinbox_value_changed(val : float, slot_idx, spinbox_x, spinbox_y) -> void:
|
||||
var vv : Vector2 = Vector2(spinbox_x.value, spinbox_y.value)
|
||||
|
||||
#_node.call(properties[slot_idx][4], vv)
|
||||
|
||||
ignore_changes(true)
|
||||
_undo_redo.create_action("MMGD: value changed")
|
||||
_undo_redo.add_do_method(_node, properties[slot_idx][4], vv)
|
||||
_undo_redo.add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]))
|
||||
_undo_redo.commit_action()
|
||||
ignore_changes(false)
|
||||
|
||||
func on_vector3_spinbox_value_changed(val : float, slot_idx, spinbox_x, spinbox_y, spinbox_z) -> void:
|
||||
var vv : Vector3 = Vector3(spinbox_x.value, spinbox_y.value, spinbox_z.value)
|
||||
|
||||
#_node.call(properties[slot_idx][4], vv)
|
||||
|
||||
ignore_changes(true)
|
||||
_undo_redo.create_action("MMGD: value changed")
|
||||
_undo_redo.add_do_method(_node, properties[slot_idx][4], vv)
|
||||
_undo_redo.add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]))
|
||||
_undo_redo.commit_action()
|
||||
ignore_changes(false)
|
||||
|
||||
func on_int_universal_spinbox_value_changed(val : float, slot_idx) -> void:
|
||||
#properties[slot_idx][6].set_default_value(int(val))
|
||||
|
||||
ignore_changes(true)
|
||||
_undo_redo.create_action("MMGD: value changed")
|
||||
_undo_redo.add_do_method(properties[slot_idx][6], "set_default_value", int(val))
|
||||
_undo_redo.add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value())
|
||||
_undo_redo.commit_action()
|
||||
ignore_changes(false)
|
||||
|
||||
func on_float_universal_spinbox_value_changed(val : float, slot_idx) -> void:
|
||||
#properties[slot_idx][6].set_default_value(val)
|
||||
|
||||
ignore_changes(true)
|
||||
_undo_redo.create_action("MMGD: value changed")
|
||||
_undo_redo.add_do_method(properties[slot_idx][6], "set_default_value", val)
|
||||
_undo_redo.add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value())
|
||||
_undo_redo.commit_action()
|
||||
ignore_changes(false)
|
||||
|
||||
func on_vector2_universal_spinbox_value_changed(val : float, slot_idx, spinbox_x, spinbox_y) -> void:
|
||||
var vv : Vector2 = Vector2(spinbox_x.value, spinbox_y.value)
|
||||
|
||||
#properties[slot_idx][6].set_default_value(vv)
|
||||
|
||||
ignore_changes(true)
|
||||
_undo_redo.create_action("MMGD: value changed")
|
||||
_undo_redo.add_do_method(properties[slot_idx][6], "set_default_value", vv)
|
||||
_undo_redo.add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value())
|
||||
_undo_redo.commit_action()
|
||||
ignore_changes(false)
|
||||
|
||||
func on_slot_enum_item_selected(val : int, slot_idx : int) -> void:
|
||||
#_node.call(properties[slot_idx][4], val)
|
||||
|
||||
ignore_changes(true)
|
||||
_undo_redo.create_action("MMGD: value changed")
|
||||
_undo_redo.add_do_method(_node, properties[slot_idx][4], val)
|
||||
_undo_redo.add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]))
|
||||
_undo_redo.commit_action()
|
||||
ignore_changes(false)
|
||||
|
||||
func on_universal_texture_changed(slot_idx : int) -> void:
|
||||
ignore_changes(true)
|
||||
|
||||
var img : Image = properties[slot_idx][6].get_active_image()
|
||||
|
||||
var tex : ImageTexture = properties[slot_idx][5].texture
|
||||
|
||||
if img:
|
||||
properties[slot_idx][5].texture.create_from_image(img, 0)
|
||||
else:
|
||||
properties[slot_idx][5].texture = ImageTexture.new()
|
||||
|
||||
ignore_changes(false)
|
||||
|
||||
func on_universal_texture_changed_image_picker(slot_idx : int) -> void:
|
||||
ignore_changes(true)
|
||||
|
||||
var img : Image = properties[slot_idx][6].get_active_image()
|
||||
|
||||
var tex : ImageTexture = properties[slot_idx][5].texture_normal
|
||||
|
||||
if img:
|
||||
properties[slot_idx][5].texture_normal.create_from_image(img, 0)
|
||||
else:
|
||||
properties[slot_idx][5].texture_normal = ImageTexture.new()
|
||||
|
||||
ignore_changes(false)
|
||||
|
||||
func on_slot_line_edit_text_entered(text : String, slot_idx : int) -> void:
|
||||
#_node.call(properties[slot_idx][4], text)
|
||||
|
||||
ignore_changes(true)
|
||||
_undo_redo.create_action("MMGD: value changed")
|
||||
_undo_redo.add_do_method(_node, properties[slot_idx][4], text)
|
||||
_undo_redo.add_undo_method(_node, properties[slot_idx][4], _node.call(properties[slot_idx][3]))
|
||||
_undo_redo.commit_action()
|
||||
ignore_changes(false)
|
||||
|
||||
func on_universal_color_changed(c : Color, slot_idx : int) -> void:
|
||||
#properties[slot_idx][6].set_default_value(c)
|
||||
|
||||
ignore_changes(true)
|
||||
_undo_redo.create_action("MMGD: value changed")
|
||||
_undo_redo.add_do_method(properties[slot_idx][6], "set_default_value", c)
|
||||
_undo_redo.add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value())
|
||||
_undo_redo.commit_action()
|
||||
ignore_changes(false)
|
||||
|
||||
func on_universal_image_path_changed(f : String, slot_idx : int) -> void:
|
||||
_node.call(properties[slot_idx][8], f)
|
||||
|
||||
ignore_changes(true)
|
||||
_undo_redo.create_action("MMGD: value changed")
|
||||
_undo_redo.add_do_method(properties[slot_idx][6], "set_default_value", f)
|
||||
_undo_redo.add_undo_method(properties[slot_idx][6], "set_default_value", properties[slot_idx][6].get_default_value())
|
||||
_undo_redo.commit_action()
|
||||
ignore_changes(false)
|
||||
|
||||
func get_material_node() -> MMNode:
|
||||
return _node
|
||||
|
||||
func on_close_request() -> void:
|
||||
var n : Node = get_parent()
|
||||
|
||||
while n:
|
||||
if n.has_method("on_graph_node_close_request"):
|
||||
n.call_deferred("on_graph_node_close_request", self)
|
||||
return
|
||||
|
||||
n = n.get_parent()
|
||||
|
||||
func get_slot_color(slot_type : int) -> Color:
|
||||
return _get_slot_color(slot_type)
|
||||
|
||||
func _get_slot_color(slot_type : int) -> Color:
|
||||
if slot_type == 0:
|
||||
return Color(0.91, 0.06, 0.06)
|
||||
elif slot_type == 1:
|
||||
return Color(0.43, 0.04, 0.04)
|
||||
elif slot_type == 2:
|
||||
return Color(0.83, 0.38, 0.38)
|
||||
elif slot_type == 3:
|
||||
return Color(0.04, 0.48, 0.43)
|
||||
elif slot_type == 4:
|
||||
return Color(0.35, 0.04, 0.34)
|
||||
elif slot_type == 5:
|
||||
return Color(0.04, 0.05, 1)
|
||||
elif slot_type == 6:
|
||||
return Color(0.37, 0.37, 0.37)
|
||||
|
||||
return Color(1, 1, 1, 1)
|
Binary file not shown.
Before Width: | Height: | Size: 549 B |
@ -1,35 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/custom.png-b026bd10e22818d25d499d2eddb137a8.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/mat_maker_gd/icons/custom.png"
|
||||
dest_files=[ "res://.import/custom.png-b026bd10e22818d25d499d2eddb137a8.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 32, 48, 16, 16 )
|
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 16, 16, 16, 16 )
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 12 KiB |
@ -1,35 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/godot_logo.svg-4e4bf625f601f4dc5d1d367a2f781011.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/mat_maker_gd/icons/godot_logo.svg"
|
||||
dest_files=[ "res://.import/godot_logo.svg-4e4bf625f601f4dc5d1d367a2f781011.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 189 KiB |
@ -1,35 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icons.svg-bac181e82e23c7264cdf6c36903654b9.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://addons/mat_maker_gd/icons/icons.svg"
|
||||
dest_files=[ "res://.import/icons.svg-bac181e82e23c7264cdf6c36903654b9.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
File diff suppressed because one or more lines are too long
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 16, 0, 16, 15 )
|
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 48, 96, 16, 16 )
|
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 0, 80, 16, 16 )
|
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 32, 64, 16, 16 )
|
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 32, 80, 16, 16 )
|
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 32, 96, 16, 16 )
|
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 32, 112, 16, 16 )
|
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 80, 32, 16, 16 )
|
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 64, 32, 16, 16 )
|
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 32, 0, 16, 16 )
|
@ -1,8 +0,0 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 16, 48, 16, 16 )
|
@ -1,509 +0,0 @@
|
||||
[gd_resource type="MMMaterial" load_steps=91 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/colorize.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/noise/voronoi.gd" type="Script" id=3]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/invert.gd" type="Script" id=4]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/combine.gd" type="Script" id=6]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/transform/scale.gd" type="Script" id=7]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/transform/repeat.gd" type="Script" id=8]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/transform/shear.gd" type="Script" id=9]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/transform/mirror.gd" type="Script" id=10]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/transform/transform.gd" type="Script" id=11]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/transform/circle_map.gd" type="Script" id=12]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/transform/rotate.gd" type="Script" id=13]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/tonality.gd" type="Script" id=14]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/fill_to_position.gd" type="Script" id=15]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/simple/shape.gd" type="Script" id=16]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/fill_to_uv.gd" type="Script" id=17]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/fill_to_random_grey.gd" type="Script" id=18]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/math.gd" type="Script" id=19]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/transform/color_tiler.gd" type="Script" id=20]
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=5]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=6]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=7]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=2]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNode" id=8]
|
||||
graph_position = Vector2( -160, 40 )
|
||||
output_properties = [ null, null, null, null, SubResource( 7 ), SubResource( 5 ), SubResource( 2 ), SubResource( 6 ) ]
|
||||
script = ExtResource( 3 )
|
||||
out_nodes = SubResource( 7 )
|
||||
out_borders = SubResource( 5 )
|
||||
out_random_color = SubResource( 2 )
|
||||
out_fill = SubResource( 6 )
|
||||
scale = Vector2( 13.6, 18.9 )
|
||||
stretch = Vector2( 2.13, 2.13 )
|
||||
intensity = 1.07
|
||||
randomness = 0.89
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=9]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=10]
|
||||
default_type = 4
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input1 "
|
||||
|
||||
[sub_resource type="MMNode" id=11]
|
||||
graph_position = Vector2( 380, 80 )
|
||||
input_properties = [ null, SubResource( 10 ) ]
|
||||
output_properties = [ null, SubResource( 9 ) ]
|
||||
script = ExtResource( 4 )
|
||||
image = SubResource( 9 )
|
||||
input = SubResource( 10 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=12]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=13]
|
||||
default_type = 1
|
||||
default_float = 1.0
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> A "
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=14]
|
||||
default_type = 1
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> B "
|
||||
input_property = SubResource( 7 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=15]
|
||||
default_type = 1
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> G "
|
||||
input_property = SubResource( 2 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=16]
|
||||
default_type = 1
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> R "
|
||||
input_property = SubResource( 5 )
|
||||
|
||||
[sub_resource type="MMNode" id=17]
|
||||
graph_position = Vector2( 380, 380 )
|
||||
input_properties = [ null, null, null, null, SubResource( 16 ), SubResource( 15 ), SubResource( 14 ), SubResource( 13 ) ]
|
||||
output_properties = [ null, SubResource( 12 ) ]
|
||||
script = ExtResource( 6 )
|
||||
image = SubResource( 12 )
|
||||
input_r = SubResource( 16 )
|
||||
input_g = SubResource( 15 )
|
||||
input_b = SubResource( 14 )
|
||||
input_a = SubResource( 13 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=18]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=19]
|
||||
default_type = 4
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input1 "
|
||||
input_property = SubResource( 12 )
|
||||
|
||||
[sub_resource type="MMNode" id=20]
|
||||
graph_position = Vector2( 1080, 180 )
|
||||
input_properties = [ null, SubResource( 19 ) ]
|
||||
output_properties = [ null, SubResource( 18 ) ]
|
||||
script = ExtResource( 7 )
|
||||
image = SubResource( 18 )
|
||||
input = SubResource( 19 )
|
||||
center = Vector2( 1, 1 )
|
||||
scale = Vector2( 1.3, 1.3 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=21]
|
||||
default_type = 4
|
||||
get_value_from_owner = true
|
||||
input_slot_type = 6
|
||||
output_slot_type = 6
|
||||
slot_name = ">>> Apply >>>"
|
||||
input_property = SubResource( 12 )
|
||||
|
||||
[sub_resource type="MMNode" id=22]
|
||||
graph_position = Vector2( 560, 300 )
|
||||
input_properties = [ null, SubResource( 21 ) ]
|
||||
output_properties = [ null, SubResource( 21 ) ]
|
||||
script = ExtResource( 8 )
|
||||
input = SubResource( 21 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=23]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=24]
|
||||
default_type = 4
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input "
|
||||
input_property = SubResource( 21 )
|
||||
|
||||
[sub_resource type="MMNode" id=25]
|
||||
graph_position = Vector2( 860, 200 )
|
||||
input_properties = [ null, SubResource( 24 ) ]
|
||||
output_properties = [ null, SubResource( 23 ) ]
|
||||
script = ExtResource( 9 )
|
||||
image = SubResource( 23 )
|
||||
input = SubResource( 24 )
|
||||
direction = 0
|
||||
amount = 1.06
|
||||
center = 0.0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=26]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=27]
|
||||
default_type = 4
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input "
|
||||
input_property = SubResource( 21 )
|
||||
|
||||
[sub_resource type="MMNode" id=28]
|
||||
graph_position = Vector2( 620, 460 )
|
||||
input_properties = [ null, SubResource( 27 ) ]
|
||||
output_properties = [ null, SubResource( 26 ) ]
|
||||
script = ExtResource( 10 )
|
||||
image = SubResource( 26 )
|
||||
input = SubResource( 27 )
|
||||
direction = 0
|
||||
offset = 0.32
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=32]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=33]
|
||||
default_type = 4
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input "
|
||||
input_property = SubResource( 21 )
|
||||
|
||||
[sub_resource type="MMNode" id=34]
|
||||
graph_position = Vector2( 820, 580 )
|
||||
input_properties = [ null, SubResource( 33 ) ]
|
||||
output_properties = [ null, SubResource( 32 ) ]
|
||||
script = ExtResource( 12 )
|
||||
image = SubResource( 32 )
|
||||
input = SubResource( 33 )
|
||||
radius = 1.0
|
||||
repeat = 4
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=35]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=36]
|
||||
default_type = 4
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input1 "
|
||||
|
||||
[sub_resource type="MMNode" id=37]
|
||||
graph_position = Vector2( 1040, 560 )
|
||||
input_properties = [ null, SubResource( 36 ) ]
|
||||
output_properties = [ null, SubResource( 35 ) ]
|
||||
script = ExtResource( 13 )
|
||||
image = SubResource( 35 )
|
||||
input = SubResource( 36 )
|
||||
center = Vector2( 0.13, 0 )
|
||||
rotate = 150.0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=38]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=39]
|
||||
default_type = 4
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input "
|
||||
input_property = SubResource( 21 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=43]
|
||||
default_type = 1
|
||||
default_float = 4.1
|
||||
input_slot_type = 6
|
||||
slot_name = "Translate X"
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=44]
|
||||
default_type = 1
|
||||
default_float = 2.2
|
||||
input_slot_type = 6
|
||||
slot_name = "Translate Y"
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=40]
|
||||
default_type = 1
|
||||
default_float = 14.5
|
||||
input_slot_type = 6
|
||||
slot_name = "Rotate"
|
||||
input_property = SubResource( 32 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=41]
|
||||
default_type = 1
|
||||
default_float = 1.6
|
||||
input_slot_type = 6
|
||||
slot_name = "Scale X"
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=42]
|
||||
default_type = 1
|
||||
default_float = 1.1
|
||||
input_slot_type = 6
|
||||
slot_name = "Scale Y"
|
||||
|
||||
[sub_resource type="MMNode" id=45]
|
||||
graph_position = Vector2( 1280, 560 )
|
||||
input_properties = [ null, null, null, null, null, null, SubResource( 39 ), SubResource( 43 ), SubResource( 44 ), SubResource( 40 ), SubResource( 41 ), SubResource( 42 ) ]
|
||||
output_properties = [ null, SubResource( 38 ) ]
|
||||
script = ExtResource( 11 )
|
||||
image = SubResource( 38 )
|
||||
input = SubResource( 39 )
|
||||
translate_x = SubResource( 43 )
|
||||
translate_y = SubResource( 44 )
|
||||
rotate = SubResource( 40 )
|
||||
scale_x = SubResource( 41 )
|
||||
scale_y = SubResource( 42 )
|
||||
mode = 1
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=46]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=47]
|
||||
default_type = 1
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input "
|
||||
input_property = SubResource( 23 )
|
||||
|
||||
[sub_resource type="MMNode" id=48]
|
||||
graph_position = Vector2( 620, 0 )
|
||||
input_properties = [ null, SubResource( 47 ) ]
|
||||
output_properties = [ null, SubResource( 46 ) ]
|
||||
script = ExtResource( 14 )
|
||||
points = [ 0.0, 0.0, 0.0, 1.0, 0.284455, 0.780757, 0.0, 0.0, 0.735577, 0.159306, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0 ]
|
||||
image = SubResource( 46 )
|
||||
input = SubResource( 47 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=49]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=50]
|
||||
default_type = 4
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input "
|
||||
|
||||
[sub_resource type="MMNode" id=51]
|
||||
graph_position = Vector2( 120, 440 )
|
||||
input_properties = [ null, SubResource( 50 ) ]
|
||||
output_properties = [ null, SubResource( 49 ) ]
|
||||
script = ExtResource( 15 )
|
||||
image = SubResource( 49 )
|
||||
input = SubResource( 50 )
|
||||
axis = 2
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=52]
|
||||
default_type = 1
|
||||
default_float = 0.1
|
||||
input_slot_type = 6
|
||||
slot_name = "edge"
|
||||
value_step = 0.05
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=53]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=54]
|
||||
default_type = 1
|
||||
default_float = 1.3
|
||||
input_slot_type = 6
|
||||
slot_name = "radius"
|
||||
value_step = 0.05
|
||||
input_property = SubResource( 2 )
|
||||
|
||||
[sub_resource type="MMNode" id=55]
|
||||
graph_position = Vector2( -440, 200 )
|
||||
input_properties = [ null, null, SubResource( 54 ), SubResource( 52 ) ]
|
||||
output_properties = [ null, SubResource( 53 ) ]
|
||||
script = ExtResource( 16 )
|
||||
image = SubResource( 53 )
|
||||
shape_type = 2
|
||||
sides = 7
|
||||
radius = SubResource( 54 )
|
||||
edge = SubResource( 52 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=56]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=59]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=57]
|
||||
default_type = 4
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input "
|
||||
input_property = SubResource( 59 )
|
||||
|
||||
[sub_resource type="MMNode" id=58]
|
||||
graph_position = Vector2( 580, 800 )
|
||||
input_properties = [ null, SubResource( 57 ) ]
|
||||
output_properties = [ null, SubResource( 56 ) ]
|
||||
script = ExtResource( 17 )
|
||||
image = SubResource( 56 )
|
||||
input = SubResource( 57 )
|
||||
mode = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=60]
|
||||
default_type = 4
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input "
|
||||
input_property = SubResource( 12 )
|
||||
|
||||
[sub_resource type="MMNode" id=61]
|
||||
graph_position = Vector2( 320, 700 )
|
||||
input_properties = [ null, SubResource( 60 ) ]
|
||||
output_properties = [ null, SubResource( 59 ) ]
|
||||
script = ExtResource( 18 )
|
||||
image = SubResource( 59 )
|
||||
input = SubResource( 60 )
|
||||
edge_color = 0.9
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=63]
|
||||
default_type = 1
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> A "
|
||||
value_step = 0.01
|
||||
value_range = Vector2( 0, 1 )
|
||||
input_property = SubResource( 5 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=64]
|
||||
default_type = 1
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> B "
|
||||
value_step = 0.01
|
||||
value_range = Vector2( 0, 1 )
|
||||
input_property = SubResource( 53 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=65]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=62]
|
||||
default_type = 1
|
||||
get_value_from_owner = true
|
||||
output_slot_type = 6
|
||||
slot_name = " Output >>>"
|
||||
|
||||
[sub_resource type="MMNode" id=66]
|
||||
graph_position = Vector2( -720, 280 )
|
||||
input_properties = [ null, null, SubResource( 63 ), SubResource( 64 ) ]
|
||||
output_properties = [ null, null, SubResource( 62 ), SubResource( 65 ) ]
|
||||
script = ExtResource( 19 )
|
||||
image = SubResource( 65 )
|
||||
a = SubResource( 63 )
|
||||
b = SubResource( 64 )
|
||||
output = SubResource( 62 )
|
||||
operation = 3
|
||||
clamp_result = true
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=67]
|
||||
default_type = 1
|
||||
default_float = 1.0
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Mask "
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=68]
|
||||
default_type = 4
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input "
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=69]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=70]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNode" id=71]
|
||||
graph_position = Vector2( -1060, 280 )
|
||||
input_properties = [ null, null, SubResource( 68 ), SubResource( 67 ) ]
|
||||
output_properties = [ null, null, SubResource( 70 ), SubResource( 69 ) ]
|
||||
script = ExtResource( 20 )
|
||||
input = SubResource( 68 )
|
||||
in_mask = SubResource( 67 )
|
||||
output = SubResource( 70 )
|
||||
instance_map = SubResource( 69 )
|
||||
tile = Vector2( 4, 4 )
|
||||
overlap = 1.0
|
||||
select_inputs = 0
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
fixed_offset = 0.0
|
||||
rnd_offset = 0.28
|
||||
rnd_rotate = 100.0
|
||||
rnd_scale = 0.2
|
||||
rnd_opacity = 0.0
|
||||
variations = false
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=74]
|
||||
default_type = 1
|
||||
default_float = 0.65
|
||||
input_slot_type = 6
|
||||
slot_name = "edge"
|
||||
value_step = 0.05
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=72]
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=75]
|
||||
default_type = 1
|
||||
default_float = 0.3
|
||||
input_slot_type = 6
|
||||
slot_name = "radius"
|
||||
value_step = 0.05
|
||||
|
||||
[sub_resource type="MMNode" id=73]
|
||||
graph_position = Vector2( -340, -420 )
|
||||
input_properties = [ null, null, SubResource( 75 ), SubResource( 74 ) ]
|
||||
output_properties = [ null, SubResource( 72 ) ]
|
||||
script = ExtResource( 16 )
|
||||
image = SubResource( 72 )
|
||||
shape_type = 1
|
||||
sides = 12
|
||||
radius = SubResource( 75 )
|
||||
edge = SubResource( 74 )
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=76]
|
||||
default_type = 5
|
||||
output_slot_type = 0
|
||||
|
||||
[sub_resource type="MMNodeUniversalProperty" id=77]
|
||||
default_type = 1
|
||||
default_float = 1.0
|
||||
input_slot_type = 6
|
||||
slot_name = ">>> Input1 "
|
||||
input_property = SubResource( 72 )
|
||||
|
||||
[sub_resource type="MMNode" id=78]
|
||||
graph_position = Vector2( -80, -520 )
|
||||
input_properties = [ null, SubResource( 77 ) ]
|
||||
output_properties = [ null, SubResource( 76 ) ]
|
||||
script = ExtResource( 1 )
|
||||
interpolation_type = 2
|
||||
points = PoolRealArray( 0, 0, 0, 0, 1, 0.458472, 0.921875, 0.860657, 0.860657, 1, 1, 1, 0, 0, 1 )
|
||||
image = SubResource( 76 )
|
||||
input = SubResource( 77 )
|
||||
|
||||
[resource]
|
||||
nodes = [ SubResource( 8 ), SubResource( 11 ), SubResource( 17 ), SubResource( 20 ), SubResource( 22 ), SubResource( 25 ), SubResource( 28 ), SubResource( 34 ), SubResource( 37 ), SubResource( 45 ), SubResource( 48 ), SubResource( 51 ), SubResource( 55 ), SubResource( 58 ), SubResource( 61 ), SubResource( 66 ), SubResource( 71 ), SubResource( 73 ), SubResource( 78 ) ]
|
@ -1,118 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
class Point:
|
||||
var p : Vector2
|
||||
var ls : float
|
||||
var rs : float
|
||||
func _init(x : float, y : float, nls : float, nrs : float) -> void:
|
||||
p = Vector2(x, y)
|
||||
ls = nls
|
||||
rs = nrs
|
||||
|
||||
export(PoolRealArray) var points
|
||||
|
||||
func init_points_01():
|
||||
if points.size() == 0:
|
||||
points = [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0 ]
|
||||
|
||||
func init_points_11():
|
||||
if points.size() == 0:
|
||||
points = [ 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0 ]
|
||||
|
||||
func to_string() -> String:
|
||||
var rv = PoolStringArray()
|
||||
for p in points:
|
||||
rv.append("("+str(p.x)+","+str(p.y)+","+str(p.ls)+","+str(p.rs)+")")
|
||||
|
||||
return rv.join(",")
|
||||
|
||||
func clear() -> void:
|
||||
points.clear()
|
||||
curve_changed()
|
||||
|
||||
func add_point(x : float, y : float, ls : float = INF, rs : float = INF) -> void:
|
||||
var indx : int = points.size() / 4
|
||||
|
||||
for i in indx:
|
||||
var ii : int = i * 4
|
||||
if x < points[ii]:
|
||||
if ls == INF:
|
||||
ls == 0
|
||||
if rs == INF:
|
||||
rs == 0
|
||||
|
||||
points.insert(ii, x)
|
||||
points.insert(ii + 1, y)
|
||||
points.insert(ii + 2, ls)
|
||||
points.insert(ii + 3, rs)
|
||||
|
||||
curve_changed()
|
||||
return
|
||||
|
||||
points.append(x)
|
||||
points.append(y)
|
||||
points.append(ls)
|
||||
points.append(rs)
|
||||
|
||||
curve_changed()
|
||||
|
||||
func remove_point(i : int) -> bool:
|
||||
var index : int = i * 4
|
||||
|
||||
if index <= 0 or index >= points.size() - 1:
|
||||
return false
|
||||
else:
|
||||
points.remove(index)
|
||||
points.remove(index)
|
||||
points.remove(index)
|
||||
points.remove(index)
|
||||
|
||||
curve_changed()
|
||||
return true
|
||||
|
||||
func get_point_count() -> int:
|
||||
return points.size() / 4
|
||||
|
||||
func set_point(i : int, v : Point) -> void:
|
||||
var indx : int = i * 4
|
||||
|
||||
points[indx + 0] = v.p.x
|
||||
points[indx + 1] = v.p.y
|
||||
points[indx + 2] = v.ls
|
||||
points[indx + 3] = v.rs
|
||||
|
||||
curve_changed()
|
||||
|
||||
func get_point(i : int) -> Point:
|
||||
var indx : int = i * 4
|
||||
|
||||
return Point.new(points[indx + 0], points[indx + 1], points[indx + 2], points[indx + 3])
|
||||
|
||||
func get_points() -> Array:
|
||||
var arr : Array = Array()
|
||||
|
||||
var c : int = get_point_count()
|
||||
|
||||
for i in range(c):
|
||||
arr.append(get_point(i))
|
||||
|
||||
return arr
|
||||
|
||||
func set_points(arr : Array, notify : bool = true) -> void:
|
||||
points.resize(0)
|
||||
|
||||
for p in arr:
|
||||
points.append(p.p.x)
|
||||
points.append(p.p.y)
|
||||
points.append(p.ls)
|
||||
points.append(p.rs)
|
||||
|
||||
if notify:
|
||||
curve_changed()
|
||||
|
||||
func curve_changed() -> void:
|
||||
_curve_changed()
|
||||
|
||||
func _curve_changed() -> void:
|
||||
emit_changed()
|
@ -1,64 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
#var Gradients = preload("res://addons/mat_maker_gd/nodes/common/gradients.gd")
|
||||
|
||||
export(int) var interpolation_type : int = 1 setget set_interpolation_type, get_interpolation_type
|
||||
export(PoolRealArray) var points : PoolRealArray = PoolRealArray()
|
||||
|
||||
func get_gradient_color(x : float) -> Color:
|
||||
# if interpolation_type == 0:
|
||||
# return Gradients.gradient_type_1(x, points)
|
||||
# elif interpolation_type == 1:
|
||||
# return Gradients.gradient_type_2(x, points)
|
||||
# elif interpolation_type == 2:
|
||||
# return Gradients.gradient_type_3(x, points)
|
||||
# elif interpolation_type == 3:
|
||||
# return Gradients.gradient_type_4(x, points)
|
||||
|
||||
return Color(1, 1, 1, 1)
|
||||
|
||||
func get_interpolation_type() -> int:
|
||||
return interpolation_type
|
||||
|
||||
func set_interpolation_type(val : int) -> void:
|
||||
interpolation_type = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_points() -> PoolRealArray:
|
||||
return points
|
||||
|
||||
func set_points(val : PoolRealArray) -> void:
|
||||
points = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_point_value(index : int) -> float:
|
||||
return points[index * 5]
|
||||
|
||||
func get_point_color(index : int) -> Color:
|
||||
var indx : int = index * 5
|
||||
|
||||
return Color(points[indx + 1], points[indx + 2], points[indx + 3], points[indx + 4])
|
||||
|
||||
func add_point(val : float, color : Color) -> void:
|
||||
var s : int = points.size()
|
||||
points.resize(s + 5)
|
||||
|
||||
points[s] = val
|
||||
|
||||
points[s + 1] = color.r
|
||||
points[s + 2] = color.g
|
||||
points[s + 3] = color.b
|
||||
points[s + 4] = color.a
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_point_count() -> int:
|
||||
return points.size() / 5
|
||||
|
||||
func clear() -> void:
|
||||
points.resize(0)
|
||||
|
||||
set_dirty(true)
|
@ -1,73 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(PoolVector2Array) var points : PoolVector2Array = [Vector2(0.2, 0.2), Vector2(0.7, 0.4), Vector2(0.4, 0.7)]
|
||||
|
||||
func clear() -> void:
|
||||
points.resize(0)
|
||||
|
||||
_polygon_changed()
|
||||
|
||||
func add_point(x : float, y : float, closed : bool = true) -> void:
|
||||
var p : Vector2 = Vector2(x, y)
|
||||
var points_count = points.size()
|
||||
|
||||
if points_count < 3:
|
||||
points.append(p)
|
||||
_polygon_changed()
|
||||
return
|
||||
|
||||
var min_length : float = (p-Geometry.get_closest_point_to_segment_2d(p, points[0], points[points_count-1])).length()
|
||||
var insert_point = 0
|
||||
|
||||
for i in points_count-1:
|
||||
var length = (p - Geometry.get_closest_point_to_segment_2d(p, points[i], points[i+1])).length()
|
||||
if length < min_length:
|
||||
min_length = length
|
||||
insert_point = i+1
|
||||
|
||||
if !closed and insert_point == 0 and (points[0]-p).length() > (points[points_count-1]-p).length():
|
||||
insert_point = points_count
|
||||
|
||||
points.insert(insert_point, p)
|
||||
|
||||
_polygon_changed()
|
||||
|
||||
func remove_point(index : int) -> bool:
|
||||
var s = points.size()
|
||||
if s < 4 or index < 0 or index >= s:
|
||||
return false
|
||||
else:
|
||||
points.remove(index)
|
||||
_polygon_changed()
|
||||
|
||||
return true
|
||||
|
||||
func get_point_count() -> int:
|
||||
return points.size()
|
||||
|
||||
func get_point(i : int) -> Vector2:
|
||||
return points[i]
|
||||
|
||||
func set_point(i : int, v : Vector2) -> void:
|
||||
points[i] = v
|
||||
|
||||
_polygon_changed()
|
||||
|
||||
func set_points(v : PoolVector2Array) -> void:
|
||||
points = v
|
||||
|
||||
_polygon_changed()
|
||||
|
||||
func polygon_changed() -> void:
|
||||
_polygon_changed()
|
||||
|
||||
func _polygon_changed() -> void:
|
||||
emit_changed()
|
||||
|
||||
func to_string() -> String:
|
||||
var rv = PoolStringArray()
|
||||
for p in points:
|
||||
rv.append("("+str(p.x)+","+str(p.y)+")")
|
||||
|
||||
return rv.join(",")
|
@ -1,72 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(float) var hue : float = 0
|
||||
export(float) var saturation : float = 1
|
||||
export(float) var value : float = 1
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_float("get_hue", "set_hue", "Hue", 0.01)
|
||||
mm_graph_node.add_slot_float("get_saturation", "set_saturation", "Saturation", 0.01)
|
||||
mm_graph_node.add_slot_float("get_value", "set_value", "Value", 0.01)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
return MMAlgos.adjust_hsv(c, hue, saturation, value)
|
||||
|
||||
#hue
|
||||
func get_hue() -> float:
|
||||
return hue
|
||||
|
||||
func set_hue(val : float) -> void:
|
||||
hue = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#saturation
|
||||
func get_saturation() -> float:
|
||||
return saturation
|
||||
|
||||
func set_saturation(val : float) -> void:
|
||||
saturation = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#value
|
||||
func get_value() -> float:
|
||||
return value
|
||||
|
||||
func set_value(val : float) -> void:
|
||||
value = val
|
||||
|
||||
set_dirty(true)
|
@ -1,123 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
enum BlendType {
|
||||
NORMAL = 0,
|
||||
DISSOLVE,
|
||||
MULTIPLY,
|
||||
SCREEN,
|
||||
OVERLAY,
|
||||
HARD_LIGHT,
|
||||
SOFT_LIGHT,
|
||||
BURN,
|
||||
DODGE,
|
||||
LIGHTEN,
|
||||
DARKEN,
|
||||
DIFFRENCE
|
||||
}
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input1 : Resource
|
||||
export(Resource) var input2 : Resource
|
||||
export(int, "Normal,Dissolve,Multiply,Screen,Overlay,Hard Light,Soft Light,Burn,Dodge,Lighten,Darken,Difference") var blend_type : int = 0
|
||||
export(Resource) var opacity : Resource
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !input1:
|
||||
input1 = MMNodeUniversalProperty.new()
|
||||
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input1.set_default_value(Color(1, 1, 1, 1))
|
||||
|
||||
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input1.slot_name = ">>> Input1 "
|
||||
|
||||
if !input2:
|
||||
input2 = MMNodeUniversalProperty.new()
|
||||
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input2.set_default_value(Color(1, 1, 1, 1))
|
||||
|
||||
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input2.slot_name = ">>> Input2 "
|
||||
|
||||
if !opacity:
|
||||
opacity = MMNodeUniversalProperty.new()
|
||||
opacity.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
opacity.set_default_value(0.5)
|
||||
opacity.value_range = Vector2(0, 1)
|
||||
opacity.value_step = 0.01
|
||||
|
||||
opacity.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
opacity.slot_name = "opacity"
|
||||
|
||||
register_input_property(input1)
|
||||
register_input_property(input2)
|
||||
|
||||
register_output_property(image)
|
||||
register_input_property(opacity)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_enum("get_blend_type", "set_blend_type", "blend_type", [ "Normal", "Dissolve", "Multiply", "Screen", "Overlay", "Hard Light", "Soft Light", "Burn", "Dodge", "Lighten", "Darken", "Difference" ])
|
||||
|
||||
mm_graph_node.add_slot_label_universal(input1)
|
||||
mm_graph_node.add_slot_label_universal(input2)
|
||||
mm_graph_node.add_slot_float_universal(opacity)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var b : Vector3 = Vector3()
|
||||
|
||||
#vec4 $(name_uv)_s1 = $s1($uv);
|
||||
var s1 : Color = input1.get_value(uv)
|
||||
#vec4 $(name_uv)_s2 = $s2($uv);
|
||||
var s2 : Color = input2.get_value(uv)
|
||||
#float $(name_uv)_a = $amount*$a($uv);
|
||||
var a : float = opacity.get_value(uv)
|
||||
|
||||
#vec4(blend_$blend_type($uv, $(name_uv)_s1.rgb, $(name_uv)_s2.rgb, $(name_uv)_a*$(name_uv)_s1.a), min(1.0, $(name_uv)_s2.a+$(name_uv)_a*$(name_uv)_s1.a))
|
||||
|
||||
#"Normal,Dissolve,Multiply,Screen,Overlay,Hard Light,Soft Light,Burn,Dodge,Lighten,Darken,Difference"
|
||||
if blend_type == BlendType.NORMAL:
|
||||
b = MMAlgos.blend_normal(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||
elif blend_type == BlendType.DISSOLVE:
|
||||
b = MMAlgos.blend_dissolve(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||
elif blend_type == BlendType.MULTIPLY:
|
||||
b = MMAlgos.blend_multiply(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||
elif blend_type == BlendType.SCREEN:
|
||||
b = MMAlgos.blend_screen(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||
elif blend_type == BlendType.OVERLAY:
|
||||
b = MMAlgos.blend_overlay(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||
elif blend_type == BlendType.HARD_LIGHT:
|
||||
b = MMAlgos.blend_hard_light(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||
elif blend_type == BlendType.SOFT_LIGHT:
|
||||
b = MMAlgos.blend_soft_light(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||
elif blend_type == BlendType.BURN:
|
||||
b = MMAlgos.blend_burn(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||
elif blend_type == BlendType.DODGE:
|
||||
b = MMAlgos.blend_dodge(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||
elif blend_type == BlendType.LIGHTEN:
|
||||
b = MMAlgos.blend_lighten(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||
elif blend_type == BlendType.DARKEN:
|
||||
b = MMAlgos.blend_darken(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||
elif blend_type == BlendType.DIFFRENCE:
|
||||
b = MMAlgos.blend_difference(uv, Vector3(s1.r, s1.g, s1.b), Vector3(s2.r, s2.g, s2.b), a * s1.a)
|
||||
|
||||
return Color(b.x, b.y, b.z, min(1, s2.a + a * s1.a))
|
||||
|
||||
func get_blend_type() -> int:
|
||||
return blend_type
|
||||
|
||||
func set_blend_type(val : int) -> void:
|
||||
blend_type = val
|
||||
|
||||
set_dirty(true)
|
@ -1,218 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var sigma : Resource
|
||||
export(int, "Both,X,Y") var direction : int = 0
|
||||
|
||||
var size : int = 0
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color())
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !sigma:
|
||||
sigma = MMNodeUniversalProperty.new()
|
||||
sigma.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
sigma.set_default_value(50)
|
||||
|
||||
sigma.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
sigma.slot_name = "Sigma"
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
register_input_property(sigma)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_int_universal(sigma)
|
||||
|
||||
mm_graph_node.add_slot_enum("get_direction", "set_direction", "Direction", [ "Both", "X", "Y" ])
|
||||
|
||||
|
||||
func _render(material) -> void:
|
||||
size = max(material.image_size.x, material.image_size.y)
|
||||
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _render_image(material) -> Image:
|
||||
var img : Image = Image.new()
|
||||
img.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
|
||||
img.lock()
|
||||
|
||||
var w : float = img.get_width()
|
||||
var h : float = img.get_width()
|
||||
|
||||
var pseed : float = randf() + randi()
|
||||
|
||||
if direction == 0:
|
||||
for x in range(img.get_width()):
|
||||
for y in range(img.get_height()):
|
||||
var v : Vector2 = Vector2(x / w, y / h)
|
||||
var col : Color = get_value_x(v, pseed)
|
||||
img.set_pixel(x, y, col)
|
||||
|
||||
img.unlock()
|
||||
image.set_value(img)
|
||||
|
||||
var image2 : Image = Image.new()
|
||||
image2.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
image2.lock()
|
||||
|
||||
for x in range(img.get_width()):
|
||||
for y in range(img.get_height()):
|
||||
var v : Vector2 = Vector2(x / w, y / h)
|
||||
var col : Color = get_value_y_img(v, pseed)
|
||||
image2.set_pixel(x, y, col)
|
||||
|
||||
image2.unlock()
|
||||
|
||||
return image2
|
||||
|
||||
if direction == 1:
|
||||
for x in range(img.get_width()):
|
||||
for y in range(img.get_height()):
|
||||
var v : Vector2 = Vector2(x / w, y / h)
|
||||
var col : Color = get_value_x(v, pseed)
|
||||
img.set_pixel(x, y, col)
|
||||
|
||||
if direction == 2:
|
||||
for x in range(img.get_width()):
|
||||
for y in range(img.get_height()):
|
||||
var v : Vector2 = Vector2(x / w, y / h)
|
||||
var col : Color = get_value_y(v, pseed)
|
||||
img.set_pixel(x, y, col)
|
||||
|
||||
img.unlock()
|
||||
|
||||
return img
|
||||
|
||||
func get_value_x(uv : Vector2, pseed : int) -> Color:
|
||||
var sig_def : float = sigma.get_default_value(uv)
|
||||
var sig : float = sigma.get_value(uv)
|
||||
|
||||
return gaussian_blur_x(uv, size, sig_def, sig)
|
||||
|
||||
func get_value_y(uv : Vector2, pseed : int) -> Color:
|
||||
var sig_def : float = sigma.get_default_value(uv)
|
||||
var sig : float = sigma.get_value(uv)
|
||||
|
||||
return gaussian_blur_y(uv, size, sig_def, sig)
|
||||
|
||||
func get_value_y_img(uv : Vector2, pseed : int) -> Color:
|
||||
var sig_def : float = sigma.get_default_value(uv)
|
||||
var sig : float = sigma.get_value(uv)
|
||||
|
||||
return gaussian_blur_y_img(uv, size, sig_def, sig)
|
||||
|
||||
func get_direction() -> int:
|
||||
return direction
|
||||
|
||||
func set_direction(val : int) -> void:
|
||||
direction = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#----------------------
|
||||
#gaussian_blur_x.mmg
|
||||
|
||||
#vec4 $(name)_fct(vec2 uv) {
|
||||
# float e = 1.0 / $size;
|
||||
# vec4 rv = vec4(0.0);
|
||||
# float sum = 0.0;
|
||||
# float sigma = max(0.000001, $sigma * $amount(uv));
|
||||
#
|
||||
# for (float i = -50.0; i <= 50.0; i += 1.0) {
|
||||
# float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma);
|
||||
# rv += $in(uv+vec2(i*e, 0.0))*coef;
|
||||
# sum += coef;
|
||||
# }
|
||||
#
|
||||
# return rv/sum;
|
||||
#}
|
||||
|
||||
func gaussian_blur_x(uv : Vector2, psize : float, psigma : float, pamount : float) -> Color:
|
||||
var e : float = 1.0 / psize
|
||||
var rv : Color = Color()
|
||||
var sum : float = 0.0
|
||||
var sigma : float = max(0.000001, psigma * pamount)#pamount(uv))
|
||||
|
||||
var i : float = -50
|
||||
|
||||
while i <= 50: #for (float i = -50.0; i <= 50.0; i += 1.0) {
|
||||
var coef : float = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma)
|
||||
rv += input.get_value(uv + Vector2(i*e, 0.0)) * coef
|
||||
sum += coef
|
||||
|
||||
i += 1
|
||||
|
||||
return rv / sum;
|
||||
|
||||
|
||||
#----------------------
|
||||
#gaussian_blur_y.mmg
|
||||
|
||||
#vec4 $(name)_fct(vec2 uv) {
|
||||
# float e = 1.0/$size;
|
||||
# vec4 rv = vec4(0.0);
|
||||
# float sum = 0.0;
|
||||
# float sigma = max(0.000001, $sigma*$amount(uv));
|
||||
# for (float i = -50.0; i <= 50.0; i += 1.0) {
|
||||
# float coef = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718*sigma*sigma);
|
||||
# rv += $in(uv+vec2(0.0, i*e))*coef;
|
||||
# sum += coef;
|
||||
# }
|
||||
#
|
||||
# return rv/sum;
|
||||
#}
|
||||
|
||||
func gaussian_blur_y(uv : Vector2, psize : float, psigma : float, pamount : float) -> Color:
|
||||
var e : float = 1.0 / psize
|
||||
var rv : Color = Color()
|
||||
var sum : float = 0.0
|
||||
var sigma : float = max(0.000001, psigma * pamount)#pamount(uv))
|
||||
|
||||
var i : float = -50
|
||||
|
||||
while i <= 50: #for (float i = -50.0; i <= 50.0; i += 1.0) {
|
||||
var coef : float = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma)
|
||||
rv += input.get_value(uv + Vector2(0.0, i * e)) * coef
|
||||
sum += coef
|
||||
|
||||
i += 1
|
||||
|
||||
return rv / sum;
|
||||
|
||||
|
||||
func gaussian_blur_y_img(uv : Vector2, psize : float, psigma : float, pamount : float) -> Color:
|
||||
var e : float = 1.0 / psize
|
||||
var rv : Color = Color()
|
||||
var sum : float = 0.0
|
||||
var sigma : float = max(0.000001, psigma * pamount)#pamount(uv))
|
||||
|
||||
var i : float = -50
|
||||
|
||||
while i <= 50: #for (float i = -50.0; i <= 50.0; i += 1.0) {
|
||||
var coef : float = exp(-0.5 * (pow(i / sigma, 2.0))) / (6.28318530718 * sigma * sigma)
|
||||
rv += image.get_value(uv + Vector2(0.0, i * e)) * coef
|
||||
sum += coef
|
||||
|
||||
i += 1
|
||||
|
||||
return rv / sum;
|
@ -1,61 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(float) var brightness : float = 0
|
||||
export(float) var contrast : float = 1
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_float("get_brightness", "set_brightness", "Brightness", 0.01)
|
||||
mm_graph_node.add_slot_float("get_contrast", "set_contrast", "Contrast", 0.01)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
return MMAlgos.brightness_contrast(c, brightness, contrast)
|
||||
|
||||
#brightness
|
||||
func get_brightness() -> float:
|
||||
return brightness
|
||||
|
||||
func set_brightness(val : float) -> void:
|
||||
brightness = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#contrast
|
||||
func get_contrast() -> float:
|
||||
return contrast
|
||||
|
||||
func set_contrast(val : float) -> void:
|
||||
contrast = val
|
||||
|
||||
set_dirty(true)
|
@ -1,53 +0,0 @@
|
||||
tool
|
||||
extends GradientBase
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
input.set_default_value(1)
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_gradient()
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var f : float = input.get_value(uv)
|
||||
|
||||
return get_gradient_color(f)
|
||||
# return Color(0.5, 0.5, 0.5, 1)
|
||||
|
||||
func get_gradient_color(x : float) -> Color:
|
||||
if interpolation_type == 0:
|
||||
return MMAlgos.gradient_type_1(x, points)
|
||||
elif interpolation_type == 1:
|
||||
return MMAlgos.gradient_type_2(x, points)
|
||||
elif interpolation_type == 2:
|
||||
return MMAlgos.gradient_type_3(x, points)
|
||||
elif interpolation_type == 3:
|
||||
return MMAlgos.gradient_type_4(x, points)
|
||||
|
||||
return Color(1, 1, 1, 1)
|
@ -1,75 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input_r : Resource
|
||||
export(Resource) var input_g : Resource
|
||||
export(Resource) var input_b : Resource
|
||||
export(Resource) var input_a : Resource
|
||||
|
||||
func _init_properties():
|
||||
if !input_r:
|
||||
input_r = MMNodeUniversalProperty.new()
|
||||
input_r.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
input_r.set_default_value(0)
|
||||
|
||||
input_r.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input_r.slot_name = ">>> R "
|
||||
|
||||
if !input_g:
|
||||
input_g = MMNodeUniversalProperty.new()
|
||||
input_g.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
input_g.set_default_value(0)
|
||||
|
||||
input_g.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input_g.slot_name = ">>> G "
|
||||
|
||||
if !input_b:
|
||||
input_b = MMNodeUniversalProperty.new()
|
||||
input_b.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
input_b.set_default_value(0)
|
||||
|
||||
input_b.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input_b.slot_name = ">>> B "
|
||||
|
||||
if !input_a:
|
||||
input_a = MMNodeUniversalProperty.new()
|
||||
input_a.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
input_a.set_default_value(1)
|
||||
|
||||
input_a.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input_a.slot_name = ">>> A "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input_r)
|
||||
register_input_property(input_g)
|
||||
register_input_property(input_b)
|
||||
register_input_property(input_a)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input_r)
|
||||
mm_graph_node.add_slot_label_universal(input_g)
|
||||
mm_graph_node.add_slot_label_universal(input_b)
|
||||
mm_graph_node.add_slot_label_universal(input_a)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var r : float = input_r.get_value(uv)
|
||||
var g : float = input_g.get_value(uv)
|
||||
var b : float = input_b.get_value(uv)
|
||||
var a : float = input_a.get_value(uv)
|
||||
|
||||
return Color(r, g, b, a)
|
@ -1,101 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var out_r : Resource
|
||||
export(Resource) var out_g : Resource
|
||||
export(Resource) var out_b : Resource
|
||||
export(Resource) var out_a : Resource
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !out_r:
|
||||
out_r = MMNodeUniversalProperty.new()
|
||||
out_r.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_r.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_g:
|
||||
out_g = MMNodeUniversalProperty.new()
|
||||
out_g.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_g.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_b:
|
||||
out_b = MMNodeUniversalProperty.new()
|
||||
out_b.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_b.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_a:
|
||||
out_a = MMNodeUniversalProperty.new()
|
||||
out_a.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_a.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(out_r)
|
||||
register_output_property(out_g)
|
||||
register_output_property(out_b)
|
||||
register_output_property(out_a)
|
||||
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(out_r)
|
||||
mm_graph_node.add_slot_texture_universal(out_g)
|
||||
mm_graph_node.add_slot_texture_universal(out_b)
|
||||
mm_graph_node.add_slot_texture_universal(out_a)
|
||||
|
||||
|
||||
func _render(material) -> void:
|
||||
var img_r : Image = Image.new()
|
||||
var img_g : Image = Image.new()
|
||||
var img_b : Image = Image.new()
|
||||
var img_a : Image = Image.new()
|
||||
|
||||
img_r.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
img_g.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
img_b.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
img_a.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
|
||||
img_r.lock()
|
||||
img_g.lock()
|
||||
img_b.lock()
|
||||
img_a.lock()
|
||||
|
||||
var w : float = material.image_size.x
|
||||
var h : float = material.image_size.y
|
||||
|
||||
var pseed : float = randf() + randi()
|
||||
|
||||
for x in range(material.image_size.x):
|
||||
for y in range(material.image_size.y):
|
||||
var uv : Vector2 = Vector2(x / w, y / h)
|
||||
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
img_r.set_pixel(x, y, Color(c.r, c.r, c.r, 1))
|
||||
img_g.set_pixel(x, y, Color(c.g, c.g, c.g, 1))
|
||||
img_b.set_pixel(x, y, Color(c.b, c.b, c.b, 1))
|
||||
img_a.set_pixel(x, y, Color(c.a, c.a, c.a, c.a))
|
||||
|
||||
img_r.unlock()
|
||||
img_g.unlock()
|
||||
img_b.unlock()
|
||||
img_a.unlock()
|
||||
|
||||
out_r.set_value(img_r)
|
||||
out_g.set_value(img_g)
|
||||
out_b.set_value(img_b)
|
||||
out_a.set_value(img_a)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
return Color()
|
@ -1,110 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(float) var angle : float = 0
|
||||
export(float) var amount : float = 5
|
||||
export(float) var width : float = 1
|
||||
|
||||
var size : int = 0
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
input.set_default_value(1)
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
|
||||
mm_graph_node.add_slot_float("get_angle", "set_angle", "Angle", 0.1)
|
||||
mm_graph_node.add_slot_float("get_amount", "set_amount", "Amount", 0.1)
|
||||
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 1)
|
||||
|
||||
|
||||
func _render(material) -> void:
|
||||
size = max(material.image_size.x, material.image_size.y)
|
||||
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var f : float = 0
|
||||
|
||||
f = emboss(uv, size, angle, amount, width)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
func get_angle() -> float:
|
||||
return angle
|
||||
|
||||
func set_angle(val : float) -> void:
|
||||
angle = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_amount() -> float:
|
||||
return amount
|
||||
|
||||
func set_amount(val : float) -> void:
|
||||
amount = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_width() -> float:
|
||||
return width
|
||||
|
||||
func set_width(val : float) -> void:
|
||||
width = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#float $(name)_fct(vec2 uv) {
|
||||
# float pixels = max(1.0, $width);
|
||||
# float e = 1.0/$size;
|
||||
# float rv = 0.0;
|
||||
#
|
||||
# for (float dx = -pixels; dx <= pixels; dx += 1.0) {
|
||||
# for (float dy = -pixels; dy <= pixels; dy += 1.0) {
|
||||
# if (abs(dx) > 0.5 || abs(dy) > 0.5) {
|
||||
# rv += $in(uv+e*vec2(dx, dy))*cos(atan(dy, dx)-$angle*3.14159265359/180.0)/length(vec2(dx, dy));
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return $amount*rv/pixels+0.5;
|
||||
#}
|
||||
|
||||
func emboss(uv : Vector2, psize : float, pangle : float, pamount : float, pwidth : float) -> float:
|
||||
var pixels : float = max(1.0, pwidth)
|
||||
var e : float = 1.0 / psize
|
||||
var rv : float = 0.0
|
||||
|
||||
var dx : float = -pixels
|
||||
var dy : float = -pixels
|
||||
|
||||
while dx <= pixels: #for (float dx = -pixels; dx <= pixels; dx += 1.0) {
|
||||
while dy <= pixels: #for (float dy = -pixels; dy <= pixels; dy += 1.0) {
|
||||
if (abs(dx) > 0.5 || abs(dy) > 0.5):
|
||||
rv += input.get_value(uv + e * Vector2(dx, dy)) * cos(atan2(dy, dx) - pangle * 3.14159265359 / 180.0) / Vector2(dx, dy).length()
|
||||
|
||||
dx += 1
|
||||
dy += 1
|
||||
|
||||
return pamount * rv / pixels + 0.5
|
||||
|
@ -1,69 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var value : Resource
|
||||
export(int, "R,G,B,A") var channel : int = 3
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color())
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !value:
|
||||
value = MMNodeUniversalProperty.new()
|
||||
value.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
value.set_default_value(1)
|
||||
|
||||
value.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
value.value_step = 0.01
|
||||
value.value_range = Vector2(0, 1)
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
register_input_property(value)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_float_universal(value)
|
||||
mm_graph_node.add_slot_enum("get_channel", "set_channel", "Channel", [ "R", "G", "B", "A" ])
|
||||
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var col : Color = input.get_value(uv)
|
||||
|
||||
if channel == 0:
|
||||
col.r = value.get_value(uv)
|
||||
if channel == 1:
|
||||
col.g = value.get_value(uv)
|
||||
if channel == 2:
|
||||
col.b = value.get_value(uv)
|
||||
if channel == 3:
|
||||
col.a = value.get_value(uv)
|
||||
|
||||
return col
|
||||
|
||||
func get_channel() -> int:
|
||||
return channel
|
||||
|
||||
func set_channel(val : int) -> void:
|
||||
channel = val
|
||||
|
||||
set_dirty(true)
|
@ -1,67 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var color_map : Resource
|
||||
export(Color) var edge_color : Color = Color(1, 1, 1, 1)
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !color_map:
|
||||
color_map = MMNodeUniversalProperty.new()
|
||||
color_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
color_map.set_default_value(Color(1, 1, 1, 1))
|
||||
|
||||
color_map.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
color_map.slot_name = ">>> Color Map "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_input_property(color_map)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_label_universal(color_map)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_color("get_edge_color", "set_edge_color")
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#vec4 $(name_uv)_bb = $in($uv);
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
#mix($edgecolor, $map(fract($(name_uv)_bb.xy+0.5*$(name_uv)_bb.zw)), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))))
|
||||
|
||||
var rc : Color = color_map.get_value(MMAlgos.fractv2(Vector2(c.r, c.g) + 0.5 * Vector2(c.b, c.a)))
|
||||
var s : float = MMAlgos.step(0.0000001, Vector2(c.b, c.a).dot(Vector2(1, 1)))
|
||||
|
||||
return lerp(edge_color, rc, s)
|
||||
|
||||
#edge_color
|
||||
func get_edge_color() -> Color:
|
||||
return edge_color
|
||||
|
||||
func set_edge_color(val : Color) -> void:
|
||||
edge_color = val
|
||||
|
||||
set_dirty(true)
|
@ -1,65 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(int, "X,Y,Radial") var axis : int = 2
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_enum("get_axis", "set_axis", "Axis", [ "X", "Y", "Radial" ])
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var c : Color = input.get_value(uv)
|
||||
#vec2 $(name_uv)_c = fract($in($uv).xy+0.5*$in($uv).zw);
|
||||
var cnv : Vector2 = MMAlgos.fractv2(Vector2(c.r, c.g) + 0.5 * Vector2(c.b, c.a))
|
||||
|
||||
#X, $(name_uv)_c.x
|
||||
#Y, $(name_uv)_c.y
|
||||
#Radial, length($(name_uv)_c-vec2(0.5))
|
||||
|
||||
if axis == 0:
|
||||
return Color(cnv.x, cnv.x, cnv.x, 1)
|
||||
elif axis == 1:
|
||||
return Color(cnv.y, cnv.y, cnv.y, 1)
|
||||
elif axis == 2:
|
||||
var f : float = (cnv - Vector2(0.5, 0.5)).length()
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
return Color(0, 0, 0, 1)
|
||||
|
||||
#axis
|
||||
func get_axis() -> int:
|
||||
return axis
|
||||
|
||||
func set_axis(val : int) -> void:
|
||||
axis = val
|
||||
|
||||
set_dirty(true)
|
@ -1,58 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(Color) var edge_color : Color = Color(1, 1, 1, 1)
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_color("get_edge_color", "set_edge_color")
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#vec4 $(name_uv)_bb = $in($uv);
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
#mix($edgecolor.rgb, rand3(vec2(float($seed), rand(vec2(rand($(name_uv)_bb.xy), rand($(name_uv)_bb.zw))))), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))))
|
||||
|
||||
var r1 : float = MMAlgos.rand(Vector2(c.r, c.g))
|
||||
var r2 : float = MMAlgos.rand(Vector2(c.b, c.a))
|
||||
var s : float = MMAlgos.step(0.0000001, Vector2(c.b, c.a).dot(Vector2(1, 1)))
|
||||
|
||||
var f : Vector3 = lerp(Vector3(edge_color.r, edge_color.g, edge_color.b), MMAlgos.rand3(Vector2(1.0 / float(pseed), MMAlgos.rand(Vector2(r1, r2)))), s)
|
||||
return Color(f.x, f.y, f.z, 1)
|
||||
|
||||
#edge_color
|
||||
func get_edge_color() -> Color:
|
||||
return edge_color
|
||||
|
||||
func set_edge_color(val : Color) -> void:
|
||||
edge_color = val
|
||||
|
||||
set_dirty(true)
|
@ -1,57 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(float) var edge_color : float = 1
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_float("get_edge_color", "set_edge_color", "Edge color", 0.01)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#vec4 $(name_uv)_bb = $in($uv);
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
#mix($edgecolor, rand(vec2(float($seed), rand(vec2(rand($(name_uv)_bb.xy), rand($(name_uv)_bb.zw))))), step(0.0000001, dot($(name_uv)_bb.zw, vec2(1.0))))
|
||||
var r1 : float = MMAlgos.rand(Vector2(c.r, c.g))
|
||||
var r2 : float = MMAlgos.rand(Vector2(c.b, c.a))
|
||||
var s : float = MMAlgos.step(0.0000001, Vector2(c.b, c.a).dot(Vector2(1, 1)))
|
||||
|
||||
var f : float = lerp(edge_color, MMAlgos.rand(Vector2(1.0 / float(pseed), MMAlgos.rand(Vector2(r1, r2)))), s)
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
#edge_color
|
||||
func get_edge_color() -> float:
|
||||
return edge_color
|
||||
|
||||
func set_edge_color(val : float) -> void:
|
||||
edge_color = val
|
||||
|
||||
set_dirty(true)
|
@ -1,67 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(int, "Area,Width,Height,Max(W,H)") var formula : int = 0
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_enum("get_formula", "set_formula", "Formula", [ "Area", "Width", "Height", "Max(W,H)" ])
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#vec4 $(name_uv)_bb = $in($uv);
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
var f : float = 0
|
||||
|
||||
#"Area" sqrt($(name_uv)_bb.z*$(name_uv)_bb.w)
|
||||
#"Width" $(name_uv)_bb.z
|
||||
#"Height" $(name_uv)_bb.w
|
||||
#"max(W, H)" max($(name_uv)_bb.z, $(name_uv)_bb.w)
|
||||
|
||||
if formula == 0:
|
||||
f = sqrt(c.b * c.a)
|
||||
elif formula == 1:
|
||||
f = c.b
|
||||
elif formula == 2:
|
||||
f = c.a
|
||||
elif formula == 3:
|
||||
f = max(c.b, c.a)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
#formula
|
||||
func get_formula() -> int:
|
||||
return formula
|
||||
|
||||
func set_formula(val : int) -> void:
|
||||
formula = val
|
||||
|
||||
set_dirty(true)
|
@ -1,59 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(int, "Stretch,Square") var mode : int = 0
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_enum("get_mode", "set_mode", "Mode", [ "Stretch", "Square" ])
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#vec4 $(name_uv)_bb = $in($uv);
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
#fill_to_uv_$mode($uv, $(name_uv)_bb, float($seed))
|
||||
var r : Vector3 = Vector3()
|
||||
|
||||
if mode == 0:
|
||||
r = MMAlgos.fill_to_uv_stretch(uv, c, float(pseed))
|
||||
elif mode == 1:
|
||||
r = MMAlgos.fill_to_uv_square(uv, c, float(pseed))
|
||||
|
||||
return Color(r.x, r.y, r.z, 1)
|
||||
|
||||
#mode
|
||||
func get_mode() -> int:
|
||||
return mode
|
||||
|
||||
func set_mode(val : int) -> void:
|
||||
mode = val
|
||||
|
||||
set_dirty(true)
|
@ -1,63 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(int, "Lightness,Average,Luminosity,Min,Max") var type : int = 2
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_enum("get_type", "set_type", "Type", [ "Lightness", "Average", "Luminosity", "Min", "Max" ])
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
var f : float = 0
|
||||
|
||||
if type == 0:
|
||||
f = MMAlgos.grayscale_lightness(Vector3(c.r, c.g, c.b))
|
||||
elif type == 1:
|
||||
f = MMAlgos.grayscale_average(Vector3(c.r, c.g, c.b))
|
||||
elif type == 2:
|
||||
f = MMAlgos.grayscale_luminosity(Vector3(c.r, c.g, c.b))
|
||||
elif type == 3:
|
||||
f = MMAlgos.grayscale_min(Vector3(c.r, c.g, c.b))
|
||||
elif type == 4:
|
||||
f = MMAlgos.grayscale_max(Vector3(c.r, c.g, c.b))
|
||||
|
||||
return Color(f, f, f, c.a)
|
||||
|
||||
#type
|
||||
func get_type() -> int:
|
||||
return type
|
||||
|
||||
func set_type(val : int) -> void:
|
||||
type = val
|
||||
|
||||
set_dirty(true)
|
@ -1,39 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
return MMAlgos.invert(c)
|
@ -1,75 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(float) var width : float = 0.1
|
||||
|
||||
var size : int = 0
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color())
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
|
||||
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01)
|
||||
|
||||
|
||||
func _render(material) -> void:
|
||||
size = max(material.image_size.x, material.image_size.y)
|
||||
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#make_tileable_$(name)($uv, 0.5*$w)
|
||||
return make_tileable(uv, 0.5 * width)
|
||||
|
||||
func get_width() -> float:
|
||||
return width
|
||||
|
||||
func set_width(val : float) -> void:
|
||||
width = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
|
||||
#----------------------
|
||||
#make_tileable.mmg
|
||||
|
||||
#vec4 make_tileable_$(name)(vec2 uv, float w) {
|
||||
# vec4 a = $in(uv);
|
||||
# vec4 b = $in(fract(uv+vec2(0.5)));
|
||||
# float coef_ab = sin(1.57079632679*clamp((length(uv-vec2(0.5))-0.5+w)/w, 0.0, 1.0));
|
||||
# vec4 c = $in(fract(uv+vec2(0.25)));
|
||||
# float coef_abc = sin(1.57079632679*clamp((min(min(length(uv-vec2(0.0, 0.5)), length(uv-vec2(0.5, 0.0))), min(length(uv-vec2(1.0, 0.5)), length(uv-vec2(0.5, 1.0))))-w)/w, 0.0, 1.0));
|
||||
# return mix(c, mix(a, b, coef_ab), coef_abc);
|
||||
#}
|
||||
|
||||
func make_tileable(uv : Vector2, w : float) -> Color:
|
||||
var a: Color = input.get_value(uv);
|
||||
var b : Color = input.get_value(MMAlgos.fractv2(uv + Vector2(0.5, 0.5)));
|
||||
var coef_ab : float = sin(1.57079632679 * clamp(((uv - Vector2(0.5, 0.5)).length() - 0.5 + w) / w, 0.0, 1.0));
|
||||
var c: Color = input.get_value(MMAlgos.fractv2(uv + Vector2(0.25, 0.25)));
|
||||
var coef_abc : float = sin(1.57079632679 * clamp((min(min((uv - Vector2(0.0, 0.5)).length(), (uv - Vector2(0.5, 0.0)).length()), min((uv- Vector2(1.0, 0.5)).length(), (uv - Vector2(0.5, 1.0)).length())) - w) / w, 0.0, 1.0));
|
||||
|
||||
return lerp(c, lerp(a, b, coef_ab), coef_abc)
|
||||
|
@ -1,148 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var a : Resource
|
||||
export(Resource) var b : Resource
|
||||
export(Resource) var output : Resource
|
||||
|
||||
export(int, "A+B,A-B,A*B,A/B,log(A),log2(A),pow(A; B),abs(A),round(A),floor(A),ceil(A),trunc(A),fract(A),min(A; B),max(A; B),A<B,cos(A*B),sin(A*B),tan(A*B),sqrt(1-A*A)") var operation : int = 0
|
||||
export(bool) var clamp_result : bool = false
|
||||
|
||||
func _init_properties():
|
||||
if !a:
|
||||
a = MMNodeUniversalProperty.new()
|
||||
a.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
a.set_default_value(0)
|
||||
|
||||
a.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
a.slot_name = ">>> A "
|
||||
a.value_step = 0.01
|
||||
a.value_range = Vector2(0, 1)
|
||||
|
||||
if !b:
|
||||
b = MMNodeUniversalProperty.new()
|
||||
b.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
b.set_default_value(0)
|
||||
|
||||
b.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
b.slot_name = ">>> B "
|
||||
b.value_step = 0.01
|
||||
b.value_range = Vector2(0, 1)
|
||||
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
output.set_default_value(0)
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
output.slot_name = " Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(a)
|
||||
register_input_property(b)
|
||||
register_output_property(output)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(a)
|
||||
mm_graph_node.add_slot_label_universal(b)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "A+B", "A-B", "A*B", "A/B", "log(A)", "log2(A)", "pow(A, B)", "abs(A)", "round(A)", "floor(A)", "ceil(A)", "trunc(A)", "fract(A)", "min(A, B)", "max(A, B)", "A<B", "cos(A*B)", "sin(A*B)", "tan(A*B)", "sqrt(1-A*A)" ])
|
||||
mm_graph_node.add_slot_bool("get_clamp_result", "set_clamp_result", "Clamp result")
|
||||
|
||||
func _get_property_value(uv : Vector2) -> float:
|
||||
var af : float = a.get_value(uv)
|
||||
var bf : float = b.get_value(uv)
|
||||
|
||||
var f : float = 0
|
||||
|
||||
if operation == 0:#"A+B",
|
||||
f = af + bf
|
||||
elif operation == 1:#"A-B",
|
||||
f = af - bf
|
||||
elif operation == 2:#"A*B",
|
||||
f = af * bf
|
||||
elif operation == 3:#"A/B",
|
||||
if bf == 0:
|
||||
bf = 0.000001
|
||||
f = af / bf
|
||||
elif operation == 4:#"log(A)",
|
||||
#todo needs to be implemented
|
||||
f = log(af)
|
||||
elif operation == 5:#"log2(A)",
|
||||
#todo needs to be implemented
|
||||
f = log(af)
|
||||
elif operation == 6:#"pow(A, B)",
|
||||
f = pow(af, bf)
|
||||
elif operation == 7:#"abs(A)",
|
||||
f = abs(af)
|
||||
elif operation == 8:#"round(A)",
|
||||
f = round(af)
|
||||
elif operation == 9:#"floor(A)",
|
||||
f = floor(af)
|
||||
elif operation == 10:#"ceil(A)",
|
||||
f = ceil(af)
|
||||
elif operation == 11:#"trunc(A)",
|
||||
f = int(af)
|
||||
elif operation == 12:#"fract(A)",
|
||||
f = MMAlgos.fractf(af)
|
||||
elif operation == 13:#"min(A, B)",
|
||||
f = min(af, bf)
|
||||
elif operation == 14:#"max(A, B)",
|
||||
f = max(af, bf)
|
||||
elif operation == 15:#"A<B",
|
||||
f = af < bf
|
||||
elif operation == 16:#"cos(A*B)",
|
||||
f = cos(af * bf)
|
||||
elif operation == 17:#"sin(A*B)",
|
||||
f = sin(af * bf)
|
||||
elif operation == 18:#"tan(A*B)",
|
||||
f = tan(af * bf)
|
||||
elif operation == 19:#"sqrt(1-A*A)"
|
||||
f = sqrt(1 - af * af)
|
||||
|
||||
if clamp_result:
|
||||
f = clamp(f, 0, 1)
|
||||
|
||||
return f
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var f : float = get_property_value(uv)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
#operation
|
||||
func get_operation() -> int:
|
||||
return operation
|
||||
|
||||
func set_operation(val : int) -> void:
|
||||
operation = val
|
||||
|
||||
set_dirty(true)
|
||||
output.emit_changed()
|
||||
|
||||
#clamp_result
|
||||
func get_clamp_result() -> bool:
|
||||
return clamp_result
|
||||
|
||||
func set_clamp_result(val : bool) -> void:
|
||||
clamp_result = val
|
||||
|
||||
set_dirty(true)
|
||||
output.emit_changed()
|
@ -1,53 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(int) var steps : int = 4
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_int("get_steps", "set_steps", "Steps")
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
#vec4(floor($in($uv).rgb*$steps)/$steps, $in($uv).a)
|
||||
var v : Vector3 = MMAlgos.floorv3(Vector3(c.r, c.g, c.b) * steps) / float(steps)
|
||||
|
||||
return Color(v.x, v.y, v.z, c.a)
|
||||
|
||||
#steps
|
||||
func get_steps() -> int:
|
||||
return steps
|
||||
|
||||
func set_steps(val : int) -> void:
|
||||
steps = val
|
||||
|
||||
set_dirty(true)
|
@ -1,108 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(int, "0,1,R,-R,G,-G,B,-B,A,-A") var op_r : int = 2
|
||||
export(int, "0,1,R,-R,G,-G,B,-B,A,-A") var op_g : int = 4
|
||||
export(int, "0,1,R,-R,G,-G,B,-B,A,-A") var op_b : int = 6
|
||||
export(int, "0,1,R,-R,G,-G,B,-B,A,-A") var op_a : int = 8
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
|
||||
mm_graph_node.add_slot_enum("get_op_r", "set_op_r", "R", [ "0", "1", "R", "-R", "G", "-G", "B", "-B", "A","-A" ])
|
||||
mm_graph_node.add_slot_enum("get_op_g", "set_op_g", "G", [ "0", "1", "R", "-R", "G", "-G", "B", "-B", "A","-A" ])
|
||||
mm_graph_node.add_slot_enum("get_op_b", "set_op_b", "B", [ "0", "1", "R", "-R", "G", "-G", "B", "-B", "A","-A" ])
|
||||
mm_graph_node.add_slot_enum("get_op_a", "set_op_a", "A", [ "0", "1", "R", "-R", "G", "-G", "B", "-B", "A","-A" ])
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func apply(op : int, val : Color) -> float:
|
||||
if op == 0:
|
||||
return 0.0
|
||||
elif op == 1:
|
||||
return 1.0
|
||||
elif op == 2:
|
||||
return val.r
|
||||
elif op == 3:
|
||||
return 1.0 - val.r
|
||||
elif op == 4:
|
||||
return val.g
|
||||
elif op == 5:
|
||||
return 1.0 - val.g
|
||||
elif op == 6:
|
||||
return val.b
|
||||
elif op == 7:
|
||||
return 1.0 - val.b
|
||||
elif op == 8:
|
||||
return val.a
|
||||
elif op == 9:
|
||||
return 1.0 - val.a
|
||||
|
||||
return 0.0
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var c : Color = input.get_value(uv)
|
||||
|
||||
return Color(apply(op_r, c), apply(op_g, c), apply(op_b, c), apply(op_a, c))
|
||||
|
||||
#op_r
|
||||
func get_op_r() -> int:
|
||||
return op_r
|
||||
|
||||
func set_op_r(val : int) -> void:
|
||||
op_r = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#op_g
|
||||
func get_op_g() -> int:
|
||||
return op_g
|
||||
|
||||
func set_op_g(val : int) -> void:
|
||||
op_g = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#op_b
|
||||
func get_op_b() -> int:
|
||||
return op_b
|
||||
|
||||
func set_op_b(val : int) -> void:
|
||||
op_b = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#op_a
|
||||
func get_op_a() -> int:
|
||||
return op_a
|
||||
|
||||
func set_op_a(val : int) -> void:
|
||||
op_a = val
|
||||
|
||||
set_dirty(true)
|
@ -1,48 +0,0 @@
|
||||
tool
|
||||
extends CurveBase
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
|
||||
func _init():
|
||||
init_points_01()
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
input.set_default_value(0)
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_curve()
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var f : float = input.get_value(uv)
|
||||
|
||||
var cf : float = MMAlgos.curve(f, points_array)
|
||||
|
||||
return Color(cf, cf, cf, 1)
|
||||
|
||||
func _curve_changed() -> void:
|
||||
set_dirty(true)
|
@ -1,58 +0,0 @@
|
||||
tool
|
||||
extends GradientBase
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(float) var repeat : float = 1
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_float("get_repeat", "set_repeat", "repeat")
|
||||
mm_graph_node.add_slot_gradient()
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
if interpolation_type == 0:
|
||||
return MMAlgos.circular_gradient_type_1(uv, repeat, points)
|
||||
elif interpolation_type == 1:
|
||||
return MMAlgos.circular_gradient_type_2(uv, repeat, points)
|
||||
elif interpolation_type == 2:
|
||||
return MMAlgos.circular_gradient_type_3(uv, repeat, points)
|
||||
elif interpolation_type == 3:
|
||||
return MMAlgos.circular_gradient_type_4(uv, repeat, points)
|
||||
|
||||
return Color(1, 1, 1, 1)
|
||||
|
||||
|
||||
func _get_gradient_color(x : float) -> Color:
|
||||
if interpolation_type == 0:
|
||||
return MMAlgos.gradient_type_1(x, points)
|
||||
elif interpolation_type == 1:
|
||||
return MMAlgos.gradient_type_2(x, points)
|
||||
elif interpolation_type == 2:
|
||||
return MMAlgos.gradient_type_3(x, points)
|
||||
elif interpolation_type == 3:
|
||||
return MMAlgos.gradient_type_4(x, points)
|
||||
|
||||
return Color(1, 1, 1, 1)
|
||||
|
||||
func get_repeat() -> float:
|
||||
return repeat
|
||||
|
||||
func set_repeat(val : float) -> void:
|
||||
repeat = val
|
||||
|
||||
set_dirty(true)
|
||||
|
@ -1,66 +0,0 @@
|
||||
tool
|
||||
extends GradientBase
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(float) var repeat : float = 1
|
||||
export(float) var rotate : float = 0
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_float("get_repeat", "set_repeat", "repeat")
|
||||
mm_graph_node.add_slot_float("get_rotate", "set_rotate", "rotate")
|
||||
mm_graph_node.add_slot_gradient()
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
if interpolation_type == 0:
|
||||
return MMAlgos.normal_gradient_type_1(uv, repeat, rotate, points)
|
||||
elif interpolation_type == 1:
|
||||
return MMAlgos.normal_gradient_type_2(uv, repeat, rotate, points)
|
||||
elif interpolation_type == 2:
|
||||
return MMAlgos.normal_gradient_type_3(uv, repeat, rotate, points)
|
||||
elif interpolation_type == 3:
|
||||
return MMAlgos.normal_gradient_type_4(uv, repeat, rotate, points)
|
||||
|
||||
return Color(1, 1, 1, 1)
|
||||
|
||||
func _get_gradient_color(x : float) -> Color:
|
||||
if interpolation_type == 0:
|
||||
return MMAlgos.gradient_type_1(x, points)
|
||||
elif interpolation_type == 1:
|
||||
return MMAlgos.gradient_type_2(x, points)
|
||||
elif interpolation_type == 2:
|
||||
return MMAlgos.gradient_type_3(x, points)
|
||||
elif interpolation_type == 3:
|
||||
return MMAlgos.gradient_type_4(x, points)
|
||||
|
||||
return Color(1, 1, 1, 1)
|
||||
|
||||
func get_repeat() -> float:
|
||||
return repeat
|
||||
|
||||
func set_repeat(val : float) -> void:
|
||||
repeat = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_rotate() -> float:
|
||||
return rotate
|
||||
|
||||
func set_rotate(val : float) -> void:
|
||||
rotate = val
|
||||
|
||||
set_dirty(true)
|
@ -1,58 +0,0 @@
|
||||
tool
|
||||
extends GradientBase
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(float) var repeat : float = 1
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_float("get_repeat", "set_repeat", "repeat")
|
||||
mm_graph_node.add_slot_gradient()
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
if interpolation_type == 0:
|
||||
return MMAlgos.radial_gradient_type_1(uv, repeat, points)
|
||||
elif interpolation_type == 1:
|
||||
return MMAlgos.radial_gradient_type_2(uv, repeat, points)
|
||||
elif interpolation_type == 2:
|
||||
return MMAlgos.radial_gradient_type_3(uv, repeat, points)
|
||||
elif interpolation_type == 3:
|
||||
return MMAlgos.radial_gradient_type_4(uv, repeat, points)
|
||||
|
||||
return Color(1, 1, 1, 1)
|
||||
|
||||
|
||||
func _get_gradient_color(x : float) -> Color:
|
||||
if interpolation_type == 0:
|
||||
return MMAlgos.gradient_type_1(x, points)
|
||||
elif interpolation_type == 1:
|
||||
return MMAlgos.gradient_type_2(x, points)
|
||||
elif interpolation_type == 2:
|
||||
return MMAlgos.gradient_type_3(x, points)
|
||||
elif interpolation_type == 3:
|
||||
return MMAlgos.gradient_type_4(x, points)
|
||||
|
||||
return Color(1, 1, 1, 1)
|
||||
|
||||
func get_repeat() -> float:
|
||||
return repeat
|
||||
|
||||
func set_repeat(val : float) -> void:
|
||||
repeat = val
|
||||
|
||||
set_dirty(true)
|
||||
|
@ -1,58 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
|
||||
export(Vector2) var scale : Vector2 = Vector2(4, 256)
|
||||
export(float) var smoothness : float = 1
|
||||
export(float) var interpolation : float = 1
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_vector2("get_scale", "set_scale", "Scale", 1)#, Vector2(1, 10))
|
||||
mm_graph_node.add_slot_float("get_smoothness", "set_smoothness", "Smoothness", 0.01)#, Vector2(0, 1))
|
||||
mm_graph_node.add_slot_float("get_interpolation", "set_interpolation", "Interpolation", 0.01)#, Vector2(0, 1))
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var ps : float = 1.0 / float(pseed)
|
||||
|
||||
#anisotropic($(uv), vec2($(scale_x), $(scale_y)), $(seed), $(smoothness), $(interpolation))
|
||||
return MMAlgos.anisotropicc(uv, scale, ps, smoothness, interpolation)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_scale() -> Vector2:
|
||||
return scale
|
||||
|
||||
func set_scale(val : Vector2) -> void:
|
||||
scale = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_smoothness() -> float:
|
||||
return smoothness
|
||||
|
||||
func set_smoothness(val : float) -> void:
|
||||
smoothness = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_interpolation() -> float:
|
||||
return interpolation
|
||||
|
||||
func set_interpolation(val : float) -> void:
|
||||
interpolation = val
|
||||
|
||||
set_dirty(true)
|
@ -1,50 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
|
||||
export(int) var size : int = 8
|
||||
|
||||
#----------------------
|
||||
#color_noise.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (rgb) - Shows the noise pattern
|
||||
#color_dots($(uv), 1.0/$(size), $(seed))
|
||||
|
||||
#Inputs:
|
||||
#size, float, default: 8, min: 2, max: 12, step: 1
|
||||
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_int("get_size", "set_size", "Size")#, Vector2(1, 10))
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var ps : float = 1.0 / float(pseed)
|
||||
|
||||
#color_dots($(uv), 1.0/$(size), $(seed))
|
||||
return MMAlgos.noise_color(uv, float(size), ps)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_size() -> int:
|
||||
return size
|
||||
|
||||
func set_size(val : int) -> void:
|
||||
size = val
|
||||
|
||||
set_dirty(true)
|
@ -1,58 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
|
||||
export(Vector2) var scale : Vector2 = Vector2(4, 4)
|
||||
export(int) var iterations : int = 3
|
||||
export(float) var persistence : float = 0.5
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_vector2("get_scale", "set_scale", "Scale")#, Vector2(1, 10))
|
||||
mm_graph_node.add_slot_int("get_iterations", "set_iterations", "Iterations")#, Vector2(0, 1))
|
||||
mm_graph_node.add_slot_float("get_persistence", "set_persistence", "Persistence", 0.01)#, Vector2(0, 1))
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var ps : float = 1.0 / float(pseed)
|
||||
|
||||
#perlin_color($(uv), vec2($(scale_x), $(scale_y)), int($(iterations)), $(persistence), $(seed))
|
||||
return MMAlgos.perlin_colorc(uv, scale, iterations, persistence, ps)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_scale() -> Vector2:
|
||||
return scale
|
||||
|
||||
func set_scale(val : Vector2) -> void:
|
||||
scale = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_iterations() -> int:
|
||||
return iterations
|
||||
|
||||
func set_iterations(val : int) -> void:
|
||||
iterations = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_persistence() -> float:
|
||||
return persistence
|
||||
|
||||
func set_persistence(val : float) -> void:
|
||||
persistence = val
|
||||
|
||||
set_dirty(true)
|
@ -1,97 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
|
||||
export(int, "Value,Perlin,Simplex,Cellular1,Cellular2,Cellular3,Cellular4,Cellular5,Cellular6") var type : int = 0
|
||||
export(Vector2) var scale : Vector2 = Vector2(2, 2)
|
||||
export(int) var folds : int = 0
|
||||
export(int) var iterations : int = 5
|
||||
export(float) var persistence : float = 0.5
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_enum("get_type", "set_type", "Type", [ "Value", "Perlin", "Simplex", "Cellular1", "Cellular2", "Cellular3", "Cellular4", "Cellular5", "Cellular6" ])#, Vector2(0, 1))
|
||||
mm_graph_node.add_slot_vector2("get_scale", "set_scale", "Scale")#, Vector2(1, 10))
|
||||
mm_graph_node.add_slot_int("get_folds", "set_folds", "folds")#, Vector2(0, 1))
|
||||
mm_graph_node.add_slot_int("get_iterations", "set_iterations", "Iterations")#, Vector2(0, 1))
|
||||
mm_graph_node.add_slot_float("get_persistence", "set_persistence", "Persistence", 0.01)#, Vector2(0, 1))
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var ps : float = 1.0 / float(pseed)
|
||||
|
||||
#"Value,Perlin,Simplex,Cellular1,Cellular2,Cellular3,Cellular4,Cellular5,Cellular6"
|
||||
if type == 0:
|
||||
return MMAlgos.fbmval(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 1:
|
||||
return MMAlgos.perlin(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 2:
|
||||
return MMAlgos.simplex(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 3:
|
||||
return MMAlgos.cellular(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 4:
|
||||
return MMAlgos.cellular2(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 5:
|
||||
return MMAlgos.cellular3(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 6:
|
||||
return MMAlgos.cellular4(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 7:
|
||||
return MMAlgos.cellular5(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 8:
|
||||
return MMAlgos.cellular6(uv, scale, folds, iterations, persistence, ps)
|
||||
|
||||
return Color()
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_type() -> int:
|
||||
return type
|
||||
|
||||
func set_type(val : int) -> void:
|
||||
type = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_scale() -> Vector2:
|
||||
return scale
|
||||
|
||||
func set_scale(val : Vector2) -> void:
|
||||
scale = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_folds() -> int:
|
||||
return folds
|
||||
|
||||
func set_folds(val : int) -> void:
|
||||
folds = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_iterations() -> int:
|
||||
return iterations
|
||||
|
||||
func set_iterations(val : int) -> void:
|
||||
iterations = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_persistence() -> float:
|
||||
return persistence
|
||||
|
||||
func set_persistence(val : float) -> void:
|
||||
persistence = val
|
||||
|
||||
set_dirty(true)
|
@ -1,50 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
|
||||
export(int) var grid_size : int = 16
|
||||
export(float) var density : float = 0.5
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_int("get_grid_size", "set_grid_size", "Grid Size")#, Vector2(1, 10))
|
||||
mm_graph_node.add_slot_float("get_density", "set_density", "Density", 0.01)#, Vector2(0, 1))
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var ps : float = 1.0 / float(pseed)
|
||||
|
||||
#return dots(uv, 1.0/$(size), $(density), $(seed));
|
||||
var f : float = MMAlgos.dots(uv, 1.0 / float(grid_size), density, ps)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func get_grid_size() -> int:
|
||||
return grid_size
|
||||
|
||||
func set_grid_size(val : int) -> void:
|
||||
grid_size = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
func get_density() -> float:
|
||||
return density
|
||||
|
||||
func set_density(val : float) -> void:
|
||||
density = val
|
||||
|
||||
set_dirty(true)
|
@ -1,160 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var out_nodes : Resource
|
||||
export(Resource) var out_borders : Resource
|
||||
export(Resource) var out_random_color : Resource
|
||||
export(Resource) var out_fill : Resource
|
||||
|
||||
export(Vector2) var scale : Vector2 = Vector2(4, 4)
|
||||
export(Vector2) var stretch : Vector2 = Vector2(1, 1)
|
||||
export(float) var intensity : float = 1
|
||||
export(float) var randomness : float = 0.85
|
||||
|
||||
func _init_properties():
|
||||
if !out_nodes:
|
||||
out_nodes = MMNodeUniversalProperty.new()
|
||||
out_nodes.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_nodes.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_borders:
|
||||
out_borders = MMNodeUniversalProperty.new()
|
||||
out_borders.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_borders.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_random_color:
|
||||
out_random_color = MMNodeUniversalProperty.new()
|
||||
out_random_color.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_random_color.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_fill:
|
||||
out_fill = MMNodeUniversalProperty.new()
|
||||
out_fill.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_fill.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(out_nodes)
|
||||
register_output_property(out_borders)
|
||||
register_output_property(out_random_color)
|
||||
register_output_property(out_fill)
|
||||
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(out_nodes)
|
||||
mm_graph_node.add_slot_texture_universal(out_borders)
|
||||
mm_graph_node.add_slot_texture_universal(out_random_color)
|
||||
mm_graph_node.add_slot_texture_universal(out_fill)
|
||||
|
||||
mm_graph_node.add_slot_vector2("get_scale", "set_scale", "Scale", 0.1)#, Vector2(1, 32))#, Vector2(0, 32))
|
||||
mm_graph_node.add_slot_vector2("get_stretch", "set_stretch", "stretch", 0.01)#, Vector2(1, 32))#, Vector2(0, 32))
|
||||
mm_graph_node.add_slot_float("get_intensity", "set_intensity", "Intensity", 0.01)#, Vector2(1, 32))#, Vector2(0, 32))
|
||||
mm_graph_node.add_slot_float("get_randomness", "set_randomness", "Randomness", 0.01)#, Vector2(1, 32))#, Vector2(0, 32))
|
||||
|
||||
|
||||
|
||||
|
||||
func _render(material) -> void:
|
||||
var nodes : Image = Image.new()
|
||||
var borders : Image = Image.new()
|
||||
var random_color : Image = Image.new()
|
||||
var fill : Image = Image.new()
|
||||
|
||||
nodes.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
borders.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
random_color.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
fill.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
|
||||
nodes.lock()
|
||||
borders.lock()
|
||||
random_color.lock()
|
||||
fill.lock()
|
||||
|
||||
var w : float = material.image_size.x
|
||||
var h : float = material.image_size.y
|
||||
|
||||
var pseed : float = randf() + randi()
|
||||
|
||||
for x in range(material.image_size.x):
|
||||
for y in range(material.image_size.y):
|
||||
var uv : Vector2 = Vector2(x / w, y / h)
|
||||
|
||||
var ps : float = 1.0 / float(pseed)
|
||||
|
||||
#vec4 $(name_uv)_xyzw = voronoi($uv, vec2($scale_x, $scale_y), vec2($stretch_y, $stretch_x), $intensity, $randomness, $seed);
|
||||
var voronoi : Color = MMAlgos.voronoi(uv, scale, stretch, intensity, randomness, ps)
|
||||
|
||||
#Nodes - float - A greyscale pattern based on the distance to cell centers
|
||||
#$(name_uv)_xyzw.z
|
||||
var nodes_col : Color = Color(voronoi.b, voronoi.b, voronoi.b, 1)
|
||||
|
||||
#Borders - float - A greyscale pattern based on the distance to borders
|
||||
#$(name_uv)_xyzw.w
|
||||
var borders_col : Color = Color(voronoi.a, voronoi.a, voronoi.a, 1)
|
||||
|
||||
#Random color - rgb - A color pattern that assigns a random color to each cell
|
||||
#rand3(fract(floor($(name_uv)_xyzw.xy)/vec2($scale_x, $scale_y)))
|
||||
var rv3 : Vector3 = MMAlgos.rand3(MMAlgos.fractv2(Vector2(voronoi.r, voronoi.g) / scale))
|
||||
var random_color_col : Color = Color(rv3.x, rv3.y, rv3.z, 1)
|
||||
|
||||
#Fill - rgba - An output that should be plugged into a Fill companion node
|
||||
#vec4(fract(($(name_uv)_xyzw.xy-1.0)/vec2($scale_x, $scale_y)), vec2(2.0)/vec2($scale_x, $scale_y))
|
||||
var fv21 : Vector2 = MMAlgos.fractv2((Vector2(voronoi.r, voronoi.g) - Vector2(1, 1)) / scale)
|
||||
var fv22 : Vector2 = Vector2(2, 2) / scale
|
||||
var fill_col : Color = Color(fv21.x, fv21.y, fv22.x, fv22.y)
|
||||
|
||||
nodes.set_pixel(x, y, nodes_col)
|
||||
borders.set_pixel(x, y, borders_col)
|
||||
random_color.set_pixel(x, y, random_color_col)
|
||||
fill.set_pixel(x, y, fill_col)
|
||||
|
||||
nodes.unlock()
|
||||
borders.unlock()
|
||||
random_color.unlock()
|
||||
fill.unlock()
|
||||
|
||||
out_nodes.set_value(nodes)
|
||||
out_borders.set_value(borders)
|
||||
out_random_color.set_value(random_color)
|
||||
out_fill.set_value(fill)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
return Color()
|
||||
|
||||
#scale
|
||||
func get_scale() -> Vector2:
|
||||
return scale
|
||||
|
||||
func set_scale(val : Vector2) -> void:
|
||||
scale = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#stretch
|
||||
func get_stretch() -> Vector2:
|
||||
return stretch
|
||||
|
||||
func set_stretch(val : Vector2) -> void:
|
||||
stretch = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#intensity
|
||||
func get_intensity() -> float:
|
||||
return intensity
|
||||
|
||||
func set_intensity(val : float) -> void:
|
||||
intensity = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#randomness
|
||||
func get_randomness() -> float:
|
||||
return randomness
|
||||
|
||||
func set_randomness(val : float) -> void:
|
||||
randomness = val
|
||||
|
||||
set_dirty(true)
|
@ -1,45 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
|
||||
export(String) var postfix : String = ""
|
||||
|
||||
func _init_properties():
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
image.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
image.slot_name = "image"
|
||||
|
||||
register_input_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_line_edit("get_postfix", "set_postfix", "postfix")
|
||||
|
||||
func _render(material) -> void:
|
||||
if !image:
|
||||
return
|
||||
|
||||
var img : Image = image.get_active_image()
|
||||
|
||||
if !img:
|
||||
return
|
||||
|
||||
var matpath : String = material.get_path()
|
||||
|
||||
if matpath == "":
|
||||
return
|
||||
|
||||
var matbn : String = matpath.get_basename()
|
||||
var final_file_name : String = matbn + postfix + ".png"
|
||||
|
||||
img.save_png(final_file_name)
|
||||
|
||||
func get_postfix() -> String:
|
||||
return postfix
|
||||
|
||||
func set_postfix(pf : String) -> void:
|
||||
postfix = pf
|
||||
|
||||
set_dirty(true)
|
@ -1,110 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var out_main : Resource
|
||||
export(Resource) var out_random_color : Resource
|
||||
export(Resource) var out_uv_map : Resource
|
||||
|
||||
export(Vector2) var size : Vector2 = Vector2(4, 4)
|
||||
|
||||
func _init_properties():
|
||||
if !out_main:
|
||||
out_main = MMNodeUniversalProperty.new()
|
||||
out_main.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_main.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_random_color:
|
||||
out_random_color = MMNodeUniversalProperty.new()
|
||||
out_random_color.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_random_color.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_uv_map:
|
||||
out_uv_map = MMNodeUniversalProperty.new()
|
||||
out_uv_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_uv_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(out_main)
|
||||
register_output_property(out_random_color)
|
||||
register_output_property(out_uv_map)
|
||||
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(out_main)
|
||||
mm_graph_node.add_slot_texture_universal(out_random_color)
|
||||
mm_graph_node.add_slot_texture_universal(out_uv_map)
|
||||
|
||||
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size")#, Vector2(1, 32))#, Vector2(0, 32))
|
||||
|
||||
|
||||
func _render(material) -> void:
|
||||
var main_pattern : Image = Image.new()
|
||||
var random_color : Image = Image.new()
|
||||
var uv_map : Image = Image.new()
|
||||
|
||||
main_pattern.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
random_color.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
uv_map.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
|
||||
main_pattern.lock()
|
||||
random_color.lock()
|
||||
uv_map.lock()
|
||||
|
||||
var w : float = material.image_size.x
|
||||
var h : float = material.image_size.y
|
||||
|
||||
var pseed : float = randf() + randi()
|
||||
|
||||
for x in range(material.image_size.x):
|
||||
for y in range(material.image_size.y):
|
||||
var uv : Vector2 = Vector2(x / w, y / h)
|
||||
|
||||
var ps : float = 1.0 / float(pseed)
|
||||
|
||||
#vec2 $(name_uv)_uv = $uv*vec2($sx, $sy*1.73205080757);
|
||||
#vec4 $(name_uv)_center = beehive_center($(name_uv)_uv);
|
||||
var beehive_uv : Vector2 = uv * size;
|
||||
var beehive_uv_center : Color = MMAlgos.beehive_center(beehive_uv);
|
||||
|
||||
#Output (float) - Shows the greyscale pattern
|
||||
#1.0-2.0*beehive_dist($(name_uv)_center.xy)
|
||||
var f : float = 1.0 - 2.0 * MMAlgos.beehive_dist(Vector2(beehive_uv_center.r, beehive_uv_center.g))
|
||||
var main_pattern_col : Color = Color(f, f, f, 1)
|
||||
|
||||
#Random color (rgb) - Shows a random color for each hexagonal tile
|
||||
#rand3(fract($(name_uv)_center.zw/vec2($sx, $sy))+vec2(float($seed)))
|
||||
var rcv3 : Vector3 = MMAlgos.rand3(MMAlgos.fractv2(Vector2(beehive_uv_center.b, beehive_uv_center.a) / size) + Vector2(ps, ps))
|
||||
var random_color_col : Color = Color(rcv3.x, rcv3.y, rcv3.z, 1)
|
||||
|
||||
#UV map (rgb) - Shows an UV map to be connected to the UV map port of the Custom UV node
|
||||
#vec3(vec2(0.5)+$(name_uv)_center.xy, rand(fract($(name_uv)_center.zw/vec2($sx, $sy))+vec2(float($seed))))
|
||||
var uvm1 : Vector2 = Vector2(0.5, 0.5) + Vector2(beehive_uv_center.r, beehive_uv_center.g)
|
||||
var uvm2 : Vector2 = MMAlgos.rand2(MMAlgos.fractv2(Vector2(beehive_uv_center.b, beehive_uv_center.a) / size) + Vector2(ps, ps))
|
||||
|
||||
var uv_map_col : Color = Color(uvm1.x, uvm1.y, uvm2.x, 1)
|
||||
|
||||
main_pattern.set_pixel(x, y, main_pattern_col)
|
||||
random_color.set_pixel(x, y, random_color_col)
|
||||
uv_map.set_pixel(x, y, uv_map_col)
|
||||
|
||||
main_pattern.unlock()
|
||||
random_color.unlock()
|
||||
uv_map.unlock()
|
||||
|
||||
out_main.set_value(main_pattern)
|
||||
out_random_color.set_value(random_color)
|
||||
out_uv_map.set_value(uv_map)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
return Color()
|
||||
|
||||
#size
|
||||
func get_size() -> Vector2:
|
||||
return size
|
||||
|
||||
func set_size(val : Vector2) -> void:
|
||||
size = val
|
||||
|
||||
set_dirty(true)
|
@ -1,286 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var out_bricks_pattern : Resource
|
||||
export(Resource) var out_random_color : Resource
|
||||
export(Resource) var out_position_x : Resource
|
||||
export(Resource) var out_position_y : Resource
|
||||
export(Resource) var out_brick_uv : Resource
|
||||
export(Resource) var out_corner_uv : Resource
|
||||
export(Resource) var out_direction : Resource
|
||||
|
||||
export(int, "Running Bond,Running Bond (2),HerringBone,Basket Weave,Spanish Bond") var type : int = 0
|
||||
export(int) var repeat : int = 1
|
||||
export(Vector2) var col_row : Vector2 = Vector2(4, 4)
|
||||
export(float) var offset : float = 0.5
|
||||
export(Resource) var mortar : Resource
|
||||
export(Resource) var bevel : Resource
|
||||
export(Resource) var roundness : Resource
|
||||
export(float) var corner : float = 0.3
|
||||
|
||||
func _init_properties():
|
||||
if !out_bricks_pattern:
|
||||
out_bricks_pattern = MMNodeUniversalProperty.new()
|
||||
out_bricks_pattern.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_bricks_pattern.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_random_color:
|
||||
out_random_color = MMNodeUniversalProperty.new()
|
||||
out_random_color.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_random_color.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_position_x:
|
||||
out_position_x = MMNodeUniversalProperty.new()
|
||||
out_position_x.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_position_x.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_position_y:
|
||||
out_position_y = MMNodeUniversalProperty.new()
|
||||
out_position_y.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_position_y.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_brick_uv:
|
||||
out_brick_uv = MMNodeUniversalProperty.new()
|
||||
out_brick_uv.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_brick_uv.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_corner_uv:
|
||||
out_corner_uv = MMNodeUniversalProperty.new()
|
||||
out_corner_uv.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_corner_uv.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_direction:
|
||||
out_direction = MMNodeUniversalProperty.new()
|
||||
out_direction.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_direction.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !mortar:
|
||||
mortar = MMNodeUniversalProperty.new()
|
||||
mortar.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
mortar.set_default_value(0.1)
|
||||
|
||||
mortar.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
mortar.slot_name = "Mortar"
|
||||
mortar.value_step = 0.01
|
||||
mortar.value_range = Vector2(0, 0.5)
|
||||
|
||||
if !bevel:
|
||||
bevel = MMNodeUniversalProperty.new()
|
||||
bevel.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
bevel.set_default_value(0.1)
|
||||
|
||||
bevel.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
bevel.slot_name = "Bevel"
|
||||
bevel.value_step = 0.01
|
||||
bevel.value_range = Vector2(0, 0.5)
|
||||
|
||||
if !roundness:
|
||||
roundness = MMNodeUniversalProperty.new()
|
||||
roundness.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
roundness.set_default_value(0.1)
|
||||
|
||||
roundness.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
roundness.slot_name = "Roundness"
|
||||
roundness.value_step = 0.01
|
||||
roundness.value_range = Vector2(0, 0.5)
|
||||
|
||||
register_output_property(out_bricks_pattern)
|
||||
register_output_property(out_random_color)
|
||||
register_output_property(out_position_x)
|
||||
register_output_property(out_position_y)
|
||||
register_output_property(out_brick_uv)
|
||||
register_output_property(out_corner_uv)
|
||||
register_output_property(out_direction)
|
||||
|
||||
register_input_property(mortar)
|
||||
register_input_property(bevel)
|
||||
register_input_property(roundness)
|
||||
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(out_bricks_pattern)
|
||||
mm_graph_node.add_slot_texture_universal(out_random_color)
|
||||
mm_graph_node.add_slot_texture_universal(out_position_x)
|
||||
mm_graph_node.add_slot_texture_universal(out_position_y)
|
||||
mm_graph_node.add_slot_texture_universal(out_brick_uv)
|
||||
mm_graph_node.add_slot_texture_universal(out_corner_uv)
|
||||
mm_graph_node.add_slot_texture_universal(out_direction)
|
||||
|
||||
mm_graph_node.add_slot_enum("get_type", "set_type", "Type", [ "Running Bond", "Running Bond (2)", "HerringBone", "Basket Weave", "Spanish Bond" ])
|
||||
mm_graph_node.add_slot_int("get_repeat", "set_repeat", "Repeat")
|
||||
|
||||
mm_graph_node.add_slot_vector2("get_col_row", "set_col_row", "Col, Row")#, Vector2(1, 32))#, Vector2(0, 32))
|
||||
mm_graph_node.add_slot_float("get_offset", "set_offset", "Offset")
|
||||
|
||||
mm_graph_node.add_slot_float_universal(mortar)
|
||||
mm_graph_node.add_slot_float_universal(bevel)
|
||||
mm_graph_node.add_slot_float_universal(roundness)
|
||||
|
||||
mm_graph_node.add_slot_float("get_corner", "set_corner", "Corner")
|
||||
|
||||
func _render(material) -> void:
|
||||
var bricks_pattern : Image = Image.new()
|
||||
var random_color : Image = Image.new()
|
||||
var position_x : Image = Image.new()
|
||||
var position_y : Image = Image.new()
|
||||
var brick_uv : Image = Image.new()
|
||||
var corner_uv : Image = Image.new()
|
||||
var direction : Image = Image.new()
|
||||
|
||||
bricks_pattern.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
random_color.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
position_x.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
position_y.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
brick_uv.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
corner_uv.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
direction.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
|
||||
bricks_pattern.lock()
|
||||
random_color.lock()
|
||||
position_x.lock()
|
||||
position_y.lock()
|
||||
brick_uv.lock()
|
||||
corner_uv.lock()
|
||||
direction.lock()
|
||||
|
||||
var w : float = material.image_size.x
|
||||
var h : float = material.image_size.y
|
||||
|
||||
var pseed : float = randf() + randi()
|
||||
|
||||
for x in range(material.image_size.x):
|
||||
for y in range(material.image_size.y):
|
||||
var uv : Vector2 = Vector2(x / w, y / h)
|
||||
|
||||
#vec4 $(name_uv)_rect = bricks_$pattern($uv, vec2($columns, $rows), $repeat, $row_offset);
|
||||
var brick_rect : Color = Color()
|
||||
|
||||
#"Running Bond,Running Bond (2),HerringBone,Basket Weave,Spanish Bond"
|
||||
|
||||
if type == 0:
|
||||
brick_rect = MMAlgos.bricks_rb(uv, col_row, repeat, offset)
|
||||
elif type == 1:
|
||||
brick_rect = MMAlgos.bricks_rb2(uv, col_row, repeat, offset)
|
||||
elif type == 2:
|
||||
brick_rect = MMAlgos.bricks_hb(uv, col_row, repeat, offset)
|
||||
elif type == 3:
|
||||
brick_rect = MMAlgos.bricks_bw(uv, col_row, repeat, offset)
|
||||
elif type == 4:
|
||||
brick_rect = MMAlgos.bricks_sb(uv, col_row, repeat, offset)
|
||||
|
||||
|
||||
#vec4 $(name_uv) = brick($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $round*$round_map($uv), max(0.001, $bevel*$bevel_map($uv)));
|
||||
var brick : Color = MMAlgos.brick(uv, Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), mortar.get_value(uv), roundness.get_value(uv), max(0.001, bevel.get_value(uv)))
|
||||
|
||||
#Bricks pattern (float) - A greyscale image that shows the bricks pattern
|
||||
#$(name_uv).x
|
||||
var bricks_pattern_col : Color = Color(brick.r, brick.r, brick.r, 1)
|
||||
|
||||
#Random color (rgb) - A random color for each brick
|
||||
#brick_random_color($(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))
|
||||
var brc : Vector3 = MMAlgos.brick_random_color(Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), 1 / float(pseed))
|
||||
var random_color_col : Color = Color(brc.x, brc.y, brc.z, 1)
|
||||
|
||||
#Position.x (float) - The position of each brick along the X axis",
|
||||
#$(name_uv).y
|
||||
var position_x_col : Color = Color(brick.g, brick.g, brick.g, 1)
|
||||
|
||||
#Position.y (float) - The position of each brick along the Y axis
|
||||
#$(name_uv).z
|
||||
var position_y_col : Color = Color(brick.b, brick.b, brick.b, 1)
|
||||
|
||||
#Brick UV (rgb) - An UV map output for each brick, to be connected to the Map input of a CustomUV node
|
||||
#brick_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, float($seed))
|
||||
var buv : Vector3 = MMAlgos.brick_uv(uv, Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), pseed)
|
||||
var brick_uv_col : Color = Color(buv.x, buv.y, buv.z, 1)
|
||||
|
||||
#Corner UV (rgb) - An UV map output for each brick corner, to be connected to the Map input of a CustomUV node
|
||||
#brick_corner_uv($uv, $(name_uv)_rect.xy, $(name_uv)_rect.zw, $mortar*$mortar_map($uv), $corner, float($seed))
|
||||
var bcuv : Vector3 = MMAlgos.brick_corner_uv(uv, Vector2(brick_rect.r, brick_rect.g), Vector2(brick_rect.b, brick_rect.a), mortar.get_value(uv), corner, pseed)
|
||||
var corner_uv_col : Color = Color(bcuv.x, bcuv.y, bcuv.z, 1)
|
||||
|
||||
#Direction (float) - The direction of each brick (white: horizontal, black: vertical)
|
||||
#0.5*(sign($(name_uv)_rect.z-$(name_uv)_rect.x-$(name_uv)_rect.w+$(name_uv)_rect.y)+1.0)
|
||||
var d : float = 0.5 * (sign(brick_rect.b - brick_rect.r - brick_rect.a + brick_rect.g) + 1.0)
|
||||
var direction_col : Color = Color(d, d, d, 1)
|
||||
|
||||
bricks_pattern.set_pixel(x, y, bricks_pattern_col)
|
||||
random_color.set_pixel(x, y, random_color_col)
|
||||
position_x.set_pixel(x, y, position_x_col)
|
||||
position_y.set_pixel(x, y, position_y_col)
|
||||
brick_uv.set_pixel(x, y, brick_uv_col)
|
||||
corner_uv.set_pixel(x, y, corner_uv_col)
|
||||
direction.set_pixel(x, y, direction_col)
|
||||
|
||||
bricks_pattern.unlock()
|
||||
random_color.unlock()
|
||||
position_x.unlock()
|
||||
position_y.unlock()
|
||||
brick_uv.unlock()
|
||||
corner_uv.unlock()
|
||||
direction.unlock()
|
||||
|
||||
out_bricks_pattern.set_value(bricks_pattern)
|
||||
out_random_color.set_value(random_color)
|
||||
out_position_x.set_value(position_x)
|
||||
out_position_y.set_value(position_y)
|
||||
out_brick_uv.set_value(brick_uv)
|
||||
out_corner_uv.set_value(corner_uv)
|
||||
out_direction.set_value(direction)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
return Color()
|
||||
|
||||
#type
|
||||
func get_type() -> int:
|
||||
return type
|
||||
|
||||
func set_type(val : int) -> void:
|
||||
type = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#repeat
|
||||
func get_repeat() -> int:
|
||||
return repeat
|
||||
|
||||
func set_repeat(val : int) -> void:
|
||||
repeat = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#col_row
|
||||
func get_col_row() -> Vector2:
|
||||
return col_row
|
||||
|
||||
func set_col_row(val : Vector2) -> void:
|
||||
col_row = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#offset
|
||||
func get_offset() -> float:
|
||||
return offset
|
||||
|
||||
func set_offset(val : float) -> void:
|
||||
offset = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#corner
|
||||
func get_corner() -> float:
|
||||
return corner
|
||||
|
||||
func set_corner(val : float) -> void:
|
||||
corner = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Vector2) var size : Vector2 = Vector2(4, 4)
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 1)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var ps : float = 1.0 / float(pseed)
|
||||
|
||||
#IChing(vec2($columns, $rows)*$uv, float($seed))
|
||||
return MMAlgos.IChingc(uv, size, ps)
|
||||
|
||||
#size
|
||||
func get_size() -> Vector2:
|
||||
return size
|
||||
|
||||
func set_size(val : Vector2) -> void:
|
||||
size = val
|
||||
|
||||
set_dirty(true)
|
@ -1,70 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(int, "Multiply,Add,Max,Min,Xor,Pow") var combiner_type : int = 0
|
||||
export(int, "Sine,Triangle,Square,Sawtooth,Constant,Bounce") var combiner_axis_type_x : int = 0
|
||||
export(int, "Sine,Triangle,Square,Sawtooth,Constant,Bounce") var combiner_axis_type_y : int = 0
|
||||
export(Vector2) var repeat : Vector2 = Vector2(4, 4)
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_enum("get_combiner_type", "set_combiner_type", "Combiner Type", [ "Multiply", "Add" , "Max", "Min", "Xor", "Pow" ])
|
||||
mm_graph_node.add_slot_enum("get_combiner_axis_type_x", "set_combiner_axis_type_x", "Combiner Axis type", [ "Sine", "Triangle", "Square", "Sawtooth", "Constant", "Bounce" ])
|
||||
mm_graph_node.add_slot_enum("get_combiner_axis_type_y", "set_combiner_axis_type_y", "", [ "Sine", "Triangle", "Square", "Sawtooth", "Constant", "Bounce" ])
|
||||
mm_graph_node.add_slot_vector2("get_repeat", "set_repeat", "Repeat", 1)#, Vector2(0, 32))
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var f : float = MMAlgos.pattern(uv, repeat.x, repeat.y, combiner_type, combiner_axis_type_x, combiner_axis_type_y)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
#combiner_type
|
||||
func get_combiner_type() -> int:
|
||||
return combiner_type
|
||||
|
||||
func set_combiner_type(val : int) -> void:
|
||||
combiner_type = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#combiner_axis_type_x
|
||||
func get_combiner_axis_type_x() -> int:
|
||||
return combiner_axis_type_x
|
||||
|
||||
func set_combiner_axis_type_x(val : int) -> void:
|
||||
combiner_axis_type_x = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#combiner_axis_type_y
|
||||
func get_combiner_axis_type_y() -> int:
|
||||
return combiner_axis_type_y
|
||||
|
||||
func set_combiner_axis_type_y(val : int) -> void:
|
||||
combiner_axis_type_y = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#repeat
|
||||
func get_repeat() -> Vector2:
|
||||
return repeat
|
||||
|
||||
func set_repeat(val : Vector2) -> void:
|
||||
repeat = val
|
||||
|
||||
set_dirty(true)
|
@ -1,38 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Vector2) var size : Vector2 = Vector2(4, 4)
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 1)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var ps : float = 1.0 / float(pseed)
|
||||
|
||||
#Rune(vec2($columns, $rows)*$uv, float($seed))
|
||||
return MMAlgos.runesc(uv, size, ps)
|
||||
|
||||
#size
|
||||
func get_size() -> Vector2:
|
||||
return size
|
||||
|
||||
func set_size(val : Vector2) -> void:
|
||||
size = val
|
||||
|
||||
set_dirty(true)
|
@ -1,80 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Vector2) var size : Vector2 = Vector2(0.25, 0.4)
|
||||
export(int) var layers : int = 4
|
||||
export(float) var waviness : float = 0.51
|
||||
export(int) var angle : int = 0
|
||||
export(float) var randomness : float = 0.44
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 0.01)
|
||||
mm_graph_node.add_slot_int("get_layers", "set_layers", "Layers")
|
||||
mm_graph_node.add_slot_float("get_waviness", "set_waviness", "Waviness", 0.01)
|
||||
mm_graph_node.add_slot_int("get_angle", "set_angle", "Angle")
|
||||
mm_graph_node.add_slot_float("get_randomness", "set_randomness", "Randomness", 0.01)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
#scratches($uv, int($layers), vec2($length, $width), $waviness, $angle, $randomness, vec2(float($seed), 0.0))
|
||||
return MMAlgos.scratchesc(uv, layers, size, waviness, angle, randomness, Vector2(pseed, 0.0))
|
||||
|
||||
#size
|
||||
func get_size() -> Vector2:
|
||||
return size
|
||||
|
||||
func set_size(val : Vector2) -> void:
|
||||
size = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#layers
|
||||
func get_layers() -> int:
|
||||
return layers
|
||||
|
||||
func set_layers(val : int) -> void:
|
||||
layers = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#waviness
|
||||
func get_waviness() -> float:
|
||||
return waviness
|
||||
|
||||
func set_waviness(val : float) -> void:
|
||||
waviness = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#angle
|
||||
func get_angle() -> int:
|
||||
return angle
|
||||
|
||||
func set_angle(val : int) -> void:
|
||||
angle = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#randomness
|
||||
func get_randomness() -> float:
|
||||
return randomness
|
||||
|
||||
func set_randomness(val : float) -> void:
|
||||
randomness = val
|
||||
|
||||
set_dirty(true)
|
@ -1,59 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(float) var amplitude : float = 0.5
|
||||
export(float) var frequency : float = 2
|
||||
export(float) var phase : float = 0
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_float("get_amplitude", "set_amplitude", "Amplitude", 0.01)
|
||||
mm_graph_node.add_slot_float("get_frequency", "set_frequency", "Frequency", 0.1)
|
||||
mm_graph_node.add_slot_float("get_phase", "set_phase", "Phase", 0.01)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var f : float = 1.0 - abs(2.0 * (uv.y - 0.5) - amplitude *sin((frequency * uv.x + phase)*6.28318530718))
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
#amplitude
|
||||
func get_amplitude() -> float:
|
||||
return amplitude
|
||||
|
||||
func set_amplitude(val : float) -> void:
|
||||
amplitude = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#frequency
|
||||
func get_frequency() -> float:
|
||||
return frequency
|
||||
|
||||
func set_frequency(val : float) -> void:
|
||||
frequency = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#phase
|
||||
func get_phase() -> float:
|
||||
return phase
|
||||
|
||||
func set_phase(val : float) -> void:
|
||||
phase = val
|
||||
|
||||
set_dirty(true)
|
@ -1,51 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(int, "Line,Circle") var shape : int = 0
|
||||
export(float) var size : float = 4
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(image)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_enum("get_shape", "set_shape", "Shape", [ "Line", "Circle" ])
|
||||
mm_graph_node.add_slot_float("get_size", "set_size", "Size", 1)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
if shape == 0:
|
||||
return MMAlgos.truchet1c(uv, size, pseed)
|
||||
elif shape == 1:
|
||||
return MMAlgos.truchet2c(uv, size, pseed)
|
||||
|
||||
return Color()
|
||||
|
||||
#shape
|
||||
func get_shape() -> int:
|
||||
return shape
|
||||
|
||||
func set_shape(val : int) -> void:
|
||||
shape = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#size
|
||||
func get_size() -> float:
|
||||
return size
|
||||
|
||||
func set_size(val : float) -> void:
|
||||
size = val
|
||||
|
||||
set_dirty(true)
|
@ -1,132 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var out_main : Resource
|
||||
export(Resource) var out_horizontal_map : Resource
|
||||
export(Resource) var out_vertical_map : Resource
|
||||
|
||||
export(Vector2) var size : Vector2 = Vector2(4, 4)
|
||||
export(Resource) var width : Resource
|
||||
export(int) var stitch : int = 1
|
||||
|
||||
func _init_properties():
|
||||
if !out_main:
|
||||
out_main = MMNodeUniversalProperty.new()
|
||||
out_main.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_main.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_horizontal_map:
|
||||
out_horizontal_map = MMNodeUniversalProperty.new()
|
||||
out_horizontal_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_horizontal_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_vertical_map:
|
||||
out_vertical_map = MMNodeUniversalProperty.new()
|
||||
out_vertical_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_vertical_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !width:
|
||||
width = MMNodeUniversalProperty.new()
|
||||
width.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
width.set_default_value(Vector2(0.9, 0.9))
|
||||
|
||||
width.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
width.slot_name = "Width"
|
||||
width.value_step = 0.01
|
||||
width.value_range = Vector2(0, 1)
|
||||
|
||||
register_output_property(out_main)
|
||||
register_output_property(out_horizontal_map)
|
||||
register_output_property(out_vertical_map)
|
||||
|
||||
register_input_property(width)
|
||||
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(out_main)
|
||||
mm_graph_node.add_slot_texture_universal(out_horizontal_map)
|
||||
mm_graph_node.add_slot_texture_universal(out_vertical_map)
|
||||
|
||||
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size")#, Vector2(1, 32))#, Vector2(0, 32))
|
||||
mm_graph_node.add_slot_vector2_universal(width)
|
||||
|
||||
mm_graph_node.add_slot_int("get_stitch", "set_stitch", "Stitch")
|
||||
|
||||
|
||||
func _render(material) -> void:
|
||||
var main_pattern : Image = Image.new()
|
||||
var horizontal_map : Image = Image.new()
|
||||
var vertical_map : Image = Image.new()
|
||||
|
||||
main_pattern.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
horizontal_map.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
vertical_map.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
|
||||
main_pattern.lock()
|
||||
horizontal_map.lock()
|
||||
vertical_map.lock()
|
||||
|
||||
var w : float = material.image_size.x
|
||||
var h : float = material.image_size.y
|
||||
|
||||
var pseed : float = randf() + randi()
|
||||
|
||||
for x in range(material.image_size.x):
|
||||
for y in range(material.image_size.y):
|
||||
var uv : Vector2 = Vector2(x / w, y / h)
|
||||
|
||||
var width_val : Vector2 = width.get_value(uv)
|
||||
|
||||
#vec3 $(name_uv) = weave2($uv, vec2($columns, $rows), $stitch, $width_x*$width_map($uv), $width_y*$width_map($uv));
|
||||
var weave : Vector3 = MMAlgos.weave2(uv, size, stitch, width_val.x, width_val.y);
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output (float) - Shows the generated greyscale weave pattern.
|
||||
#$(name_uv).x
|
||||
var main_pattern_col : Color = Color(weave.x, weave.x, weave.x, 1)
|
||||
|
||||
#Horizontal mask (float) - Horizontal mask
|
||||
#$(name_uv).y
|
||||
var horizontal_map_col : Color = Color(weave.y, weave.y, weave.y, 1)
|
||||
|
||||
#Vertical mask (float) - Mask for vertical stripes
|
||||
#$(name_uv).z
|
||||
var vertical_map_col : Color = Color(weave.z, weave.z, weave.z, 1)
|
||||
|
||||
main_pattern.set_pixel(x, y, main_pattern_col)
|
||||
horizontal_map.set_pixel(x, y, horizontal_map_col)
|
||||
vertical_map.set_pixel(x, y, vertical_map_col)
|
||||
|
||||
main_pattern.unlock()
|
||||
horizontal_map.unlock()
|
||||
vertical_map.unlock()
|
||||
|
||||
out_main.set_value(main_pattern)
|
||||
out_horizontal_map.set_value(horizontal_map)
|
||||
out_vertical_map.set_value(vertical_map)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
return Color()
|
||||
|
||||
#size
|
||||
func get_size() -> Vector2:
|
||||
return size
|
||||
|
||||
func set_size(val : Vector2) -> void:
|
||||
size = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#stitch
|
||||
func get_stitch() -> int:
|
||||
return stitch
|
||||
|
||||
func set_stitch(val : int) -> void:
|
||||
stitch = val
|
||||
|
||||
set_dirty(true)
|
||||
|
@ -1,51 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(float) var width : float = 0.1
|
||||
export(int) var ripples : int = 1
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
#output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Apply >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(output)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01)
|
||||
mm_graph_node.add_slot_int("get_ripples", "set_ripples", "Ripples")
|
||||
|
||||
func _get_property_value(uv : Vector2):
|
||||
var val : float = output.get_value(uv, true)
|
||||
|
||||
return MMAlgos.sdRipples(val, width, ripples)
|
||||
|
||||
#width
|
||||
func get_width() -> float:
|
||||
return width
|
||||
|
||||
func set_width(val : float) -> void:
|
||||
width = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#ripples
|
||||
func get_ripples() -> int:
|
||||
return ripples
|
||||
|
||||
func set_ripples(val : int) -> void:
|
||||
ripples = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,73 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input1 : Resource
|
||||
export(Resource) var input2 : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(int, "Union,Substraction,Intersection") var operation : int = 0
|
||||
|
||||
func _init_properties():
|
||||
if !input1:
|
||||
input1 = MMNodeUniversalProperty.new()
|
||||
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
input1.slot_name = ">>> Input 1 "
|
||||
if !input1.is_connected("changed", self, "on_input_changed"):
|
||||
input1.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !input2:
|
||||
input2 = MMNodeUniversalProperty.new()
|
||||
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
input2.slot_name = ">>> Input 2 "
|
||||
|
||||
if !input2.is_connected("changed", self, "on_input_changed"):
|
||||
input2.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = " Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input1)
|
||||
register_input_property(input2)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input1)
|
||||
mm_graph_node.add_slot_label_universal(input2)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "Union", "Substraction", "Intersection" ])
|
||||
|
||||
func _get_property_value(uv : Vector2) -> float:
|
||||
if operation == 0:
|
||||
return MMAlgos.sdf_boolean_union(input1.get_value(uv), input2.get_value(uv))
|
||||
elif operation == 1:
|
||||
return MMAlgos.sdf_boolean_substraction(input1.get_value(uv), input2.get_value(uv))
|
||||
elif operation == 2:
|
||||
return MMAlgos.sdf_boolean_intersection(input1.get_value(uv), input2.get_value(uv))
|
||||
|
||||
return 0.0
|
||||
|
||||
#operation
|
||||
func get_operation() -> int:
|
||||
return operation
|
||||
|
||||
func set_operation(val : int) -> void:
|
||||
operation = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,41 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(int) var count : int = 6
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
#output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Apply >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(output)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_int("get_count", "set_count", "Count")
|
||||
|
||||
func _get_property_value(uv : Vector2):
|
||||
#$in(circle_repeat_transform_2d($uv-vec2(0.5), $c)+vec2(0.5))
|
||||
var new_uv : Vector2 = MMAlgos.circle_repeat_transform_2d(uv - Vector2(0.5, 0.5), count) + Vector2(0.5, 0.5)
|
||||
|
||||
return output.get_value(new_uv, true)
|
||||
|
||||
#count
|
||||
func get_count() -> int:
|
||||
return count
|
||||
|
||||
func set_count(val : int) -> void:
|
||||
count = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
@ -1,66 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input1 : Resource
|
||||
export(Resource) var input2 : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(float) var amount : float = 0.5
|
||||
|
||||
func _init_properties():
|
||||
if !input1:
|
||||
input1 = MMNodeUniversalProperty.new()
|
||||
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
input1.slot_name = ">>> Input 1 "
|
||||
if !input1.is_connected("changed", self, "on_input_changed"):
|
||||
input1.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !input2:
|
||||
input2 = MMNodeUniversalProperty.new()
|
||||
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
input2.slot_name = ">>> Input 2 "
|
||||
|
||||
if !input2.is_connected("changed", self, "on_input_changed"):
|
||||
input2.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = " Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input1)
|
||||
register_input_property(input2)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input1)
|
||||
mm_graph_node.add_slot_label_universal(input2)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_float("get_amount", "set_amount", "Amount", 0.01)
|
||||
|
||||
func _get_property_value(uv : Vector2) -> float:
|
||||
return MMAlgos.sdf_morph(input1.get_value(uv), input2.get_value(uv), amount)
|
||||
|
||||
#amount
|
||||
func get_amount() -> float:
|
||||
return amount
|
||||
|
||||
func set_amount(val : float) -> void:
|
||||
amount = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,66 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(int) var x : int = 3
|
||||
export(int) var y : int = 3
|
||||
export(float) var random_rotation : float = 0.5
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
#output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Apply >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(output)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_int("get_x", "set_x", "X")
|
||||
mm_graph_node.add_slot_int("get_y", "set_y", "Y")
|
||||
mm_graph_node.add_slot_float("get_random_rotation", "set_random_rotation", "Random rotation", 0.01)
|
||||
|
||||
func _get_property_value(uv : Vector2):
|
||||
#todo add this as a parameter
|
||||
var pseed : int = 123123
|
||||
|
||||
#$in(repeat_2d($uv, vec2(1.0/$rx, 1.0/$ry), float($seed), $r))
|
||||
var new_uv : Vector2 = MMAlgos.repeat_2d(uv, Vector2(1.0 / float(x), 1.0/ float(y)), 1.0/float(pseed), random_rotation)
|
||||
|
||||
return output.get_value(new_uv, true)
|
||||
#x
|
||||
func get_x() -> int:
|
||||
return x
|
||||
|
||||
func set_x(val : int) -> void:
|
||||
x = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#y
|
||||
func get_y() -> int:
|
||||
return y
|
||||
|
||||
func set_y(val : int) -> void:
|
||||
y = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#random_rotation
|
||||
func get_random_rotation() -> float:
|
||||
return random_rotation
|
||||
|
||||
func set_random_rotation(val : float) -> void:
|
||||
random_rotation = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,40 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(float) var radius : float = 0
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
#output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Apply >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(output)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01)
|
||||
|
||||
func _get_property_value(uv : Vector2):
|
||||
var val : float = output.get_value(uv, true)
|
||||
|
||||
return MMAlgos.sdf_rounded_shape(val, radius)
|
||||
|
||||
#radius
|
||||
func get_radius() -> float:
|
||||
return radius
|
||||
|
||||
func set_radius(val : float) -> void:
|
||||
radius = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
@ -1,85 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input1 : Resource
|
||||
export(Resource) var input2 : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(int, "Union,Substraction,Intersection") var operation : int = 0
|
||||
export(float) var smoothness : float = 0.15
|
||||
|
||||
func _init_properties():
|
||||
if !input1:
|
||||
input1 = MMNodeUniversalProperty.new()
|
||||
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
input1.slot_name = ">>> Input 1 "
|
||||
if !input1.is_connected("changed", self, "on_input_changed"):
|
||||
input1.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !input2:
|
||||
input2 = MMNodeUniversalProperty.new()
|
||||
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
input2.slot_name = ">>> Input 2 "
|
||||
|
||||
if !input2.is_connected("changed", self, "on_input_changed"):
|
||||
input2.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = " Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input1)
|
||||
register_input_property(input2)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input1)
|
||||
mm_graph_node.add_slot_label_universal(input2)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "Union", "Substraction", "Intersection" ])
|
||||
mm_graph_node.add_slot_float("get_smoothness", "set_smoothness", "Smoothness", 0.01)
|
||||
|
||||
func _get_property_value(uv : Vector2) -> float:
|
||||
if operation == 0:
|
||||
return MMAlgos.sdf_smooth_boolean_union(input1.get_value(uv), input2.get_value(uv), smoothness)
|
||||
elif operation == 1:
|
||||
return MMAlgos.sdf_smooth_boolean_substraction(input1.get_value(uv), input2.get_value(uv), smoothness)
|
||||
elif operation == 2:
|
||||
return MMAlgos.sdf_smooth_boolean_intersection(input1.get_value(uv), input2.get_value(uv), smoothness)
|
||||
|
||||
return 0.0
|
||||
|
||||
#operation
|
||||
func get_operation() -> int:
|
||||
return operation
|
||||
|
||||
func set_operation(val : int) -> void:
|
||||
operation = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#smoothness
|
||||
func get_smoothness() -> float:
|
||||
return smoothness
|
||||
|
||||
func set_smoothness(val : float) -> void:
|
||||
smoothness = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,58 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(Vector2) var angle : Vector2 = Vector2(30, 150)
|
||||
export(float) var radius : float = 0.3
|
||||
export(float) var width : float = 0.1
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_vector2("get_angle", "set_angle", "Angle", 1)
|
||||
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01)
|
||||
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01)
|
||||
|
||||
func _get_property_value(uv : Vector2) -> float:
|
||||
return MMAlgos.sdf_arc(uv, angle, Vector2(radius, width))
|
||||
|
||||
#angle
|
||||
func get_angle() -> Vector2:
|
||||
return angle
|
||||
|
||||
func set_angle(val : Vector2) -> void:
|
||||
angle = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#radius
|
||||
func get_radius() -> float:
|
||||
return radius
|
||||
|
||||
func set_radius(val : float) -> void:
|
||||
radius = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#width
|
||||
func get_width() -> float:
|
||||
return width
|
||||
|
||||
func set_width(val : float) -> void:
|
||||
width = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,46 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(Vector2) var center : Vector2 = Vector2(0, 0)
|
||||
export(Vector2) var size : Vector2 = Vector2(0.3, 0.2)
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_vector2("get_center", "set_center", "Center", 0.01)
|
||||
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 0.01)
|
||||
|
||||
func _get_property_value(uv : Vector2) -> float:
|
||||
return MMAlgos.sdf_box(uv, center, size)
|
||||
|
||||
#center
|
||||
func get_center() -> Vector2:
|
||||
return center
|
||||
|
||||
func set_center(val : Vector2) -> void:
|
||||
center = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#size
|
||||
func get_size() -> Vector2:
|
||||
return size
|
||||
|
||||
func set_size(val : Vector2) -> void:
|
||||
size = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,46 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(Vector2) var center : Vector2 = Vector2(0, 0)
|
||||
export(float) var radius : float = 0.4
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_vector2("get_center", "set_center", "Center", 0.01)
|
||||
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01)
|
||||
|
||||
func _get_property_value(uv : Vector2) -> float:
|
||||
return MMAlgos.sdf_circle(uv, center, radius)
|
||||
|
||||
#center
|
||||
func get_center() -> Vector2:
|
||||
return center
|
||||
|
||||
func set_center(val : Vector2) -> void:
|
||||
center = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#radius
|
||||
func get_radius() -> float:
|
||||
return radius
|
||||
|
||||
func set_radius(val : float) -> void:
|
||||
radius = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,70 +0,0 @@
|
||||
tool
|
||||
extends CurveBase
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(Vector2) var A : Vector2 = Vector2(-0.3, -0.3)
|
||||
export(Vector2) var B : Vector2 = Vector2(0.3, 0.3)
|
||||
export(float) var width : float = 0.1
|
||||
|
||||
func _init():
|
||||
init_points_11()
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_vector2("get_a", "set_a", "A", 0.01)
|
||||
mm_graph_node.add_slot_vector2("get_b", "set_b", "B", 0.01)
|
||||
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01)
|
||||
mm_graph_node.add_slot_curve()
|
||||
|
||||
func _get_property_value(uv : Vector2) -> float:
|
||||
var line : Vector2 = MMAlgos.sdf_line(uv, A, B, width)
|
||||
|
||||
#$(name_uv)_sdl.x - $r * $profile($(name_uv)_sdl.y)
|
||||
|
||||
return line.x - width * MMAlgos.curve(line.y, points_array)
|
||||
|
||||
#a
|
||||
func get_a() -> Vector2:
|
||||
return A
|
||||
|
||||
func set_a(val : Vector2) -> void:
|
||||
A = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#b
|
||||
func get_b() -> Vector2:
|
||||
return B
|
||||
|
||||
func set_b(val : Vector2) -> void:
|
||||
B = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#width
|
||||
func get_width() -> float:
|
||||
return width
|
||||
|
||||
func set_width(val : float) -> void:
|
||||
width = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func _curve_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,26 +0,0 @@
|
||||
tool
|
||||
extends PolygonBase
|
||||
|
||||
export(Resource) var output : Resource
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
mm_graph_node.add_slot_polygon()
|
||||
|
||||
func _get_property_value(uv : Vector2) -> float:
|
||||
return MMAlgos.sdPolygon(uv, points)
|
||||
|
||||
func _polygon_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,46 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(Vector2) var center : Vector2 = Vector2(0, 0)
|
||||
export(Vector2) var size : Vector2 = Vector2(0.3, 0.2)
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_vector2("get_center", "set_center", "Center", 0.01)
|
||||
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 0.01)
|
||||
|
||||
func _get_property_value(uv : Vector2) -> float:
|
||||
return MMAlgos.sdf_rhombus(uv, center, size)
|
||||
|
||||
#center
|
||||
func get_center() -> Vector2:
|
||||
return center
|
||||
|
||||
func set_center(val : Vector2) -> void:
|
||||
center = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#size
|
||||
func get_size() -> Vector2:
|
||||
return size
|
||||
|
||||
func set_size(val : Vector2) -> void:
|
||||
size = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,64 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
export(float) var bevel : float = 0
|
||||
export(float) var base : float = 0
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
#for some reason this doesn't work, todo check
|
||||
# input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = "Input"
|
||||
|
||||
register_output_property(image)
|
||||
register_input_property(input)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_texture_universal(image)
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
|
||||
mm_graph_node.add_slot_float("get_bevel", "set_bevel", "Bevel", 0.01)
|
||||
mm_graph_node.add_slot_float("get_base", "set_base", "Base", 0.01)
|
||||
|
||||
func _render(material) -> void:
|
||||
var img : Image = render_image(material)
|
||||
|
||||
image.set_value(img)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
var f : float = input.get_value(uv)
|
||||
|
||||
#clamp($base-$in($uv)/max($bevel, 0.00001), 0.0, 1.0)
|
||||
var cf : float = clamp(base - f / max(bevel, 0.00001), 0.0, 1.0)
|
||||
|
||||
return Color(cf, cf, cf, 1)
|
||||
|
||||
#bevel
|
||||
func get_bevel() -> float:
|
||||
return bevel
|
||||
|
||||
func set_bevel(val : float) -> void:
|
||||
bevel = val
|
||||
|
||||
set_dirty(true)
|
||||
|
||||
#base
|
||||
func get_base() -> float:
|
||||
return base
|
||||
|
||||
func set_base(val : float) -> void:
|
||||
base = val
|
||||
|
||||
set_dirty(true)
|
@ -1,39 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(float) var angle : float = 0
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
#output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Apply >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(output)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_float("get_angle", "set_angle", "Angle", 1)
|
||||
|
||||
func _get_property_value(uv : Vector2):
|
||||
#$in(sdf2d_rotate($uv, $a*0.01745329251))",
|
||||
return output.get_value(MMAlgos.sdf2d_rotate(uv, angle * 0.01745329251), true)
|
||||
|
||||
#angle
|
||||
func get_angle() -> float:
|
||||
return angle
|
||||
|
||||
func set_angle(val : float) -> void:
|
||||
angle = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
@ -1,39 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(float) var scale : float = 1
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
#output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Apply >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(output)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_float("get_scale", "set_scale", "Scale", 0.01)
|
||||
|
||||
func _get_property_value(uv : Vector2):
|
||||
#$in(($uv-vec2(0.5))/$s+vec2(0.5))*$s
|
||||
return output.get_value(((uv - Vector2(0.5, 0.5)) / scale + Vector2(0.5, 0.5)), true)
|
||||
|
||||
#scale
|
||||
func get_scale() -> float:
|
||||
return scale
|
||||
|
||||
func set_scale(val : float) -> void:
|
||||
scale = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
@ -1,38 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var output : Resource
|
||||
export(Vector2) var translation : Vector2 = Vector2(0, 0)
|
||||
|
||||
func _init_properties():
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
#output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Apply >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(output)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_vector2("get_translation", "set_translation", "Translation", 0.01)
|
||||
|
||||
func _get_property_value(uv : Vector2):
|
||||
return output.get_value(uv - translation, true)
|
||||
|
||||
#a
|
||||
func get_translation() -> Vector2:
|
||||
return translation
|
||||
|
||||
func set_translation(val : Vector2) -> void:
|
||||
translation = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
@ -1,56 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(float) var color : float = 0.5
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2
|
||||
input.slot_name = ">>> Input "
|
||||
if !input.is_connected("changed", self, "on_input_changed"):
|
||||
input.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_float("get_color", "set_color", "Color", 0.01)
|
||||
|
||||
func _get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
var v : Vector2 = input.get_value_sdf3d(uv3)
|
||||
|
||||
v.y = color
|
||||
|
||||
return v
|
||||
|
||||
|
||||
#color
|
||||
func get_color() -> float:
|
||||
return color
|
||||
|
||||
func set_color(val : float) -> void:
|
||||
color = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,76 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input1 : Resource
|
||||
export(Resource) var input2 : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(int, "Union,Substraction,Intersection") var operation : int = 0
|
||||
|
||||
func _init_properties():
|
||||
if !input1:
|
||||
input1 = MMNodeUniversalProperty.new()
|
||||
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2
|
||||
input1.slot_name = ">>> Input 1 "
|
||||
|
||||
if !input1.is_connected("changed", self, "on_input_changed"):
|
||||
input1.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !input2:
|
||||
input2 = MMNodeUniversalProperty.new()
|
||||
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2
|
||||
input2.slot_name = ">>> Input 2 "
|
||||
|
||||
if !input2.is_connected("changed", self, "on_input_changed"):
|
||||
input2.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input1)
|
||||
register_input_property(input2)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input1)
|
||||
mm_graph_node.add_slot_label_universal(input2)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "Union", "Substraction", "Intersection" ])
|
||||
|
||||
func _get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
var s1 : Vector2 = input1.get_value_sdf3d(uv3)
|
||||
var s2 : Vector2 = input2.get_value_sdf3d(uv3)
|
||||
|
||||
if operation == 0:
|
||||
return MMAlgos.sdf3dc_union(s1, s2)
|
||||
elif operation == 1:
|
||||
return MMAlgos.sdf3dc_sub(s1, s2)
|
||||
elif operation == 2:
|
||||
return MMAlgos.sdf3dc_inter(s1, s2)
|
||||
|
||||
return Vector2()
|
||||
|
||||
#operation
|
||||
func get_operation() -> int:
|
||||
return operation
|
||||
|
||||
func set_operation(val : int) -> void:
|
||||
operation = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,56 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(int) var count : int = 5
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !input.is_connected("changed", self, "on_input_changed"):
|
||||
input.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_int("get_count", "set_count", "Count")
|
||||
|
||||
func _get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
#todo make seed a class variable probably into MMNode
|
||||
|
||||
var new_uv : Vector3 = MMAlgos.circle_repeat_transform(uv3, count)
|
||||
|
||||
return input.get_value_sdf3d(new_uv)
|
||||
|
||||
#count
|
||||
func get_count() -> int:
|
||||
return count
|
||||
|
||||
func set_count(val : int) -> void:
|
||||
count = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,56 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(Vector3) var length : Vector3 = Vector3(0.2, 0, 0)
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2
|
||||
input.slot_name = ">>> Input "
|
||||
if !input.is_connected("changed", self, "on_input_changed"):
|
||||
input.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_vector3("get_length", "set_length", "Length", 0.01)
|
||||
|
||||
func _get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
#$in($uv - clamp($uv, -abs(vec3($x, $y, $z)), abs(vec3($x, $y, $z))))
|
||||
|
||||
var new_uv : Vector3 = uv3 - MMAlgos.clampv3(uv3, -MMAlgos.absv3(length), MMAlgos.absv3(length))
|
||||
|
||||
return input.get_value_sdf3d(new_uv)
|
||||
|
||||
|
||||
#length
|
||||
func get_length() -> Vector3:
|
||||
return length
|
||||
|
||||
func set_length(val : Vector3) -> void:
|
||||
length = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,60 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(float) var length : float = 0.25
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !input.is_connected("changed", self, "on_input_changed"):
|
||||
input.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_float("get_length", "set_length", "Length", 0.01)
|
||||
|
||||
func _get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
#vec2 $(name_uv)_w = vec2($in($uv.xz+vec2(0.5)),abs($uv.y)-$d);
|
||||
#ret min(max($(name_uv)_w.x,$(name_uv)_w.y),0.0)+length(max($(name_uv)_w,0.0))
|
||||
|
||||
var f : float = input.get_value(Vector2(uv3.x, uv3.z) + Vector2(0.5, 0.5))
|
||||
var w : Vector2 = Vector2(f, abs(uv3.y) - length)
|
||||
|
||||
var ff : float = min(max(w.x,w.y),0.0) + MMAlgos.maxv2(w, Vector2()).length()
|
||||
|
||||
return Vector2(ff, 0)
|
||||
|
||||
#length
|
||||
func get_length() -> float:
|
||||
return length
|
||||
|
||||
func set_length(val : float) -> void:
|
||||
length = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,71 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input1 : Resource
|
||||
export(Resource) var input2 : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(float) var amount : float = 0.5
|
||||
|
||||
func _init_properties():
|
||||
if !input1:
|
||||
input1 = MMNodeUniversalProperty.new()
|
||||
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2
|
||||
input1.slot_name = ">>> Input 1 "
|
||||
|
||||
if !input1.is_connected("changed", self, "on_input_changed"):
|
||||
input1.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !input2:
|
||||
input2 = MMNodeUniversalProperty.new()
|
||||
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2
|
||||
input2.slot_name = ">>> Input 2 "
|
||||
|
||||
if !input2.is_connected("changed", self, "on_input_changed"):
|
||||
input2.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input1)
|
||||
register_input_property(input2)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input1)
|
||||
mm_graph_node.add_slot_label_universal(input2)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_float("get_amount", "set_amount", "Amount", 0.01)
|
||||
|
||||
func _get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
var s1 : Vector2 = input1.get_value_sdf3d(uv3)
|
||||
var s2 : Vector2 = input2.get_value_sdf3d(uv3)
|
||||
|
||||
#mix($in1($uv), $in2($uv), $amount)
|
||||
|
||||
return lerp(s1, s2, amount)
|
||||
|
||||
#amount
|
||||
func get_amount() -> float:
|
||||
return amount
|
||||
|
||||
func set_amount(val : float) -> void:
|
||||
amount = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,68 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(Vector2) var col_row : Vector2 = Vector2(3, 3)
|
||||
export(float) var rotation : float = 0.3
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !input.is_connected("changed", self, "on_input_changed"):
|
||||
input.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_vector2("get_col_row", "set_col_row", "Col,Row", 1)
|
||||
mm_graph_node.add_slot_float("get_rotation", "set_rotation", "Rotation", 0.01)
|
||||
|
||||
func _get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
#todo make seed a class variable probably into MMNode
|
||||
|
||||
var new_uv : Vector3 = MMAlgos.sdf3d_repeat(uv3, col_row, rotation, 1)
|
||||
|
||||
return input.get_value_sdf3d(new_uv)
|
||||
|
||||
#col_row
|
||||
func get_col_row() -> Vector2:
|
||||
return col_row
|
||||
|
||||
func set_col_row(val : Vector2) -> void:
|
||||
col_row = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#rotation
|
||||
func get_rotation() -> float:
|
||||
return rotation
|
||||
|
||||
func set_rotation(val : float) -> void:
|
||||
rotation = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,57 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(float) var offset : float = 0.25
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !input.is_connected("changed", self, "on_input_changed"):
|
||||
input.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_float("get_offset", "set_offset", "Offset", 0.01)
|
||||
|
||||
func _get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
#vec2 $(name_uv)_q = vec2(length($uv.xy) - $d + 0.5, $uv.z + 0.5);
|
||||
|
||||
var uv : Vector2 = Vector2(Vector2(uv3.x, uv3.y).length() - offset + 0.5, uv3.z + 0.5)
|
||||
var f : float = input.get_value(uv)
|
||||
|
||||
return Vector2(f, 0)
|
||||
|
||||
#offset
|
||||
func get_offset() -> float:
|
||||
return offset
|
||||
|
||||
func set_offset(val : float) -> void:
|
||||
offset = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,58 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(float) var radius : float = 0.15
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2
|
||||
input.slot_name = ">>> Input "
|
||||
if !input.is_connected("changed", self, "on_input_changed"):
|
||||
input.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01)
|
||||
|
||||
func _get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
var v : Vector2 = input.get_value_sdf3d(uv3)
|
||||
|
||||
#vec2($(name_uv)_v.x-$r, $(name_uv)_v.y)
|
||||
|
||||
v.x -= radius
|
||||
|
||||
return v
|
||||
|
||||
|
||||
#radius
|
||||
func get_radius() -> float:
|
||||
return radius
|
||||
|
||||
func set_radius(val : float) -> void:
|
||||
radius = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,88 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input1 : Resource
|
||||
export(Resource) var input2 : Resource
|
||||
export(Resource) var output : Resource
|
||||
export(int, "Union,Substraction,Intersection") var operation : int = 0
|
||||
export(float) var smoothness : float = 0.15
|
||||
|
||||
func _init_properties():
|
||||
if !input1:
|
||||
input1 = MMNodeUniversalProperty.new()
|
||||
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2
|
||||
input1.slot_name = ">>> Input 1 "
|
||||
|
||||
if !input1.is_connected("changed", self, "on_input_changed"):
|
||||
input1.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !input2:
|
||||
input2 = MMNodeUniversalProperty.new()
|
||||
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
# input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_VECTOR2
|
||||
input2.slot_name = ">>> Input 2 "
|
||||
|
||||
if !input2.is_connected("changed", self, "on_input_changed"):
|
||||
input2.connect("changed", self, "on_input_changed")
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
output.slot_name = ">>> Output >>>"
|
||||
output.get_value_from_owner = true
|
||||
|
||||
register_input_property(input1)
|
||||
register_input_property(input2)
|
||||
register_output_property(output)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input1)
|
||||
mm_graph_node.add_slot_label_universal(input2)
|
||||
mm_graph_node.add_slot_label_universal(output)
|
||||
|
||||
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "Union", "Substraction", "Intersection" ])
|
||||
mm_graph_node.add_slot_float("get_smoothness", "set_smoothness", "Smoothness", 0.01)
|
||||
|
||||
func _get_property_value_sdf3d(uv3 : Vector3) -> Vector2:
|
||||
var s1 : Vector2 = input1.get_value_sdf3d(uv3)
|
||||
var s2 : Vector2 = input2.get_value_sdf3d(uv3)
|
||||
|
||||
if operation == 0:
|
||||
return MMAlgos.sdf3d_smooth_union(s1, s2, smoothness)
|
||||
elif operation == 1:
|
||||
return MMAlgos.sdf3d_smooth_subtraction(s1, s2, smoothness)
|
||||
elif operation == 2:
|
||||
return MMAlgos.sdf3d_smooth_intersection(s1, s2, smoothness)
|
||||
|
||||
return Vector2()
|
||||
|
||||
#operation
|
||||
func get_operation() -> int:
|
||||
return operation
|
||||
|
||||
func set_operation(val : int) -> void:
|
||||
operation = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
#smoothness
|
||||
func get_smoothness() -> float:
|
||||
return smoothness
|
||||
|
||||
func set_smoothness(val : float) -> void:
|
||||
smoothness = val
|
||||
|
||||
emit_changed()
|
||||
output.emit_changed()
|
||||
|
||||
func on_input_changed() -> void:
|
||||
emit_changed()
|
||||
output.emit_changed()
|
@ -1,176 +0,0 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var input : Resource
|
||||
|
||||
export(Resource) var out_height_map : Resource
|
||||
export(Resource) var out_normal_map : Resource
|
||||
export(Resource) var out_color_map : Resource
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_VECTOR2
|
||||
|
||||
#for some reason this doesn't work, todo check
|
||||
# input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT
|
||||
input.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = "Input"
|
||||
|
||||
if !out_height_map:
|
||||
out_height_map = MMNodeUniversalProperty.new()
|
||||
out_height_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_height_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_normal_map:
|
||||
out_normal_map = MMNodeUniversalProperty.new()
|
||||
out_normal_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_normal_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_color_map:
|
||||
out_color_map = MMNodeUniversalProperty.new()
|
||||
out_color_map.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_color_map.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_IMAGE
|
||||
|
||||
register_output_property(out_height_map)
|
||||
register_output_property(out_normal_map)
|
||||
register_output_property(out_color_map)
|
||||
register_input_property(input)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
mm_graph_node.add_slot_label_universal(input)
|
||||
mm_graph_node.add_slot_texture_universal(out_height_map)
|
||||
mm_graph_node.add_slot_texture_universal(out_normal_map)
|
||||
mm_graph_node.add_slot_texture_universal(out_color_map)
|
||||
|
||||
|
||||
func _render(material) -> void:
|
||||
var height_map : Image = Image.new()
|
||||
var normal_map : Image = Image.new()
|
||||
var color_map : Image = Image.new()
|
||||
|
||||
height_map.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
normal_map.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
color_map.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
|
||||
height_map.lock()
|
||||
normal_map.lock()
|
||||
color_map.lock()
|
||||
|
||||
var w : float = material.image_size.x
|
||||
var h : float = material.image_size.y
|
||||
|
||||
var pseed : float = randf() + randi()
|
||||
|
||||
for x in range(material.image_size.x):
|
||||
for y in range(material.image_size.y):
|
||||
var uv : Vector2 = Vector2(x / w, y / h)
|
||||
|
||||
var raymarch : Vector2 = sdf3d_raymarch(uv)
|
||||
|
||||
#HeightMap - float - The generated height map
|
||||
#1.0-$(name_uv)_d.x
|
||||
var hmf : float = 1.0 - raymarch.x
|
||||
var height_map_col : Color = Color(hmf, hmf, hmf, 1)
|
||||
|
||||
#NormalMap - rgb - The generated normal map
|
||||
#vec3(0.5) + 0.5* normal_$name(vec3($uv-vec2(0.5), 1.0-$(name_uv)_d.x))
|
||||
var nuv : Vector2 = uv - Vector2(0.5, 0.5)
|
||||
var n : Vector3 = sdf3d_normal(Vector3(nuv.x, nuv.y, 1.0 - raymarch.x))
|
||||
var nn : Vector3 = Vector3(0.5, 0.5, 0.5) + 0.5 * n
|
||||
|
||||
var normal_map_col : Color = Color(nn.x, nn.y, nn.z, 1)
|
||||
|
||||
#ColorMap - float - The generated color index map
|
||||
#$(name_uv)_d.y
|
||||
var color_map_col : Color = Color(raymarch.y, raymarch.y, raymarch.y, 1)
|
||||
|
||||
height_map.set_pixel(x, y, height_map_col)
|
||||
normal_map.set_pixel(x, y, normal_map_col)
|
||||
color_map.set_pixel(x, y, color_map_col)
|
||||
|
||||
height_map.unlock()
|
||||
normal_map.unlock()
|
||||
color_map.unlock()
|
||||
|
||||
out_height_map.set_value(height_map)
|
||||
out_normal_map.set_value(normal_map)
|
||||
out_color_map.set_value(color_map)
|
||||
|
||||
func _get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
return Color()
|
||||
|
||||
#vec2 raymarch_$name(vec2 uv) {
|
||||
# vec3 ro = vec3(uv-vec2(0.5), 1.0);
|
||||
# vec3 rd = vec3(0.0, 0.0, -1.0);
|
||||
# float dO = 0.0;
|
||||
# float c = 0.0;
|
||||
#
|
||||
# for (int i=0; i < 100; i++) {
|
||||
# vec3 p = ro + rd*dO;
|
||||
# vec2 dS = $sdf(p);
|
||||
# dO += dS.x;
|
||||
#
|
||||
# if (dO >= 1.0) {
|
||||
# break;
|
||||
# } else if (dS.x < 0.0001) {
|
||||
# c = dS.y;
|
||||
# break;
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return vec2(dO, c);
|
||||
#}
|
||||
|
||||
func sdf3d_raymarch(uv : Vector2) -> Vector2:
|
||||
var ro : Vector3 = Vector3(uv.x - 0.5, uv.y - 0.5, 1.0);
|
||||
var rd : Vector3 = Vector3(0.0, 0.0, -1.0);
|
||||
var dO : float = 0.0;
|
||||
var c : float = 0.0;
|
||||
|
||||
for i in range(100):
|
||||
var p : Vector3 = ro + rd * dO;
|
||||
var dS : Vector2 = input.get_value_sdf3d(p)
|
||||
|
||||
dO += dS.x;
|
||||
|
||||
if (dO >= 1.0):
|
||||
break;
|
||||
elif (dS.x < 0.0001):
|
||||
c = dS.y;
|
||||
break;
|
||||
|
||||
return Vector2(dO, c);
|
||||
|
||||
#vec3 normal_$name(vec3 p) {
|
||||
# if (p.z <= 0.0) {
|
||||
# return vec3(0.0, 0.0, 1.0);
|
||||
# }
|
||||
#
|
||||
# float d = $sdf(p).x;
|
||||
# float e = .001;
|
||||
# vec3 n = d - vec3(
|
||||
# $sdf(p-vec3(e, 0.0, 0.0)).x,
|
||||
# $sdf(p-vec3(0.0, e, 0.0)).x,
|
||||
# $sdf(p-vec3(0.0, 0.0, e)).x);
|
||||
#
|
||||
# return vec3(-1.0, -1.0, -1.0)*normalize(n);
|
||||
#}
|
||||
|
||||
func sdf3d_normal(p : Vector3) -> Vector3:
|
||||
if (p.z <= 0.0):
|
||||
return Vector3(0.0, 0.0, 1.0);
|
||||
|
||||
var d : float = input.get_value_sdf3d(p).x
|
||||
var e : float = .001;
|
||||
|
||||
var n : Vector3 = Vector3(
|
||||
d - input.get_value_sdf3d(p - Vector3(e, 0.0, 0.0)).x,
|
||||
d - input.get_value_sdf3d(p - Vector3(0.0, e, 0.0)).x,
|
||||
d - input.get_value_sdf3d(p - Vector3(0.0, 0.0, e)).x)
|
||||
|
||||
return Vector3(-1.0, -1.0, -1.0) * n.normalized()
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user