mirror of
https://github.com/Relintai/mat_maker_gd.git
synced 2025-04-23 02:51:18 +02:00
Bring back the addon from the broken seals repo.
This commit is contained in:
parent
b082fbfaf4
commit
3afa4a93b5
@ -1,7 +0,0 @@
|
||||
[plugin]
|
||||
|
||||
name="Godot Plugin Refresher"
|
||||
description="A toolbar addition to facilitate toggling off/on a selected plugin."
|
||||
author="willnationsdev"
|
||||
version="1.0"
|
||||
script="plugin_refresher_plugin.gd"
|
@ -1,53 +0,0 @@
|
||||
tool
|
||||
extends HBoxContainer
|
||||
|
||||
signal request_refresh_plugin(p_name)
|
||||
signal confirm_refresh_plugin(p_name)
|
||||
|
||||
onready var options = $OptionButton
|
||||
|
||||
func _ready():
|
||||
$RefreshButton.icon = get_icon('Reload', 'EditorIcons')
|
||||
|
||||
func update_items(p_plugins):
|
||||
if not options:
|
||||
return
|
||||
options.clear()
|
||||
var plugin_dirs = p_plugins.keys()
|
||||
for idx in plugin_dirs.size():
|
||||
var plugin_dirname = plugin_dirs[idx]
|
||||
var plugin_name = p_plugins[plugin_dirname]
|
||||
options.add_item(plugin_name, idx)
|
||||
options.set_item_metadata(idx, plugin_dirname)
|
||||
|
||||
func select_plugin(p_name):
|
||||
if not options:
|
||||
return
|
||||
if p_name == null or p_name.empty():
|
||||
return
|
||||
|
||||
for idx in options.get_item_count():
|
||||
var plugin = options.get_item_metadata(idx)
|
||||
if plugin == p_name:
|
||||
options.selected = options.get_item_id(idx)
|
||||
break
|
||||
|
||||
func _on_RefreshButton_pressed():
|
||||
if options.selected == -1:
|
||||
return # nothing selected
|
||||
|
||||
var plugin = options.get_item_metadata(options.selected)
|
||||
if not plugin or plugin.empty():
|
||||
return
|
||||
emit_signal("request_refresh_plugin", plugin)
|
||||
|
||||
func show_warning(p_name):
|
||||
$ConfirmationDialog.dialog_text = """
|
||||
Plugin `%s` is currently disabled.\n
|
||||
Do you want to enable it now?
|
||||
""" % [p_name]
|
||||
$ConfirmationDialog.popup_centered()
|
||||
|
||||
func _on_ConfirmationDialog_confirmed():
|
||||
var plugin = options.get_item_metadata(options.selected)
|
||||
emit_signal('confirm_refresh_plugin', plugin)
|
@ -1,32 +0,0 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/godot-plugin-refresher/plugin_refresher.gd" type="Script" id=1]
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="VSeparator" type="VSeparator" parent="."]
|
||||
margin_right = 4.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="OptionButton" type="OptionButton" parent="."]
|
||||
margin_left = 8.0
|
||||
margin_right = 158.0
|
||||
margin_bottom = 40.0
|
||||
rect_min_size = Vector2( 150, 0 )
|
||||
|
||||
[node name="RefreshButton" type="ToolButton" parent="."]
|
||||
margin_left = 162.0
|
||||
margin_right = 174.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="ConfirmationDialog" type="ConfirmationDialog" parent="."]
|
||||
margin_right = 278.0
|
||||
margin_bottom = 110.0
|
||||
rect_min_size = Vector2( 300, 70 )
|
||||
window_title = "Plugin Refresher"
|
||||
dialog_autowrap = true
|
||||
[connection signal="pressed" from="RefreshButton" to="." method="_on_RefreshButton_pressed"]
|
||||
[connection signal="confirmed" from="ConfirmationDialog" to="." method="_on_ConfirmationDialog_confirmed"]
|
@ -1,125 +0,0 @@
|
||||
tool
|
||||
extends EditorPlugin
|
||||
|
||||
const ADDONS_PATH = "res://addons/"
|
||||
const PLUGIN_CONFIG_DIR = 'plugins/plugin_refresher'
|
||||
const PLUGIN_CONFIG = 'settings.cfg'
|
||||
const SETTINGS = 'settings'
|
||||
const SETTING_RECENT = 'recently_used'
|
||||
|
||||
var plugin_config = ConfigFile.new()
|
||||
var refresher
|
||||
|
||||
func _enter_tree():
|
||||
refresher = preload("plugin_refresher.tscn").instance()
|
||||
add_control_to_container(CONTAINER_TOOLBAR, refresher)
|
||||
|
||||
# Watch whether any plugin is changed, added or removed on the filesystem
|
||||
var efs = get_editor_interface().get_resource_filesystem()
|
||||
efs.connect("filesystem_changed", self, "_on_filesystem_changed")
|
||||
|
||||
refresher.connect("request_refresh_plugin", self, "_on_request_refresh_plugin")
|
||||
refresher.connect("confirm_refresh_plugin", self, "_on_confirm_refresh_plugin")
|
||||
|
||||
_reload_plugins_list()
|
||||
_load_settings()
|
||||
|
||||
func _exit_tree():
|
||||
remove_control_from_container(CONTAINER_TOOLBAR, refresher)
|
||||
refresher.free()
|
||||
|
||||
func _reload_plugins_list():
|
||||
var refresher_dir = get_plugin_path().get_file()
|
||||
var plugins = {}
|
||||
var origins = {}
|
||||
|
||||
var dir = Directory.new()
|
||||
dir.open(ADDONS_PATH)
|
||||
dir.list_dir_begin(true, true)
|
||||
var file = dir.get_next()
|
||||
while file:
|
||||
var addon_dir = ADDONS_PATH.plus_file(file)
|
||||
if dir.dir_exists(addon_dir) and file != refresher_dir:
|
||||
var display_name = file
|
||||
var plugin_config_path = addon_dir.plus_file("plugin.cfg")
|
||||
if not dir.file_exists(plugin_config_path):
|
||||
continue # not a plugin
|
||||
var plugin_cfg = ConfigFile.new()
|
||||
plugin_cfg.load(plugin_config_path)
|
||||
display_name = plugin_cfg.get_value("plugin", "name", file)
|
||||
if not display_name in origins:
|
||||
origins[display_name] = [file]
|
||||
else:
|
||||
origins[display_name].append(file)
|
||||
plugins[file] = display_name
|
||||
file = dir.get_next()
|
||||
|
||||
# Specify the exact plugin name in parenthesis in case of naming collisions.
|
||||
for display_name in origins:
|
||||
var plugin_names = origins[display_name]
|
||||
if plugin_names.size() > 1:
|
||||
for n in plugin_names:
|
||||
plugins[n] = "%s (%s)" % [display_name, n]
|
||||
|
||||
refresher.update_items(plugins)
|
||||
|
||||
func _load_settings():
|
||||
var path = get_config_path()
|
||||
|
||||
var fs = Directory.new()
|
||||
if not fs.file_exists(path):
|
||||
# Create new if running for the first time
|
||||
var config = ConfigFile.new()
|
||||
fs.make_dir_recursive(path.get_base_dir())
|
||||
config.save(path)
|
||||
else:
|
||||
plugin_config.load(path)
|
||||
|
||||
func _save_settings():
|
||||
plugin_config.save(get_config_path())
|
||||
|
||||
func get_config_path():
|
||||
var dir = get_editor_interface().get_editor_settings().get_project_settings_dir()
|
||||
var home = dir.plus_file(PLUGIN_CONFIG_DIR)
|
||||
var path = home.plus_file(PLUGIN_CONFIG)
|
||||
|
||||
return path
|
||||
|
||||
func _on_filesystem_changed():
|
||||
if refresher:
|
||||
_reload_plugins_list()
|
||||
refresher.select_plugin(get_recent_plugin())
|
||||
|
||||
func get_recent_plugin():
|
||||
if not plugin_config.has_section_key(SETTINGS, SETTING_RECENT):
|
||||
return null # not saved yet
|
||||
|
||||
var recent = plugin_config.get_value(SETTINGS, SETTING_RECENT)
|
||||
return recent
|
||||
|
||||
func _on_request_refresh_plugin(p_name):
|
||||
assert(not p_name.empty())
|
||||
|
||||
var disabled = not get_editor_interface().is_plugin_enabled(p_name)
|
||||
if disabled:
|
||||
refresher.show_warning(p_name)
|
||||
else:
|
||||
refresh_plugin(p_name)
|
||||
|
||||
func _on_confirm_refresh_plugin(p_name):
|
||||
refresh_plugin(p_name)
|
||||
|
||||
func get_plugin_path():
|
||||
return get_script().resource_path.get_base_dir()
|
||||
|
||||
func refresh_plugin(p_name):
|
||||
print("Refreshing plugin: ", p_name)
|
||||
|
||||
var enabled = get_editor_interface().is_plugin_enabled(p_name)
|
||||
if enabled: # can only disable an active plugin
|
||||
get_editor_interface().set_plugin_enabled(p_name, false)
|
||||
|
||||
get_editor_interface().set_plugin_enabled(p_name, true)
|
||||
|
||||
plugin_config.set_value(SETTINGS, SETTING_RECENT, p_name)
|
||||
_save_settings()
|
22
addons/mat_maker_gd/LICENSE.md
Normal file
22
addons/mat_maker_gd/LICENSE.md
Normal file
@ -0,0 +1,22 @@
|
||||
# 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.
|
6
addons/mat_maker_gd/README.md
Normal file
6
addons/mat_maker_gd/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
# 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.
|
65
addons/mat_maker_gd/editor/CreateNamePopup.gd
Normal file
65
addons/mat_maker_gd/editor/CreateNamePopup.gd
Normal file
@ -0,0 +1,65 @@
|
||||
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()
|
61
addons/mat_maker_gd/editor/CreateNamePopup.tscn
Normal file
61
addons/mat_maker_gd/editor/CreateNamePopup.tscn
Normal file
@ -0,0 +1,61 @@
|
||||
[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
|
148
addons/mat_maker_gd/editor/MatMakerGDEditor.gd
Normal file
148
addons/mat_maker_gd/editor/MatMakerGDEditor.gd
Normal file
@ -0,0 +1,148 @@
|
||||
tool
|
||||
extends MarginContainer
|
||||
|
||||
var MMGraphNode = preload("res://addons/mat_maker_gd/editor/mm_graph_node.gd")
|
||||
|
||||
export(PoolColorArray) var slot_colors : PoolColorArray
|
||||
|
||||
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 : MMMateial
|
||||
|
||||
func _enter_tree():
|
||||
ensure_objs()
|
||||
|
||||
func ensure_objs() -> void:
|
||||
if !_graph_edit:
|
||||
_graph_edit = get_node(graph_edit_path)
|
||||
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_INT, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR2, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR3, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_COLOR, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL)
|
||||
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_INT)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR2)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR3)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_COLOR)
|
||||
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL)
|
||||
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_INT, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_INT)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR2, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR2)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR3, MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_VECTOR3)
|
||||
_graph_edit.add_valid_connection_type(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_COLOR, MMNodeUniversalProperty.SlotTypes.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:
|
||||
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.slot_colors = slot_colors
|
||||
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()
|
||||
|
||||
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 : MMMateial):
|
||||
_material = object
|
||||
|
||||
recreate()
|
||||
|
||||
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)
|
||||
|
||||
_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)
|
||||
|
||||
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)
|
||||
|
||||
_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)
|
||||
|
||||
func on_graph_node_close_request(node : GraphNode) -> void:
|
||||
if _material:
|
||||
_material.cancel_render_and_wait()
|
||||
_material.remove_node(node._node)
|
||||
recreate()
|
||||
|
||||
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
|
||||
|
||||
_material.add_node(nnode)
|
||||
|
||||
var gn : GraphNode = MMGraphNode.new()
|
||||
gn.slot_colors = slot_colors
|
||||
gn.set_node(_material, nnode)
|
||||
_graph_edit.add_child(gn)
|
||||
|
55
addons/mat_maker_gd/editor/MatMakerGDEditor.tscn
Normal file
55
addons/mat_maker_gd/editor/MatMakerGDEditor.tscn
Normal file
@ -0,0 +1,55 @@
|
||||
[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 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
slot_colors = PoolColorArray( 0.905882, 0.0627451, 0.0627451, 1, 0.431373, 0.0352941, 0.0352941, 1, 0.827451, 0.376471, 0.376471, 1, 0.0431373, 0.478431, 0.427451, 1, 0.352941, 0.0352941, 0.341176, 1, 0.0352941, 0.0509804, 1, 1, 0.372549, 0.372549, 0.372549, 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"]
|
607
addons/mat_maker_gd/editor/mm_graph_node.gd
Normal file
607
addons/mat_maker_gd/editor/mm_graph_node.gd
Normal file
@ -0,0 +1,607 @@
|
||||
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 slot_colors : PoolColorArray
|
||||
|
||||
var _material : MMMateial = null
|
||||
var _node : MMNode = null
|
||||
var properties : Array = Array()
|
||||
|
||||
func _init():
|
||||
show_close = true
|
||||
connect("offset_changed", self, "on_offset_changed")
|
||||
connect("close_request", self, "on_close_request")
|
||||
|
||||
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.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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()
|
||||
|
||||
var slot_idx : int = add_slot(MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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.SlotTypes.SLOT_TYPE_NONE, MMNodeUniversalProperty.SlotTypes.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)
|
||||
|
||||
if output_type != -1:
|
||||
set_slot_type_left(slot_idx, output_type)
|
||||
|
||||
if input_type != -1 && slot_colors.size() > input_type:
|
||||
set_slot_color_left(slot_idx, slot_colors[input_type])
|
||||
|
||||
if output_type != -1 && slot_colors.size() > output_type:
|
||||
set_slot_color_right(slot_idx, slot_colors[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])
|
||||
|
||||
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)
|
||||
|
||||
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 : MMMateial, 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_offset_changed():
|
||||
if _node:
|
||||
_node.set_graph_position(offset)
|
||||
|
||||
func on_node_changed():
|
||||
#get all properties again
|
||||
#_node.recalculate_image(_material)
|
||||
|
||||
propagate_node_change()
|
||||
|
||||
func on_int_spinbox_value_changed(val : float, slot_idx) -> void:
|
||||
_node.call(properties[slot_idx][4], int(val))
|
||||
|
||||
func on_float_spinbox_value_changed(val : float, slot_idx) -> void:
|
||||
_node.call(properties[slot_idx][4], val)
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
func on_int_universal_spinbox_value_changed(val : float, slot_idx) -> void:
|
||||
properties[slot_idx][6].set_default_value(int(val))
|
||||
|
||||
func on_float_universal_spinbox_value_changed(val : float, slot_idx) -> void:
|
||||
properties[slot_idx][6].set_default_value(val)
|
||||
|
||||
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)
|
||||
|
||||
func on_slot_enum_item_selected(val : int, slot_idx : int) -> void:
|
||||
_node.call(properties[slot_idx][4], val)
|
||||
|
||||
func on_universal_texture_changed(slot_idx : int) -> void:
|
||||
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()
|
||||
|
||||
func on_universal_texture_changed_image_picker(slot_idx : int) -> void:
|
||||
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()
|
||||
|
||||
func on_slot_line_edit_text_entered(text : String, slot_idx : int) -> void:
|
||||
_node.call(properties[slot_idx][4], text)
|
||||
|
||||
func on_universal_color_changed(c : Color, slot_idx : int) -> void:
|
||||
properties[slot_idx][6].set_default_value(c)
|
||||
|
||||
func on_universal_image_path_changed(f : String, slot_idx : int) -> void:
|
||||
_node.call(properties[slot_idx][8], f)
|
||||
|
||||
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()
|
BIN
addons/mat_maker_gd/icons/custom.png
Normal file
BIN
addons/mat_maker_gd/icons/custom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 549 B |
@ -2,15 +2,15 @@
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/Studio.png-1e6b72b05bd3afe09c3b67063dbebc60.stex"
|
||||
path="res://.import/custom.png-b026bd10e22818d25d499d2eddb137a8.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://material_maker/panels/preview_3d/thumbnails/environments/Studio.png"
|
||||
dest_files=[ "res://.import/Studio.png-1e6b72b05bd3afe09c3b67063dbebc60.stex" ]
|
||||
source_file="res://addons/mat_maker_gd/icons/custom.png"
|
||||
dest_files=[ "res://.import/custom.png-b026bd10e22818d25d499d2eddb137a8.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
@ -28,6 +28,7 @@ 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
|
8
addons/mat_maker_gd/icons/down.tres
Normal file
8
addons/mat_maker_gd/icons/down.tres
Normal file
@ -0,0 +1,8 @@
|
||||
[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 +1,8 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
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 After Width: | Height: | Size: 12 KiB |
@ -2,15 +2,15 @@
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/godot_logo.svg-4b89d8bf8533de4522d0f7d92c0a0af4.stex"
|
||||
path="res://.import/godot_logo.svg-4e4bf625f601f4dc5d1d367a2f781011.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://material_maker/icons/godot_logo.svg"
|
||||
dest_files=[ "res://.import/godot_logo.svg-4b89d8bf8533de4522d0f7d92c0a0af4.stex" ]
|
||||
source_file="res://addons/mat_maker_gd/icons/godot_logo.svg"
|
||||
dest_files=[ "res://.import/godot_logo.svg-4e4bf625f601f4dc5d1d367a2f781011.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
@ -28,6 +28,7 @@ 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
|
3522
addons/mat_maker_gd/icons/icons.svg
Normal file
3522
addons/mat_maker_gd/icons/icons.svg
Normal file
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 189 KiB |
@ -2,15 +2,15 @@
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icons.svg-7e4b30239fa94a02566e96134c06aedb.stex"
|
||||
path="res://.import/icons.svg-bac181e82e23c7264cdf6c36903654b9.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://material_maker/icons/icons.svg"
|
||||
dest_files=[ "res://.import/icons.svg-7e4b30239fa94a02566e96134c06aedb.stex" ]
|
||||
source_file="res://addons/mat_maker_gd/icons/icons.svg"
|
||||
dest_files=[ "res://.import/icons.svg-bac181e82e23c7264cdf6c36903654b9.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
@ -28,6 +28,7 @@ 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
|
30
addons/mat_maker_gd/icons/icons.tres
Normal file
30
addons/mat_maker_gd/icons/icons.tres
Normal file
File diff suppressed because one or more lines are too long
@ -1,9 +1,8 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 16, 0, 16, 15 )
|
@ -1,8 +1,8 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 48, 96, 16, 16 )
|
@ -1,8 +1,8 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 0, 80, 16, 16 )
|
@ -1,8 +1,8 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 32, 64, 16, 16 )
|
@ -1,8 +1,8 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 32, 80, 16, 16 )
|
@ -1,6 +1,6 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
@ -1,8 +1,8 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 32, 112, 16, 16 )
|
@ -1,6 +1,6 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
@ -1,8 +1,8 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 64, 32, 16, 16 )
|
@ -1,9 +1,8 @@
|
||||
[gd_resource type="AtlasTexture" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=1]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/icons/icons.tres" type="Texture" id=1]
|
||||
|
||||
[resource]
|
||||
flags = 4
|
||||
flags = 7
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 32, 0, 16, 16 )
|
8
addons/mat_maker_gd/icons/up.tres
Normal file
8
addons/mat_maker_gd/icons/up.tres
Normal file
@ -0,0 +1,8 @@
|
||||
[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 )
|
652
addons/mat_maker_gd/new_resource.tres
Normal file
652
addons/mat_maker_gd/new_resource.tres
Normal file
@ -0,0 +1,652 @@
|
||||
[gd_resource type="Resource" load_steps=89 format=2]
|
||||
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/mm_material.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/mat_maker_gd/nodes/filter/adjust_hsv.gd" type="Script" id=2]
|
||||
[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/mm_node_universal_property.gd" type="Script" id=5]
|
||||
[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="Resource" id=1]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=3]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=4]
|
||||
script = ExtResource( 2 )
|
||||
graph_position = Vector2( 140, 0 )
|
||||
image = SubResource( 1 )
|
||||
input = SubResource( 3 )
|
||||
hue = 0.0
|
||||
saturation = 1.0
|
||||
value = 1.0
|
||||
|
||||
[sub_resource type="Resource" id=5]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=6]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=7]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=2]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=8]
|
||||
script = ExtResource( 3 )
|
||||
graph_position = Vector2( -160, 40 )
|
||||
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="Resource" id=9]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=10]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=11]
|
||||
script = ExtResource( 4 )
|
||||
graph_position = Vector2( 380, 80 )
|
||||
image = SubResource( 9 )
|
||||
input = SubResource( 10 )
|
||||
|
||||
[sub_resource type="Resource" id=12]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=13]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 1.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=14]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 7 )
|
||||
|
||||
[sub_resource type="Resource" id=15]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 2 )
|
||||
|
||||
[sub_resource type="Resource" id=16]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 5 )
|
||||
|
||||
[sub_resource type="Resource" id=17]
|
||||
script = ExtResource( 6 )
|
||||
graph_position = Vector2( 380, 380 )
|
||||
image = SubResource( 12 )
|
||||
input_r = SubResource( 16 )
|
||||
input_g = SubResource( 15 )
|
||||
input_b = SubResource( 14 )
|
||||
input_a = SubResource( 13 )
|
||||
|
||||
[sub_resource type="Resource" id=18]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=19]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 12 )
|
||||
|
||||
[sub_resource type="Resource" id=20]
|
||||
script = ExtResource( 7 )
|
||||
graph_position = Vector2( 1080, 180 )
|
||||
image = SubResource( 18 )
|
||||
input = SubResource( 19 )
|
||||
center = Vector2( 1, 1 )
|
||||
scale = Vector2( 1.3, 1.3 )
|
||||
|
||||
[sub_resource type="Resource" id=21]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 12 )
|
||||
|
||||
[sub_resource type="Resource" id=22]
|
||||
script = ExtResource( 8 )
|
||||
graph_position = Vector2( 560, 300 )
|
||||
input = SubResource( 21 )
|
||||
|
||||
[sub_resource type="Resource" id=23]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=24]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 21 )
|
||||
|
||||
[sub_resource type="Resource" id=25]
|
||||
script = ExtResource( 9 )
|
||||
graph_position = Vector2( 860, 200 )
|
||||
image = SubResource( 23 )
|
||||
input = SubResource( 24 )
|
||||
direction = 0
|
||||
amount = 1.06
|
||||
center = 0.0
|
||||
|
||||
[sub_resource type="Resource" id=26]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=27]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 21 )
|
||||
|
||||
[sub_resource type="Resource" id=28]
|
||||
script = ExtResource( 10 )
|
||||
graph_position = Vector2( 620, 460 )
|
||||
image = SubResource( 26 )
|
||||
input = SubResource( 27 )
|
||||
direction = 0
|
||||
offset = 0.32
|
||||
|
||||
[sub_resource type="Resource" id=32]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=33]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 21 )
|
||||
|
||||
[sub_resource type="Resource" id=34]
|
||||
script = ExtResource( 12 )
|
||||
graph_position = Vector2( 820, 580 )
|
||||
image = SubResource( 32 )
|
||||
input = SubResource( 33 )
|
||||
radius = 1.0
|
||||
repeat = 4
|
||||
|
||||
[sub_resource type="Resource" id=35]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=36]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=37]
|
||||
script = ExtResource( 13 )
|
||||
graph_position = Vector2( 1040, 560 )
|
||||
image = SubResource( 35 )
|
||||
input = SubResource( 36 )
|
||||
center = Vector2( 0.13, 0 )
|
||||
rotate = 150.0
|
||||
|
||||
[sub_resource type="Resource" id=38]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=39]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 21 )
|
||||
|
||||
[sub_resource type="Resource" id=40]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 14.5
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 32 )
|
||||
|
||||
[sub_resource type="Resource" id=41]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 1.6
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=42]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 1.1
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=43]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 4.1
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=44]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 2.2
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=45]
|
||||
script = ExtResource( 11 )
|
||||
graph_position = Vector2( 1280, 560 )
|
||||
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="Resource" id=46]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=47]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 23 )
|
||||
|
||||
[sub_resource type="Resource" id=48]
|
||||
script = ExtResource( 14 )
|
||||
graph_position = Vector2( 620, 0 )
|
||||
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="Resource" id=49]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=50]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=51]
|
||||
script = ExtResource( 15 )
|
||||
graph_position = Vector2( 120, 440 )
|
||||
image = SubResource( 49 )
|
||||
input = SubResource( 50 )
|
||||
axis = 2
|
||||
|
||||
[sub_resource type="Resource" id=52]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.1
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=53]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=54]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 1.3
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 2 )
|
||||
|
||||
[sub_resource type="Resource" id=55]
|
||||
script = ExtResource( 16 )
|
||||
graph_position = Vector2( -440, 200 )
|
||||
image = SubResource( 53 )
|
||||
shape_type = 3
|
||||
sides = 7
|
||||
radius = SubResource( 54 )
|
||||
edge = SubResource( 52 )
|
||||
|
||||
[sub_resource type="Resource" id=56]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=59]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=57]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 59 )
|
||||
|
||||
[sub_resource type="Resource" id=58]
|
||||
script = ExtResource( 17 )
|
||||
graph_position = Vector2( 580, 800 )
|
||||
image = SubResource( 56 )
|
||||
input = SubResource( 57 )
|
||||
mode = 0
|
||||
|
||||
[sub_resource type="Resource" id=60]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 12 )
|
||||
|
||||
[sub_resource type="Resource" id=61]
|
||||
script = ExtResource( 18 )
|
||||
graph_position = Vector2( 320, 700 )
|
||||
image = SubResource( 59 )
|
||||
input = SubResource( 60 )
|
||||
edge_color = 0.9
|
||||
|
||||
[sub_resource type="Resource" id=63]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 5 )
|
||||
|
||||
[sub_resource type="Resource" id=64]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
input_property = SubResource( 53 )
|
||||
|
||||
[sub_resource type="Resource" id=65]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=62]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=66]
|
||||
script = ExtResource( 19 )
|
||||
graph_position = Vector2( -720, 280 )
|
||||
image = SubResource( 65 )
|
||||
a = SubResource( 63 )
|
||||
b = SubResource( 64 )
|
||||
output = SubResource( 62 )
|
||||
operation = 3
|
||||
clamp_result = true
|
||||
|
||||
[sub_resource type="Resource" id=67]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 1
|
||||
default_int = 0
|
||||
default_float = 1.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=68]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 4
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=69]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=70]
|
||||
script = ExtResource( 5 )
|
||||
default_type = 5
|
||||
default_int = 0
|
||||
default_float = 0.0
|
||||
default_vector2 = Vector2( 0, 0 )
|
||||
default_vector3 = Vector3( 0, 0, 0 )
|
||||
default_color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[sub_resource type="Resource" id=71]
|
||||
script = ExtResource( 20 )
|
||||
graph_position = Vector2( -1060, 280 )
|
||||
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
|
||||
|
||||
[resource]
|
||||
script = ExtResource( 1 )
|
||||
image_size = Vector2( 128, 128 )
|
||||
nodes = [ SubResource( 4 ), 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 ) ]
|
118
addons/mat_maker_gd/nodes/bases/curve_base.gd
Normal file
118
addons/mat_maker_gd/nodes/bases/curve_base.gd
Normal file
@ -0,0 +1,118 @@
|
||||
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()
|
64
addons/mat_maker_gd/nodes/bases/gradient_base.gd
Normal file
64
addons/mat_maker_gd/nodes/bases/gradient_base.gd
Normal file
@ -0,0 +1,64 @@
|
||||
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)
|
73
addons/mat_maker_gd/nodes/bases/polygon_base.gd
Normal file
73
addons/mat_maker_gd/nodes/bases/polygon_base.gd
Normal file
@ -0,0 +1,73 @@
|
||||
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(",")
|
1172
addons/mat_maker_gd/nodes/common/blur.gd
Normal file
1172
addons/mat_maker_gd/nodes/common/blur.gd
Normal file
File diff suppressed because it is too large
Load Diff
393
addons/mat_maker_gd/nodes/common/commons.gd
Normal file
393
addons/mat_maker_gd/nodes/common/commons.gd
Normal file
@ -0,0 +1,393 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
#pattern.mmg
|
||||
|
||||
#----------------------
|
||||
#hlsl_defs.tmpl
|
||||
|
||||
##define hlsl_atan(x,y) atan2(x, y)
|
||||
##define mod(x,y) ((x)-(y)*floor((x)/(y)))
|
||||
#inline float4 textureLod(sampler2D tex, float2 uv, float lod) {
|
||||
# return tex2D(tex, uv);
|
||||
#}
|
||||
#inline float2 tofloat2(float x) {
|
||||
# return float2(x, x);
|
||||
#}
|
||||
#inline float2 tofloat2(float x, float y) {
|
||||
# return float2(x, y);
|
||||
#}
|
||||
#inline float3 tofloat3(float x) {
|
||||
# return float3(x, x, x);
|
||||
#}
|
||||
#inline float3 tofloat3(float x, float y, float z) {
|
||||
# return float3(x, y, z);
|
||||
#}
|
||||
#inline float3 tofloat3(float2 xy, float z) {
|
||||
# return float3(xy.x, xy.y, z);
|
||||
#}
|
||||
#inline float3 tofloat3(float x, float2 yz) {
|
||||
# return float3(x, yz.x, yz.y);
|
||||
#}
|
||||
#inline float4 tofloat4(float x, float y, float z, float w) {
|
||||
# return float4(x, y, z, w);
|
||||
#}
|
||||
#inline float4 tofloat4(float x) {
|
||||
# return float4(x, x, x, x);
|
||||
#}
|
||||
#inline float4 tofloat4(float x, float3 yzw) {
|
||||
# return float4(x, yzw.x, yzw.y, yzw.z);
|
||||
#}
|
||||
#inline float4 tofloat4(float2 xy, float2 zw) {
|
||||
# return float4(xy.x, xy.y, zw.x, zw.y);
|
||||
#}
|
||||
#inline float4 tofloat4(float3 xyz, float w) {
|
||||
# return float4(xyz.x, xyz.y, xyz.z, w);
|
||||
#}
|
||||
#inline float2x2 tofloat2x2(float2 v1, float2 v2) {
|
||||
# return float2x2(v1.x, v1.y, v2.x, v2.y);
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
#glsl_defs.tmpl
|
||||
|
||||
#float rand(vec2 x) {
|
||||
# return fract(cos(mod(dot(x, vec2(13.9898, 8.141)), 3.14)) * 43758.5453);
|
||||
#}
|
||||
|
||||
#vec2 rand2(vec2 x) {
|
||||
# return fract(cos(mod(vec2(dot(x, vec2(13.9898, 8.141)),
|
||||
# dot(x, vec2(3.4562, 17.398))), vec2(3.14))) * 43758.5453);
|
||||
#}
|
||||
|
||||
#vec3 rand3(vec2 x) {
|
||||
# return fract(cos(mod(vec3(dot(x, vec2(13.9898, 8.141)),
|
||||
# dot(x, vec2(3.4562, 17.398)),
|
||||
# dot(x, vec2(13.254, 5.867))), vec3(3.14))) * 43758.5453);
|
||||
#}
|
||||
|
||||
#float param_rnd(float minimum, float maximum, float seed) {
|
||||
# return minimum+(maximum-minimum)*rand(vec2(seed));
|
||||
#}
|
||||
|
||||
#vec3 rgb2hsv(vec3 c) {
|
||||
# vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
# vec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy);
|
||||
# vec4 q = c.r < p.x ? vec4(p.xyw, c.r) : vec4(c.r, p.yzx);
|
||||
#
|
||||
# float d = q.x - min(q.w, q.y);
|
||||
# float e = 1.0e-10;
|
||||
# return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
#}
|
||||
|
||||
#vec3 hsv2rgb(vec3 c) {
|
||||
# vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
# vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
||||
# return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
|
||||
static func clampv3(v : Vector3, mi : Vector3, ma : Vector3) -> Vector3:
|
||||
v.x = clamp(v.x, mi.x, ma.x)
|
||||
v.y = clamp(v.y, mi.y, ma.y)
|
||||
v.z = clamp(v.z, mi.z, ma.z)
|
||||
|
||||
return v
|
||||
|
||||
static func floorc(a : Color) -> Color:
|
||||
var v : Color = Color()
|
||||
|
||||
v.r = floor(a.r)
|
||||
v.g = floor(a.g)
|
||||
v.b = floor(a.b)
|
||||
v.a = floor(a.a)
|
||||
|
||||
return v
|
||||
|
||||
static func floorv2(a : Vector2) -> Vector2:
|
||||
var v : Vector2 = Vector2()
|
||||
|
||||
v.x = floor(a.x)
|
||||
v.y = floor(a.y)
|
||||
|
||||
return v
|
||||
|
||||
static func floorv3(a : Vector3) -> Vector3:
|
||||
var v : Vector3 = Vector3()
|
||||
|
||||
v.x = floor(a.x)
|
||||
v.y = floor(a.y)
|
||||
v.z = floor(a.z)
|
||||
|
||||
return v
|
||||
|
||||
static func smoothstepv2(a : float, b : float, c : Vector2) -> Vector2:
|
||||
var v : Vector2 = Vector2()
|
||||
|
||||
v.x = smoothstep(a, b, c.x)
|
||||
v.y = smoothstep(a, b, c.y)
|
||||
|
||||
return v
|
||||
|
||||
static func maxv2(a : Vector2, b : Vector2) -> Vector2:
|
||||
var v : Vector2 = Vector2()
|
||||
|
||||
v.x = max(a.x, b.x)
|
||||
v.y = max(a.y, b.y)
|
||||
|
||||
return v
|
||||
|
||||
static func maxv3(a : Vector3, b : Vector3) -> Vector3:
|
||||
var v : Vector3 = Vector3()
|
||||
|
||||
v.x = max(a.x, b.x)
|
||||
v.y = max(a.y, b.y)
|
||||
v.z = max(a.z, b.z)
|
||||
|
||||
return v
|
||||
|
||||
static func absv2(v : Vector2) -> Vector2:
|
||||
v.x = abs(v.x)
|
||||
v.y = abs(v.y)
|
||||
|
||||
return v
|
||||
|
||||
static func absv3(v : Vector3) -> Vector3:
|
||||
v.x = abs(v.x)
|
||||
v.y = abs(v.y)
|
||||
v.z = abs(v.z)
|
||||
|
||||
return v
|
||||
|
||||
static func cosv2(v : Vector2) -> Vector2:
|
||||
v.x = cos(v.x)
|
||||
v.y = cos(v.y)
|
||||
|
||||
return v
|
||||
|
||||
static func cosv3(v : Vector3) -> Vector3:
|
||||
v.x = cos(v.x)
|
||||
v.y = cos(v.y)
|
||||
v.z = cos(v.z)
|
||||
|
||||
return v
|
||||
|
||||
static func powv2(x : Vector2, y : Vector2) -> Vector2:
|
||||
x.x = pow(x.x, y.x)
|
||||
x.y = pow(x.y, y.y)
|
||||
|
||||
return x
|
||||
|
||||
static func modv3(a : Vector3, b : Vector3) -> Vector3:
|
||||
var v : Vector3 = Vector3()
|
||||
|
||||
v.x = modf(a.x, b.x)
|
||||
v.y = modf(a.y, b.y)
|
||||
v.z = modf(a.z, b.z)
|
||||
|
||||
return v
|
||||
|
||||
|
||||
static func modv2(a : Vector2, b : Vector2) -> Vector2:
|
||||
var v : Vector2 = Vector2()
|
||||
|
||||
v.x = modf(a.x, b.x)
|
||||
v.y = modf(a.y, b.y)
|
||||
|
||||
return v
|
||||
|
||||
static func modf(x : float, y : float) -> float:
|
||||
return x - y * floor(x / y)
|
||||
|
||||
static func fractv2(v : Vector2) -> Vector2:
|
||||
v.x = v.x - floor(v.x)
|
||||
v.y = v.y - floor(v.y)
|
||||
|
||||
return v
|
||||
|
||||
static func fractv3(v : Vector3) -> Vector3:
|
||||
v.x = v.x - floor(v.x)
|
||||
v.y = v.y - floor(v.y)
|
||||
v.z = v.z - floor(v.z)
|
||||
|
||||
return v
|
||||
|
||||
static func fract(f : float) -> float:
|
||||
return f - floor(f)
|
||||
|
||||
static func clampv2(v : Vector2, pmin : Vector2, pmax : Vector2) -> Vector2:
|
||||
v.x = clamp(v.x, pmin.x, pmax.x)
|
||||
v.y = clamp(v.y, pmin.y, pmax.y)
|
||||
|
||||
return v
|
||||
|
||||
static func minv2(v1 : Vector2, v2 : Vector2) -> Vector2:
|
||||
v1.x = min(v1.x, v2.x)
|
||||
v1.y = min(v1.y, v2.y)
|
||||
|
||||
return v1
|
||||
|
||||
static func minv3(v1 : Vector3, v2 : Vector3) -> Vector3:
|
||||
v1.x = min(v1.x, v2.x)
|
||||
v1.y = min(v1.y, v2.y)
|
||||
v1.z = min(v1.z, v2.z)
|
||||
|
||||
return v1
|
||||
|
||||
static func rand(x : Vector2) -> float:
|
||||
return fract(cos(x.dot(Vector2(13.9898, 8.141))) * 43758.5453);
|
||||
|
||||
static func rand2(x : Vector2) -> Vector2:
|
||||
return fractv2(cosv2(Vector2(x.dot(Vector2(13.9898, 8.141)),
|
||||
x.dot(Vector2(3.4562, 17.398)))) * 43758.5453);
|
||||
|
||||
static func rand3(x : Vector2) -> Vector3:
|
||||
return fractv3(cosv3(Vector3(x.dot(Vector2(13.9898, 8.141)),
|
||||
x.dot(Vector2(3.4562, 17.398)),
|
||||
x.dot(Vector2(13.254, 5.867)))) * 43758.5453);
|
||||
|
||||
static func step(edge : float, x : float) -> float:
|
||||
if x < edge:
|
||||
return 0.0
|
||||
else:
|
||||
return 1.0
|
||||
|
||||
static func stepv2(edge : Vector2, x : Vector2) -> Vector2:
|
||||
edge.x = step(edge.x, x.x)
|
||||
edge.y = step(edge.y, x.y)
|
||||
|
||||
return edge
|
||||
|
||||
static func signv2(x : Vector2) -> Vector2:
|
||||
x.x = sign(x.x)
|
||||
x.y = sign(x.y)
|
||||
|
||||
return x
|
||||
|
||||
static func transform(uv : Vector2, translate : Vector2, rotate : float, scale : Vector2, repeat : bool) -> Vector2:
|
||||
var rv : Vector2 = Vector2();
|
||||
uv -= translate;
|
||||
uv -= Vector2(0.5, 0.5);
|
||||
rv.x = cos(rotate)*uv.x + sin(rotate)*uv.y;
|
||||
rv.y = -sin(rotate)*uv.x + cos(rotate)*uv.y;
|
||||
rv /= scale;
|
||||
rv += Vector2(0.5, 0.5);
|
||||
|
||||
if (repeat):
|
||||
return fractv2(rv);
|
||||
else:
|
||||
return clampv2(rv, Vector2(0, 0), Vector2(1, 1));
|
||||
|
||||
static func fractf(x : float) -> float:
|
||||
return x - floor(x)
|
||||
|
||||
#float mix_mul(float x, float y) {
|
||||
# return x*y;
|
||||
#}
|
||||
|
||||
static func mix_mul(x : float, y : float) -> float:
|
||||
return x*y;
|
||||
|
||||
#float mix_add(float x, float y) {
|
||||
# return min(x+y, 1.0);
|
||||
#}
|
||||
|
||||
static func mix_add(x : float, y : float) -> float:
|
||||
return min(x+y, 1.0);
|
||||
|
||||
#float mix_max(float x, float y) {
|
||||
# return max(x, y);
|
||||
#}
|
||||
|
||||
static func mix_max(x : float, y : float) -> float:
|
||||
return max(x, y);
|
||||
|
||||
#float mix_min(float x, float y) {
|
||||
# return min(x, y);
|
||||
#}
|
||||
|
||||
static func mix_min(x : float, y : float) -> float:
|
||||
return min(x, y);
|
||||
|
||||
#float mix_xor(float x, float y) {
|
||||
# return min(x+y, 2.0-x-y);
|
||||
#}
|
||||
|
||||
static func mix_xor(x : float, y : float) -> float:
|
||||
return min(x+y, 2.0-x-y);
|
||||
|
||||
#float mix_pow(float x, float y) {
|
||||
# return pow(x, y);
|
||||
#}
|
||||
|
||||
static func mix_pow(x : float, y : float) -> float:
|
||||
return pow(x, y);
|
||||
|
||||
|
||||
#float wave_constant(float x) {
|
||||
# return 1.0;
|
||||
#}
|
||||
|
||||
static func wave_constant(x : float) -> float:
|
||||
return 1.0;
|
||||
|
||||
#float wave_sine(float x) {
|
||||
# return 0.5-0.5*cos(3.14159265359*2.0*x);
|
||||
#}
|
||||
|
||||
static func wave_sine(x : float) -> float:
|
||||
return 0.5-0.5*cos(3.14159265359*2.0*x);
|
||||
|
||||
#float wave_triangle(float x) {
|
||||
# x = fract(x);
|
||||
# return min(2.0*x, 2.0-2.0*x);
|
||||
#}
|
||||
|
||||
static func wave_triangle(x : float) -> float:
|
||||
x = fractf(x);
|
||||
return min(2.0*x, 2.0-2.0*x);
|
||||
|
||||
#float wave_sawtooth(float x) {
|
||||
# return fract(x);
|
||||
#}
|
||||
|
||||
static func wave_sawtooth(x : float) -> float:
|
||||
return fractf(x);
|
||||
|
||||
#float wave_square(float x) {
|
||||
# return (fract(x) < 0.5) ? 0.0 : 1.0;
|
||||
#}
|
||||
|
||||
static func wave_square(x : float) -> float:
|
||||
if (fractf(x) < 0.5):
|
||||
return 0.0
|
||||
else:
|
||||
return 1.0
|
||||
|
||||
#float wave_bounce(float x) {
|
||||
# x = 2.0*(fract(x)-0.5);
|
||||
# return sqrt(1.0-x*x);
|
||||
#}
|
||||
|
||||
static func wave_bounce(x : float) -> float:
|
||||
x = 2.0*(fractf(x)-0.5);
|
||||
return sqrt(1.0-x*x);
|
||||
|
||||
static func sinewave(uv : Vector2, amplitude : float, frequency : float, phase : float) -> 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)
|
||||
|
||||
#from runes.mmg (old)
|
||||
|
||||
static func ThickLine(uv : Vector2, posA : Vector2, posB : Vector2, radiusInv : float) -> float:
|
||||
var dir : Vector2 = posA - posB;
|
||||
var dirLen : float = dir.length()
|
||||
var dirN : Vector2 = dir.normalized()
|
||||
var dotTemp : float = clamp((uv - posB).dot(dirN), 0.0, dirLen);
|
||||
var proj : Vector2 = dotTemp * dirN + posB;
|
||||
var d1 : float = (uv - proj).length()
|
||||
var finalGray : float = clamp(1.0 - d1 * radiusInv, 0.0, 1.0);
|
||||
|
||||
return finalGray;
|
85
addons/mat_maker_gd/nodes/common/curves.gd
Normal file
85
addons/mat_maker_gd/nodes/common/curves.gd
Normal file
@ -0,0 +1,85 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#Based on MaterialMaker's curve.gd
|
||||
|
||||
#Curve PoolRealArray: p.x, p.y, ls, rs, p.x, p.y ....
|
||||
|
||||
#class Point:
|
||||
# var p : Vector2
|
||||
# var ls : float
|
||||
# var rs : float
|
||||
|
||||
#func get_shader(name) -> String:
|
||||
# var shader
|
||||
# shader = "float "+name+"_curve_fct(float x) {\n"
|
||||
# for i in range(points.size()-1):
|
||||
# if i < points.size()-2:
|
||||
# shader += "if (x <= p_"+name+"_"+str(i+1)+"_x) "
|
||||
#
|
||||
# shader += "{\n"
|
||||
# shader += "float dx = x - p_"+name+"_"+str(i)+"_x;\n"
|
||||
# shader += "float d = p_"+name+"_"+str(i+1)+"_x - p_"+name+"_"+str(i)+"_x;\n"
|
||||
# shader += "float t = dx/d;\n"
|
||||
# shader += "float omt = (1.0 - t);\n"
|
||||
# shader += "float omt2 = omt * omt;\n"
|
||||
# shader += "float omt3 = omt2 * omt;\n"
|
||||
# shader += "float t2 = t * t;\n"
|
||||
# shader += "float t3 = t2 * t;\n"
|
||||
# shader += "d /= 3.0;\n"
|
||||
# shader += "float y1 = p_"+name+"_"+str(i)+"_y;\n"
|
||||
# shader += "float yac = p_"+name+"_"+str(i)+"_y + d*p_"+name+"_"+str(i)+"_rs;\n"
|
||||
# shader += "float ybc = p_"+name+"_"+str(i+1)+"_y - d*p_"+name+"_"+str(i+1)+"_ls;\n"
|
||||
# shader += "float y2 = p_"+name+"_"+str(i+1)+"_y;\n"
|
||||
# shader += "return y1*omt3 + yac*omt2*t*3.0 + ybc*omt*t2*3.0 + y2*t3;\n"
|
||||
# shader += "}\n"
|
||||
#
|
||||
# shader += "}\n"
|
||||
# return shader
|
||||
|
||||
static func curve(x : float, points : PoolRealArray) -> float:
|
||||
if points.size() % 4 != 0 || points.size() < 8:
|
||||
return 0.0
|
||||
|
||||
var ps : int = points.size() / 4
|
||||
|
||||
for i in range(ps - 1):
|
||||
var pi : int = i * 4
|
||||
var pip1 : int = (i + 1) * 4
|
||||
|
||||
if i < ps - 2:
|
||||
# if (x <= p_"+name+"_"+str(i+1)+"_x)
|
||||
if x > points[pip1]:
|
||||
continue
|
||||
|
||||
#float dx = x - p_"+name+"_"+str(i)+"_x;
|
||||
var dx : float = x - points[pi];
|
||||
|
||||
#var d : float = p_"+name+"_"+str(i+1)+"_x - p_"+name+"_"+str(i)+"_x;
|
||||
var d : float = points[pip1] - points[pi];
|
||||
|
||||
var t : float = dx / d
|
||||
var omt : float = (1.0 - t)
|
||||
var omt2 : float = omt * omt
|
||||
var omt3 : float = omt2 * omt
|
||||
var t2 : float = t * t
|
||||
var t3 : float = t2 * t
|
||||
d /= 3.0
|
||||
|
||||
# var y1 : float = p_"+name+"_"+str(i)+"_y
|
||||
var y1 : float = points[pi + 1]
|
||||
|
||||
# var yac : float = p_"+name+"_"+str(i)+"_y + d*p_"+name+"_"+str(i)+"_rs
|
||||
var yac : float = points[pi + 1] + d * points[pi + 3]
|
||||
|
||||
# var ybc : float = p_"+name+"_"+str(i+1)+"_y - d*p_"+name+"_"+str(i+1)+"_ls
|
||||
var ybc : float = points[pip1 + 1] - d * points[pip1 + 2]
|
||||
|
||||
# var y2 : float = p_"+name+"_"+str(i+1)+"_y
|
||||
var y2 : float = points[pip1 + 1]
|
||||
|
||||
return y1 * omt3 + yac * omt2 * t * 3.0 + ybc * omt * t2 * 3.0 + y2 * t3;
|
||||
|
||||
return 0.0
|
521
addons/mat_maker_gd/nodes/common/dilate.gd
Normal file
521
addons/mat_maker_gd/nodes/common/dilate.gd
Normal file
@ -0,0 +1,521 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#dilate.mmg
|
||||
|
||||
#{
|
||||
# "connections": [
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 0,
|
||||
# "to": "buffer",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "buffer",
|
||||
# "from_port": 0,
|
||||
# "to": "dilate_pass_1",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "dilate_pass_1",
|
||||
# "from_port": 0,
|
||||
# "to": "buffer_2",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "buffer_2",
|
||||
# "from_port": 0,
|
||||
# "to": "dilate_pass_4",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "dilate_pass_3",
|
||||
# "from_port": 0,
|
||||
# "to": "buffer_2_3",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "buffer_2_3",
|
||||
# "from_port": 0,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "buffer_2_2",
|
||||
# "from_port": 0,
|
||||
# "to": "dilate_pass_3",
|
||||
# "to_port": 1
|
||||
# },
|
||||
# {
|
||||
# "from": "dilate_pass_4",
|
||||
# "from_port": 0,
|
||||
# "to": "dilate_pass_3",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "default_color",
|
||||
# "from_port": 0,
|
||||
# "to": "buffer_2_2",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 1,
|
||||
# "to": "default_color",
|
||||
# "to_port": 0
|
||||
# }
|
||||
# ],
|
||||
# "label": "Dilate",
|
||||
# "longdesc": "Dilates the white areas of a mask, using the colors of an optional input",
|
||||
# "name": "dilate",
|
||||
# "node_position": {
|
||||
# "x": 0,
|
||||
# "y": 0
|
||||
# },
|
||||
# "nodes": [
|
||||
# {
|
||||
# "name": "buffer",
|
||||
# "node_position": {
|
||||
# "x": -473.691315,
|
||||
# "y": -200.988342
|
||||
# },
|
||||
# "parameters": {
|
||||
# "lod": 0,
|
||||
# "size": 9
|
||||
# },
|
||||
# "type": "buffer"
|
||||
# },
|
||||
# {
|
||||
# "name": "buffer_2",
|
||||
# "node_position": {
|
||||
# "x": -255.691315,
|
||||
# "y": -123.988342
|
||||
# },
|
||||
# "parameters": {
|
||||
# "lod": 0,
|
||||
# "size": 9
|
||||
# },
|
||||
# "type": "buffer"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_parameters",
|
||||
# "node_position": {
|
||||
# "x": -140.306458,
|
||||
# "y": -377.953613
|
||||
# },
|
||||
# "parameters": {
|
||||
# "param0": 9,
|
||||
# "param1": 0.1,
|
||||
# "param2": 0,
|
||||
# "param3": 0
|
||||
# },
|
||||
# "type": "remote",
|
||||
# "widgets": [
|
||||
# {
|
||||
# "label": "",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "buffer",
|
||||
# "widget": "size"
|
||||
# },
|
||||
# {
|
||||
# "node": "buffer_2",
|
||||
# "widget": "size"
|
||||
# },
|
||||
# {
|
||||
# "node": "buffer_2_2",
|
||||
# "widget": "size"
|
||||
# },
|
||||
# {
|
||||
# "node": "dilate_pass_1",
|
||||
# "widget": "s"
|
||||
# },
|
||||
# {
|
||||
# "node": "dilate_pass_4",
|
||||
# "widget": "s"
|
||||
# },
|
||||
# {
|
||||
# "node": "buffer_2_3",
|
||||
# "widget": "size"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "The resolution of the input images",
|
||||
# "name": "param0",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "linked_control"
|
||||
# },
|
||||
# {
|
||||
# "label": "",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "dilate_pass_1",
|
||||
# "widget": "d"
|
||||
# },
|
||||
# {
|
||||
# "node": "dilate_pass_4",
|
||||
# "widget": "d"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "The length of the dilate effect",
|
||||
# "name": "param1",
|
||||
# "shortdesc": "Length",
|
||||
# "type": "linked_control"
|
||||
# },
|
||||
# {
|
||||
# "label": "",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "dilate_pass_3",
|
||||
# "widget": "amount"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "0 to generate a gradient to black while dilating, 1 to fill with input color",
|
||||
# "name": "param2",
|
||||
# "shortdesc": "Fill",
|
||||
# "type": "linked_control"
|
||||
# },
|
||||
# {
|
||||
# "label": "",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "dilate_pass_4",
|
||||
# "widget": "distance"
|
||||
# }
|
||||
# ],
|
||||
# "name": "param3",
|
||||
# "shortdesc": "Distance function",
|
||||
# "type": "linked_control"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_inputs",
|
||||
# "node_position": {
|
||||
# "x": -872.306458,
|
||||
# "y": -171.4814
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "ports": [
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "The input mask whose white areas will be dilated",
|
||||
# "name": "mask",
|
||||
# "shortdesc": "Mask",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "The optional source for colors",
|
||||
# "name": "source",
|
||||
# "shortdesc": "Source",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "type": "ios"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_outputs",
|
||||
# "node_position": {
|
||||
# "x": 254.21106,
|
||||
# "y": -64.4814
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "ports": [
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "Shows the dilated image",
|
||||
# "name": "out",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "seed_value": -14401,
|
||||
# "type": "ios"
|
||||
# },
|
||||
# {
|
||||
# "name": "buffer_2_2",
|
||||
# "node_position": {
|
||||
# "x": -255.323547,
|
||||
# "y": -44.695679
|
||||
# },
|
||||
# "parameters": {
|
||||
# "lod": 0,
|
||||
# "size": 9
|
||||
# },
|
||||
# "type": "buffer"
|
||||
# },
|
||||
# {
|
||||
# "name": "dilate_pass_1",
|
||||
# "node_position": {
|
||||
# "x": -252.698792,
|
||||
# "y": -201.368988
|
||||
# },
|
||||
# "parameters": {
|
||||
# "d": 0.1,
|
||||
# "s": 9
|
||||
# },
|
||||
# "seed_value": 71939,
|
||||
# "type": "dilate_pass_1"
|
||||
# },
|
||||
# {
|
||||
# "name": "dilate_pass_3",
|
||||
# "node_position": {
|
||||
# "x": -31.698792,
|
||||
# "y": -72.368988
|
||||
# },
|
||||
# "parameters": {
|
||||
# "amount": 0
|
||||
# },
|
||||
# "type": "dilate_pass_3"
|
||||
# },
|
||||
# {
|
||||
# "name": "dilate_pass_4",
|
||||
# "node_position": {
|
||||
# "x": -31.689392,
|
||||
# "y": -186.577301
|
||||
# },
|
||||
# "parameters": {
|
||||
# "d": 0.1,
|
||||
# "distance": 0,
|
||||
# "s": 9
|
||||
# },
|
||||
# "type": "dilate_pass_2"
|
||||
# },
|
||||
# {
|
||||
# "name": "buffer_2_3",
|
||||
# "node_position": {
|
||||
# "x": -46.966125,
|
||||
# "y": -0.711548
|
||||
# },
|
||||
# "parameters": {
|
||||
# "lod": 0,
|
||||
# "size": 9
|
||||
# },
|
||||
# "type": "buffer"
|
||||
# },
|
||||
# {
|
||||
# "name": "default_color",
|
||||
# "node_position": {
|
||||
# "x": -469.868713,
|
||||
# "y": -98.02066
|
||||
# },
|
||||
# "parameters": {
|
||||
# "default": {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "r": 1,
|
||||
# "type": "Color"
|
||||
# }
|
||||
# },
|
||||
# "type": "default_color"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": {
|
||||
# "param0": 9,
|
||||
# "param1": 0.1,
|
||||
# "param2": 0,
|
||||
# "param3": 0
|
||||
# },
|
||||
# "shortdesc": "Dilate",
|
||||
# "type": "graph"
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
#dilate_pass_1.mmg
|
||||
|
||||
#{
|
||||
# "name": "distance_pass_1",
|
||||
# "node_position": {
|
||||
# "x": 0,
|
||||
# "y": 0
|
||||
# },
|
||||
# "parameters": {
|
||||
# "d": 0.1,
|
||||
# "s": 9
|
||||
# },
|
||||
# "seed_value": 8258,
|
||||
# "shader_model": {
|
||||
# "code": "",
|
||||
# "global": "",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "name": "in",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "vec3 $(name)_distance_h(vec2 uv) {\n\tvec2 e = vec2(1.0/$s, 0.0);\n\tint steps = int($s*$d);\n\tfloat rv = 0.0;\n\tvec2 source_uv;\n\tfor (int i = 0; i < steps; ++i) {\n\t\tsource_uv = uv+float(i)*e;\n\t\tif ($in(source_uv) > 0.5) {\n\t\t\trv = 1.0-float(i)*e.x/$d;\n\t\t\tbreak;\n\t\t}\n\t\tsource_uv = uv-float(i)*e;\n\t\tif ($in(source_uv) > 0.5) {\n\t\t\trv = 1.0-float(i)*e.x/$d;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn vec3(rv, source_uv);\n}\n",
|
||||
# "name": "Distance pass 1",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "rgb": "$(name)_distance_h($uv)",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 6,
|
||||
# "label": "",
|
||||
# "last": 12,
|
||||
# "name": "s",
|
||||
# "type": "size"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "d",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# "type": "shader"
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
#dilate_pass_2.mmg
|
||||
|
||||
#{
|
||||
# "name": "dilate_pass_2",
|
||||
# "node_position": {
|
||||
# "x": 0,
|
||||
# "y": 0
|
||||
# },
|
||||
# "parameters": {
|
||||
# "d": 0.25,
|
||||
# "distance": 0,
|
||||
# "s": 9
|
||||
# },
|
||||
# "seed_value": 44978,
|
||||
# "shader_model": {
|
||||
# "code": "",
|
||||
# "global": "float dilate_distance_euclidian(float x, float y, float d) {\n\treturn 1.0-sqrt((1.0-x)*(1.0-x)+y*y/d/d);\n}\n\nfloat dilate_distance_manhattan(float x, float y, float d) {\n\treturn 1.0-(abs(1.0-x)+abs(y)/d);\n}\n\nfloat dilate_distance_chebyshev(float x, float y, float d) {\n\treturn 1.0-max(abs(1.0-x), abs(y)/d);\n}\n\n",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "name": "in",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "vec3 $(name)_distance_v(vec2 uv) {\n\tvec2 e = vec2(0.0, 1.0/$s);\n\tint steps = int($s*$d);\n\tvec3 p = $in(uv);\n\tfor (int i = 0; i < steps; ++i) {\n\t\tvec2 dx = float(i)*e;\n\t\tvec3 p2 = $in(uv+dx);\n\t\tif (p2.x > p.x) {\n\t\t\tp2.x = dilate_distance_$distance(p2.x, dx.y, $d);\n\t\t\tp = mix(p, p2, step(p.x, p2.x));\n\t\t}\n\t\tp2 = $in(uv-dx);\n\t\tif (p2.x > p.x) {\n\t\t\tp2.x = dilate_distance_$distance(p2.x, dx.y, $d);\n\t\t\tp = mix(p, p2, step(p.x, p2.x));\n\t\t}\n\t}\n\treturn p;\n}\n",
|
||||
# "name": "Distance pass 2",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "rgb": "$(name)_distance_v($uv)",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 6,
|
||||
# "label": "",
|
||||
# "last": 12,
|
||||
# "name": "s",
|
||||
# "type": "size"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "d",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": 2,
|
||||
# "label": "",
|
||||
# "name": "distance",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Euclidian",
|
||||
# "value": "euclidian"
|
||||
# },
|
||||
# {
|
||||
# "name": "Manhattan",
|
||||
# "value": "manhattan"
|
||||
# },
|
||||
# {
|
||||
# "name": "Chebyshev",
|
||||
# "value": "chebyshev"
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# "type": "shader"
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
#dilate_pass_3.mmg
|
||||
|
||||
#{
|
||||
# "name": "distance_pass_3",
|
||||
# "node_position": {
|
||||
# "x": 0,
|
||||
# "y": 0
|
||||
# },
|
||||
# "parameters": {
|
||||
# "amount": 0
|
||||
# },
|
||||
# "shader_model": {
|
||||
# "code": "",
|
||||
# "global": "",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "",
|
||||
# "name": "distance",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(1.0)",
|
||||
# "label": "",
|
||||
# "name": "source",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "",
|
||||
# "name": "Distance pass 3",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "rgb": "$source($distance($uv).yz)*mix($distance($uv).x, 1.0, $amount)",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "amount",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# "type": "shader"
|
||||
#}
|
||||
|
223
addons/mat_maker_gd/nodes/common/edge_detect.gd
Normal file
223
addons/mat_maker_gd/nodes/common/edge_detect.gd
Normal file
@ -0,0 +1,223 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
#An edge detect filter that detects edges along all directions and draws them in white on a black background
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The input image",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "float $(name)_fct(vec2 uv) {\n\tvec3 e_base = vec3(1.0/$size, -1.0/$size, 0);\n\tvec3 ref = $in(uv);\n\tvec3 e = vec3(0);\n\tfloat rv = 0.0;\n\tfor (int i = 0; i < int($width); ++i) {\n\t\te += e_base;\n\t\trv += length($in(uv+e.xy)-ref);\n\t\trv += length($in(uv-e.xy)-ref);\n\t\trv += length($in(uv+e.xx)-ref);\n\t\trv += length($in(uv-e.xx)-ref);\n\t\trv += length($in(uv+e.xz)-ref);\n\t\trv += length($in(uv-e.xz)-ref);\n\t\trv += length($in(uv+e.zx)-ref);\n\t\trv += length($in(uv-e.zx)-ref);\n\t\trv *= 2.0;\n\t}\n\treturn rv*pow(2.0, -$width);\n}",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "clamp(100.0*($(name)_fct($uv)-$threshold), 0.0, 1.0)",
|
||||
# "longdesc": "Shows the generated outlines",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 4,
|
||||
# "label": "Size",
|
||||
# "last": 12,
|
||||
# "longdesc": "The resolution of the input image",
|
||||
# "name": "size",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "size"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Width",
|
||||
# "max": 5,
|
||||
# "min": 1,
|
||||
# "name": "width",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Threshold",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "threshold",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#edge_detect_1.mmg
|
||||
#An edge detect filter that detects edges along all directions and draws them in white on a black background
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The input image",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "float $(name)_fct(vec2 uv) {\n\tvec3 e = vec3(1.0/$size, -1.0/$size, 0);\n\tvec3 rv = 8.0*$in(uv);\n\trv -= $in(uv+e.xy);\n\trv -= $in(uv-e.xy);\n\trv -= $in(uv+e.xx);\n\trv -= $in(uv-e.xx);\n\trv -= $in(uv+e.xz);\n\trv -= $in(uv-e.xz);\n\trv -= $in(uv+e.zx);\n\trv -= $in(uv-e.zx);\n\trv = abs(rv);\n\treturn max(rv.x, max(rv.y ,rv.z))*$size;\n}",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "clamp($(name)_fct($uv), 0.0, 1.0)",
|
||||
# "longdesc": "Shows the generated outlines",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 4,
|
||||
# "label": "Size",
|
||||
# "last": 12,
|
||||
# "longdesc": "The resolution of the input image",
|
||||
# "name": "size",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "size"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#edge_detect_2.mmg
|
||||
#An edge detect filter that detects edges horizontally and vertically and draws them in white on a black background
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The input image",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "float $(name)_fct(vec2 uv) {\n\tvec2 e = vec2(1.0/$size, 0.0);\n\tvec3 rv = 4.0*$in(uv);\n\trv -= $in(uv+e.xy);\n\trv -= $in(uv-e.xy);\n\trv -= $in(uv+e.yx);\n\trv -= $in(uv-e.yx);\n\trv = abs(rv);\n\treturn max(rv.x, max(rv.y ,rv.z))*$size;\n}",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "clamp($(name)_fct($uv), 0.0, 1.0)",
|
||||
# "longdesc": "Shows the generated outlines",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 4,
|
||||
# "label": "Size",
|
||||
# "last": 12,
|
||||
# "longdesc": "The resolution of the input image",
|
||||
# "name": "size",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "size"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#edge_detect_3.mmg
|
||||
#An edge detect filter that detects edges along diagonals and draws them in white on a black background
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The input image",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "float $(name)_fct(vec2 uv) {\n\tvec2 e = vec2(1.0/$size, -1.0/$size);\n\tvec3 rv = 4.0*$in(uv);\n\trv -= $in(uv+e.xy);\n\trv -= $in(uv-e.xy);\n\trv -= $in(uv+e.xx);\n\trv -= $in(uv-e.xx);\n\trv = abs(rv);\n\treturn max(rv.x, max(rv.y ,rv.z))*$size;\n}",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "clamp($(name)_fct($uv), 0.0, 1.0)",
|
||||
# "longdesc": "Shows the generated outlines",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 4,
|
||||
# "label": "Size",
|
||||
# "last": 12,
|
||||
# "longdesc": "The resolution of the input image",
|
||||
# "name": "size",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "size"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#mul_detect.mmg
|
||||
|
||||
# "code": "float $(name_uv)_d = ($in($uv)-$v)/$t;",
|
||||
# "global": "",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "label": "",
|
||||
# "name": "mul",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "label": "",
|
||||
# "name": "in",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "",
|
||||
# "name": "MulDetect",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "$mul($uv)*clamp(1.0-$(name_uv)_d*$(name_uv)_d, 0.0, 1.0)",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Value",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "v",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.1,
|
||||
# "label": "Tolerance",
|
||||
# "max": 1,
|
||||
# "min": 0.01,
|
||||
# "name": "t",
|
||||
# "step": 0.001,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ]
|
||||
|
559
addons/mat_maker_gd/nodes/common/fills.gd
Normal file
559
addons/mat_maker_gd/nodes/common/fills.gd
Normal file
@ -0,0 +1,559 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#fill.mmg
|
||||
#Fills areas defined by white outlines of its input
|
||||
|
||||
#{
|
||||
# "connections": [
|
||||
# {
|
||||
# "from": "iterate_buffer",
|
||||
# "from_port": 0,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "iterate_buffer",
|
||||
# "from_port": 1,
|
||||
# "to": "fill_iterate",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "fill_iterate",
|
||||
# "from_port": 0,
|
||||
# "to": "iterate_buffer",
|
||||
# "to_port": 1
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 0,
|
||||
# "to": "fill_preprocess",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "fill_preprocess",
|
||||
# "from_port": 0,
|
||||
# "to": "iterate_buffer",
|
||||
# "to_port": 0
|
||||
# }
|
||||
# ],
|
||||
# "nodes": [
|
||||
# {
|
||||
# "name": "iterate_buffer",
|
||||
# "node_position": {
|
||||
# "x": -129.307083,
|
||||
# "y": -370.480591
|
||||
# },
|
||||
# "parameters": {
|
||||
# "iterations": 10,
|
||||
# "size": 8
|
||||
# },
|
||||
# "seed_value": 29168,
|
||||
# "type": "iterate_buffer"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_inputs",
|
||||
# "node_position": {
|
||||
# "x": -542.307068,
|
||||
# "y": -370.662445
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "ports": [
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "The input image whose white outlines must be filled",
|
||||
# "name": "port0",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "type": "ios"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_outputs",
|
||||
# "node_position": {
|
||||
# "x": 198.267258,
|
||||
# "y": -362.662445
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "ports": [
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "Generates fill data, to be connected to a fill companion node",
|
||||
# "name": "port0",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "type": "ios"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_parameters",
|
||||
# "node_position": {
|
||||
# "x": -171.110138,
|
||||
# "y": -541.509705
|
||||
# },
|
||||
# "parameters": {
|
||||
# "param0": 8,
|
||||
# "param1": 10
|
||||
# },
|
||||
# "type": "remote",
|
||||
# "widgets": [
|
||||
# {
|
||||
# "label": "",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "iterate_buffer",
|
||||
# "widget": "size"
|
||||
# },
|
||||
# {
|
||||
# "node": "fill_preprocess",
|
||||
# "widget": "s"
|
||||
# },
|
||||
# {
|
||||
# "node": "fill_iterate",
|
||||
# "widget": "s"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "The resolution of the inptu image",
|
||||
# "name": "param0",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "linked_control"
|
||||
# },
|
||||
# {
|
||||
# "label": "",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "iterate_buffer",
|
||||
# "widget": "iterations"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "The number of iterations of the algorithm. The optimal value depends a lot on the input image.",
|
||||
# "name": "param1",
|
||||
# "shortdesc": "Iterations",
|
||||
# "type": "linked_control"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "name": "fill_iterate",
|
||||
# "node_position": {
|
||||
# "x": -92.913391,
|
||||
# "y": -290.886963
|
||||
# },
|
||||
# "parameters": {
|
||||
# "s": 8
|
||||
# },
|
||||
# "type": "fill_iterate"
|
||||
# },
|
||||
# {
|
||||
# "name": "fill_preprocess",
|
||||
# "node_position": {
|
||||
# "x": -110.443481,
|
||||
# "y": -427.202026
|
||||
# },
|
||||
# "parameters": {
|
||||
# "s": 8
|
||||
# },
|
||||
# "type": "fill_preprocess"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": {
|
||||
# "param0": 8,
|
||||
# "param1": 10
|
||||
# },
|
||||
# "shortdesc": "Fill",
|
||||
# "type": "graph"
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
#fill_iterate.mmg
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "name": "in",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "vec4 $(name)_fill(vec2 uv) {\n\tfloat size = $s;\n\tint iterations = min(int(size), 256);\n\tvec4 color = $in(fract(uv));\n\tif (color.z+color.w < 1.0/size) {\n\t\treturn vec4(0.0);\n\t}\n\tvec2 offsets[8] = { vec2(1.0, 0.0), vec2(-1.0, 0.0), vec2(0.0, 1.0), vec2(0.0, -1.0), vec2(1.0, 1.0), vec2(-1.0, 1.0), vec2(-1.0, 1.0), vec2(-1.0, -1.0) };\n\tfor (int o = 0; o < 8; ++o) {\n\t\tvec2 uv2 = uv;\n\t\tvec2 offset = offsets[o]/size;\n\t\tfor (int i = 1; i < iterations; i += 1) {\n\t\t\tuv2 += offset;\n\t\t\tvec4 color2 = $in(fract(uv2));\n\t\t\tif (color2.z+color2.w == 0.0) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tvec2 p1 = color.xy+floor(uv-color.xy);\n\t\t\tvec2 p2 = color2.xy+floor(uv2-color2.xy);\n\t\t\tvec2 p = min(p1, p2);\n\t\t\tvec2 s = max(p1+color.zw, p2+color2.zw)-p;\n\t\t\tcolor = mix(vec4(0.0, 0.0, 1.0, 1.0), vec4(fract(p), s), step(s.xyxy, vec4(1.0)));\n\t\t}\n\t}\n\treturn floor(color*size)/size;\n}\n",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "rgba": "$(name)_fill($uv)",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 9,
|
||||
# "first": 6,
|
||||
# "label": "",
|
||||
# "last": 12,
|
||||
# "name": "s",
|
||||
# "type": "size"
|
||||
# }
|
||||
# ]
|
||||
|
||||
#----------------------
|
||||
#fill_preprocess.mmg
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "name": "in",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "rgba": "flood_fill_preprocess($uv, $in($uv), $s)",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 10,
|
||||
# "first": 0,
|
||||
# "label": "",
|
||||
# "last": 12,
|
||||
# "name": "s",
|
||||
# "type": "size"
|
||||
# }
|
||||
# ]
|
||||
|
||||
|
||||
|
||||
|
||||
#----------------------
|
||||
#fill_to_color.mmg
|
||||
#A fill companion node that fills each area with a color taken from a color map image
|
||||
|
||||
# "code": "vec4 $(name_uv)_bb = $in($uv);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input fill data, to be connected to the output of a Fill node",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(1.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The image from which colors are taken",
|
||||
# "name": "map",
|
||||
# "shortdesc": "Color map",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated output image",
|
||||
# "rgba": "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))))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "r": 1
|
||||
# },
|
||||
# "label": "Edge Color",
|
||||
# "longdesc": "The color used to draw outlines",
|
||||
# "name": "edgecolor",
|
||||
# "shortdesc": "Outline color",
|
||||
# "type": "color"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#fill_to_position.mmg
|
||||
#A fill companion node that fills each area with a greyscale value that depends on its position
|
||||
|
||||
# "code": "vec2 $(name_uv)_c = fract($in($uv).xy+0.5*$in($uv).zw);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input fill data, to be connected to the output of a Fill node",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "$axis",
|
||||
# "longdesc": "The generated output image",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 2,
|
||||
# "label": "",
|
||||
# "longdesc": "The position value to be used:\n- X for horizontal axis\n- Y for vertical axis\n- Radial for distance to center",
|
||||
# "name": "axis",
|
||||
# "shortdesc": "Position",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "X",
|
||||
# "value": "$(name_uv)_c.x"
|
||||
# },
|
||||
# {
|
||||
# "name": "Y",
|
||||
# "value": "$(name_uv)_c.y"
|
||||
# },
|
||||
# {
|
||||
# "name": "Radial",
|
||||
# "value": "length($(name_uv)_c-vec2(0.5))"
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#fill_to_random_color.mmg
|
||||
#A fill companion node that fills each area with a random color
|
||||
|
||||
# "code": "vec4 $(name_uv)_bb = $in($uv);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input fill data, to be connected to the output of a Fill node",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated output image",
|
||||
# "rgb": "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))))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "r": 1
|
||||
# },
|
||||
# "label": "Edge Color",
|
||||
# "longdesc": "The color used for outlines",
|
||||
# "name": "edgecolor",
|
||||
# "shortdesc": "Outline color",
|
||||
# "type": "color"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#fill_to_random_grey.mmg
|
||||
#A fill companion node that fills each area with a random greyscale value
|
||||
|
||||
# "code": "vec4 $(name_uv)_bb = $in($uv);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input fill data, to be connected to the output of a Fill node",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "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))))",
|
||||
# "longdesc": "The generated output image",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Edge color",
|
||||
# "longdesc": "The value used for the outlines",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "edgecolor",
|
||||
# "shortdesc": "Outline color",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#fill_to_size.mmg
|
||||
#A fill companion node that fills each area with a greyscale value that depends on its size
|
||||
|
||||
# "code": "vec4 $(name_uv)_bb = $in($uv);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input fill data, to be connected to the output of a Fill node",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "$formula",
|
||||
# "longdesc": "The generated output image",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "",
|
||||
# "longdesc": "The size value to be used (area, width, height or maximum between width and height)",
|
||||
# "name": "formula",
|
||||
# "shortdesc": "Size",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Area",
|
||||
# "value": "sqrt($(name_uv)_bb.z*$(name_uv)_bb.w)"
|
||||
# },
|
||||
# {
|
||||
# "name": "Width",
|
||||
# "value": "$(name_uv)_bb.z"
|
||||
# },
|
||||
# {
|
||||
# "name": "Height",
|
||||
# "value": "$(name_uv)_bb.w"
|
||||
# },
|
||||
# {
|
||||
# "name": "max(W, H)",
|
||||
# "value": "max($(name_uv)_bb.z, $(name_uv)_bb.w)"
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#fill_to_uv.mmg
|
||||
#A fill companion node that generated an UV map that follows each filled area
|
||||
|
||||
# "code": "vec4 $(name_uv)_bb = $in($uv);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input fill data, to be connected to the output of a Fill node",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated output UV map, to be connected to a Custom UV node",
|
||||
# "rgb": "fill_to_uv_$mode($uv, $(name_uv)_bb, float($seed))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "",
|
||||
# "longdesc": "The mode decides how the UVs are layed out on each bounding box:\n- Stretch mode where the UV layout is stretched to the bounding box. \n- Square mode where the UV layout is even and centerered based on the longest axis of the bounding box.",
|
||||
# "name": "mode",
|
||||
# "shortdesc": "Mode",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Stretch",
|
||||
# "value": "stretch"
|
||||
# },
|
||||
# {
|
||||
# "name": "Square",
|
||||
# "value": "square"
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
# ],
|
||||
|
||||
#vec4 flood_fill_preprocess(vec2 uv, float c, float s) {
|
||||
# if (c > 0.5) {
|
||||
# return vec4(0.0);
|
||||
# } else {
|
||||
# return vec4(floor(uv*s)/s, vec2(1.0/s));
|
||||
# }
|
||||
#}
|
||||
|
||||
static func flood_fill_preprocess(uv : Vector2, c : float, s : float) -> Color:
|
||||
if (c > 0.5):
|
||||
return Color(0, 0, 0, 0)
|
||||
else:
|
||||
uv = Commons.floorv2(uv * s) / s
|
||||
var f : float = 1.0 / s
|
||||
return Color(uv.x, uv.y, f, f)
|
||||
|
||||
#vec3 fill_to_uv_stretch(vec2 coord, vec4 bb, float seed) {
|
||||
# vec2 uv_islands = fract(coord-bb.xy)/bb.zw;
|
||||
# float random_value = rand(vec2(seed)+bb.xy+bb.zw);
|
||||
# return vec3(uv_islands, random_value);
|
||||
#}
|
||||
|
||||
static func fill_to_uv_stretch(coord : Vector2, bb : Color, pseed : float) -> Vector3:
|
||||
var uv_islands : Vector2 = Commons.fractv2(coord - Vector2(bb.r, bb.g)) / Vector2(bb.b, bb.a)
|
||||
var random_value : float = Commons.rand(Vector2(pseed, pseed) + Vector2(bb.r, bb.g) + Vector2(bb.b, bb.a))
|
||||
return Vector3(uv_islands.x, uv_islands.y, random_value)
|
||||
|
||||
#vec3 fill_to_uv_square(vec2 coord, vec4 bb, float seed) {
|
||||
# vec2 uv_islands;
|
||||
#
|
||||
# if (bb.z > bb.w) {
|
||||
# vec2 adjusted_coord = coord + vec2(0.0, (bb.z - bb.w) / 2.0);
|
||||
# uv_islands = fract(adjusted_coord-bb.xy)/bb.zz;
|
||||
# } else {
|
||||
# vec2 adjusted_coord = coord + vec2((bb.w - bb.z) / 2.0, 0.0);
|
||||
# uv_islands = fract(adjusted_coord-bb.xy)/bb.ww;
|
||||
# }
|
||||
#
|
||||
# float random_value = rand(vec2(seed)+bb.xy+bb.zw);
|
||||
# return vec3(uv_islands, random_value);
|
||||
#}
|
||||
|
||||
static func fill_to_uv_square(coord : Vector2, bb : Color, pseed : float) -> Vector3:
|
||||
var uv_islands : Vector2 = Vector2()
|
||||
|
||||
if (bb.b > bb.a):
|
||||
var adjusted_coord : Vector2 = coord + Vector2(0.0, (bb.b - bb.a) / 2.0);
|
||||
uv_islands = Commons.fractv2(adjusted_coord - Vector2(bb.r, bb.g)) / Vector2(bb.b, bb.b)
|
||||
else:
|
||||
var adjusted_coord : Vector2 = coord + Vector2((bb.a - bb.b) / 2.0, 0.0);
|
||||
uv_islands = Commons.fractv2(adjusted_coord - Vector2(bb.r, bb.g)) / Vector2(bb.a, bb.a)
|
||||
|
||||
var random_value : float = Commons.rand(Vector2(pseed, pseed) + Vector2(bb.r, bb.g) + Vector2(bb.b, bb.a))
|
||||
return Vector3(uv_islands.x, uv_islands.y, random_value)
|
4442
addons/mat_maker_gd/nodes/common/filter.gd
Normal file
4442
addons/mat_maker_gd/nodes/common/filter.gd
Normal file
File diff suppressed because it is too large
Load Diff
225
addons/mat_maker_gd/nodes/common/gradients.gd
Normal file
225
addons/mat_maker_gd/nodes/common/gradients.gd
Normal file
@ -0,0 +1,225 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#note: data : PoolRealArray -> pos, r, g, b, a, pos, r, g, b, a ....
|
||||
|
||||
#gradient.mmg
|
||||
|
||||
#float $(name_uv)_r = 0.5+(cos($rotate*0.01745329251)*($uv.x-0.5)+sin($rotate*0.01745329251)*($uv.y-0.5))/(cos(abs(mod($rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);"
|
||||
|
||||
#output: $gradient(fract($(name_uv)_r*$repeat))
|
||||
|
||||
#repeat: default: 1, min: 1, max : 32, step: 1
|
||||
#rotate: default: 0, min: -180, max: 180, step: 0.1
|
||||
|
||||
#default: "interpolation": 1,
|
||||
# "points": [{"a": 1,"b": 0,"g": 0,"pos": 0,"r": 0},{"a": 1,"b": 1,"g": 1,"pos": 1,"r": 1} ],
|
||||
|
||||
#radial_gradient.mmg
|
||||
|
||||
#output: $gradient(fract($repeat*1.41421356237*length(fract($uv)-vec2(0.5, 0.5))))
|
||||
|
||||
#repeat: default: 1, min: 1, max : 32, step: 1
|
||||
|
||||
#circular_gradient.mmg
|
||||
|
||||
#output: gradient(fract($repeat*0.15915494309*atan($uv.y-0.5, $uv.x-0.5)))
|
||||
|
||||
#repeat: default: 1, min: 1, max : 32, step: 1
|
||||
|
||||
#gradient.gd
|
||||
|
||||
static func radial_gradient_type_1(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_1(Commons.fractf(repeat * 1.41421356237* (Commons.fractv2(uv) - Vector2(0.5, 0.5)).length()), data)
|
||||
|
||||
static func radial_gradient_type_2(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_2(Commons.fractf(repeat * 1.41421356237* (Commons.fractv2(uv) - Vector2(0.5, 0.5)).length()), data)
|
||||
|
||||
static func radial_gradient_type_3(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_3(Commons.fractf(repeat * 1.41421356237* (Commons.fractv2(uv) - Vector2(0.5, 0.5)).length()), data)
|
||||
|
||||
static func radial_gradient_type_4(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_4(Commons.fractf(repeat * 1.41421356237* (Commons.fractv2(uv) - Vector2(0.5, 0.5)).length()), data)
|
||||
|
||||
|
||||
|
||||
static func normal_gradient_type_1(uv : Vector2, repeat : float, rotate : float, data : PoolRealArray) -> Color:
|
||||
var rr : float = 0.5+(cos(rotate*0.01745329251)*(uv.x-0.5)+sin(rotate*0.01745329251)*(uv.y-0.5))/(cos(abs(Commons.modf(rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
return gradient_type_1(Commons.fractf(rr * repeat), data)
|
||||
|
||||
static func normal_gradient_type_2(uv : Vector2, repeat : float, rotate : float, data : PoolRealArray) -> Color:
|
||||
var rr : float = 0.5+(cos(rotate*0.01745329251)*(uv.x-0.5)+sin(rotate*0.01745329251)*(uv.y-0.5))/(cos(abs(Commons.modf(rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
return gradient_type_2(Commons.fractf(rr * repeat), data)
|
||||
|
||||
static func normal_gradient_type_3(uv : Vector2, repeat : float, rotate : float, data : PoolRealArray) -> Color:
|
||||
var rr : float = 0.5+(cos(rotate*0.01745329251)*(uv.x-0.5)+sin(rotate*0.01745329251)*(uv.y-0.5))/(cos(abs(Commons.modf(rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
return gradient_type_3(Commons.fractf(rr * repeat), data)
|
||||
|
||||
static func normal_gradient_type_4(uv : Vector2, repeat : float, rotate : float, data : PoolRealArray) -> Color:
|
||||
var rr : float = 0.5+(cos(rotate*0.01745329251)*(uv.x-0.5)+sin(rotate*0.01745329251)*(uv.y-0.5))/(cos(abs(Commons.modf(rotate, 90.0)-45.0)*0.01745329251)*1.41421356237);
|
||||
return gradient_type_4(Commons.fractf(rr * repeat), data)
|
||||
|
||||
|
||||
|
||||
static func circular_gradient_type_1(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_1(Commons.fractf(repeat * 0.15915494309 * atan2((uv.y - 0.5), uv.x - 0.5)), data)
|
||||
|
||||
static func circular_gradient_type_2(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_2(Commons.fractf(repeat * 0.15915494309 * atan2((uv.y - 0.5), uv.x - 0.5)), data)
|
||||
|
||||
static func circular_gradient_type_3(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_3(Commons.fractf(repeat * 0.15915494309 * atan2((uv.y - 0.5), uv.x - 0.5)), data)
|
||||
|
||||
static func circular_gradient_type_4(uv : Vector2, repeat : float, data : PoolRealArray) -> Color:
|
||||
return gradient_type_4(Commons.fractf(repeat * 0.15915494309 * atan2((uv.y - 0.5), uv.x - 0.5)), data)
|
||||
|
||||
|
||||
static func gradient_type_1(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
|
||||
for i in range(0, data.size() - 5, 5):
|
||||
if x < 0.5 * (data[i] + data[i + 5]):
|
||||
return Color(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
|
||||
|
||||
var ds = data.size() - 5
|
||||
return Color(data[ds + 1], data[ds + 2], data[ds + 3], data[ds + 4])
|
||||
|
||||
static func gradient_type_2(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
|
||||
for i in range(0, data.size(), 5):
|
||||
if x < data[i]:
|
||||
if i == 0:
|
||||
return Color(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
|
||||
|
||||
var cprev : Color = Color(data[i - 4], data[i - 3], data[i - 2], data[i - 1])
|
||||
var ccurr : Color = Color(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
|
||||
return lerp(cprev, ccurr, (x - data[i - 5]) / (data[i] - data[i - 5]));
|
||||
|
||||
var ds = data.size() - 5
|
||||
return Color(data[ds + 1], data[ds + 2], data[ds + 3], data[ds + 4])
|
||||
|
||||
static func gradient_type_3(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
|
||||
for i in range(0, data.size(), 5):
|
||||
if x < data[i]:
|
||||
if i == 0:
|
||||
return Color(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
|
||||
|
||||
var cprev : Color = Color(data[i - 4], data[i - 3], data[i - 2], data[i - 1])
|
||||
var ccurr : Color = Color(data[i + 1], data[i + 2], data[i + 3], data[i + 4])
|
||||
return lerp(cprev, ccurr, 0.5 - 0.5 * cos(3.14159265359 * ((x - data[i - 5]) / (data[i] - data[i - 5]))))
|
||||
|
||||
var ds = data.size() - 5
|
||||
return Color(data[ds + 1], data[ds + 2], data[ds + 3], data[ds + 4])
|
||||
|
||||
static func get_data_color(index : int, data : PoolRealArray) -> Color:
|
||||
var i : int = index * 5
|
||||
|
||||
return Color(data[i + 1], data[i + 2],data[i + 3], data[i + 4])
|
||||
|
||||
static func get_data_pos(index : int, data : PoolRealArray) -> float:
|
||||
return data[index * 5]
|
||||
|
||||
static func gradient_type_4(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
|
||||
var ds : int = data.size() / 5
|
||||
var s : int = ds - 1
|
||||
|
||||
for i in range(0, s):
|
||||
if x < get_data_pos(i, data):
|
||||
if i == 0:
|
||||
return get_data_color(i, data)
|
||||
|
||||
# var dx : String = "(x-%s)/(%s-%s)" % [ pv(name, i), pv(name, i+1), pv(name, i) ]
|
||||
var dx : float = (x - get_data_pos(i, data))/(get_data_pos(i + 1, data) - get_data_pos(i, data))
|
||||
# var b : String = "mix(%s, %s, %s)" % [ pc(name, i), pc(name, i+1), dx ]
|
||||
var b : Color = lerp(get_data_color(i - 1, data), get_data_color(i - 1, data), dx)
|
||||
|
||||
if i == 1:
|
||||
# var c : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i+1), pc(name, i+2), pv(name, i+1), pv(name, i+2), pv(name, i+1) ]
|
||||
var c : Color = lerp(get_data_color(i + 1, data), get_data_color(i + 2, data), (x - get_data_pos(i + 1, data))/(get_data_pos(i + 2, data) - get_data_pos(i + 1, data)))
|
||||
# shader += " return mix("+c+", "+b+", 1.0-0.5*"+dx+");\n"
|
||||
return lerp(c, b, 1.0 - 0.5 * dx)
|
||||
|
||||
# var a : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i-1), pc(name, i), pv(name, i-1), pv(name, i), pv(name, i-1) ]
|
||||
var a : Color = lerp(get_data_color(i - 1, data), get_data_color(i, data), (x - get_data_pos(i - 1, data)) / (get_data_pos(i, data) - get_data_pos(i - 1, data)))
|
||||
|
||||
# if i < s-1:
|
||||
if i < s - 1:
|
||||
# var c : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i+1), pc(name, i+2), pv(name, i+1), pv(name, i+2), pv(name, i+1) ]
|
||||
var c : Color = lerp(get_data_color(i + 1, data), get_data_color(i + 2, data), (x - get_data_pos(i + 1, data)) / (get_data_pos(i + 2, data) - get_data_pos(i + 1, data)))
|
||||
# var ac : String = "mix("+a+", "+c+", 0.5-0.5*cos(3.14159265359*"+dx+"))"
|
||||
var ac : Color = lerp(a, c, 0.5-0.5*cos(3.14159265359 * dx))
|
||||
# shader += " return 0.5*("+b+" + "+ac+");\n"
|
||||
var dt : Color = b + ac
|
||||
|
||||
dt.r *= 0.5
|
||||
dt.g *= 0.5
|
||||
dt.b *= 0.5
|
||||
dt.a = clamp(0, 1, dt.a)
|
||||
|
||||
return dt
|
||||
# else
|
||||
else:
|
||||
# shader += " return mix("+a+", "+b+", 0.5+0.5*"+dx+");\n"
|
||||
return lerp(a, b, 0.5 + 0.5 * dx)
|
||||
|
||||
return get_data_color(ds - 1, data)
|
||||
|
||||
#todo make it selectable
|
||||
static func gradient_type_5(x : float, data : PoolRealArray) -> Color:
|
||||
if data.size() % 5 != 0 || data.size() == 0:
|
||||
return Color()
|
||||
|
||||
var ds : int = data.size() / 5
|
||||
var s : int = ds - 1
|
||||
|
||||
for i in range(0, s):
|
||||
if x < get_data_pos(i, data):
|
||||
if i == 0:
|
||||
return get_data_color(i, data)
|
||||
|
||||
# var dx : String = "(x-%s)/(%s-%s)" % [ pv(name, i), pv(name, i+1), pv(name, i) ]
|
||||
var dx : float = (x - get_data_pos(i, data))/(get_data_pos(i + 1, data) - get_data_pos(i, data))
|
||||
# var b : String = "mix(%s, %s, %s)" % [ pc(name, i), pc(name, i+1), dx ]
|
||||
var b : Color = lerp(get_data_color(i - 1, data), get_data_color(i - 1, data), dx)
|
||||
|
||||
if i == 1:
|
||||
# var c : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i+1), pc(name, i+2), pv(name, i+1), pv(name, i+2), pv(name, i+1) ]
|
||||
var c : Color = lerp(get_data_color(i + 1, data), get_data_color(i + 2, data), (x - get_data_pos(i + 1, data))/(get_data_pos(i + 2, data) - get_data_pos(i + 1, data)))
|
||||
# shader += " return mix("+c+", "+b+", 1.0-0.5*"+dx+");\n"
|
||||
return lerp(c, b, 1.0 - 0.5 * dx)
|
||||
|
||||
# var a : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i-1), pc(name, i), pv(name, i-1), pv(name, i), pv(name, i-1) ]
|
||||
var a : Color = lerp(get_data_color(i - 1, data), get_data_color(i, data), (x - get_data_pos(i - 1, data)) / (get_data_pos(i, data) - get_data_pos(i - 1, data)))
|
||||
|
||||
# if i < s-1:
|
||||
if i < s - 1:
|
||||
# var c : String = "mix(%s, %s, (x-%s)/(%s-%s))" % [ pc(name, i+1), pc(name, i+2), pv(name, i+1), pv(name, i+2), pv(name, i+1) ]
|
||||
var c : Color = lerp(get_data_color(i+1, data), get_data_color(i+2, data), (x - get_data_pos(i + 1, data)) / (get_data_pos(i + 2, data) - get_data_pos(i + 1, data)))
|
||||
# var ac : String = "mix("+a+", "+c+", 0.5-0.5*cos(3.14159265359*"+dx+"))"
|
||||
var ac : Color = lerp(a, c, 0.5-0.5*cos(3.14159265359 * dx))
|
||||
# shader += " return 0.5*("+b+" + "+ac+");\n"
|
||||
var dt : Color = b + ac
|
||||
|
||||
dt.r *= 0.5
|
||||
dt.g *= 0.5
|
||||
dt.b *= 0.5
|
||||
dt.a = clamp(0, 1, dt.a)
|
||||
|
||||
return dt
|
||||
# else
|
||||
else:
|
||||
# shader += " return mix("+a+", "+b+", 0.5+0.5*"+dx+");\n"
|
||||
return lerp(a, b, 0.5 + 0.5 * dx)
|
||||
|
||||
return get_data_color(ds - 1, data)
|
705
addons/mat_maker_gd/nodes/common/mwf.gd
Normal file
705
addons/mat_maker_gd/nodes/common/mwf.gd
Normal file
@ -0,0 +1,705 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#mwf_create_map.mmg
|
||||
#Creates a workflow map using a heightmap and an optional seed map. The workflow map contains height information as well as orientation and a seed for random offset for the material it will be applied to.
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "label": "",
|
||||
# "longdesc": "The input height map",
|
||||
# "name": "h",
|
||||
# "shortdesc": "Height",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "label": "",
|
||||
# "longdesc": "The input offset seed map",
|
||||
# "name": "o",
|
||||
# "shortdesc": "Offset",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated workflow map, to be connected to a MixMap or an ApplyMap node",
|
||||
# "rgb": "vec3($height*$h($uv), $angle*0.00277777777+0.5, rand(vec2(float($seed)+$o($uv))))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Height",
|
||||
# "longdesc": "The maximum height of the workflow map, used as multiplier for the input height map",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "height",
|
||||
# "shortdesc": "Height",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Angle",
|
||||
# "longdesc": "The angle stored in the workflow map",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "angle",
|
||||
# "shortdesc": "Angle",
|
||||
# "step": 0.1,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#mwf_mix_maps.mmg
|
||||
#Mixes up to 4 workflow maps, to be used with the same base material
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The first workflow map",
|
||||
# "name": "in1",
|
||||
# "shortdesc": "Input1",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The second workflow map",
|
||||
# "name": "in2",
|
||||
# "shortdesc": "Input2",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The third input map",
|
||||
# "name": "in3",
|
||||
# "shortdesc": "Input3",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The fourth input map",
|
||||
# "name": "in4",
|
||||
# "shortdesc": "Input4",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "Generates a merged workflow map",
|
||||
# "rgb": "matmap_mix(matmap_mix($in1($uv), $in2($uv)), matmap_mix($in3($uv), $in4($uv)))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#mwf_map.mmg
|
||||
#"Applies a workflow map to a base material, and generates height information as well as PBR channels for the result.\nThe height input must be connected to a Create Map or Mix Maps node. The other inputs must be connected to a base material.\nThe outputs must be connected to the Mix or the Output node, or a workflow filter node.
|
||||
|
||||
# "code": "float $(name_uv)_angle = 6.28318530718*($map($uv).y-0.5);\nvec2 $(name_uv)_uv = matmap_uv($uv, $(name_uv)_angle, $map($uv).z);\n",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(1.0, 0.5, 0.0)",
|
||||
# "label": "Map",
|
||||
# "longdesc": "The input workflow map",
|
||||
# "name": "map",
|
||||
# "shortdesc": "Map",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "group_size": 4,
|
||||
# "label": "Albedo",
|
||||
# "longdesc": "The Albedo channel of the input base material",
|
||||
# "name": "mat1",
|
||||
# "shortdesc": "Albedo",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "ORM",
|
||||
# "longdesc": "The ambient occlusion, roughness and metallic channels of the input material",
|
||||
# "name": "mat2",
|
||||
# "shortdesc": "ORM",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "Emission",
|
||||
# "longdesc": "The emission channel of the input material",
|
||||
# "name": "mat3",
|
||||
# "shortdesc": "Emission",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.5, 0.5, 1.0)",
|
||||
# "label": "Normal",
|
||||
# "longdesc": "The normal map of the input material",
|
||||
# "name": "mat4",
|
||||
# "shortdesc": "Normal",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "$map($uv).x",
|
||||
# "group_size": 5,
|
||||
# "longdesc": "The height map of the result",
|
||||
# "shortdesc": "Height",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "The albedo channel of the result",
|
||||
# "rgb": "$mat1($(name_uv)_uv)",
|
||||
# "shortdesc": "Albedo",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "The ambient occlusion, roughness and metallic channels of the result",
|
||||
# "rgb": "$mat2($(name_uv)_uv)",
|
||||
# "shortdesc": "ORM",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "The emission channel of the result",
|
||||
# "rgb": "$mat3($(name_uv)_uv)",
|
||||
# "shortdesc": "Emission",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "The normal map of the result",
|
||||
# "rgb": "matmap_rotate_nm($mat4($(name_uv)_uv), -$(name_uv)_angle)",
|
||||
# "shortdesc": "Normal",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#mwf_mix.mmg
|
||||
#Combines the outputs of 2 mapped base materials (keeping the \"highest\" material).
|
||||
|
||||
# "code": "float $(name_uv)_a1 = step($h1($uv), $h2($uv));",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "group_size": 5,
|
||||
# "label": "Height 1",
|
||||
# "longdesc": "The height map of the first input",
|
||||
# "name": "h1",
|
||||
# "shortdesc": "Height1",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "Albedo 1",
|
||||
# "longdesc": "The albedo channel of the first input",
|
||||
# "name": "c1",
|
||||
# "shortdesc": "Albedo1",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "ORM 1",
|
||||
# "longdesc": "The ambient occlusion, roughness and metallic channels of the first input",
|
||||
# "name": "orm1",
|
||||
# "shortdesc": "ORM1",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "Emission 1",
|
||||
# "longdesc": "The emission channel of the first input",
|
||||
# "name": "em1",
|
||||
# "shortdesc": "Emission1",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.5, 0.5, 1.0)",
|
||||
# "label": "Normal 1",
|
||||
# "longdesc": "The normal map of the first input",
|
||||
# "name": "nm1",
|
||||
# "shortdesc": "Normal1",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "group_size": 5,
|
||||
# "label": "Height 2",
|
||||
# "longdesc": "The height map of the second input",
|
||||
# "name": "h2",
|
||||
# "shortdesc": "Height2",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "Albedo 2",
|
||||
# "longdesc": "The albedo channel of the second input",
|
||||
# "name": "c2",
|
||||
# "shortdesc": "Albedo2",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "ORM 2",
|
||||
# "longdesc": "The ambient occlusion, roughness and metallic channels of the second input",
|
||||
# "name": "orm2",
|
||||
# "shortdesc": "ORM2",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "Emission 2",
|
||||
# "longdesc": "The emission channel of the second input",
|
||||
# "name": "em2",
|
||||
# "shortdesc": "Emission2",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.5, 0.5, 1.0)",
|
||||
# "label": "Normal 2",
|
||||
# "longdesc": "The normal map of the second input",
|
||||
# "name": "nm2",
|
||||
# "shortdesc": "Normal2",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "max($h1($uv), $h2($uv))",
|
||||
# "group_size": 5,
|
||||
# "longdesc": "Generates the height of the result",
|
||||
# "shortdesc": "Height",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows the output albedo channel",
|
||||
# "rgb": "mix($c1($uv), $c2($uv), $(name_uv)_a1)",
|
||||
# "shortdesc": "Albedo",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows the output ambient occlusion, roughness and metallic channels",
|
||||
# "rgb": "mix($orm1($uv), $orm2($uv), $(name_uv)_a1)",
|
||||
# "shortdesc": "ORM",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows the output emission channel",
|
||||
# "rgb": "mix($em1($uv), $em2($uv), $(name_uv)_a1)",
|
||||
# "shortdesc": "Emission",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows the output normal map",
|
||||
# "rgb": "mix($nm1($uv), $nm2($uv), $(name_uv)_a1)",
|
||||
# "shortdesc": "Normal",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
|
||||
|
||||
#----------------------
|
||||
#mwf_output.mmg
|
||||
|
||||
#{
|
||||
# "connections": [
|
||||
# {
|
||||
# "from": "colorize_3",
|
||||
# "from_port": 0,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 6
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 0,
|
||||
# "to": "colorize_3",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 0,
|
||||
# "to": "occlusion",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "occlusion",
|
||||
# "from_port": 0,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 5
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 2,
|
||||
# "to": "decompose",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "decompose",
|
||||
# "from_port": 1,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 2
|
||||
# },
|
||||
# {
|
||||
# "from": "decompose",
|
||||
# "from_port": 2,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 1
|
||||
# },
|
||||
# {
|
||||
# "from": "blend_2",
|
||||
# "from_port": 0,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 4
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 1,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 3,
|
||||
# "to": "gen_outputs",
|
||||
# "to_port": 3
|
||||
# },
|
||||
# {
|
||||
# "from": "brightness_contrast",
|
||||
# "from_port": 0,
|
||||
# "to": "blend_2",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 4,
|
||||
# "to": "brightness_contrast",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "gen_inputs",
|
||||
# "from_port": 0,
|
||||
# "to": "normal_map_2",
|
||||
# "to_port": 0
|
||||
# },
|
||||
# {
|
||||
# "from": "normal_map_2",
|
||||
# "from_port": 0,
|
||||
# "to": "blend_2",
|
||||
# "to_port": 1
|
||||
# }
|
||||
# ],
|
||||
# "label": "Output",
|
||||
# "longdesc": "Converts a workflow mapped material (from an Apply Map or a Mix node) for a Material node",
|
||||
# "name": "mwf_output",
|
||||
# "node_position": {
|
||||
# "x": 0,
|
||||
# "y": 0
|
||||
# },
|
||||
# "nodes": [
|
||||
# {
|
||||
# "name": "colorize_3",
|
||||
# "node_position": {
|
||||
# "x": -939.637451,
|
||||
# "y": 871.842407
|
||||
# },
|
||||
# "parameters": {
|
||||
# "gradient": {
|
||||
# "interpolation": 1,
|
||||
# "points": [
|
||||
# {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "pos": 0,
|
||||
# "r": 1
|
||||
# },
|
||||
# {
|
||||
# "a": 1,
|
||||
# "b": 0,
|
||||
# "g": 0,
|
||||
# "pos": 1,
|
||||
# "r": 0
|
||||
# }
|
||||
# ],
|
||||
# "type": "Gradient"
|
||||
# }
|
||||
# },
|
||||
# "type": "colorize"
|
||||
# },
|
||||
# {
|
||||
# "name": "occlusion",
|
||||
# "node_position": {
|
||||
# "x": -994.845825,
|
||||
# "y": 786.968262
|
||||
# },
|
||||
# "parameters": {
|
||||
# "param0": 10,
|
||||
# "param2": 1
|
||||
# },
|
||||
# "type": "occlusion"
|
||||
# },
|
||||
# {
|
||||
# "name": "decompose",
|
||||
# "node_position": {
|
||||
# "x": -924.371338,
|
||||
# "y": 570.25
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "type": "decompose"
|
||||
# },
|
||||
# {
|
||||
# "name": "blend_2",
|
||||
# "node_position": {
|
||||
# "x": -931.305542,
|
||||
# "y": 677.328491
|
||||
# },
|
||||
# "parameters": {
|
||||
# "amount": 1,
|
||||
# "blend_type": 4
|
||||
# },
|
||||
# "type": "blend"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_inputs",
|
||||
# "node_position": {
|
||||
# "x": -1626.805542,
|
||||
# "y": 608.758606
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "ports": [
|
||||
# {
|
||||
# "group_size": 5,
|
||||
# "name": "Height",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "name": "Albedo",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "name": "ORM",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "name": "Emission",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "name": "Normal",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "type": "ios"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_outputs",
|
||||
# "node_position": {
|
||||
# "x": -635.305542,
|
||||
# "y": 597.758606
|
||||
# },
|
||||
# "parameters": {
|
||||
#
|
||||
# },
|
||||
# "ports": [
|
||||
# {
|
||||
# "group_size": 7,
|
||||
# "longdesc": "",
|
||||
# "name": "Albedo",
|
||||
# "shortdesc": "Albedo",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "",
|
||||
# "name": "Metallic",
|
||||
# "shortdesc": "Metallic",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "",
|
||||
# "name": "Roughness",
|
||||
# "shortdesc": "Roughness",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "",
|
||||
# "name": "Emission",
|
||||
# "shortdesc": "Emission",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "",
|
||||
# "name": "Normal",
|
||||
# "shortdesc": "Normal",
|
||||
# "type": "rgb"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "",
|
||||
# "name": "Occlusion",
|
||||
# "shortdesc": "Occlusion",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "group_size": 0,
|
||||
# "longdesc": "",
|
||||
# "name": "Depth",
|
||||
# "shortdesc": "Depth",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "type": "ios"
|
||||
# },
|
||||
# {
|
||||
# "name": "gen_parameters",
|
||||
# "node_position": {
|
||||
# "x": -1104.881836,
|
||||
# "y": 425.25
|
||||
# },
|
||||
# "parameters": {
|
||||
# "param0": 1,
|
||||
# "param2": 1
|
||||
# },
|
||||
# "type": "remote",
|
||||
# "widgets": [
|
||||
# {
|
||||
# "label": "Occlusion",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "occlusion",
|
||||
# "widget": "param2"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "The strength of the calculated occlusion effect",
|
||||
# "name": "param2",
|
||||
# "shortdesc": "Occlusion",
|
||||
# "type": "linked_control"
|
||||
# },
|
||||
# {
|
||||
# "label": "Mat Normal",
|
||||
# "linked_widgets": [
|
||||
# {
|
||||
# "node": "blend_2",
|
||||
# "widget": "amount"
|
||||
# }
|
||||
# ],
|
||||
# "longdesc": "The strength of normals from the base materials (compared to the normal generated from height information))",
|
||||
# "name": "param0",
|
||||
# "shortdesc": "MatNormal",
|
||||
# "type": "linked_control"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "name": "brightness_contrast",
|
||||
# "node_position": {
|
||||
# "x": -1177.223877,
|
||||
# "y": 677.062317
|
||||
# },
|
||||
# "parameters": {
|
||||
# "brightness": 0,
|
||||
# "contrast": 1
|
||||
# },
|
||||
# "type": "brightness_contrast"
|
||||
# },
|
||||
# {
|
||||
# "name": "normal_map_2",
|
||||
# "node_position": {
|
||||
# "x": -1152.5,
|
||||
# "y": 544.75
|
||||
# },
|
||||
# "parameters": {
|
||||
# "param0": 10,
|
||||
# "param1": 1.02,
|
||||
# "param2": 0,
|
||||
# "param4": 1
|
||||
# },
|
||||
# "type": "normal_map"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": {
|
||||
# "param0": 1,
|
||||
# "param2": 1
|
||||
# },
|
||||
# "shortdesc": "Output",
|
||||
# "type": "graph"
|
||||
#}
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
#----------------------
|
||||
#edge_detect.mmg
|
||||
|
||||
|
||||
#vec3 matmap_mix(vec3 in1, vec3 in2) {\n\t
|
||||
# float is_in1 = step(in2.x, in1.x);\n\t
|
||||
# //return vec3(max(in1.x, in2.x), in1.yz*is_in1+in2.yz*(1.0-is_in1));\n\t
|
||||
# return vec3(max(in1.x, in2.x), mix(in2.yz, in1.yz, is_in1));\n
|
||||
#}
|
||||
|
||||
#vec2 matmap_uv(vec2 uv, float angle, float seed) {\n\t
|
||||
# uv -= vec2(0.5);\n\tvec2 rv;\n\t
|
||||
# rv.x = uv.x*cos(angle)+uv.y*sin(angle);\n\t
|
||||
# rv.y = -uv.x*sin(angle)+uv.y*cos(angle);\n\t
|
||||
# return fract(rv + rand2(vec2(seed)));\n
|
||||
#}
|
||||
|
||||
#vec3 matmap_rotate_nm(vec3 input, float angle) {\n\t
|
||||
# vec2 uv = input.xy - vec2(0.5);\n\t
|
||||
# vec2 rv;\n\t
|
||||
# rv.x = uv.x*cos(angle)+uv.y*sin(angle);\n\t
|
||||
# rv.y = -uv.x*sin(angle)+uv.y*cos(angle);\n\t
|
||||
# return vec3(rv + vec2(0.5), input.z);\n
|
||||
#}
|
||||
|
691
addons/mat_maker_gd/nodes/common/noise_fbm.gd
Normal file
691
addons/mat_maker_gd/nodes/common/noise_fbm.gd
Normal file
@ -0,0 +1,691 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#fbm2.mmg (and fbm.mmg)
|
||||
|
||||
#Output:
|
||||
#$(name)_fbm($(uv), vec2($(scale_x), $(scale_y)), int($(folds)), int($(iterations)), $(persistence), float($(seed)))
|
||||
|
||||
#Instance:
|
||||
#float $(name)_fbm(vec2 coord, vec2 size, int folds, int octaves, float persistence, float seed) {
|
||||
# float normalize_factor = 0.0;
|
||||
# float value = 0.0;
|
||||
# float scale = 1.0;
|
||||
#
|
||||
# for (int i = 0; i < octaves; i++) {
|
||||
# float noise = fbm_$noise(coord*size, size, seed);
|
||||
#
|
||||
# for (int f = 0; f < folds; ++f) {
|
||||
# noise = abs(2.0*noise-1.0);
|
||||
# }
|
||||
#
|
||||
# value += noise * scale;
|
||||
# normalize_factor += scale;
|
||||
# size *= 2.0;
|
||||
# scale *= persistence;
|
||||
# }
|
||||
#
|
||||
# return value / normalize_factor;
|
||||
#}
|
||||
|
||||
#Inputs:
|
||||
#noise, enum, default: 2, values: Value, Perlin, Simplex, Cellular, Cellular2, Cellular3, Cellular4, Cellular5, Cellular6
|
||||
#scale, vector2, default: 4, min: 1, max: 32, step: 1
|
||||
#folds, float, default: 0, min: 0, max: 5, step: 1
|
||||
#iterations (octaves), float, default: 3, min: 1, max: 10, step: 1
|
||||
#persistence, float, default: 0.5, min: 0, max: 1, step: 0.01
|
||||
|
||||
static func fbmval(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
|
||||
var f : float = fbmf(uv, size, folds, octaves, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func perlin(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
|
||||
var f : float = perlinf(uv, size, folds, octaves, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func perlinabs(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
|
||||
var f : float = perlinf(uv, size, folds, octaves, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func simplex(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
|
||||
var f : float = fbm_simplexf(uv, size, folds, octaves, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func cellular(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
|
||||
var f : float = cellularf(uv, size, folds, octaves, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func cellular2(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
|
||||
var f : float = cellular2f(uv, size, folds, octaves, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func cellular3(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
|
||||
var f : float = cellular3f(uv, size, folds, octaves, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func cellular4(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
|
||||
var f : float = cellular4f(uv, size, folds, octaves, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func cellular5(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
|
||||
var f : float = cellular5f(uv, size, folds, octaves, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func cellular6(uv : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> Color:
|
||||
var f : float = cellular6f(uv, size, folds, octaves, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
|
||||
static func fbmf(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
|
||||
var normalize_factor : float = 0.0;
|
||||
var value : float = 0.0;
|
||||
var scale : float = 1.0;
|
||||
|
||||
for i in range(octaves):# (int i = 0; i < octaves; i++) {
|
||||
var noise : float = fbm_value(coord*size, size, pseed)
|
||||
|
||||
for j in range(folds):# (int f = 0; f < folds; ++f) {
|
||||
noise = abs(2.0*noise-1.0);
|
||||
|
||||
value += noise * scale
|
||||
normalize_factor += scale;
|
||||
size *= 2.0;
|
||||
scale *= persistence;
|
||||
|
||||
return value / normalize_factor;
|
||||
|
||||
static func perlinf(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
|
||||
var normalize_factor : float = 0.0;
|
||||
var value : float = 0.0;
|
||||
var scale : float = 1.0;
|
||||
|
||||
for i in range(octaves):# (int i = 0; i < octaves; i++) {
|
||||
var noise : float = fbm_perlin(coord*size, size, pseed)
|
||||
|
||||
for j in range(folds):# (int f = 0; f < folds; ++f) {
|
||||
noise = abs(2.0*noise-1.0);
|
||||
|
||||
value += noise * scale
|
||||
normalize_factor += scale;
|
||||
size *= 2.0;
|
||||
scale *= persistence;
|
||||
|
||||
return value / normalize_factor;
|
||||
|
||||
static func perlinabsf(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
|
||||
var normalize_factor : float = 0.0;
|
||||
var value : float = 0.0;
|
||||
var scale : float = 1.0;
|
||||
|
||||
for i in range(octaves):# (int i = 0; i < octaves; i++) {
|
||||
var noise : float = fbm_perlinabs(coord*size, size, pseed)
|
||||
|
||||
for j in range(folds):# (int f = 0; f < folds; ++f) {
|
||||
noise = abs(2.0*noise-1.0);
|
||||
|
||||
value += noise * scale
|
||||
normalize_factor += scale;
|
||||
size *= 2.0;
|
||||
scale *= persistence;
|
||||
|
||||
return value / normalize_factor;
|
||||
|
||||
static func fbm_simplexf(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
|
||||
var normalize_factor : float = 0.0;
|
||||
var value : float = 0.0;
|
||||
var scale : float = 1.0;
|
||||
|
||||
for i in range(octaves):# (int i = 0; i < octaves; i++) {
|
||||
var noise : float = fbm_simplex(coord*size, size, pseed)
|
||||
|
||||
for j in range(folds):# (int f = 0; f < folds; ++f) {
|
||||
noise = abs(2.0*noise-1.0);
|
||||
|
||||
value += noise * scale
|
||||
normalize_factor += scale;
|
||||
size *= 2.0;
|
||||
scale *= persistence;
|
||||
|
||||
return value / normalize_factor;
|
||||
|
||||
static func cellularf(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
|
||||
var normalize_factor : float = 0.0;
|
||||
var value : float = 0.0;
|
||||
var scale : float = 1.0;
|
||||
|
||||
for i in range(octaves):# (int i = 0; i < octaves; i++) {
|
||||
var noise : float = fbm_cellular(coord*size, size, pseed)
|
||||
|
||||
for j in range(folds):# (int f = 0; f < folds; ++f) {
|
||||
noise = abs(2.0*noise-1.0);
|
||||
|
||||
value += noise * scale
|
||||
normalize_factor += scale;
|
||||
size *= 2.0;
|
||||
scale *= persistence;
|
||||
|
||||
return value / normalize_factor;
|
||||
|
||||
static func cellular2f(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
|
||||
var normalize_factor : float = 0.0;
|
||||
var value : float = 0.0;
|
||||
var scale : float = 1.0;
|
||||
|
||||
for i in range(octaves):# (int i = 0; i < octaves; i++) {
|
||||
var noise : float = fbm_cellular2(coord*size, size, pseed)
|
||||
|
||||
for j in range(folds):# (int f = 0; f < folds; ++f) {
|
||||
noise = abs(2.0*noise-1.0);
|
||||
|
||||
value += noise * scale
|
||||
normalize_factor += scale;
|
||||
size *= 2.0;
|
||||
scale *= persistence;
|
||||
|
||||
return value / normalize_factor;
|
||||
|
||||
static func cellular3f(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
|
||||
var normalize_factor : float = 0.0;
|
||||
var value : float = 0.0;
|
||||
var scale : float = 1.0;
|
||||
|
||||
for i in range(octaves):# (int i = 0; i < octaves; i++) {
|
||||
var noise : float = fbm_cellular3(coord*size, size, pseed)
|
||||
|
||||
for j in range(folds):# (int f = 0; f < folds; ++f) {
|
||||
noise = abs(2.0*noise-1.0);
|
||||
|
||||
value += noise * scale
|
||||
normalize_factor += scale;
|
||||
size *= 2.0;
|
||||
scale *= persistence;
|
||||
|
||||
return value / normalize_factor;
|
||||
|
||||
static func cellular4f(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
|
||||
var normalize_factor : float = 0.0;
|
||||
var value : float = 0.0;
|
||||
var scale : float = 1.0;
|
||||
|
||||
for i in range(octaves):# (int i = 0; i < octaves; i++) {
|
||||
var noise : float = fbm_cellular4(coord*size, size, pseed)
|
||||
|
||||
for j in range(folds):# (int f = 0; f < folds; ++f) {
|
||||
noise = abs(2.0*noise-1.0);
|
||||
|
||||
value += noise * scale
|
||||
normalize_factor += scale;
|
||||
size *= 2.0;
|
||||
scale *= persistence;
|
||||
|
||||
return value / normalize_factor;
|
||||
|
||||
static func cellular5f(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
|
||||
var normalize_factor : float = 0.0;
|
||||
var value : float = 0.0;
|
||||
var scale : float = 1.0;
|
||||
|
||||
for i in range(octaves):# (int i = 0; i < octaves; i++) {
|
||||
var noise : float = fbm_cellular5(coord*size, size, pseed)
|
||||
|
||||
for j in range(folds):# (int f = 0; f < folds; ++f) {
|
||||
noise = abs(2.0*noise-1.0);
|
||||
|
||||
value += noise * scale
|
||||
normalize_factor += scale;
|
||||
size *= 2.0;
|
||||
scale *= persistence;
|
||||
|
||||
return value / normalize_factor;
|
||||
|
||||
static func cellular6f(coord : Vector2, size : Vector2, folds : int, octaves : int, persistence : float, pseed : float) -> float:
|
||||
var normalize_factor : float = 0.0;
|
||||
var value : float = 0.0;
|
||||
var scale : float = 1.0;
|
||||
|
||||
for i in range(octaves):# (int i = 0; i < octaves; i++) {
|
||||
var noise : float = fbm_cellular6(coord*size, size, pseed)
|
||||
|
||||
for j in range(folds):# (int f = 0; f < folds; ++f) {
|
||||
noise = abs(2.0*noise-1.0);
|
||||
|
||||
value += noise * scale
|
||||
normalize_factor += scale;
|
||||
size *= 2.0;
|
||||
scale *= persistence;
|
||||
|
||||
return value / normalize_factor;
|
||||
|
||||
|
||||
#float fbm_value(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
#
|
||||
# float p00 = rand(mod(o, size));
|
||||
# float p01 = rand(mod(o + vec2(0.0, 1.0), size));
|
||||
# float p10 = rand(mod(o + vec2(1.0, 0.0), size));
|
||||
# float p11 = rand(mod(o + vec2(1.0, 1.0), size));
|
||||
#
|
||||
# vec2 t = f * f * (3.0 - 2.0 * f);
|
||||
#
|
||||
# return mix(mix(p00, p10, t.x), mix(p01, p11, t.x), t.y);
|
||||
#}
|
||||
|
||||
static func fbm_value(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
var p00 : float = Commons.rand(Commons.modv2(o, size));
|
||||
var p01 : float = Commons.rand(Commons.modv2(o + Vector2(0.0, 1.0), size));
|
||||
var p10 : float = Commons.rand(Commons.modv2(o + Vector2(1.0, 0.0), size));
|
||||
var p11 : float = Commons.rand(Commons.modv2(o + Vector2(1.0, 1.0), size));
|
||||
|
||||
var t : Vector2 = f * f * (Vector2(3, 3) - 2.0 * f);
|
||||
return lerp(lerp(p00, p10, t.x), lerp(p01, p11, t.x), t.y);
|
||||
|
||||
|
||||
#float fbm_perlin(vec2 coord, vec2 size, float seed) {
|
||||
# tvec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
#
|
||||
# float a00 = rand(mod(o, size)) * 6.28318530718;
|
||||
# float a01 = rand(mod(o + vec2(0.0, 1.0), size)) * 6.28318530718;
|
||||
# float a10 = rand(mod(o + vec2(1.0, 0.0), size)) * 6.28318530718;
|
||||
# float a11 = rand(mod(o + vec2(1.0, 1.0), size)) * 6.28318530718;
|
||||
#
|
||||
# vec2 v00 = vec2(cos(a00), sin(a00));
|
||||
# vec2 v01 = vec2(cos(a01), sin(a01));
|
||||
# vec2 v10 = vec2(cos(a10), sin(a10));
|
||||
# vec2 v11 = vec2(cos(a11), sin(a11));
|
||||
#
|
||||
# float p00 = dot(v00, f);
|
||||
# float p01 = dot(v01, f - vec2(0.0, 1.0));
|
||||
# float p10 = dot(v10, f - vec2(1.0, 0.0));
|
||||
# float p11 = dot(v11, f - vec2(1.0, 1.0));
|
||||
#
|
||||
# vec2 t = f * f * (3.0 - 2.0 * f);
|
||||
#
|
||||
# return 0.5 + mix(mix(p00, p10, t.x), mix(p01, p11, t.x), t.y);
|
||||
#}
|
||||
|
||||
static func fbm_perlin(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
var a00 : float = Commons.rand(Commons.modv2(o, size)) * 6.28318530718;
|
||||
var a01 : float = Commons.rand(Commons.modv2(o + Vector2(0.0, 1.0), size)) * 6.28318530718;
|
||||
var a10 : float = Commons.rand(Commons.modv2(o + Vector2(1.0, 0.0), size)) * 6.28318530718;
|
||||
var a11 : float = Commons.rand(Commons.modv2(o + Vector2(1.0, 1.0), size)) * 6.28318530718;
|
||||
var v00 : Vector2 = Vector2(cos(a00), sin(a00));
|
||||
var v01 : Vector2 = Vector2(cos(a01), sin(a01));
|
||||
var v10 : Vector2 = Vector2(cos(a10), sin(a10));
|
||||
var v11 : Vector2 = Vector2(cos(a11), sin(a11));
|
||||
var p00 : float = v00.dot(f);
|
||||
var p01 : float = v01.dot(f - Vector2(0.0, 1.0));
|
||||
var p10 : float = v10.dot(f - Vector2(1.0, 0.0));
|
||||
var p11 : float = v11.dot(f - Vector2(1.0, 1.0));
|
||||
|
||||
var t : Vector2 = f * f * (Vector2(3, 3) - 2.0 * f);
|
||||
|
||||
return 0.5 + lerp(lerp(p00, p10, t.x), lerp(p01, p11, t.x), t.y);
|
||||
|
||||
#float fbm_perlinabs(vec2 coord, vec2 size, float seed) {
|
||||
# return abs(2.0*fbm_perlin(coord, size, seed)-1.0);
|
||||
#}
|
||||
|
||||
static func fbm_perlinabs(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
return abs(2.0*fbm_perlin(coord, size, pseed)-1.0)
|
||||
|
||||
#vec2 rgrad2(vec2 p, float rot, float seed) {
|
||||
# float u = rand(p + vec2(seed, 1.0-seed));
|
||||
# u = fract(u) * 6.28318530718; // 2*pi
|
||||
# return vec2(cos(u), sin(u));
|
||||
#}
|
||||
|
||||
static func rgrad2(p : Vector2, rot : float, pseed : float) -> Vector2:
|
||||
var u : float = Commons.rand(p + Vector2(pseed, 1.0-pseed));
|
||||
u = Commons.fract(u) * 6.28318530718; # 2*pi
|
||||
return Vector2(cos(u), sin(u))
|
||||
|
||||
#float fbm_simplex(vec2 coord, vec2 size, float seed) {
|
||||
# coord *= 2.0; // needed for it to tile
|
||||
# coord += rand2(vec2(seed, 1.0-seed)) + size;
|
||||
# size *= 2.0; // needed for it to tile
|
||||
# coord.y += 0.001;
|
||||
#
|
||||
# vec2 uv = vec2(coord.x + coord.y*0.5, coord.y);
|
||||
# vec2 i0 = floor(uv); vec2 f0 = fract(uv);
|
||||
# vec2 i1 = (f0.x > f0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
|
||||
# vec2 p0 = vec2(i0.x - i0.y * 0.5, i0.y);
|
||||
# vec2 p1 = vec2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);
|
||||
# vec2 p2 = vec2(p0.x + 0.5, p0.y + 1.0);
|
||||
#
|
||||
# i1 = i0 + i1;
|
||||
#
|
||||
# vec2 i2 = i0 + vec2(1.0, 1.0);
|
||||
# vec2 d0 = coord - p0;
|
||||
# vec2 d1 = coord - p1;
|
||||
# vec2 d2 = coord - p2;
|
||||
#
|
||||
# vec3 xw = mod(vec3(p0.x, p1.x, p2.x), size.x);
|
||||
# vec3 yw = mod(vec3(p0.y, p1.y, p2.y), size.y);
|
||||
#
|
||||
# vec3 iuw = xw + 0.5 * yw;
|
||||
# vec3 ivw = yw;
|
||||
#
|
||||
# vec2 g0 = rgrad2(vec2(iuw.x, ivw.x), 0.0, seed);
|
||||
# vec2 g1 = rgrad2(vec2(iuw.y, ivw.y), 0.0, seed);
|
||||
# vec2 g2 = rgrad2(vec2(iuw.z, ivw.z), 0.0, seed);
|
||||
#
|
||||
# vec3 w = vec3(dot(g0, d0), dot(g1, d1), dot(g2, d2));
|
||||
# vec3 t = 0.8 - vec3(dot(d0, d0), dot(d1, d1), dot(d2, d2));
|
||||
#
|
||||
# t = max(t, vec3(0.0));
|
||||
# vec3 t2 = t * t;
|
||||
# vec3 t4 = t2 * t2;
|
||||
# float n = dot(t4, w);
|
||||
#
|
||||
# return 0.5 + 5.5 * n;
|
||||
#}
|
||||
|
||||
static func fbm_simplex(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
coord *= 2.0; # needed for it to tile
|
||||
coord += Commons.rand2(Vector2(pseed, 1.0-pseed)) + size;
|
||||
size *= 2.0; # needed for it to tile
|
||||
coord.y += 0.001;
|
||||
|
||||
var uv : Vector2 = Vector2(coord.x + coord.y*0.5, coord.y);
|
||||
var i0 : Vector2 = Commons.floorv2(uv);
|
||||
var f0 : Vector2 = Commons.fractv2(uv);
|
||||
var i1 : Vector2
|
||||
|
||||
if (f0.x > f0.y):
|
||||
i1 = Vector2(1.0, 0.0)
|
||||
else:
|
||||
i1 = Vector2(0.0, 1.0);
|
||||
|
||||
var p0 : Vector2 = Vector2(i0.x - i0.y * 0.5, i0.y);
|
||||
var p1 : Vector2 = Vector2(p0.x + i1.x - i1.y * 0.5, p0.y + i1.y);
|
||||
var p2 : Vector2 = Vector2(p0.x + 0.5, p0.y + 1.0);
|
||||
|
||||
i1 = i0 + i1;
|
||||
|
||||
var i2 : Vector2 = i0 + Vector2(1.0, 1.0);
|
||||
var d0 : Vector2 = coord - p0;
|
||||
var d1 : Vector2 = coord - p1;
|
||||
var d2 : Vector2 = coord - p2;
|
||||
|
||||
var xw : Vector3 = Commons.modv3(Vector3(p0.x, p1.x, p2.x), Vector3(size.x, size.x, size.x));
|
||||
var yw : Vector3 = Commons.modv3(Vector3(p0.y, p1.y, p2.y), Vector3(size.y, size.y, size.y));
|
||||
|
||||
var iuw : Vector3 = xw + 0.5 * yw;
|
||||
var ivw : Vector3 = yw;
|
||||
|
||||
var g0 : Vector2 = rgrad2(Vector2(iuw.x, ivw.x), 0.0, pseed);
|
||||
var g1 : Vector2 = rgrad2(Vector2(iuw.y, ivw.y), 0.0, pseed);
|
||||
var g2 : Vector2 = rgrad2(Vector2(iuw.z, ivw.z), 0.0, pseed);
|
||||
|
||||
var w : Vector3 = Vector3(g0.dot(d0), g1.dot(d1), g2.dot(d2));
|
||||
var t : Vector3 = Vector3(0.8, 0.8, 0.8) - Vector3(d0.dot(d0), d1.dot(d1), d2.dot(d2));
|
||||
|
||||
t = Commons.maxv3(t, Vector3());
|
||||
var t2 : Vector3 = t * t;
|
||||
var t4 : Vector3 = t2 * t2;
|
||||
var n : float = t4.dot(w);
|
||||
|
||||
return 0.5 + 5.5 * n;
|
||||
|
||||
#float fbm_cellular(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
# float min_dist = 2.0;
|
||||
#
|
||||
# for(float x = -1.0; x <= 1.0; x++) {
|
||||
# for(float y = -1.0; y <= 1.0; y++) {
|
||||
# vec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);
|
||||
# float dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);
|
||||
# min_dist = min(min_dist, dist);
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return min_dist;
|
||||
#}
|
||||
|
||||
static func fbm_cellular(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
var min_dist : float = 2.0;
|
||||
|
||||
for xx in range(-1, 2): #(float x = -1.0; x <= 1.0; x++) {
|
||||
var x : float = xx
|
||||
|
||||
for yy in range(-1, 2):#(float y = -1.0; y <= 1.0; y++) {
|
||||
var y : float = yy
|
||||
|
||||
var node : Vector2 = Commons.rand2(Commons.modv2(o + Vector2(x, y), size)) + Vector2(x, y);
|
||||
var dist : float = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);
|
||||
min_dist = min(min_dist, dist);
|
||||
|
||||
return min_dist;
|
||||
|
||||
#float fbm_cellular2(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
# float min_dist1 = 2.0;
|
||||
# float min_dist2 = 2.0;
|
||||
#
|
||||
# for(float x = -1.0; x <= 1.0; x++) {
|
||||
# for(float y = -1.0; y <= 1.0; y++) {
|
||||
# vec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);
|
||||
# float dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);
|
||||
# if (min_dist1 > dist) {
|
||||
# min_dist2 = min_dist1;
|
||||
# min_dist1 = dist;
|
||||
# } else if (min_dist2 > dist) {
|
||||
# min_dist2 = dist;
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return min_dist2-min_dist1;
|
||||
#}
|
||||
|
||||
static func fbm_cellular2(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
|
||||
var min_dist1 : float = 2.0;
|
||||
var min_dist2 : float = 2.0;
|
||||
|
||||
for xx in range(-1, 2): #(float x = -1.0; x <= 1.0; x++) {
|
||||
var x : float = xx
|
||||
|
||||
for yy in range(-1, 2):#(float y = -1.0; y <= 1.0; y++) {
|
||||
var y : float = yy
|
||||
|
||||
var node : Vector2 = Commons.rand2(Commons.modv2(o + Vector2(x, y), size)) + Vector2(x, y);
|
||||
|
||||
var dist : float = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y);
|
||||
|
||||
if (min_dist1 > dist):
|
||||
min_dist2 = min_dist1;
|
||||
min_dist1 = dist;
|
||||
elif (min_dist2 > dist):
|
||||
min_dist2 = dist;
|
||||
|
||||
return min_dist2-min_dist1;
|
||||
|
||||
#float fbm_cellular3(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
# float min_dist = 2.0;
|
||||
#
|
||||
# for(float x = -1.0; x <= 1.0; x++) {
|
||||
# for(float y = -1.0; y <= 1.0; y++) {
|
||||
# vec2 node = rand2(mod(o + vec2(x, y), size))*0.5 + vec2(x, y);
|
||||
# float dist = abs((f - node).x) + abs((f - node).y);
|
||||
# min_dist = min(min_dist, dist);
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return min_dist;
|
||||
#}
|
||||
|
||||
static func fbm_cellular3(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
|
||||
var min_dist : float = 2.0;
|
||||
|
||||
for xx in range(-1, 2): #(float x = -1.0; x <= 1.0; x++) {
|
||||
var x : float = xx
|
||||
|
||||
for yy in range(-1, 2):#(float y = -1.0; y <= 1.0; y++) {
|
||||
var y : float = yy
|
||||
|
||||
var node : Vector2 = Commons.rand2(Commons.modv2(o + Vector2(x, y), size))*0.5 + Vector2(x, y);
|
||||
|
||||
var dist : float = abs((f - node).x) + abs((f - node).y);
|
||||
|
||||
min_dist = min(min_dist, dist);
|
||||
|
||||
return min_dist;
|
||||
|
||||
#float fbm_cellular4(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
# float min_dist1 = 2.0;
|
||||
# float min_dist2 = 2.0;
|
||||
#
|
||||
# for(float x = -1.0; x <= 1.0; x++) {
|
||||
# for(float y = -1.0; y <= 1.0; y++) {
|
||||
# vec2 node = rand2(mod(o + vec2(x, y), size))*0.5 + vec2(x, y);
|
||||
# float dist = abs((f - node).x) + abs((f - node).y);
|
||||
#
|
||||
# if (min_dist1 > dist) {
|
||||
# min_dist2 = min_dist1;
|
||||
# min_dist1 = dist;
|
||||
# } else if (min_dist2 > dist) {
|
||||
# min_dist2 = dist;
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return min_dist2-min_dist1;
|
||||
#}
|
||||
|
||||
static func fbm_cellular4(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
|
||||
var min_dist1 : float = 2.0;
|
||||
var min_dist2 : float = 2.0;
|
||||
|
||||
for xx in range(-1, 2): #(float x = -1.0; x <= 1.0; x++) {
|
||||
var x : float = xx
|
||||
|
||||
for yy in range(-1, 2):#(float y = -1.0; y <= 1.0; y++) {
|
||||
var y : float = yy
|
||||
|
||||
var node : Vector2 = Commons.rand2(Commons.modv2(o + Vector2(x, y), size))*0.5 + Vector2(x, y);
|
||||
|
||||
var dist : float = abs((f - node).x) + abs((f - node).y);
|
||||
|
||||
if (min_dist1 > dist):
|
||||
min_dist2 = min_dist1;
|
||||
min_dist1 = dist;
|
||||
elif (min_dist2 > dist):
|
||||
min_dist2 = dist;
|
||||
|
||||
return min_dist2 - min_dist1;
|
||||
|
||||
#float fbm_cellular5(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
# float min_dist = 2.0;
|
||||
#
|
||||
# for(float x = -1.0; x <= 1.0; x++) {
|
||||
# for(float y = -1.0; y <= 1.0; y++) {
|
||||
# vec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);
|
||||
# float dist = max(abs((f - node).x), abs((f - node).y));
|
||||
# min_dist = min(min_dist, dist);
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return min_dist;
|
||||
#}
|
||||
|
||||
static func fbm_cellular5(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
|
||||
var min_dist : float = 2.0;
|
||||
|
||||
for xx in range(-1, 2): #(float x = -1.0; x <= 1.0; x++) {
|
||||
var x : float = xx
|
||||
|
||||
for yy in range(-1, 2):#(float y = -1.0; y <= 1.0; y++) {
|
||||
var y : float = yy
|
||||
|
||||
var node : Vector2 = Commons.rand2(Commons.modv2(o + Vector2(x, y), size)) + Vector2(x, y);
|
||||
var dist : float = max(abs((f - node).x), abs((f - node).y));
|
||||
min_dist = min(min_dist, dist);
|
||||
|
||||
return min_dist;
|
||||
|
||||
#float fbm_cellular6(vec2 coord, vec2 size, float seed) {
|
||||
# vec2 o = floor(coord)+rand2(vec2(seed, 1.0-seed))+size;
|
||||
# vec2 f = fract(coord);
|
||||
# float min_dist1 = 2.0;
|
||||
# float min_dist2 = 2.0;
|
||||
#
|
||||
# for(float x = -1.0; x <= 1.0; x++) {
|
||||
# for(float y = -1.0; y <= 1.0; y++) {
|
||||
# vec2 node = rand2(mod(o + vec2(x, y), size)) + vec2(x, y);
|
||||
# float dist = max(abs((f - node).x), abs((f - node).y));
|
||||
#
|
||||
# if (min_dist1 > dist) {
|
||||
# min_dist2 = min_dist1;
|
||||
# min_dist1 = dist;
|
||||
# } else if (min_dist2 > dist) {
|
||||
# min_dist2 = dist;
|
||||
# }
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# return min_dist2-min_dist1;
|
||||
#}
|
||||
|
||||
static func fbm_cellular6(coord : Vector2, size : Vector2, pseed : float) -> float:
|
||||
var o : Vector2 = Commons.floorv2(coord) + Commons.rand2(Vector2(float(pseed), 1.0 - float(pseed))) + size;
|
||||
var f : Vector2 = Commons.fractv2(coord);
|
||||
|
||||
var min_dist1 : float = 2.0;
|
||||
var min_dist2 : float = 2.0;
|
||||
|
||||
for xx in range(-1, 2): #(float x = -1.0; x <= 1.0; x++) {
|
||||
var x : float = xx
|
||||
|
||||
for yy in range(-1, 2):#(float y = -1.0; y <= 1.0; y++) {
|
||||
var y : float = yy
|
||||
|
||||
var node : Vector2 = Commons.rand2(Commons.modv2(o + Vector2(x, y), size)) + Vector2(x, y);
|
||||
var dist : float = max(abs((f - node).x), abs((f - node).y));
|
||||
|
||||
if (min_dist1 > dist):
|
||||
min_dist2 = min_dist1;
|
||||
min_dist1 = dist;
|
||||
elif (min_dist2 > dist):
|
||||
min_dist2 = dist;
|
||||
|
||||
return min_dist2 - min_dist1;
|
157
addons/mat_maker_gd/nodes/common/noise_perlin.gd
Normal file
157
addons/mat_maker_gd/nodes/common/noise_perlin.gd
Normal file
@ -0,0 +1,157 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#perlin.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (float) - Shows a greyscale value noise
|
||||
#perlin($(uv), vec2($(scale_x), $(scale_y)), int($(iterations)), $(persistence), $(seed))
|
||||
|
||||
#Inputs:
|
||||
#scale, vector2, default: 4, min: 1, max: 32, step: 1
|
||||
#iterations, float, min: 0, max: 10, default: 3, step:1
|
||||
#persistence, float, min: 0, max: 1, default: 0.5, step:0.05
|
||||
|
||||
#----------------------
|
||||
#perlin_color.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (rgb) - Shows a color value noise
|
||||
#perlin_color($(uv), vec2($(scale_x), $(scale_y)), int($(iterations)), $(persistence), $(seed))
|
||||
|
||||
#Inputs:
|
||||
#scale, vector2, default: 4, min: 1, max: 32, step: 1
|
||||
#iterations, float, min: 0, max: 10, default: 3, step:1
|
||||
#persistence, float, min: 0, max: 1, default: 0.5, step:0.05
|
||||
|
||||
static func perlinc(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int) -> Color:
|
||||
var f : float = perlin(uv, size, iterations, persistence, pseed)
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
|
||||
#float perlin(vec2 uv, vec2 size, int iterations, float persistence, float seed) {
|
||||
# vec2 seed2 = rand2(vec2(seed, 1.0-seed));
|
||||
# float rv = 0.0;
|
||||
# float coef = 1.0;
|
||||
# float acc = 0.0;
|
||||
#
|
||||
# for (int i = 0; i < iterations; ++i) {
|
||||
# vec2 step = vec2(1.0)/size;
|
||||
# vec2 xy = floor(uv*size);
|
||||
#
|
||||
# float f0 = rand(seed2+mod(xy, size));
|
||||
# float f1 = rand(seed2+mod(xy+vec2(1.0, 0.0), size));
|
||||
# float f2 = rand(seed2+mod(xy+vec2(0.0, 1.0), size));
|
||||
# float f3 = rand(seed2+mod(xy+vec2(1.0, 1.0), size));
|
||||
#
|
||||
# vec2 mixval = smoothstep(0.0, 1.0, fract(uv*size));
|
||||
# rv += coef * mix(mix(f0, f1, mixval.x), mix(f2, f3, mixval.x), mixval.y);
|
||||
# acc += coef;
|
||||
# size *= 2.0;
|
||||
# coef *= persistence;
|
||||
# }
|
||||
#
|
||||
# return rv / acc;
|
||||
#}
|
||||
|
||||
static func perlin(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int) -> float:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(float(pseed), 1.0-float(pseed)));
|
||||
var rv : float = 0.0;
|
||||
var coef : float = 1.0;
|
||||
var acc : float = 0.0;
|
||||
|
||||
for i in range(iterations):
|
||||
var step : Vector2 = Vector2(1, 1) / size;
|
||||
var xy : Vector2 = Commons.floorv2(uv * size);
|
||||
var f0 : float = Commons.rand(seed2 + Commons.modv2(xy, size));
|
||||
var f1 : float = Commons.rand(seed2 + Commons.modv2(xy + Vector2(1.0, 0.0), size));
|
||||
var f2 : float = Commons.rand(seed2 + Commons.modv2(xy + Vector2(0.0, 1.0), size));
|
||||
var f3 : float = Commons.rand(seed2 + Commons.modv2(xy + Vector2(1.0, 1.0), size));
|
||||
|
||||
var mixval : Vector2 = Commons.smoothstepv2(0.0, 1.0, Commons.fractv2(uv * size));
|
||||
|
||||
rv += coef * lerp(lerp(f0, f1, mixval.x), lerp(f2, f3, mixval.x), mixval.y);
|
||||
acc += coef;
|
||||
size *= 2.0;
|
||||
coef *= persistence;
|
||||
|
||||
return rv / acc;
|
||||
|
||||
#vec3 perlin_color(vec2 uv, vec2 size, int iterations, float persistence, float seed) {
|
||||
# vec2 seed2 = rand2(vec2(seed, 1.0-seed));
|
||||
# vec3 rv = vec3(0.0);
|
||||
# float coef = 1.0;
|
||||
# float acc = 0.0;
|
||||
#
|
||||
# for (int i = 0; i < iterations; ++i) {
|
||||
# vec2 step = vec2(1.0)/size;
|
||||
# vec2 xy = floor(uv*size);
|
||||
# vec3 f0 = rand3(seed2+mod(xy, size));
|
||||
# vec3 f1 = rand3(seed2+mod(xy+vec2(1.0, 0.0), size));
|
||||
# vec3 f2 = rand3(seed2+mod(xy+vec2(0.0, 1.0), size));
|
||||
# vec3 f3 = rand3(seed2+mod(xy+vec2(1.0, 1.0), size));
|
||||
# vec2 mixval = smoothstep(0.0, 1.0, fract(uv*size));
|
||||
#
|
||||
# rv += coef * mix(mix(f0, f1, mixval.x), mix(f2, f3, mixval.x), mixval.y);
|
||||
# acc += coef;
|
||||
# size *= 2.0;
|
||||
# coef *= persistence;
|
||||
# }
|
||||
#
|
||||
# return rv / acc;
|
||||
#}
|
||||
|
||||
static func perlin_color(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int) -> Vector3:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(float(pseed), 1.0-float(pseed)));
|
||||
var rv : Vector3 = Vector3();
|
||||
var coef : float = 1.0;
|
||||
var acc : float = 0.0;
|
||||
|
||||
for i in range(iterations):
|
||||
var step : Vector2 = Vector2(1, 1) / size;
|
||||
var xy : Vector2 = Commons.floorv2(uv * size);
|
||||
var f0 : Vector3 = Commons.rand3(seed2 + Commons.modv2(xy, size));
|
||||
var f1 : Vector3 = Commons.rand3(seed2 + Commons.modv2(xy + Vector2(1.0, 0.0), size));
|
||||
var f2 : Vector3 = Commons.rand3(seed2 + Commons.modv2(xy + Vector2(0.0, 1.0), size));
|
||||
var f3 : Vector3 = Commons.rand3(seed2 + Commons.modv2(xy + Vector2(1.0, 1.0), size));
|
||||
|
||||
var mixval : Vector2 = Commons.smoothstepv2(0.0, 1.0, Commons.fractv2(uv * size));
|
||||
|
||||
rv += coef * lerp(lerp(f0, f1, mixval.x), lerp(f2, f3, mixval.x), mixval.y)
|
||||
acc += coef;
|
||||
size *= 2.0;
|
||||
coef *= persistence;
|
||||
|
||||
return rv / acc;
|
||||
|
||||
static func perlin_colorc(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int) -> Color:
|
||||
var f : Vector3 = perlin_color(uv, size, iterations, persistence, pseed)
|
||||
|
||||
return Color(f.x, f.y, f.z, 1)
|
||||
|
||||
static func perlin_warp_1(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int, translate : Vector2, rotate : float, size2 : Vector2) -> Color:
|
||||
var f : float = perlin(uv, size2, iterations, persistence, pseed)
|
||||
var vt : Vector2 = Commons.transform(uv, Vector2(translate.x*(2.0*f-1.0), translate.y*(2.0*f-1.0)), rotate*0.01745329251*(2.0*1.0-1.0), Vector2(size.x*(2.0*1.0-1.0), size.y*(2.0*1.0-1.0)), true)
|
||||
var ff : float = perlin(vt, size2, iterations, persistence, pseed)
|
||||
|
||||
return Color(ff, ff, ff, 1)
|
||||
|
||||
static func perlin_warp_2(uv : Vector2, size : Vector2, iterations : int, persistence : float, pseed : int, translate : Vector2, rotate : float, size2 : Vector2) -> Color:
|
||||
var f = perlin(uv, size2, iterations, persistence, pseed)
|
||||
var vt : Vector2 = Commons.transform(uv, Vector2(translate.x*(2.0*f-1.0), translate.y*(2.0*f-1.0)), rotate*0.01745329251*(2.0*1.0-1.0), Vector2(size.x*(2.0*1.0-1.0), size.y*(2.0*1.0-1.0)), true)
|
||||
var ff : float = perlin(vt, size2, iterations, persistence, pseed)
|
||||
|
||||
var rgba : Vector3 = Vector3(ff, ff, ff)
|
||||
|
||||
var tf : Vector2 = Commons.transform(uv, Vector2(translate.x * (2.0 * (rgba.dot(Vector3(1, 1, 1) / 3.0) - 1.0)), translate.y*(2.0*(rgba.dot(Vector3(1, 1, 1) /3.0)-1.0))), rotate*0.01745329251*(2.0*1.0-1.0), Vector2(size.x*(2.0*1.0-1.0), size.y*(2.0*1.0-1.0)), true)
|
||||
|
||||
var fff : float = perlin(tf, size2, iterations, persistence, pseed);
|
||||
|
||||
return Color(fff, fff, fff, 1)
|
||||
|
141
addons/mat_maker_gd/nodes/common/noise_voronoi.gd
Normal file
141
addons/mat_maker_gd/nodes/common/noise_voronoi.gd
Normal file
@ -0,0 +1,141 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#voronoi.mmg
|
||||
|
||||
#voronoi_1, 2, 3, 4 -> different outputs
|
||||
|
||||
#Outputs:
|
||||
|
||||
#vec4 $(name_uv)_xyzw = voronoi($uv, vec2($scale_x, $scale_y), vec2($stretch_y, $stretch_x), $intensity, $randomness, $seed);
|
||||
|
||||
#Nodes - float - A greyscale pattern based on the distance to cell centers
|
||||
#$(name_uv)_xyzw.z
|
||||
|
||||
#Borders - float - A greyscale pattern based on the distance to borders
|
||||
#$(name_uv)_xyzw.w
|
||||
|
||||
#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)))
|
||||
|
||||
#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))
|
||||
|
||||
#Inputs:
|
||||
|
||||
#scale, min: 1, max: 32, step: 1, default: 4
|
||||
#stretch, min: 0.01, max: 1, step: 0.01, default: 1
|
||||
#intensity, min: 0, max: 1, step: 0.01, default: 0.75
|
||||
#randomness, min: 0, max: 1, step: 0.01, default: 1
|
||||
|
||||
#vec4 $(name_uv)_xyzw = voronoi($uv, vec2($scale_x, $scale_y), vec2($stretch_y, $stretch_x), $intensity, $randomness, $seed);
|
||||
|
||||
#note this is newer than what I have TODO
|
||||
|
||||
#// Based on https://www.shadertoy.com/view/ldl3W8
|
||||
#// The MIT License
|
||||
#// Copyright © 2013 Inigo Quilez
|
||||
#vec3 iq_voronoi(vec2 x, vec2 size, vec2 stretch, float randomness, vec2 seed) {
|
||||
# vec2 n = floor(x);
|
||||
# vec2 f = fract(x);
|
||||
# vec2 mg, mr, mc;
|
||||
# float md = 8.0;
|
||||
#
|
||||
# for (int j=-1; j<=1; j++)
|
||||
# for (int i=-1; i<=1; i++) {
|
||||
# vec2 g = vec2(float(i),float(j));
|
||||
# vec2 o = randomness*rand2(seed + mod(n + g + size, size));
|
||||
# vec2 c = g + o;
|
||||
# vec2 r = c - f;
|
||||
# vec2 rr = r*stretch;
|
||||
# float d = dot(rr,rr);
|
||||
# if (d<md) {
|
||||
# mc = c;
|
||||
# md = d;
|
||||
# mr = r;
|
||||
# mg = g;
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# md = 8.0;
|
||||
#
|
||||
# for (int j=-2; j<=2; j++)
|
||||
# for (int i=-2; i<=2; i++) {
|
||||
# vec2 g = mg + vec2(float(i),float(j));
|
||||
# vec2 o = randomness*rand2(seed + mod(n + g + size, size));
|
||||
# vec2 r = g + o - f;
|
||||
# vec2 rr = (mr-r)*stretch;
|
||||
#
|
||||
# if (dot(rr,rr)>0.00001)
|
||||
# md = min(md, dot(0.5*(mr+r)*stretch, normalize((r-mr)*stretch)));
|
||||
# }
|
||||
#
|
||||
# return vec3(md, mc+n);
|
||||
#}
|
||||
#
|
||||
#vec4 voronoi(vec2 uv, vec2 size, vec2 stretch, float intensity, float randomness, float seed) {
|
||||
# uv *= size;
|
||||
# vec3 v = iq_voronoi(uv, size, stretch, randomness, rand2(vec2(seed, 1.0-seed)));
|
||||
# return vec4(v.yz, intensity*length((uv-v.yz)*stretch), v.x);
|
||||
#}
|
||||
|
||||
static func voronoi(uv : Vector2, size : Vector2, stretch : Vector2, intensity : float, randomness : float, pseed : int) -> Color:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(float(pseed), 1.0-float(pseed)));
|
||||
uv *= size;
|
||||
var best_distance0 : float = 1.0;
|
||||
var best_distance1 : float = 1.0;
|
||||
var point0 : Vector2;
|
||||
var point1 : Vector2;
|
||||
var p0 : Vector2 = Commons.floorv2(uv);
|
||||
|
||||
for dx in range(-1, 2):# (int dx = -1; dx < 2; ++dx) {
|
||||
for dy in range(-1, 2):# (int dy = -1; dy < 2; ++dy) {
|
||||
var d : Vector2 = Vector2(float(dx), float(dy));
|
||||
var p : Vector2 = p0+d;
|
||||
|
||||
p += randomness * Commons.rand2(seed2 + Commons.modv2(p, size));
|
||||
var distance : float = (stretch * (uv - p) / size).length();
|
||||
|
||||
if (best_distance0 > distance):
|
||||
best_distance1 = best_distance0;
|
||||
best_distance0 = distance;
|
||||
point1 = point0;
|
||||
point0 = p;
|
||||
elif (best_distance1 > distance):
|
||||
best_distance1 = distance;
|
||||
point1 = p;
|
||||
|
||||
var edge_distance : float = (uv - 0.5*(point0+point1)).dot((point0-point1).normalized());
|
||||
|
||||
return Color(point0.x, point0.y, best_distance0 * (size).length() * intensity, edge_distance);
|
||||
|
||||
#$(name_uv)_xyzw.z
|
||||
|
||||
static func voronoi_1(uv : Vector2, size : Vector2, stretch : Vector2, intensity : float, randomness : float, pseed : int) -> Color:
|
||||
var c : Color = voronoi(uv, size, stretch, intensity, randomness, pseed);
|
||||
|
||||
return Color(c.b, c.b, c.b, 1)
|
||||
|
||||
#$(name_uv)_xyzw.w
|
||||
|
||||
static func voronoi_2(uv : Vector2, size : Vector2, stretch : Vector2, intensity : float, randomness : float, pseed : int) -> Color:
|
||||
var c : Color = voronoi(uv, size, stretch, intensity, randomness, pseed);
|
||||
|
||||
return Color(c.a, c.a, c.a, 1)
|
||||
|
||||
#rand3(fract(floor($(name_uv)_xyzw.xy)/vec2($scale_x, $scale_y)))
|
||||
|
||||
static func voronoi_3(uv : Vector2, size : Vector2, stretch : Vector2, intensity : float, randomness : float, pseed : int) -> Color:
|
||||
var c : Color = voronoi(uv, size, stretch, intensity, randomness, pseed);
|
||||
|
||||
var vv : Vector2 = Vector2(c.r, c.g)
|
||||
|
||||
var v : Vector3 = Commons.rand3(Commons.fractv2(vv));
|
||||
|
||||
return Color(v.x, v.y, v.z, 1)
|
||||
|
||||
#vec4(fract(($(name_uv)_xyzw.xy-1.0)/vec2($scale_x, $scale_y)), vec2(2.0)/vec2($scale_x, $scale_y))
|
||||
|
||||
#voronoi_4 todo
|
122
addons/mat_maker_gd/nodes/common/noises.gd
Normal file
122
addons/mat_maker_gd/nodes/common/noises.gd
Normal file
@ -0,0 +1,122 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#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
|
||||
|
||||
#----------------------
|
||||
#noise.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#float $(name)_f(vec2 uv) {
|
||||
# return dots(uv, 1.0/$(size), $(density), $(seed));
|
||||
#}
|
||||
|
||||
#Output - (float) - Shows the noise pattern
|
||||
#$(name)_f($(uv))
|
||||
|
||||
#Inputs:
|
||||
#grid_size, float, default: 4, min: 2, max: 12, step: 1
|
||||
#density, float, default: 0.5, min: 0, max: 1, step: 0.01
|
||||
|
||||
#----------------------
|
||||
#noise_anisotropic.mmg
|
||||
#Generates x-axis interpolated value noise
|
||||
|
||||
#Output:
|
||||
#Output (float) - Shows a greyscale value noise
|
||||
#anisotropic($(uv), vec2($(scale_x), $(scale_y)), $(seed), $(smoothness), $(interpolation))
|
||||
|
||||
#Input:
|
||||
#scale, Vector2, min: 1, 1, max: 32, 1024, step: 1, 1, default 4, 256
|
||||
#smoothness, float, min: 0, max: 1, step: 0,01, default: 1
|
||||
#Interpolation, float, min: 0, max: 1, step: 0,01, default: 1
|
||||
|
||||
#float dots(vec2 uv, float size, float density, float seed) {
|
||||
# vec2 seed2 = rand2(vec2(seed, 1.0-seed));
|
||||
# uv /= size;
|
||||
# vec2 point_pos = floor(uv)+vec2(0.5);
|
||||
# float color = step(rand(seed2+point_pos), density);
|
||||
# return color;
|
||||
#}
|
||||
|
||||
static func dots(uv : Vector2, size : float, density : float, pseed : float) -> float:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(pseed, 1.0 - pseed))
|
||||
uv /= size
|
||||
var point_pos : Vector2 = Commons.floorv2(uv) + Vector2(0.5, 0.5)
|
||||
var color : float = Commons.step(Commons.rand2(seed2 + point_pos).x, density);
|
||||
return color
|
||||
|
||||
static func anisotropicc(uv : Vector2, size : Vector2, pseed : float, smoothness : float, interpolation : float) -> Color:
|
||||
var v : float = anisotropic(uv, size, pseed, smoothness, interpolation)
|
||||
|
||||
return Color(v, v, v, 1)
|
||||
|
||||
#float anisotropic(vec2 uv, vec2 size, float seed, float smoothness, float interpolation) {
|
||||
# vec2 seed2 = rand2(vec2(seed, 1.0-seed));
|
||||
# vec2 xy = floor(uv*size);
|
||||
# vec2 offset = vec2(rand(seed2 + xy.y), 0.0);
|
||||
# vec2 xy_offset = floor(uv * size + offset );
|
||||
#
|
||||
# float f0 = rand(seed2+mod(xy_offset, size));
|
||||
# float f1 = rand(seed2+mod(xy_offset+vec2(1.0, 0.0), size));
|
||||
# float mixer = clamp( (fract(uv.x*size.x+offset.x) -.5) / smoothness + 0.5, 0.0, 1.0 );
|
||||
# float smooth_mix = smoothstep(0.0, 1.0, mixer);
|
||||
# float linear = mix(f0, f1, mixer);
|
||||
# float smoothed = mix(f0, f1, smooth_mix);
|
||||
#
|
||||
# return mix(linear, smoothed, interpolation);
|
||||
#}
|
||||
|
||||
static func anisotropic(uv : Vector2, size : Vector2, pseed : float, smoothness : float, interpolation : float) -> float:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(pseed, 1.0 - pseed))
|
||||
|
||||
var xy : Vector2 = Commons.floorv2(uv * size)
|
||||
var s2xy : Vector2 = seed2
|
||||
s2xy.x += xy.y
|
||||
s2xy.y += xy.y
|
||||
|
||||
var offset : Vector2 = Vector2(Commons.rand(s2xy), 0.0)
|
||||
var xy_offset : Vector2 = Commons.floorv2(uv * size + offset)
|
||||
|
||||
var f0 : float = Commons.rand(seed2 + Commons.modv2(xy_offset, size));
|
||||
var f1 : float = Commons.rand(seed2 + Commons.modv2(xy_offset + Vector2(1.0, 0.0), size))
|
||||
var mixer : float = clamp((Commons.fract(uv.x * size.x + offset.x) - 0.5) / smoothness + 0.5, 0.0, 1.0)
|
||||
var smooth_mix : float = smoothstep(0.0, 1.0, mixer)
|
||||
var linear : float = lerp(f0, f1, mixer)
|
||||
var smoothed : float = lerp(f0, f1, smooth_mix)
|
||||
|
||||
return lerp(linear, smoothed, interpolation)
|
||||
|
||||
#vec3 color_dots(vec2 uv, float size, float seed) {
|
||||
# vec2 seed2 = rand2(vec2(seed, 1.0-seed));
|
||||
# uv /= size;
|
||||
# vec2 point_pos = floor(uv)+vec2(0.5);
|
||||
# return rand3(seed2+point_pos);
|
||||
#}
|
||||
|
||||
static func color_dots(uv : Vector2, size : float, pseed : float) -> Vector3:
|
||||
var seed2 : Vector2 = Commons.rand2(Vector2(pseed, 1.0 - pseed))
|
||||
|
||||
uv /= size
|
||||
|
||||
var point_pos : Vector2 = Commons.floorv2(uv) + Vector2(0.5, 0.5)
|
||||
|
||||
return Commons.rand3(seed2 + point_pos)
|
||||
|
||||
static func noise_color(uv : Vector2, size : float, pseed : float) -> Color:
|
||||
var v : Vector3 = color_dots(uv, 1.0 / size, pseed)
|
||||
|
||||
return Color(v.x, v.y, v.z, 1)
|
||||
|
1170
addons/mat_maker_gd/nodes/common/patterns.gd
Normal file
1170
addons/mat_maker_gd/nodes/common/patterns.gd
Normal file
File diff suppressed because it is too large
Load Diff
2451
addons/mat_maker_gd/nodes/common/sdf2d.gd
Normal file
2451
addons/mat_maker_gd/nodes/common/sdf2d.gd
Normal file
File diff suppressed because it is too large
Load Diff
789
addons/mat_maker_gd/nodes/common/sdf3d.gd
Normal file
789
addons/mat_maker_gd/nodes/common/sdf3d.gd
Normal file
@ -0,0 +1,789 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#sdf3d_box.mmg
|
||||
#Generates a rounded box as a signed distance function
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Common
|
||||
#vec3 $(name_uv)_q = abs($uv) - vec3($sx, $sy, $sz);
|
||||
|
||||
#Output - (sdf3d) - Shows the rounded box
|
||||
#length(max($(name_uv)_q,0.0))+min(max($(name_uv)_q.x,max($(name_uv)_q.y,$(name_uv)_q.z)),0.0)-$r
|
||||
|
||||
#Inputs:
|
||||
#size, vector3, min: 0, max: 1, default:0.5, step:0.01
|
||||
#size, float, min: 0, max: 1, default:0.5, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_sphere.mmg
|
||||
#Generates a sphere as a signed distance function
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (sdf3d) - Shows the sphere
|
||||
#length($uv)-$r
|
||||
|
||||
#Inputs:
|
||||
#radius, vector3, min: 0, max: 1, default:0.5, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_capsule.mmg
|
||||
#Generates a capsule as a signed distance function
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Common
|
||||
#vec3 $(name_uv)_p = $uv;
|
||||
#$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);
|
||||
|
||||
#Output - (sdf3d) - Shows the capsule
|
||||
#length($(name_uv)_p)-$r*$profile(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0))
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 1, values: x, y, z
|
||||
#length, float, min: 0, max: 1, default:0.25, step:0.01
|
||||
#radius, float, min: 0, max: 1, default:0.2, step:0.01
|
||||
#profile, curve, default: (ls, rs, x, z) 0, 0, 0, 1, 0, 0, 1, 1
|
||||
|
||||
#----------------------
|
||||
#sdf3d_cone.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#+X: $axis = length($uv.yz),-$uv.x
|
||||
#-X: $axis = length($uv.yz),$uv.x
|
||||
#+Y: $axis = length($uv.xz),$uv.y
|
||||
#-Y: $axis = length($uv.xz),-$uv.y
|
||||
#+Z: $axis = length($uv.xy),-$uv.z
|
||||
#-Z: $axis = length($uv.xy),$uv.z
|
||||
|
||||
#Output - (sdf3d)
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default:5, values: +X, -X, +Y, -Y, +Z, -Z
|
||||
#angle, float, min: 0, max: 90, default:30, step:1
|
||||
|
||||
#----------------------
|
||||
#sdf3d_repeat.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output (sdf3d)
|
||||
#Output - (sdf3dc) - The shape generated by the repeat operation
|
||||
#$in(repeat($uv, vec3(1.0/$rx, 1.0/$ry, 0.0), float($seed), $r))
|
||||
|
||||
#Inputs:
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
|
||||
#X, int, min: 1, max: 32, default:4, step:1
|
||||
#Y, int, min: 1, max: 32, default:4, step:1
|
||||
#R, float, min: 0, max: 1, default:0.5, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_rotate.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (sdf3dc) - The rotated object
|
||||
#$in(rotate3d($uv, -vec3($ax, $ay, $az)*0.01745329251))
|
||||
|
||||
#Inputs:
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#rotation, vector3, min: -180, max: 180, default:0, step:1
|
||||
|
||||
#----------------------
|
||||
#sdf3d_cylinder.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (sdf3dc) - Shows the cylinder
|
||||
#min(max($(name_uv)_d.x,$(name_uv)_d.y),0.0) + length(max($(name_uv)_d,0.0))
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 1, values: X, Y, Z
|
||||
#length, float, min: 0, max: 1, default:0.5, step:0.01
|
||||
#radius, float, min: 0, max: 1, default:0.2, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_plane.mmg
|
||||
#Generates a plane that can be used to cut other shapes
|
||||
|
||||
#Outputs:
|
||||
|
||||
#X: $axis = x
|
||||
#Y: $axis = y
|
||||
#Z: $axis = z
|
||||
|
||||
#Output - (sdf3dc) - Shows the plane
|
||||
#$uv.$axis
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 1, values: X, Y, Z
|
||||
|
||||
#----------------------
|
||||
#sdf3d_torus.mmg
|
||||
#Generates a torus as a signed distance function
|
||||
|
||||
#Outputs:
|
||||
|
||||
#X: $axis = length($uv.yz)-$R,$uv.x
|
||||
#Y: $axis = length($uv.zx)-$R,$uv.y
|
||||
#Z: $axis = length($uv.xy)-$R,$uv.z
|
||||
#vec2 $(name_uv)_q = vec2($axis);
|
||||
|
||||
#Output - (sdf3dc) - Shows the torus
|
||||
#length($(name_uv)_q)-$r
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 1, values: X, Y, Z
|
||||
#R, float, min: 0, max: 1, default:0.5, step:0.01
|
||||
#r, float, min: 0, max: 1, default:0.1, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_boolean.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Union: $op = sdf3dc_union
|
||||
#Subtraction $op = sdf3dc_sub
|
||||
#Intersection $op = sdf3dc_inter
|
||||
|
||||
#Output - (sdf3dc) - The shape generated by the boolean operation
|
||||
#$op($in1($uv), $in2($uv))
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 2, values: Union, Subtraction, Intersection
|
||||
#in1, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#in2, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
|
||||
#----------------------
|
||||
#sdf3d_circle_repeat.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output (sdf3dc) - The shape generated by the boolean operation
|
||||
#$in(circle_repeat_transform($uv, $c))
|
||||
|
||||
#Inputs:
|
||||
#count, float, min: 1, max: 32, default:5, step:1
|
||||
|
||||
#----------------------
|
||||
#sdf3d_angle.mmg (includes sdf3d_rotate.mmg)
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Shows the angleThe shape generated by the boolean operation
|
||||
#$(name_uv)_d
|
||||
|
||||
#X: $axis = xyz
|
||||
#Y: $axis = yzx
|
||||
#Z: $axis = zxy
|
||||
|
||||
#vec3 $(name_uv)_uv = $uv.$axis;
|
||||
#float $(name_uv)_rotated = rotate3d($(name_uv)_uv, vec3(($angle-180.0)*0.01745329251, 0.0, 0.0)).y;
|
||||
#float $(name_uv)_d1 = max($(name_uv)_uv.y, $(name_uv)_rotated);
|
||||
#float $(name_uv)_d2 = min($(name_uv)_uv.y, $(name_uv)_rotated);
|
||||
#float $(name_uv)_d = (mod($angle, 360.0) < 180.0) ? $(name_uv)_d1 : $(name_uv)_d2;
|
||||
|
||||
#Inputs:
|
||||
#axis, enum, default: 0, values: X, Y, Z
|
||||
#angle, float, min: 0, max: 360, default:180, step:0.1
|
||||
|
||||
#----------------------
|
||||
#sdf3d_color.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - sdf3dc - The colored 3D object
|
||||
#vec2($in($uv), $c)
|
||||
|
||||
#Inputs:
|
||||
#color_index, float, min: 0, max: 1, default:0, step:0.01
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
|
||||
#----------------------
|
||||
#sdf3d_translate.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - sdf3dc
|
||||
#$in($uv-vec3($x, $y, $z))
|
||||
|
||||
#Inputs:
|
||||
#translation, vector3, min: -1, max: 1, default:0, step:0.01
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3dc input)
|
||||
|
||||
#----------------------
|
||||
#sdf3d_scale.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#vec2 $(name_uv)_in = $in(($uv)/$s);
|
||||
|
||||
#Output - sdf3dc
|
||||
#vec2($(name_uv)_in.x*$s, $(name_uv)_in.y)
|
||||
|
||||
#Inputs:
|
||||
#scale_factor, float, min: 0, max: 5, default:1, step:0.01
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3dc input)
|
||||
|
||||
#----------------------
|
||||
#sdf3d_rounded.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#vec2 $(name_uv)_v = $in($uv);
|
||||
|
||||
#Output - sdf3dc
|
||||
#vec2($(name_uv)_v.x-$r, $(name_uv)_v.y)
|
||||
|
||||
#Inputs:
|
||||
#radius, float, min: 0, max: 1, default:0, step:0.01
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3dc input)
|
||||
|
||||
#----------------------
|
||||
#sdf3d_revolution.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#vec2 $(name_uv)_q = vec2(length($uv.xy)-$d+0.5, $uv.z+0.5);
|
||||
|
||||
#Output - sdf3dc
|
||||
#$in($(name_uv)_q)
|
||||
|
||||
#Inputs:
|
||||
#d, float, min: 0, max: 1, default:0.25, step:0.01
|
||||
#input, float, default:10.0, (sdf2d input)
|
||||
|
||||
#----------------------
|
||||
#sdf3d_smoothboolean.mmg
|
||||
#Performs a smooth boolean operation (union, intersection or difference) between two shapes
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Union: $op = union
|
||||
#Subtraction: $op = subtraction
|
||||
#Intersection: $op = intersection
|
||||
|
||||
#Output - sdf3dc
|
||||
#sdf3d_smooth_$op($in1($uv), $in2($uv), $k)
|
||||
|
||||
#Inputs:
|
||||
#in1, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#in2, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#operation, enum, default: 1, values: Union, Subtraction, Intersection
|
||||
#smoothness, float, min: 0, max: 1, default:0, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_elongation.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - sdf3dc
|
||||
#$in($uv-clamp($uv, -abs(vec3($x, $y, $z)), abs(vec3($x, $y, $z))))
|
||||
|
||||
#Inputs:
|
||||
#in, vec2, default:vec2(100, 0.0), (sdf3dc input)
|
||||
#elongation, vector3, min: 0, max: 1, default:0, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_extrusion.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#vec2 $(name_uv)_w = vec2($in($uv.xz+vec2(0.5)),abs($uv.y)-$d);
|
||||
|
||||
#Output - sdf3dc
|
||||
#min(max($(name_uv)_w.x,$(name_uv)_w.y),0.0)+length(max($(name_uv)_w,0.0))
|
||||
|
||||
#Inputs:
|
||||
#in, sdf2d, default:100, (input)
|
||||
#length, float, min: 0, max: 1, default:0.25, step:0.01
|
||||
|
||||
#----------------------
|
||||
#sdf3d_morph.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - sdf3d
|
||||
#mix($in1($uv), $in2($uv), $amount)
|
||||
|
||||
#Inputs:
|
||||
#in1, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#in2, vec2, default:vec2(100, 0.0), (sdf3d input)
|
||||
#amount, float, min: 0, max: 1, default:0.5, step:0.01
|
||||
|
||||
#----------------------
|
||||
#raymarching.mmg (raymarching_preview.mmg)
|
||||
#Raymarches a 3D object (described as signed distance function with optional color index)
|
||||
#to render a heightmap, a normal map and a color index map.
|
||||
|
||||
#raymarch_$name = sdf3d_raymarch
|
||||
#vec2 $(name_uv)_d = raymarch_$name($uv);
|
||||
|
||||
#Outputs:
|
||||
|
||||
#HeightMap - float - The generated height map
|
||||
#1.0-$(name_uv)_d.x
|
||||
|
||||
#NormalMap - rgb - The generated normal map
|
||||
#vec3(0.5)+0.5*normal_$name(vec3($uv-vec2(0.5), 1.0-$(name_uv)_d.x))
|
||||
|
||||
#ColorMap - float - The generated color index map
|
||||
#$(name_uv)_d.y
|
||||
|
||||
#Inputs:
|
||||
#input, vec2, default:vec2(100, 0.0), (sdf3dc input)
|
||||
|
||||
#----------------------
|
||||
#raymarching_preview.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output (rgb)
|
||||
#render_$name($uv-vec2(0.5))
|
||||
|
||||
#Inputs:
|
||||
#input, vec2, default:vec2(100, 0.0), (sdf3dc input)
|
||||
|
||||
static func raymarch(uv : Vector2) -> Color:
|
||||
var d : Vector2 = sdf3d_raymarch(uv);
|
||||
|
||||
var f : float = 1.0 - d.x;
|
||||
|
||||
return Color(f, f, f, 1)
|
||||
|
||||
static func raymarch2(uv : Vector2) -> Color:
|
||||
var d : Vector2 = sdf3d_raymarch(uv);
|
||||
|
||||
var v : Vector3 = Vector3(0.5, 0.5, 0.5) + 0.5 * sdf3d_normal(Vector3(uv.x - 0.5, uv.y - 0.5, 1.0 - d.x));
|
||||
|
||||
return Color(v.x, v.y, v.z, 1)
|
||||
|
||||
static func raymarch3(uv : Vector2) -> Color:
|
||||
var v : Vector2 = sdf3d_raymarch(uv);
|
||||
|
||||
return Color(v.y, v.y, v.y, 1)
|
||||
|
||||
#length($uv)-$r
|
||||
|
||||
static func sdf3d_sphere(p : Vector3, r : float) -> Vector2:
|
||||
var s : float = p.length() - r;
|
||||
|
||||
return Vector2(s, 0.0);
|
||||
|
||||
#vec3 $(name_uv)_q = abs($uv) - vec3($sx, $sy, $sz);
|
||||
#length(max($(name_uv)_q,0.0))+min(max($(name_uv)_q.x,max($(name_uv)_q.y,$(name_uv)_q.z)),0.0)-$r
|
||||
|
||||
static func sdf3d_box(p : Vector3, sx : float, sy : float, sz : float, r : float) -> Vector2:
|
||||
var v : Vector3 = Commons.absv3((p)) - Vector3(sx, sy, sz);
|
||||
var f : float = (Commons.maxv3(v,Vector3())).length() + min(max(v.x,max(v.y, v.z)),0.0) - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#Y: $axis = length($uv.xz),$uv.y
|
||||
#vec2 $(name_uv)_d = abs(vec2($axis)) - vec2($r,$l);
|
||||
|
||||
static func sdf3d_cylinder_y(p : Vector3, r : float, l : float) -> Vector2:
|
||||
var v : Vector2 = Commons.absv2(Vector2(Vector2(p.x, p.z).length(),(p).y)) - Vector2(r,l);
|
||||
var f : float = min(max(v.x, v.y),0.0) + Commons.maxv2(v, Vector2()).length();
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#X: $axis = length($uv.yz),$uv.x
|
||||
#vec2 $(name_uv)_d = abs(vec2($axis)) - vec2($r,$l);
|
||||
|
||||
static func sdf3d_cylinder_x(p : Vector3, r : float, l : float) -> Vector2:
|
||||
var v : Vector2 = Commons.absv2(Vector2(Vector2(p.y, p.z).length(),(p).x)) - Vector2(r, l);
|
||||
var f : float = min(max(v.x, v.y),0.0) + Commons.maxv2(v, Vector2()).length();
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#Z: $axis = length($uv.xy),$uv.z
|
||||
#vec2 $(name_uv)_d = abs(vec2($axis)) - vec2($r,$l);
|
||||
|
||||
static func sdf3d_cylinder_z(p : Vector3, r : float, l : float) -> Vector2:
|
||||
var v : Vector2 = Commons.absv2(Vector2(Vector2(p.x, p.y).length(),(p).z)) - Vector2(r, l);
|
||||
var f : float = min(max(v.x, v.y),0.0) + Commons.maxv2(v, Vector2()).length();
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#vec3 $(name_uv)_p = $uv;
|
||||
#$(name_uv)_p.$axis -= clamp($(name_uv)_p.$axis, -$l, $l);
|
||||
#return length($(name_uv)_p)-$r*$profile(clamp(0.5+0.5*($uv).$axis/$l, 0.0, 1.0))
|
||||
|
||||
static func sdf3d_capsule_y(p : Vector3, r : float, l : float) -> Vector2:
|
||||
var v : Vector3 = p;
|
||||
v.y -= clamp(v.y, -l, l);
|
||||
var f : float = v.length() - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
static func sdf3d_capsule_x(p : Vector3, r : float, l : float) -> Vector2:
|
||||
var v : Vector3 = p;
|
||||
v.x -= clamp(v.x, -l, l);
|
||||
var f : float = v.length() - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
static func sdf3d_capsule_z(p : Vector3, r : float, l : float) -> Vector2:
|
||||
var v : Vector3 = p;
|
||||
v.z -= clamp(v.z, -l, l);
|
||||
var f : float = v.length() - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#+X: $axis = length($uv.yz),-$uv.x
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
static func sdf3d_cone_px(p : Vector3, a : float) -> Vector2:
|
||||
var f : float = Vector2(cos(a*0.01745329251),sin(a*0.01745329251)).dot(Vector2(Vector2(p.y, p.z).length(), - (p).x));
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#-X: $axis = length($uv.yz),$uv.x
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
static func sdf3d_cone_nx(p : Vector3, a : float) -> Vector2:
|
||||
var f : float = Vector2(cos(a*0.01745329251),sin(a*0.01745329251)).dot(Vector2(Vector2(p.y, p.z).length(),(p).x));
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#+Y: $axis = length($uv.xz),$uv.y
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
static func sdf3d_cone_py(p : Vector3, a : float) -> Vector2:
|
||||
var f : float = Vector2(cos(a*0.01745329251),sin(a*0.01745329251)).dot(Vector2(Vector2(p.x, p.z).length(),(p).y));
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#-Y: $axis = length($uv.xz),-$uv.y
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
static func sdf3d_cone_ny(p : Vector3, a : float) -> Vector2:
|
||||
var f : float = Vector2(cos(a*0.01745329251),sin(a*0.01745329251)).dot(Vector2(Vector2(p.x, p.z).length(),-(p).y));
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
#+Z: $axis = length($uv.xy),-$uv.z
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
static func sdf3d_cone_pz(p : Vector3, a : float) -> Vector2:
|
||||
var f : float = Vector2(cos(a*0.01745329251),sin(a*0.01745329251)).dot(Vector2(Vector2(p.x, p.y).length(),-(p).z));
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
|
||||
#-Z: $axis = length($uv.xy),$uv.z
|
||||
#dot(vec2(cos($a*0.01745329251),sin($a*0.01745329251)),vec2($axis))
|
||||
|
||||
static func sdf3d_cone_nz(p : Vector3, a : float) -> Vector2:
|
||||
var f : float = Vector2(cos(a*0.01745329251),sin(a*0.01745329251)).dot(Vector2(Vector2(p.x, p.y).length(),(p).z));
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
static func sdf3d_torus_x(p : Vector3, R : float, r : float) -> Vector2:
|
||||
var q : Vector2 = Vector2(Vector2(p.y, p.z).length() - R,(p).x);
|
||||
var f : float = q.length() - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
static func sdf3d_torus_y(p : Vector3, R : float, r : float) -> Vector2:
|
||||
var q : Vector2 = Vector2(Vector2(p.z, p.x).length() - R,(p).y);
|
||||
var f : float = q.length() - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
static func sdf3d_torus_z(p : Vector3, R : float, r : float) -> Vector2:
|
||||
var q : Vector2 = Vector2(Vector2(p.x, p.y).length() - R,(p).z);
|
||||
var f : float = q.length() - r;
|
||||
|
||||
return Vector2(f, 0.0);
|
||||
|
||||
|
||||
#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);
|
||||
#}
|
||||
|
||||
static 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 = sdf3d_input(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);
|
||||
#}
|
||||
|
||||
static func sdf3d_normal(p : Vector3) -> Vector3:
|
||||
if (p.z <= 0.0):
|
||||
return Vector3(0.0, 0.0, 1.0);
|
||||
|
||||
var d : float = sdf3d_input(p).x;
|
||||
var e : float = .001;
|
||||
|
||||
var n : Vector3 = Vector3(
|
||||
d - sdf3d_input(p - Vector3(e, 0.0, 0.0)).x,
|
||||
d - sdf3d_input(p - Vector3(0.0, e, 0.0)).x,
|
||||
d - sdf3d_input(p - Vector3(0.0, 0.0, e)).x);
|
||||
|
||||
return Vector3(-1.0, -1.0, -1.0) * n.normalized();
|
||||
|
||||
#vec2 sdf3dc_union(vec2 a, vec2 b) {
|
||||
# return vec2(min(a.x, b.x), mix(b.y, a.y, step(a.x, b.x)));
|
||||
#}
|
||||
|
||||
static func sdf3dc_union(a : Vector2, b : Vector2) -> Vector2:
|
||||
return Vector2(min(a.x, b.x), lerp(b.y, a.y, Commons.step(a.x, b.x)));
|
||||
|
||||
#vec2 sdf3dc_sub(vec2 a, vec2 b) {
|
||||
# return vec2(max(-a.x, b.x), a.y);
|
||||
#}
|
||||
|
||||
static func sdf3dc_sub(a : Vector2, b : Vector2) -> Vector2:
|
||||
return Vector2(max(-a.x, b.x), a.y);
|
||||
|
||||
#vec2 sdf3dc_inter(vec2 a, vec2 b) {
|
||||
# return vec2(max(a.x, b.x), mix(a.y, b.y, step(a.x, b.x)));
|
||||
#}
|
||||
|
||||
static func sdf3dc_inter(a : Vector2, b : Vector2) -> Vector2:
|
||||
return Vector2(max(a.x, b.x), lerp(a.y, b.y, Commons.step(a.x, b.x)));
|
||||
|
||||
#vec2 sdf3d_smooth_union(vec2 d1, vec2 d2, float k) {
|
||||
# float h = clamp(0.5+0.5*(d2.x-d1.x)/k, 0.0, 1.0);
|
||||
# return vec2(mix(d2.x, d1.x, h)-k*h*(1.0-h), mix(d2.y, d1.y, step(d1.x, d2.x)));
|
||||
#}
|
||||
|
||||
static func sdf3d_smooth_union(d1 : Vector2, d2 : Vector2, k : float) -> Vector2:
|
||||
var h : float = clamp(0.5 + 0.5 * (d2.x - d1.x) / k, 0.0, 1.0);
|
||||
return Vector2(lerp(d2.x, d1.x, h)-k*h*(1.0 - h), lerp(d2.y, d1.y, Commons.step(d1.x, d2.x)));
|
||||
|
||||
#vec2 sdf3d_smooth_subtraction(vec2 d1, vec2 d2, float k ) {
|
||||
# float h = clamp(0.5-0.5*(d2.x+d1.x)/k, 0.0, 1.0);
|
||||
# return vec2(mix(d2.x, -d1.x, h )+k*h*(1.0-h), d2.y);
|
||||
#}
|
||||
|
||||
static func sdf3d_smooth_subtraction(d1 : Vector2, d2 : Vector2, k : float) -> Vector2:
|
||||
var h : float = clamp(0.5 - 0.5 * (d2.x + d1.x) / k, 0.0, 1.0);
|
||||
return Vector2(lerp(d2.x, -d1.x, h )+k*h*(1.0-h), d2.y);
|
||||
|
||||
#vec2 sdf3d_smooth_intersection(vec2 d1, vec2 d2, float k ) {
|
||||
# float h = clamp(0.5-0.5*(d2.x-d1.x)/k, 0.0, 1.0);
|
||||
# return vec2(mix(d2.x, d1.x, h)+k*h*(1.0-h), mix(d1.y, d2.y, step(d1.x, d2.x)));
|
||||
#}
|
||||
|
||||
static func sdf3d_smooth_intersection(d1 : Vector2, d2 : Vector2, k : float) -> Vector2:
|
||||
var h : float = clamp(0.5 - 0.5 * (d2.x - d1.x) / k, 0.0, 1.0);
|
||||
return Vector2(lerp(d2.x, d1.x, h)+k*h*(1.0-h), lerp(d1.y, d2.y, Commons.step(d1.x, d2.x)));
|
||||
|
||||
static func sdf3d_rounded(v : Vector2, r : float) -> Vector2:
|
||||
return Vector2(v.x - r, v.y);
|
||||
|
||||
static func sdf3d_elongation(p : Vector3, v : Vector3) -> Vector3:
|
||||
return ((p) - Commons.clampv3((p), - Commons.absv3(v), Commons.absv3(v)))
|
||||
|
||||
static func sdf3d_repeat(p : Vector3, r : Vector2, randomness : float, pseed : int) -> Vector3:
|
||||
#$in(repeat($uv, vec3(1.0/$rx, 1.0/$ry, 0.0), float($seed), $r))
|
||||
return repeat(p, Vector3(1.0 / r.x, 1.0 / r.y, 0.00001), float(pseed), randomness)
|
||||
|
||||
#vec3 repeat(vec3 p, vec3 r, float seed, float randomness) {
|
||||
# vec3 a = (rand3(floor(mod((p.xy+0.5*r.xy)/r.xy, 1.0/r.xy)+vec2(seed)))-0.5)*6.28*randomness;
|
||||
# p = mod(p+0.5*r,r)-0.5*r;
|
||||
#
|
||||
# vec3 rv;
|
||||
# float c;
|
||||
# float s;
|
||||
#
|
||||
# c = cos(a.x);
|
||||
# s = sin(a.x);
|
||||
#
|
||||
# rv.x = p.x;
|
||||
# rv.y = p.y*c+p.z*s;rv.z = -p.y*s+p.z*c;
|
||||
#
|
||||
# c = cos(a.y);
|
||||
# s = sin(a.y);
|
||||
#
|
||||
# p.x = rv.x*c+rv.z*s;
|
||||
# p.y = rv.y;
|
||||
# p.z = -rv.x*s+rv.z*c;
|
||||
#
|
||||
# c = cos(a.z);
|
||||
# s = sin(a.z);
|
||||
#
|
||||
# rv.x = p.x*c+p.y*s;
|
||||
# rv.y = -p.x*s+p.y*c;
|
||||
# rv.z = p.z;
|
||||
#
|
||||
# return rv;
|
||||
#}
|
||||
|
||||
static func repeat(p : Vector3, r : Vector3, pseed : float, randomness : float) -> Vector3:
|
||||
var a : Vector3 = (Commons.rand3(Commons.floorv2(Commons.modv2((Vector2(p.x, p.y) + Vector2(0.5, 0.5) * Vector2(r.x, r.y)) / Vector2(r.x, r.y), Vector2(1, 1) / Vector2(r.x, r.y)) + Vector2(pseed, pseed))) - Vector3(0.5, 0.5, 0.5)) * 6.28 * randomness
|
||||
p = Commons.modv3(p + Vector3(0.5, 0.5, 0.5) * r, r) - Vector3(0.5, 0.5, 0.5) * r;
|
||||
|
||||
var rv : Vector3 = Vector3()
|
||||
var c : float = 0
|
||||
var s : float = 0
|
||||
|
||||
c = cos(a.x);
|
||||
s = sin(a.x);
|
||||
|
||||
rv.x = p.x;
|
||||
rv.y = p.y* c + p.z * s;
|
||||
rv.z = -p.y * s + p.z * c;
|
||||
|
||||
c = cos(a.y);
|
||||
s = sin(a.y);
|
||||
|
||||
p.x = rv.x*c+rv.z*s;
|
||||
p.y = rv.y;
|
||||
p.z = -rv.x*s+rv.z*c;
|
||||
|
||||
c = cos(a.z);
|
||||
s = sin(a.z);
|
||||
|
||||
rv.x = p.x * c + p.y * s;
|
||||
rv.y = -p.x * s + p.y * c;
|
||||
rv.z = p.z;
|
||||
|
||||
return rv;
|
||||
|
||||
#vec3 rotate3d(vec3 p, vec3 a) {
|
||||
# vec3 rv;
|
||||
# float c;
|
||||
# float s;
|
||||
# c = cos(a.x);
|
||||
# s = sin(a.x);
|
||||
# rv.x = p.x;
|
||||
# rv.y = p.y*c+p.z*s;
|
||||
# rv.z = -p.y*s+p.z*c;
|
||||
# c = cos(a.y);
|
||||
# s = sin(a.y);
|
||||
# p.x = rv.x*c+rv.z*s;
|
||||
# p.y = rv.y;
|
||||
# p.z = -rv.x*s+rv.z*c;
|
||||
# c = cos(a.z);
|
||||
# s = sin(a.z);
|
||||
# rv.x = p.x*c+p.y*s;
|
||||
# rv.y = -p.x*s+p.y*c;
|
||||
# rv.z = p.z;
|
||||
# return rv;
|
||||
#}
|
||||
|
||||
static func rotate3d(p : Vector3, a : Vector3) -> Vector3:
|
||||
var rv : Vector3 = Vector3()
|
||||
var c : float = 0
|
||||
var s : float = 0
|
||||
c = cos(a.x)
|
||||
s = sin(a.x)
|
||||
rv.x = p.x
|
||||
rv.y = p.y * c + p.z * s
|
||||
rv.z = -p.y * s + p.z * c
|
||||
c = cos(a.y)
|
||||
s = sin(a.y)
|
||||
p.x = rv.x * c + rv.z * s
|
||||
p.y = rv.y
|
||||
p.z = -rv.x * s + rv.z * c
|
||||
c = cos(a.z)
|
||||
s = sin(a.z)
|
||||
rv.x = p.x * c + p.y * s
|
||||
rv.y = -p.x * s + p.y * c
|
||||
rv.z = p.z
|
||||
|
||||
return rv
|
||||
|
||||
#vec3 circle_repeat_transform(vec3 p, float count) {
|
||||
# float r = 6.28/count;
|
||||
# float pa = atan(p.x, p.y);
|
||||
# float a = mod(pa+0.5*r, r)-0.5*r;
|
||||
# vec3 rv;
|
||||
# float c = cos(a-pa);
|
||||
# float s = sin(a-pa);
|
||||
# rv.x = p.x*c+p.y*s;
|
||||
# rv.y = -p.x*s+p.y*c;
|
||||
# rv.z = p.z;
|
||||
# return rv;
|
||||
#}
|
||||
|
||||
static func circle_repeat_transform(p : Vector3, count : float) -> Vector3:
|
||||
var r : float = 6.28 / count
|
||||
var pa : float = atan2(p.x, p.y)
|
||||
var a : float = Commons.modf(pa + 0.5 * r, r) - 0.5 * r
|
||||
var rv : Vector3 = Vector3()
|
||||
var c : float = cos(a-pa)
|
||||
var s : float = sin(a-pa)
|
||||
rv.x = p.x * c + p.y * s
|
||||
rv.y = -p.x * s + p.y * c
|
||||
rv.z = p.z
|
||||
return rv
|
||||
|
||||
#todo this needs to be solved
|
||||
static func sdf3d_input(p : Vector3) -> Vector2:
|
||||
return sdf3d_sphere(p, 0.5)
|
||||
|
||||
#raymarching_preview.mmg
|
||||
#vec3 render_$name(vec2 uv) {
|
||||
# vec3 p = vec3(uv, 2.0-raymarch_$name(vec3(uv, 2.0), vec3(0.0, 0.0, -1.0)));
|
||||
# vec3 n = normal_$name(p);
|
||||
# vec3 l = vec3(5.0, 5.0, 10.0);
|
||||
# vec3 ld = normalize(l-p);
|
||||
#
|
||||
# float o = step(p.z, 0.001);
|
||||
# float shadow = 1.0-0.75*step(raymarch_$name(l, -ld), length(l-p)-0.01);
|
||||
# float light = 0.3+0.7*dot(n, ld)*shadow;
|
||||
#
|
||||
# return vec3(0.8+0.2*o, 0.8+0.2*o, 1.0)*light;
|
||||
#}
|
||||
|
||||
#static func sdf3d_render(p : Vector2) -> Vector3:
|
||||
# return Vector3()
|
292
addons/mat_maker_gd/nodes/common/shapes.gd
Normal file
292
addons/mat_maker_gd/nodes/common/shapes.gd
Normal file
@ -0,0 +1,292 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#sphere.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (float) - A heightmap of the specified sphere
|
||||
#sphere($uv, vec2($cx, $cy), $r)
|
||||
|
||||
#Inputs:
|
||||
#center, vector2, default: 0.5, min: 0, max: 1, step: 0.01
|
||||
#radius, float, min: 0, max: 1, default: 0.5, step:0.01
|
||||
|
||||
#----------------------
|
||||
#shape.mmg
|
||||
|
||||
#Outputs:
|
||||
|
||||
#Output - (float) - Shows a white shape on a black background
|
||||
#shape_$(shape)($(uv), $(sides), $(radius)*$radius_map($uv), $(edge)*$edge_map($uv))
|
||||
|
||||
#Inputs:
|
||||
#shape, enum, default: 0, values: circle, ploygon, star, curved_star, rays
|
||||
#sides, int, min: 2, max: 32, default: 3, step:1
|
||||
#radius, float, min: 0, max: 1, default: 1, step:0.01 (universal input)
|
||||
#edge, float, min: 0, max: 1, default: 0.2, step:0.01 (universal input)
|
||||
|
||||
#----------------------
|
||||
#box.mmg
|
||||
#A heightmap of the specified box
|
||||
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "1.0-box($uv, vec3($cx, $cy, $cz), vec3($sx, $sy, $sz), 0.01745329251*vec3($rx, $ry, $rz))",
|
||||
# "longdesc": "A heightmap of the specified box",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Center X",
|
||||
# "longdesc": "X coordinate of the center of the box",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "cx",
|
||||
# "shortdesc": "Center.x",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Center Y",
|
||||
# "longdesc": "Y coordinate of the center of the box",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "cy",
|
||||
# "shortdesc": "Center.y",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Center Z",
|
||||
# "longdesc": "Z coordinate of the center of the box",
|
||||
# "max": 0.5,
|
||||
# "min": -0.5,
|
||||
# "name": "cz",
|
||||
# "shortdesc": "Center.z",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Size X",
|
||||
# "longdesc": "Size along X axis",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "sx",
|
||||
# "shortdesc": "Size.x",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Size Y",
|
||||
# "longdesc": "Size along Y axis",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "sy",
|
||||
# "shortdesc": "Size.y",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Size Z",
|
||||
# "longdesc": "Size along Z axis",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "sz",
|
||||
# "shortdesc": "Size.z",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Rot X",
|
||||
# "longdesc": "Rotation angle around X axis",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "rx",
|
||||
# "shortdesc": "Rot.x",
|
||||
# "step": 0.1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Rot Y",
|
||||
# "longdesc": "Rotation angle around Y axis",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "ry",
|
||||
# "shortdesc": "Rot.y",
|
||||
# "step": 0.1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Rot Z",
|
||||
# "longdesc": "Rotation angle around Y axis",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "rz",
|
||||
# "shortdesc": "Rot.z",
|
||||
# "step": 0.1,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ]
|
||||
|
||||
#float sphere(vec2 uv, vec2 c, float r) {
|
||||
# uv -= c;
|
||||
# uv /= r;
|
||||
# return 2.0*r*sqrt(max(0.0, 1.0-dot(uv, uv)));
|
||||
#}
|
||||
|
||||
static func sphere(uv : Vector2, c : Vector2, r : float) -> float:
|
||||
return 0.0
|
||||
|
||||
#float shape_circle(vec2 uv, float sides, float size, float edge) {
|
||||
# uv = 2.0*uv-1.0;
|
||||
# edge = max(edge, 1.0e-8);
|
||||
# float distance = length(uv);
|
||||
# return clamp((1.0-distance/size)/edge, 0.0, 1.0);
|
||||
#}
|
||||
|
||||
static func shape_circle(uv : Vector2, sides : float, size : float, edge : float) -> float:
|
||||
uv.x = 2.0 * uv.x - 1.0
|
||||
uv.y = 2.0 * uv.y - 1.0
|
||||
|
||||
edge = max(edge, 1.0e-8)
|
||||
|
||||
var distance : float = uv.length()
|
||||
|
||||
return clamp((1.0 - distance / size) / edge, 0.0, 1.0)
|
||||
|
||||
#float shape_polygon(vec2 uv, float sides, float size, float edge) {
|
||||
# uv = 2.0*uv-1.0;
|
||||
# edge = max(edge, 1.0e-8);
|
||||
# float angle = atan(uv.x, uv.y)+3.14159265359;
|
||||
# float slice = 6.28318530718/sides;
|
||||
# return clamp((1.0-(cos(floor(0.5+angle/slice)*slice-angle)*length(uv))/size)/edge, 0.0, 1.0);
|
||||
#}
|
||||
|
||||
static func shape_polygon(uv : Vector2, sides : float, size : float, edge : float) -> float:
|
||||
uv.x = 2.0 * uv.x - 1.0
|
||||
uv.y = 2.0 * uv.y - 1.0
|
||||
|
||||
edge = max(edge, 1.0e-8)
|
||||
|
||||
#simple no branch for division by zero
|
||||
uv.x += 0.0000001
|
||||
|
||||
var angle : float = atan(uv.y / uv.x) + 3.14159265359
|
||||
var slice : float = 6.28318530718 / sides
|
||||
|
||||
return clamp((size - cos(floor(0.5 + angle / slice) * slice - angle) * uv.length()) / (edge * size), 0.0, 1.0)
|
||||
|
||||
#float shape_star(vec2 uv, float sides, float size, float edge) {
|
||||
# uv = 2.0*uv-1.0;
|
||||
# edge = max(edge, 1.0e-8);
|
||||
# float angle = atan(uv.x, uv.y);
|
||||
# float slice = 6.28318530718/sides;
|
||||
# return clamp((1.0-(cos(floor(angle*sides/6.28318530718-0.5+2.0*step(fract(angle*sides/6.28318530718), 0.5))*slice-angle)*length(uv))/size)/edge, 0.0, 1.0);
|
||||
#}
|
||||
|
||||
static func shape_star(uv : Vector2, sides : float, size : float, edge : float) -> float:
|
||||
uv.x = 2.0 * uv.x - 1.0
|
||||
uv.y = 2.0 * uv.y - 1.0
|
||||
|
||||
edge = max(edge, 1.0e-8);
|
||||
|
||||
#simple no branch for division by zero
|
||||
uv.x += 0.0000001
|
||||
|
||||
var angle : float = atan(uv.y / uv.x)
|
||||
var slice : float = 6.28318530718 / sides
|
||||
|
||||
return clamp((size - cos(floor(1.5 + angle / slice - 2.0 * Commons.step(0.5 * slice, Commons.modf(angle, slice))) * slice - angle) * uv.length()) / (edge * size), 0.0, 1.0);
|
||||
|
||||
#float shape_curved_star(vec2 uv, float sides, float size, float edge) {
|
||||
# uv = 2.0*uv-1.0;
|
||||
# edge = max(edge, 1.0e-8);
|
||||
# float angle = 2.0*(atan(uv.x, uv.y)+3.14159265359);
|
||||
# float slice = 6.28318530718/sides;
|
||||
# return clamp((1.0-cos(floor(0.5+0.5*angle/slice)*2.0*slice-angle)*length(uv)/size)/edge, 0.0, 1.0);
|
||||
#}
|
||||
|
||||
static func shape_curved_star(uv : Vector2, sides : float, size : float, edge : float) -> float:
|
||||
uv.x = 2.0 * uv.x - 1.0
|
||||
uv.y = 2.0 * uv.y - 1.0
|
||||
|
||||
edge = max(edge, 1.0e-8);
|
||||
|
||||
#simple no branch for division by zero
|
||||
uv.x += 0.0000001
|
||||
|
||||
var angle : float = 2.0*(atan(uv.y / uv.x) + 3.14159265359)
|
||||
var slice : float = 6.28318530718 / sides
|
||||
|
||||
return clamp((size - cos(floor(0.5 + 0.5 * angle / slice) * 2.0 * slice - angle) * uv.length())/(edge * size), 0.0, 1.0);
|
||||
|
||||
#float shape_rays(vec2 uv, float sides, float size, float edge) {
|
||||
# uv = 2.0*uv-1.0;
|
||||
# edge = 0.5*max(edge, 1.0e-8)*size;
|
||||
# float slice = 6.28318530718/sides;
|
||||
# float angle = mod(atan(uv.x, uv.y)+3.14159265359, slice)/slice;
|
||||
# return clamp(min((size-angle)/edge, angle/edge), 0.0, 1.0);
|
||||
#}
|
||||
|
||||
static func shape_rays(uv : Vector2, sides : float, size : float, edge : float) -> float:
|
||||
|
||||
uv.x = 2.0 * uv.x - 1.0
|
||||
uv.y = 2.0 * uv.y - 1.0
|
||||
|
||||
edge = 0.5 * max(edge, 1.0e-8) * size
|
||||
|
||||
#simple no branch for division by zero
|
||||
uv.x += 0.0000001
|
||||
|
||||
var slice : float = 6.28318530718 / sides
|
||||
var angle : float = Commons.modf(atan(uv.y / uv.x) + 3.14159265359, slice) / slice
|
||||
|
||||
return clamp(min((size - angle) / edge, angle / edge), 0.0, 1.0);
|
||||
|
||||
#float box(vec2 uv, vec3 center, vec3 rad, vec3 rot) {\n\t
|
||||
# vec3 ro = vec3(uv, 1.0)-center;\n\t
|
||||
# vec3 rd = vec3(0.0000001, 0.0000001, -1.0);\n\t
|
||||
# mat3 r = mat3(vec3(1, 0, 0), vec3(0, cos(rot.x), -sin(rot.x)), vec3(0, sin(rot.x), cos(rot.x)));\n\t
|
||||
#
|
||||
# r *= mat3(vec3(cos(rot.y), 0, -sin(rot.y)), vec3(0, 1, 0), vec3(sin(rot.y), 0, cos(rot.y)));\n\t
|
||||
# r *= mat3(vec3(cos(rot.z), -sin(rot.z), 0), vec3(sin(rot.z), cos(rot.z), 0), vec3(0, 0, 1));\n\t
|
||||
# ro = r * ro;\n\t
|
||||
# rd = r * rd;\n
|
||||
# vec3 m = 1.0/rd;\n
|
||||
# vec3 n = m*ro;\n
|
||||
# vec3 k = abs(m)*rad;\n
|
||||
# vec3 t1 = -n - k;\n
|
||||
# vec3 t2 = -n + k;\n\n
|
||||
#
|
||||
# float tN = max(max(t1.x, t1.y), t1.z);\n
|
||||
# float tF = min(min(t2.x, t2.y), t2.z);\n
|
||||
#
|
||||
# if(tN>tF || tF<0.0) return 1.0;\n
|
||||
#
|
||||
# return tN;\n
|
||||
#}
|
||||
|
147
addons/mat_maker_gd/nodes/common/simple.gd
Normal file
147
addons/mat_maker_gd/nodes/common/simple.gd
Normal file
@ -0,0 +1,147 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#profile.mmg
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "dot($gradient($uv.x).xyz, vec3(1.0/3.0))",
|
||||
# "label": "2:",
|
||||
# "name": "in",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "draw_profile_$style($uv, $in($uv), (dot($gradient($uv.x+0.001).xyz, vec3(1.0/3.0))-dot($gradient($uv.x-0.001).xyz, vec3(1.0/3.0)))/0.002, max(0.0001, $width))",
|
||||
# "longdesc": "An image showing the profile defined by the gradient",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "",
|
||||
# "longdesc": "Style of the output image (fill or curve)",
|
||||
# "name": "style",
|
||||
# "shortdesc": "Style",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Curve",
|
||||
# "value": "curve"
|
||||
# },
|
||||
# {
|
||||
# "name": "Fill",
|
||||
# "value": "fill"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "default": {
|
||||
# "interpolation": 1,
|
||||
# "points": [
|
||||
# {
|
||||
# "a": 1,
|
||||
# "b": 0,
|
||||
# "g": 0,
|
||||
# "pos": 0,
|
||||
# "r": 0
|
||||
# },
|
||||
# {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "pos": 1,
|
||||
# "r": 1
|
||||
# }
|
||||
# ],
|
||||
# "type": "Gradient"
|
||||
# },
|
||||
# "label": "",
|
||||
# "longdesc": "Gradient that defines the profile to be shown",
|
||||
# "name": "gradient",
|
||||
# "shortdesc": "Gradient",
|
||||
# "type": "gradient"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.05,
|
||||
# "label": "",
|
||||
# "longdesc": "Width of the curve",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "width",
|
||||
# "shortdesc": "Width",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ]
|
||||
|
||||
#----------------------
|
||||
#uniform.mmg
|
||||
#Draws a uniform image
|
||||
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "A uniform image of the selected color",
|
||||
# "rgba": "$(color)",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "r": 1
|
||||
# },
|
||||
# "label": "",
|
||||
# "longdesc": "Color of the uniform image",
|
||||
# "name": "color",
|
||||
# "shortdesc": "Color",
|
||||
# "type": "color"
|
||||
# }
|
||||
# ]
|
||||
|
||||
#----------------------
|
||||
#uniform_greyscale.mmg
|
||||
#Draws a uniform greyscale image
|
||||
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "$(color)",
|
||||
# "longdesc": "A uniform image of the selected value",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "",
|
||||
# "longdesc": "The value of the uniform greyscale image",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "color",
|
||||
# "shortdesc": "Value",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ]
|
||||
|
||||
#float draw_profile_fill(vec2 uv, float y, float dy, float w) {\n\t
|
||||
# return 1.0-clamp(sin(1.57079632679-atan(dy))*(1.0-uv.y-y)/w, 0.0, 1.0);\n
|
||||
#}
|
||||
|
||||
#float draw_profile_curve(vec2 uv, float y, float dy, float w) {\n\t
|
||||
# return 1.0-clamp(sin(1.57079632679-atan(dy))*abs(1.0-uv.y-y)/w, 0.0, 1.0);\n
|
||||
#}
|
||||
|
979
addons/mat_maker_gd/nodes/common/tex3d.gd
Normal file
979
addons/mat_maker_gd/nodes/common/tex3d.gd
Normal file
@ -0,0 +1,979 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#tex3d_apply.mmg
|
||||
#Applies 3D textures to a rendered 3D signed distance function scene.
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "label": "Height",
|
||||
# "longdesc": "The height map generated by the Render node",
|
||||
# "name": "z",
|
||||
# "shortdesc": "HeightMap",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "label": "Color",
|
||||
# "longdesc": "The color map generated by the Render node",
|
||||
# "name": "c",
|
||||
# "shortdesc": "ColorMap",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(1.0)",
|
||||
# "label": "Texture",
|
||||
# "longdesc": "The 3D texture",
|
||||
# "name": "t",
|
||||
# "shortdesc": "Tex3D",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The textured 3D scene",
|
||||
# "rgb": "$t(vec4($uv, $z($uv), $c($uv)))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_apply_invuvmap.mmg
|
||||
#This node applies a 3D texture to an object using its inverse UV map.
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(1.0)",
|
||||
# "label": "Texture",
|
||||
# "longdesc": "The input 3D texture",
|
||||
# "name": "t",
|
||||
# "shortdesc": "Texture",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "Inv. UV Map",
|
||||
# "longdesc": "The inverse UV map of the object",
|
||||
# "name": "map",
|
||||
# "shortdesc": "InvUVMap",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated texture",
|
||||
# "rgb": "$t(vec4($map($uv), 0.0))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_blend.mmg
|
||||
#Blends its 3D texture inputs, using an optional mask
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3($uv.x, 1.0, 1.0)",
|
||||
# "label": "Source1",
|
||||
# "longdesc": "The foreground input",
|
||||
# "name": "s1",
|
||||
# "shortdesc": "Foreground",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(1.0, $uv.y, 1.0)",
|
||||
# "label": "Source2",
|
||||
# "longdesc": "The background input",
|
||||
# "name": "s2",
|
||||
# "shortdesc": "Background",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(1.0)",
|
||||
# "label": "Opacity",
|
||||
# "longdesc": "The optional opacity mask",
|
||||
# "name": "a",
|
||||
# "shortdesc": "Mask",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The 3D texture generated by the blend operation",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "blend3d_$blend_type($s1($uv).rgb, $s2($uv).rgb, $amount*dot($a($uv), vec3(1.0))/3.0)",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "",
|
||||
# "longdesc": "The algorithm used to blend the inputs",
|
||||
# "name": "blend_type",
|
||||
# "shortdesc": "Blend mode",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Normal",
|
||||
# "value": "normal"
|
||||
# },
|
||||
# {
|
||||
# "name": "Multiply",
|
||||
# "value": "multiply"
|
||||
# },
|
||||
# {
|
||||
# "name": "Screen",
|
||||
# "value": "screen"
|
||||
# },
|
||||
# {
|
||||
# "name": "Overlay",
|
||||
# "value": "overlay"
|
||||
# },
|
||||
# {
|
||||
# "name": "Hard Light",
|
||||
# "value": "hard_light"
|
||||
# },
|
||||
# {
|
||||
# "name": "Soft Light",
|
||||
# "value": "soft_light"
|
||||
# },
|
||||
# {
|
||||
# "name": "Burn",
|
||||
# "value": "burn"
|
||||
# },
|
||||
# {
|
||||
# "name": "Dodge",
|
||||
# "value": "dodge"
|
||||
# },
|
||||
# {
|
||||
# "name": "Lighten",
|
||||
# "value": "lighten"
|
||||
# },
|
||||
# {
|
||||
# "name": "Darken",
|
||||
# "value": "darken"
|
||||
# },
|
||||
# {
|
||||
# "name": "Difference",
|
||||
# "value": "difference"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "3:",
|
||||
# "longdesc": "The opacity of the blend operation",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "amount",
|
||||
# "shortdesc": "Opacity",
|
||||
# "step": 0,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_colorize.mmg
|
||||
#Remaps a greyscale 3D texture to a custom gradient
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3($uv.x+0.5)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input greyscale 3D texture",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The remapped color 3D texture ",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "$g(dot($in($uv), vec3(1.0))/3.0).rgb",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": {
|
||||
# "interpolation": 1,
|
||||
# "points": [
|
||||
# {
|
||||
# "a": 1,
|
||||
# "b": 0,
|
||||
# "g": 0,
|
||||
# "pos": 0,
|
||||
# "r": 0
|
||||
# },
|
||||
# {
|
||||
# "a": 1,
|
||||
# "b": 1,
|
||||
# "g": 1,
|
||||
# "pos": 1,
|
||||
# "r": 1
|
||||
# }
|
||||
# ],
|
||||
# "type": "Gradient"
|
||||
# },
|
||||
# "label": "",
|
||||
# "longdesc": "The gradient to which the input is remapped",
|
||||
# "name": "g",
|
||||
# "shortdesc": "Gradient",
|
||||
# "type": "gradient"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_distort.mmg
|
||||
#Distorts its input 3D texture using another 3D texture
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(1.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The 3D texture to be distorted",
|
||||
# "name": "in1",
|
||||
# "shortdesc": "Input1",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The 3D texture used to distort Input1",
|
||||
# "name": "in2",
|
||||
# "shortdesc": "Input2",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The distorted 3D texture",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "$in1(vec4($uv.xyz+($in2($uv)*$Distort*0.5-0.5), 0.0))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Distort",
|
||||
# "longdesc": "The strength of the distort effect",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "Distort",
|
||||
# "shortdesc": "Strength",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_fbm.mmg
|
||||
#Generates a 3D noise made of several octaves of a simple noise
|
||||
|
||||
# "instance": "float $(name)_fbm(vec3 coord, vec3 size, int octaves, float persistence, float seed) {\n\tfloat normalize_factor = 0.0;\n\tfloat value = 0.0;\n\tfloat scale = 1.0;\n\tfor (int i = 0; i < octaves; i++) {\n\t\tvalue += tex3d_fbm_$noise(coord*size, size, seed) * scale;\n\t\tnormalize_factor += scale;\n\t\tsize *= 2.0;\n\t\tscale *= persistence;\n\t}\n\treturn value / normalize_factor;\n}\n",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "Shows a greyscale 3D texture of the generated noise",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "vec3($(name)_fbm($(uv).xyz, vec3($(scale_x), $(scale_y), $(scale_z)), int($(iterations)), $(persistence), float($(seed))))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 2,
|
||||
# "label": "Noise",
|
||||
# "longdesc": "The simple noise type",
|
||||
# "name": "noise",
|
||||
# "shortdesc": "Noise type",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Value",
|
||||
# "value": "value"
|
||||
# },
|
||||
# {
|
||||
# "name": "Perlin",
|
||||
# "value": "perlin"
|
||||
# },
|
||||
# {
|
||||
# "name": "Cellular",
|
||||
# "value": "cellular"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Scale X",
|
||||
# "longdesc": "The scale of the first octave along the X axis",
|
||||
# "max": 32,
|
||||
# "min": 1,
|
||||
# "name": "scale_x",
|
||||
# "shortdesc": "Scale.x",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Scale Y",
|
||||
# "longdesc": "The scale of the first octave along the Y axis",
|
||||
# "max": 32,
|
||||
# "min": 1,
|
||||
# "name": "scale_y",
|
||||
# "shortdesc": "Scale.y",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Scale Z",
|
||||
# "longdesc": "The scale of the first octave along the Z axis",
|
||||
# "max": 32,
|
||||
# "min": 1,
|
||||
# "name": "scale_z",
|
||||
# "shortdesc": "Scale.z",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 3,
|
||||
# "label": "Iterations",
|
||||
# "longdesc": "The number of noise octaves",
|
||||
# "max": 10,
|
||||
# "min": 1,
|
||||
# "name": "iterations",
|
||||
# "shortdesc": "Octaves",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Persistence",
|
||||
# "longdesc": "The persistence between two consecutive octaves",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "persistence",
|
||||
# "shortdesc": "Persistence",
|
||||
# "step": 0.05,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_from2d.mmg
|
||||
#Creates a 3D texture from a 2D texture
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.5)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input 2D texture",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgb"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated 3D texture",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "$in($uv.xy+vec2(0.5))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_pattern.mmg
|
||||
#A greyscale 3D texture that combines patterns along all 3 axes
|
||||
|
||||
# "instance": "float $(name)_fct(vec3 uv) {\n\treturn mix3d_$(mix)(wave3d_$(x_wave)($(x_scale)*uv.x), wave3d_$(y_wave)($(y_scale)*uv.y), wave3d_$(z_wave)($(z_scale)*uv.z));\n}",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The generated 3D texture",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "vec3($(name)_fct($(uv).xyz))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "Combiner",
|
||||
# "longdesc": "The operation used to combine the X, Y and Z patterns",
|
||||
# "name": "mix",
|
||||
# "shortdesc": "Combine",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Multiply",
|
||||
# "value": "mul"
|
||||
# },
|
||||
# {
|
||||
# "name": "Add",
|
||||
# "value": "add"
|
||||
# },
|
||||
# {
|
||||
# "name": "Max",
|
||||
# "value": "max"
|
||||
# },
|
||||
# {
|
||||
# "name": "Min",
|
||||
# "value": "min"
|
||||
# },
|
||||
# {
|
||||
# "name": "Xor",
|
||||
# "value": "xor"
|
||||
# },
|
||||
# {
|
||||
# "name": "Pow",
|
||||
# "value": "pow"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "X",
|
||||
# "longdesc": "Pattern generated along the X axis",
|
||||
# "name": "x_wave",
|
||||
# "shortdesc": "Pattern.x",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Sine",
|
||||
# "value": "sine"
|
||||
# },
|
||||
# {
|
||||
# "name": "Triangle",
|
||||
# "value": "triangle"
|
||||
# },
|
||||
# {
|
||||
# "name": "Square",
|
||||
# "value": "square"
|
||||
# },
|
||||
# {
|
||||
# "name": "Sawtooth",
|
||||
# "value": "sawtooth"
|
||||
# },
|
||||
# {
|
||||
# "name": "Constant",
|
||||
# "value": "constant"
|
||||
# },
|
||||
# {
|
||||
# "name": "Bounce",
|
||||
# "value": "bounce"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "2:",
|
||||
# "longdesc": "Repetitions of the pattern along X axis",
|
||||
# "max": 32,
|
||||
# "min": 0,
|
||||
# "name": "x_scale",
|
||||
# "shortdesc": "Repeat.x",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "Y",
|
||||
# "longdesc": "Pattern generated along the Y axis",
|
||||
# "name": "y_wave",
|
||||
# "shortdesc": "Pattern.y",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Sine",
|
||||
# "value": "sine"
|
||||
# },
|
||||
# {
|
||||
# "name": "Triangle",
|
||||
# "value": "triangle"
|
||||
# },
|
||||
# {
|
||||
# "name": "Square",
|
||||
# "value": "square"
|
||||
# },
|
||||
# {
|
||||
# "name": "Sawtooth",
|
||||
# "value": "sawtooth"
|
||||
# },
|
||||
# {
|
||||
# "name": "Constant",
|
||||
# "value": "constant"
|
||||
# },
|
||||
# {
|
||||
# "name": "Bounce",
|
||||
# "value": "bounce"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "3:",
|
||||
# "longdesc": "Repetitions of the pattern along Y axis",
|
||||
# "max": 32,
|
||||
# "min": 0,
|
||||
# "name": "y_scale",
|
||||
# "shortdesc": "Repeat.y",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "Z",
|
||||
# "longdesc": "Pattern generated along the Z axis",
|
||||
# "name": "z_wave",
|
||||
# "shortdesc": "Pattern.z",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "Sine",
|
||||
# "value": "sine"
|
||||
# },
|
||||
# {
|
||||
# "name": "Triangle",
|
||||
# "value": "triangle"
|
||||
# },
|
||||
# {
|
||||
# "name": "Square",
|
||||
# "value": "square"
|
||||
# },
|
||||
# {
|
||||
# "name": "Sawtooth",
|
||||
# "value": "sawtooth"
|
||||
# },
|
||||
# {
|
||||
# "name": "Constant",
|
||||
# "value": "constant"
|
||||
# },
|
||||
# {
|
||||
# "name": "Bounce",
|
||||
# "value": "bounce"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "4:",
|
||||
# "longdesc": "Repetitions of the pattern along Z axis",
|
||||
# "max": 32,
|
||||
# "min": 0,
|
||||
# "name": "z_scale",
|
||||
# "shortdesc": "Repeat.z",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_rotate.mmg
|
||||
#Rotates a 3D texture
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(1.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The input 3D texture",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The rotated 3D texture",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "$in(vec4(tex3d_rotate($uv.xyz, -vec3($ax, $ay, $az)*0.01745329251), $uv.w))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "X",
|
||||
# "longdesc": "The rotation around the X axis",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "ax",
|
||||
# "shortdesc": "Rotate.x",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Y",
|
||||
# "longdesc": "The rotation around the Y axis",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "ay",
|
||||
# "shortdesc": "Rotate.y",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Z",
|
||||
# "longdesc": "The rotation around the Z axis",
|
||||
# "max": 180,
|
||||
# "min": -180,
|
||||
# "name": "az",
|
||||
# "shortdesc": "Rotate.z",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_select.mmg
|
||||
#Selects a 3D texture for a given color index. This can be used to map several textures into a single 3D scene.
|
||||
|
||||
# "code": "float $(name_uv)_d = ($uv.w-$v)/$t;",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.5)",
|
||||
# "label": "",
|
||||
# "longdesc": "The 3D texture associated to the specified color index",
|
||||
# "name": "in1",
|
||||
# "shortdesc": "Input1",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.5)",
|
||||
# "label": "",
|
||||
# "longdesc": "The 3D texture(s) associated to other color indices",
|
||||
# "name": "in2",
|
||||
# "shortdesc": "Input2",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The merged 3D texture",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "mix($in1($uv), $in2($uv), clamp(1.0-$(name_uv)_d*$(name_uv)_d, 0.0, 1.0))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Value",
|
||||
# "longdesc": "The value of the selected color index",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "v",
|
||||
# "shortdesc": "Value",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.1,
|
||||
# "label": "Tolerance",
|
||||
# "longdesc": "The tolerance used when comparing color indices",
|
||||
# "max": 1,
|
||||
# "min": 0.01,
|
||||
# "name": "t",
|
||||
# "shortdesc": "Tolerance",
|
||||
# "step": 0.001,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_select_shape.mmg
|
||||
#Selects a 3D texture inside, and another outside a shape. This can be used to map several textures into a single 3D scene.
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec3(0.5)",
|
||||
# "label": "",
|
||||
# "longdesc": "The 3D texture associated to the specified color index",
|
||||
# "name": "in1",
|
||||
# "shortdesc": "Input1",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec3(0.5)",
|
||||
# "label": "",
|
||||
# "longdesc": "The 3D texture(s) associated to other color indices",
|
||||
# "name": "in2",
|
||||
# "shortdesc": "Input2",
|
||||
# "type": "tex3d"
|
||||
# },
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "label": "",
|
||||
# "longdesc": "The shape in which input1 is applied",
|
||||
# "name": "shape",
|
||||
# "shortdesc": "Shape",
|
||||
# "type": "sdf3d"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "The merged 3D texture",
|
||||
# "shortdesc": "Output",
|
||||
# "tex3d": "mix($in1($uv), $in2($uv), clamp($shape($uv.xyz)/max($d, 0.0001), 0.0, 1.0))",
|
||||
# "type": "tex3d"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0.5,
|
||||
# "label": "Smoothness",
|
||||
# "longdesc": "The width of the transition area between both textures",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "d",
|
||||
# "shortdesc": "Smoothness",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tex3d_apply.mmg
|
||||
|
||||
#----------------------
|
||||
#tex3d_apply.mmg
|
||||
|
||||
#----------------------
|
||||
#tex3d_apply.mmg
|
||||
|
||||
#----------------------
|
||||
#tex3d_apply.mmg
|
||||
|
||||
#vec3 blend3d_normal(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*c1 + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_multiply(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*c1*c2 + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_screen(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*(1.0-(1.0-c1)*(1.0-c2)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#float blend3d_overlay_f(float c1, float c2) {\n\t
|
||||
# return (c1 < 0.5) ? (2.0*c1*c2) : (1.0-2.0*(1.0-c1)*(1.0-c2));\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_overlay(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*vec3(blend3d_overlay_f(c1.x, c2.x), blend3d_overlay_f(c1.y, c2.y), blend3d_overlay_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_hard_light(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*0.5*(c1*c2+blend3d_overlay(c1, c2, 1.0)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#float blend3d_soft_light_f(float c1, float c2) {\n\t
|
||||
# return (c2 < 0.5) ? (2.0*c1*c2+c1*c1*(1.0-2.0*c2)) : 2.0*c1*(1.0-c2)+sqrt(c1)*(2.0*c2-1.0);\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_soft_light(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*vec3(blend3d_soft_light_f(c1.x, c2.x), blend3d_soft_light_f(c1.y, c2.y), blend3d_soft_light_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#float blend3d_burn_f(float c1, float c2) {\n\t
|
||||
# return (c1==0.0)?c1:max((1.0-((1.0-c2)/c1)),0.0);\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_burn(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*vec3(blend3d_burn_f(c1.x, c2.x), blend3d_burn_f(c1.y, c2.y), blend3d_burn_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#float blend3d_dodge_f(float c1, float c2) {\n\t
|
||||
# return (c1==1.0)?c1:min(c2/(1.0-c1),1.0);\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_dodge(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*vec3(blend3d_dodge_f(c1.x, c2.x), blend3d_dodge_f(c1.y, c2.y), blend3d_dodge_f(c1.z, c2.z)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_lighten(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*max(c1, c2) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#vec3 blend3d_darken(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*min(c1, c2) + (1.0-opacity)*c2;
|
||||
#}
|
||||
|
||||
#vec3 blend3d_difference(vec3 c1, vec3 c2, float opacity) {\n\t
|
||||
# return opacity*clamp(c2-c1, vec3(0.0), vec3(1.0)) + (1.0-opacity)*c2;\n
|
||||
#}
|
||||
|
||||
#float rand31(vec3 p) {\n\t
|
||||
# return fract(sin(dot(p,vec3(127.1,311.7, 74.7)))*43758.5453123);\n
|
||||
#}
|
||||
|
||||
#vec3 rand33(vec3 p) {\n\t
|
||||
# p = vec3( dot(p,vec3(127.1,311.7, 74.7)),
|
||||
# dot(p,vec3(269.5,183.3,246.1)),\n\t\t\t
|
||||
# dot(p,vec3(113.5,271.9,124.6)));\n\n\t
|
||||
#
|
||||
# return -1.0 + 2.0*fract(sin(p)*43758.5453123);
|
||||
#}
|
||||
|
||||
#float tex3d_fbm_value(vec3 coord, vec3 size, float seed) {\n\t
|
||||
# vec3 o = floor(coord)+rand3(vec2(seed, 1.0-seed))+size;\n\t
|
||||
# vec3 f = fract(coord);\n\t
|
||||
# float p000 = rand31(mod(o, size));\n\t
|
||||
# float p001 = rand31(mod(o + vec3(0.0, 0.0, 1.0), size));\n\t
|
||||
# float p010 = rand31(mod(o + vec3(0.0, 1.0, 0.0), size));\n\t
|
||||
# float p011 = rand31(mod(o + vec3(0.0, 1.0, 1.0), size));\n\t
|
||||
# float p100 = rand31(mod(o + vec3(1.0, 0.0, 0.0), size));\n\t
|
||||
# float p101 = rand31(mod(o + vec3(1.0, 0.0, 1.0), size));\n\t
|
||||
# float p110 = rand31(mod(o + vec3(1.0, 1.0, 0.0), size));\n\t
|
||||
# float p111 = rand31(mod(o + vec3(1.0, 1.0, 1.0), size));\n\t
|
||||
#
|
||||
# vec3 t = f * f * (3.0 - 2.0 * f);\n\t
|
||||
#
|
||||
# return mix(mix(mix(p000, p100, t.x), mix(p010, p110, t.x), t.y), mix(mix(p001, p101, t.x), mix(p011, p111, t.x), t.y), t.z);\n
|
||||
#}
|
||||
|
||||
#float tex3d_fbm_perlin(vec3 coord, vec3 size, float seed) {\n\t
|
||||
# vec3 o = floor(coord)+rand3(vec2(seed, 1.0-seed))+size;\n\t
|
||||
# vec3 f = fract(coord);\n\t
|
||||
# vec3 v000 = normalize(rand33(mod(o, size))-vec3(0.5));\n\t
|
||||
# vec3 v001 = normalize(rand33(mod(o + vec3(0.0, 0.0, 1.0), size))-vec3(0.5));\n\t
|
||||
# vec3 v010 = normalize(rand33(mod(o + vec3(0.0, 1.0, 0.0), size))-vec3(0.5));\n\t
|
||||
# vec3 v011 = normalize(rand33(mod(o + vec3(0.0, 1.0, 1.0), size))-vec3(0.5));\n\t
|
||||
# vec3 v100 = normalize(rand33(mod(o + vec3(1.0, 0.0, 0.0), size))-vec3(0.5));\n\t
|
||||
# vec3 v101 = normalize(rand33(mod(o + vec3(1.0, 0.0, 1.0), size))-vec3(0.5));\n\t
|
||||
# vec3 v110 = normalize(rand33(mod(o + vec3(1.0, 1.0, 0.0), size))-vec3(0.5));\n\t
|
||||
# vec3 v111 = normalize(rand33(mod(o + vec3(1.0, 1.0, 1.0), size))-vec3(0.5));\n\t
|
||||
#
|
||||
# float p000 = dot(v000, f);\n\tfloat p001 = dot(v001, f - vec3(0.0, 0.0, 1.0));\n\t
|
||||
# float p010 = dot(v010, f - vec3(0.0, 1.0, 0.0));\n\t
|
||||
# float p011 = dot(v011, f - vec3(0.0, 1.0, 1.0));\n\t
|
||||
# float p100 = dot(v100, f - vec3(1.0, 0.0, 0.0));\n\t
|
||||
# float p101 = dot(v101, f - vec3(1.0, 0.0, 1.0));\n\t
|
||||
# float p110 = dot(v110, f - vec3(1.0, 1.0, 0.0));\n\t
|
||||
# float p111 = dot(v111, f - vec3(1.0, 1.0, 1.0));\n\t
|
||||
#
|
||||
# vec3 t = f * f * (3.0 - 2.0 * f);\n\t
|
||||
#
|
||||
# return 0.5 + mix(mix(mix(p000, p100, t.x), mix(p010, p110, t.x), t.y), mix(mix(p001, p101, t.x), mix(p011, p111, t.x), t.y), t.z);
|
||||
#}
|
||||
|
||||
#float tex3d_fbm_cellular(vec3 coord, vec3 size, float seed) {\n\t
|
||||
# vec3 o = floor(coord)+rand3(vec2(seed, 1.0-seed))+size;\n\t
|
||||
# vec3 f = fract(coord);\n\tfloat min_dist = 3.0;\n\t
|
||||
#
|
||||
# for (float x = -1.0; x <= 1.0; x++) {\n\t\t
|
||||
# for (float y = -1.0; y <= 1.0; y++) {\n\t\t\t
|
||||
# for (float z = -1.0; z <= 1.0; z++) {\n\t\t\t\t
|
||||
# vec3 node = 0.4*rand33(mod(o + vec3(x, y, z), size)) + vec3(x, y, z);\n\t\t\t\t
|
||||
# float dist = sqrt((f - node).x * (f - node).x + (f - node).y * (f - node).y + (f - node).z * (f - node).z);\n\t\t\t\t
|
||||
# min_dist = min(min_dist, dist);\n\t\t\t
|
||||
# }\n\t\t
|
||||
#
|
||||
# }\n\t
|
||||
#
|
||||
# }\n\t
|
||||
#
|
||||
# return min_dist;
|
||||
#}
|
||||
|
||||
|
||||
#float wave3d_constant(float x) {\n\t
|
||||
# return 1.0;\n
|
||||
#}
|
||||
|
||||
#float wave3d_sine(float x) {\n\t
|
||||
# return 0.5-0.5*cos(3.14159265359*2.0*x);\n
|
||||
#}
|
||||
|
||||
#float wave3d_triangle(float x) {\n\t
|
||||
# x = fract(x);\n\t
|
||||
# return min(2.0*x, 2.0-2.0*x);\n
|
||||
#}
|
||||
|
||||
#float wave3d_sawtooth(float x) {\n\t
|
||||
# return fract(x);\n
|
||||
#}
|
||||
|
||||
#float wave3d_square(float x) {\n\t
|
||||
# return (fract(x) < 0.5) ? 0.0 : 1.0;\n
|
||||
#}
|
||||
|
||||
#float wave3d_bounce(float x) {\n\t
|
||||
# x = 2.0*(fract(x)-0.5);\n\t
|
||||
# return sqrt(1.0-x*x);\n
|
||||
#}
|
||||
|
||||
#float mix3d_mul(float x, float y, float z) {\n\t
|
||||
# return x*y*z;\n
|
||||
#}
|
||||
|
||||
#float mix3d_add(float x, float y, float z) {\n\t
|
||||
# return min(x+y+z, 1.0);\n
|
||||
#}
|
||||
|
||||
#float mix3d_max(float x, float y, float z) {\n\t
|
||||
# return max(max(x, y), z);\n
|
||||
#}
|
||||
|
||||
#float mix3d_min(float x, float y, float z) {\n\t
|
||||
# return min(min(x, y), z);\n
|
||||
#}
|
||||
|
||||
#float mix3d_xor(float x, float y, float z) {\n\t
|
||||
# float xy = min(x+y, 2.0-x-y);\n\t
|
||||
# return min(xy+z, 2.0-xy-z);\n
|
||||
#}
|
||||
|
||||
#float mix3d_pow(float x, float y, float z) {\n\t
|
||||
# return pow(pow(x, y), z);\n
|
||||
#}
|
||||
|
||||
#vec3 tex3d_rotate(vec3 p, vec3 a) {\n\t
|
||||
# vec3 rv;\n\t
|
||||
# float c;\n\t
|
||||
# float s;\n\t
|
||||
# c = cos(a.x);\n\t
|
||||
# s = sin(a.x);\n\t
|
||||
# rv.x = p.x;\n\t
|
||||
# rv.y = p.y*c+p.z*s;\n\t
|
||||
# rv.z = -p.y*s+p.z*c;\n\t
|
||||
# c = cos(a.y);\n\t
|
||||
# s = sin(a.y);\n\t
|
||||
# p.x = rv.x*c+rv.z*s;\n\t
|
||||
# p.y = rv.y;\n\t
|
||||
# p.z = -rv.x*s+rv.z*c;\n\t
|
||||
# c = cos(a.z);\n\t
|
||||
# s = sin(a.z);\n\t
|
||||
# rv.x = p.x*c+p.y*s;\n\t
|
||||
# rv.y = -p.x*s+p.y*c;\n\t
|
||||
# rv.z = p.z;\n\t
|
||||
# return rv;\n
|
||||
#}
|
||||
|
707
addons/mat_maker_gd/nodes/common/tile.gd
Normal file
707
addons/mat_maker_gd/nodes/common/tile.gd
Normal file
@ -0,0 +1,707 @@
|
||||
tool
|
||||
extends Reference
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
|
||||
#----------------------
|
||||
#tile2x2.mmg
|
||||
#Places 4 input images into a single output to create an atlas of 4 images.
|
||||
#Chaining Tile2x2 nodes can be useful to create 16 images atlases.
|
||||
#Atlases are used by remapping nodes such as CustomUV, Tiler and Splatter.
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The first input",
|
||||
# "name": "in1",
|
||||
# "shortdesc": "Input1",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The second input",
|
||||
# "name": "in2",
|
||||
# "shortdesc": "Input2",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The third input",
|
||||
# "name": "in3",
|
||||
# "shortdesc": "Input3",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "label": "",
|
||||
# "longdesc": "The fourth input",
|
||||
# "name": "in4",
|
||||
# "shortdesc": "Input4",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "Shows the generated atlas",
|
||||
# "rgba": "($uv.y < 0.5) ? (($uv.x < 0.5) ? ($in1(2.0*$uv)) : ($in2(2.0*$uv-vec2(1.0, 0.0)))) : (($uv.x < 0.5) ? ($in3(2.0*$uv-vec2(0.0, 1.0))) : ($in4(2.0*$uv-vec2(1.0, 1.0))))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tile2x2_variations.mmg
|
||||
#Places 4 input images into a single output to create an atlas of 4 images.
|
||||
#Chaining Tile2x2 nodes can be useful to create 16 images atlases.
|
||||
#Atlases are used by remapping nodes such as CustomUV, Tiler and Splatter.
|
||||
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(0.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The first input",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input1",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "Shows the generated atlas",
|
||||
# "rgba": "($uv.y < 0.5) ? (($uv.x < 0.5) ? ($in.variation(2.0*$uv, $seed)) : ($in.variation(2.0*$uv-vec2(1.0, 0.0), $seed+0.1))) : (($uv.x < 0.5) ? ($in.variation(2.0*$uv-vec2(0.0, 1.0), $seed+0.2)) : ($in.variation(2.0*$uv-vec2(1.0, 1.0), $seed+0.3)))",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tiler.mmg
|
||||
#Tiles several occurences of an input image while adding randomness.
|
||||
|
||||
#vec4 $(name_uv)_rch = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), vec2(float($seed)));
|
||||
|
||||
#instance
|
||||
#vec4 tiler_$(name)(vec2 uv, vec2 tile, int overlap, vec2 _seed) {\n\t
|
||||
# float c = 0.0;\n\t
|
||||
# vec3 rc = vec3(0.0);\n\t
|
||||
# vec3 rc1;\n\t
|
||||
# for (int dx = -overlap; dx <= overlap; ++dx) {\n\t\t
|
||||
# for (int dy = -overlap; dy <= overlap; ++dy) {\n\t\t\t
|
||||
# vec2 pos = fract((floor(uv*tile)+vec2(float(dx), float(dy))+vec2(0.5))/tile-vec2(0.5));\n\t\t\t
|
||||
# vec2 seed = rand2(pos+_seed);\n\t\t\t
|
||||
# rc1 = rand3(seed);\n\t\t\t
|
||||
# pos = fract(pos+vec2($fixed_offset/tile.x, 0.0)*floor(mod(pos.y*tile.y, 2.0))+$offset*seed/tile);\n\t\t\t
|
||||
# float mask = $mask(fract(pos+vec2(0.5)));\n\t\t\t
|
||||
#
|
||||
# if (mask > 0.01) {\n\t\t\t\t
|
||||
# vec2 pv = fract(uv - pos)-vec2(0.5);\n\t\t\t\t
|
||||
# seed = rand2(seed);\n\t\t\t\t
|
||||
# float angle = (seed.x * 2.0 - 1.0) * $rotate * 0.01745329251;\n\t\t\t\t
|
||||
# float ca = cos(angle);\n\t\t\t\t
|
||||
# float sa = sin(angle);\n\t\t\t\t
|
||||
# pv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\t\t
|
||||
# pv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\t\t
|
||||
# pv /= vec2($scale_x, $scale_y);\n\t\t\t\t
|
||||
# pv += vec2(0.5);\n\t\t\t\t
|
||||
# seed = rand2(seed);\n\t\t\t\t
|
||||
# vec2 clamped_pv = clamp(pv, vec2(0.0), vec2(1.0));\n\t\t\t\t
|
||||
# if (pv.x != clamped_pv.x || pv.y != clamped_pv.y) {\n\t\t\t\t\t
|
||||
# continue;\n\t\t\t\t
|
||||
# }\n\t\t\t\t
|
||||
#
|
||||
# $select_inputs\n\t\t\t\t
|
||||
#
|
||||
# float c1 = $in.variation(pv, $variations ? seed.x : 0.0)*mask*(1.0-$value*seed.x);\n\t\t\t\t
|
||||
# c = max(c, c1);\n\t\t\t\t
|
||||
# rc = mix(rc, rc1, step(c, c1));\n\t\t\t
|
||||
# }\n\t\t
|
||||
# }\n\t
|
||||
# }\n\t
|
||||
#
|
||||
# return vec4(rc, c);\n
|
||||
#}
|
||||
|
||||
#Inputs:
|
||||
|
||||
#in, float, default: 0, - The input image or atlas of 4 or 16 input images
|
||||
#Mask, float, default: 1, - The mask applied to the pattern
|
||||
|
||||
#Outputs:
|
||||
#Output, float, Shows the generated pattern
|
||||
#$(name_uv)_rch.a
|
||||
|
||||
#Instance map, rgb, Shows a random color for each instance of the input image
|
||||
#$(name_uv)_rch.rgb
|
||||
|
||||
#select_inputs enum
|
||||
#1, " "
|
||||
#4, "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));"
|
||||
#16, "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));"
|
||||
|
||||
#Parameters:
|
||||
#tile, Vector2, default 4, min:1, max:64, step:1 - The number of columns of the tiles pattern
|
||||
#overlap, float, default 1, min 0, max 5, step 1 - The number of neighbour tiles an instance of the input image can overlap. Set this parameter to the lowest value that generates the expected result (where all instances are fully visible) to improve performance.
|
||||
#select_inputs (Inputs), enum, default 0, values 1, 4, 16
|
||||
#scale, Vector2, default 1, min:0, max:2, step:0.01 - "The scale of input images on the X axis
|
||||
#fixed_offset, float, default 0.5, min 0, max 1, step 0.01 - The relative offset of odd rows
|
||||
#offset (rnd_offset), float, default 0.5, min 0, max 1, step 0.01
|
||||
#rotate (rnd_rotate), float, default 0, min 0, max 180, step 0.1
|
||||
#scale (rnd_scale), float, default 0.5, min 0, max 1, step 0.01 - The random scale applied to each image instance
|
||||
#value (rnd_value), float, default 0.5, min 0, max 1, step 0.01 - The random greyscale value applied to each image instance
|
||||
#variations, bool, default false, (disabled) - Check to tile variations of the input
|
||||
|
||||
#----------------------
|
||||
#tiler_advanced.mmg
|
||||
#Tiles several occurences of an input image while adding randomness.
|
||||
|
||||
# "code": "vec4 $(name_uv)_rch = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), float($seed));",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "0.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The input image or atlas of 4 or 16 input images",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The mask applied to the pattern",
|
||||
# "name": "mask",
|
||||
# "shortdesc": "Mask",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(rand2($uv+vec2(float($seed))), rand2($uv-vec2(float($seed))))",
|
||||
# "label": "",
|
||||
# "longdesc": "An input color map used to generate the Instance map 1 output",
|
||||
# "name": "color1",
|
||||
# "shortdesc": "Color map 1",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(rand2(-$uv+vec2(float($seed))), rand2(-$uv-vec2(float($seed))))",
|
||||
# "label": "",
|
||||
# "longdesc": "An input color map used to generate the Instance map 2 output",
|
||||
# "name": "color2",
|
||||
# "shortdesc": "Color map 2",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "5:",
|
||||
# "longdesc": "A map for translation along the X axis",
|
||||
# "name": "tr_x",
|
||||
# "shortdesc": "Translate map X",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for translation along the Y axis",
|
||||
# "name": "tr_y",
|
||||
# "shortdesc": "Translate map Y",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for rotation",
|
||||
# "name": "r",
|
||||
# "shortdesc": "Rotate map",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for scale along the X axis",
|
||||
# "name": "sc_x",
|
||||
# "shortdesc": "Scale map X",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for scale along the Y axis",
|
||||
# "name": "sc_y",
|
||||
# "shortdesc": "Scale map Y",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "vec4 tiler_$(name)(vec2 uv, vec2 tile, int overlap, float _seed) {\n\tfloat c = 0.0;\n\tvec2 map_uv = vec2(0.0);\n\tfor (int dx = -overlap; dx <= overlap; ++dx) {\n\t\tfor (int dy = -overlap; dy <= overlap; ++dy) {\n\t\t\tvec2 pos = fract((floor(uv*tile)+vec2(float(dx), float(dy))+vec2(0.5))/tile-vec2(0.5));\n\t\t\tfloat mask = $mask(fract(pos+vec2(0.5)));\n\t\t\tif (mask > 0.01) {\n\t\t\t\tvec2 pv = fract(uv - pos)-vec2(0.5);\n\t\t\t\tpos = fract(pos+vec2(0.5));\n\t\t\t\tpv -= vec2($translate_x*$tr_x(pos), $translate_y*$tr_y(pos))/tile;\n\t\t\t\tfloat angle = $r(pos) * $rotate * 0.01745329251;\n\t\t\t\tfloat ca = cos(angle);\n\t\t\t\tfloat sa = sin(angle);\n\t\t\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\t\tpv /= vec2($scale_x*$sc_x(pos), $scale_y*$sc_y(pos));\n\t\t\t\tpv += vec2(0.5);\n\t\t\t\tif (pv != clamp(pv, vec2(0.0), vec2(1.0))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tvec2 seed = rand2(vec2(_seed)+pos);\n\t\t\t\t$select_inputs\n\t\t\t\tfloat c1 = $in.variation(pv, $variations ? seed.x : 0.0)*mask;\n\t\t\t\tc = max(c, c1);\n\t\t\t\tmap_uv = mix(map_uv, pos, step(c, c1));\n\t\t\t}\n\t\t}\n\t}\n\treturn vec4(map_uv, 0.0, c);\n}",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "f": "$(name_uv)_rch.a",
|
||||
# "longdesc": "Shows the generated pattern",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows a color for each instance of the input image",
|
||||
# "rgba": "$color1($(name_uv)_rch.rg)",
|
||||
# "shortdesc": "Instance map 1",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows a color for each instance of the input image",
|
||||
# "rgba": "$color2($(name_uv)_rch.rg)",
|
||||
# "shortdesc": "Instance map 2",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Tile X",
|
||||
# "longdesc": "The number of columns of the tiles pattern",
|
||||
# "max": 64,
|
||||
# "min": 1,
|
||||
# "name": "tx",
|
||||
# "shortdesc": "Tile.x",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Tile Y",
|
||||
# "longdesc": "The number of rows of the tiles pattern",
|
||||
# "max": 64,
|
||||
# "min": 1,
|
||||
# "name": "ty",
|
||||
# "shortdesc": "Tile.y",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Overlap",
|
||||
# "longdesc": "The number of neighbour tiles an instance of the input image can overlap. Set this parameter to the lowest value that generates the expected result (where all instances are fully visible) to improve performance.",
|
||||
# "max": 5,
|
||||
# "min": 0,
|
||||
# "name": "overlap",
|
||||
# "shortdesc": "Overlap",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "Inputs",
|
||||
# "longdesc": "The input type of the node:\n- 1: single image\n- 4: atlas of 4 images\n- 16: atlas of 16 images\nAtlases can be created using the Tile2x2 node.",
|
||||
# "name": "select_inputs",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "1",
|
||||
# "value": " "
|
||||
# },
|
||||
# {
|
||||
# "name": "4",
|
||||
# "value": "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));"
|
||||
# },
|
||||
# {
|
||||
# "name": "16",
|
||||
# "value": "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Translate X",
|
||||
# "longdesc": "The translation along the X axis applied to the instances",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "translate_x",
|
||||
# "shortdesc": "Translate.x",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Translate Y",
|
||||
# "longdesc": "The translation along the Y axis applied to the instances",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "translate_y",
|
||||
# "shortdesc": "Translate.y",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Rotate",
|
||||
# "longdesc": "The angle of instances of the input",
|
||||
# "max": 180,
|
||||
# "min": 0,
|
||||
# "name": "rotate",
|
||||
# "shortdesc": "Rotate",
|
||||
# "step": 0.1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Scale X",
|
||||
# "longdesc": "The scale of input images on the X axis",
|
||||
# "max": 2,
|
||||
# "min": 0,
|
||||
# "name": "scale_x",
|
||||
# "shortdesc": "Scale.x",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Scale Y",
|
||||
# "longdesc": "The scale of input images on the Y axis",
|
||||
# "max": 2,
|
||||
# "min": 0,
|
||||
# "name": "scale_y",
|
||||
# "shortdesc": "Scale.y",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": false,
|
||||
# "label": "Variations",
|
||||
# "longdesc": "Check to tile variations of the input",
|
||||
# "name": "variations",
|
||||
# "shortdesc": "Variations",
|
||||
# "type": "boolean"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tiler_advanced_color.mmg
|
||||
#Tiles several occurences of an input image while adding randomness.
|
||||
|
||||
# "code": "vec2 $(name_uv)_mapuv;\nvec4 $(name_uv)_rch = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), float($seed), $(name_uv)_mapuv);",
|
||||
# "inputs": [
|
||||
# {
|
||||
# "default": "vec4(1.0)",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The input image or atlas of 4 or 16 input images",
|
||||
# "name": "in",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "The mask applied to the pattern",
|
||||
# "name": "mask",
|
||||
# "shortdesc": "Mask",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(rand2($uv+vec2(float($seed))), rand2($uv-vec2(float($seed))))",
|
||||
# "label": "",
|
||||
# "longdesc": "An input color map used to generate the Instance map 1 output",
|
||||
# "name": "color1",
|
||||
# "shortdesc": "Color map 1",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "vec4(rand2(-$uv+vec2(float($seed))), rand2(-$uv-vec2(float($seed))))",
|
||||
# "label": "",
|
||||
# "longdesc": "An input color map used to generate the Instance map 2 output",
|
||||
# "name": "color2",
|
||||
# "shortdesc": "Color map 2",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "5:",
|
||||
# "longdesc": "A map for translation along the X axis",
|
||||
# "name": "tr_x",
|
||||
# "shortdesc": "Translate map X",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for translation along the Y axis",
|
||||
# "name": "tr_y",
|
||||
# "shortdesc": "Translate map Y",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for rotation",
|
||||
# "name": "r",
|
||||
# "shortdesc": "Rotate map",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for scale along the X axis",
|
||||
# "name": "sc_x",
|
||||
# "shortdesc": "Scale map X",
|
||||
# "type": "f"
|
||||
# },
|
||||
# {
|
||||
# "default": "1.0",
|
||||
# "function": true,
|
||||
# "label": "",
|
||||
# "longdesc": "A map for scale along the Y axis",
|
||||
# "name": "sc_y",
|
||||
# "shortdesc": "Scale map Y",
|
||||
# "type": "f"
|
||||
# }
|
||||
# ],
|
||||
# "instance": "vec4 tiler_$(name)(vec2 uv, vec2 tile, int overlap, float _seed, out vec2 outmapuv) {\n\t// $seed\n\tvec4 c = vec4(0.0);\n\toutmapuv = vec2(0.0);\n\tfor (int dx = -overlap; dx <= overlap; ++dx) {\n\t\tfor (int dy = -overlap; dy <= overlap; ++dy) {\n\t\t\tvec2 pos = fract((floor(uv*tile)+vec2(float(dx), float(dy))+vec2(0.5))/tile-vec2(0.5));\n\t\t\tfloat mask = $mask(fract(pos+vec2(0.5)));\n\t\t\tif (mask > 0.01) {\n\t\t\t\tvec2 pv = fract(uv - pos)-vec2(0.5);\n\t\t\t\tpos = fract(pos+vec2(0.5));\n\t\t\t\tpv -= vec2($translate_x*$tr_x(pos), $translate_y*$tr_y(pos))/tile;\n\t\t\t\tfloat angle = $r(pos) * $rotate * 0.01745329251;\n\t\t\t\tfloat ca = cos(angle);\n\t\t\t\tfloat sa = sin(angle);\n\t\t\t\tpv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\t\tpv /= vec2($scale_x*$sc_x(pos), $scale_y*$sc_y(pos));\n\t\t\t\tpv += vec2(0.5);\n\t\t\t\tif (pv != clamp(pv, vec2(0.0), vec2(1.0))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tvec2 seed = rand2(vec2(_seed)+pos);\n\t\t\t\t$select_inputs\n\t\t\t\tvec4 n = $in.variation(pv, $variations ? seed.x : 0.0);\n\t\t\t\tfloat na = n.a*mask;\n\t\t\t\toutmapuv = mix(outmapuv, pos, step(c.a, na));\n\t\t\t\tc = mix(c, n, na);\n\t\t\t}\n\t\t}\n\t}\n\treturn c;\n}\n",
|
||||
# "outputs": [
|
||||
# {
|
||||
# "longdesc": "Shows the generated pattern",
|
||||
# "rgba": "$(name_uv)_rch",
|
||||
# "shortdesc": "Output",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows a color for each instance of the input image",
|
||||
# "rgba": "$color1($(name_uv)_mapuv)",
|
||||
# "shortdesc": "Instance map 1",
|
||||
# "type": "rgba"
|
||||
# },
|
||||
# {
|
||||
# "longdesc": "Shows a color for each instance of the input image",
|
||||
# "rgba": "$color2($(name_uv)_mapuv)",
|
||||
# "shortdesc": "Instance map 2",
|
||||
# "type": "rgba"
|
||||
# }
|
||||
# ],
|
||||
# "parameters": [
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Tile X",
|
||||
# "longdesc": "The number of columns of the tiles pattern",
|
||||
# "max": 64,
|
||||
# "min": 1,
|
||||
# "name": "tx",
|
||||
# "shortdesc": "Tile.x",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 4,
|
||||
# "label": "Tile Y",
|
||||
# "longdesc": "The number of rows of the tiles pattern",
|
||||
# "max": 64,
|
||||
# "min": 1,
|
||||
# "name": "ty",
|
||||
# "shortdesc": "Tile.y",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Overlap",
|
||||
# "longdesc": "The number of neighbour tiles an instance of the input image can overlap. Set this parameter to the lowest value that generates the expected result (where all instances are fully visible) to improve performance.",
|
||||
# "max": 5,
|
||||
# "min": 0,
|
||||
# "name": "overlap",
|
||||
# "shortdesc": "Overlap",
|
||||
# "step": 1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": 0,
|
||||
# "label": "Inputs",
|
||||
# "longdesc": "The input type of the node:\n- 1: single image\n- 4: atlas of 4 images\n- 16: atlas of 16 images\nAtlases can be created using the Tile2x2 node.",
|
||||
# "name": "select_inputs",
|
||||
# "shortdesc": "Input",
|
||||
# "type": "enum",
|
||||
# "values": [
|
||||
# {
|
||||
# "name": "1",
|
||||
# "value": " "
|
||||
# },
|
||||
# {
|
||||
# "name": "4",
|
||||
# "value": "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));"
|
||||
# },
|
||||
# {
|
||||
# "name": "16",
|
||||
# "value": "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));"
|
||||
# }
|
||||
# ]
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Translate X",
|
||||
# "longdesc": "The translation along the X axis applied to the instances",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "translate_x",
|
||||
# "shortdesc": "Translate.x",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Translate Y",
|
||||
# "longdesc": "The translation along the Y axis applied to the instances",
|
||||
# "max": 1,
|
||||
# "min": 0,
|
||||
# "name": "translate_y",
|
||||
# "shortdesc": "Translate.y",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 0,
|
||||
# "label": "Rotate",
|
||||
# "longdesc": "The angle of instances of the input",
|
||||
# "max": 180,
|
||||
# "min": 0,
|
||||
# "name": "rotate",
|
||||
# "shortdesc": "Rotate",
|
||||
# "step": 0.1,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Scale X",
|
||||
# "longdesc": "The scale of input images on the X axis",
|
||||
# "max": 2,
|
||||
# "min": 0,
|
||||
# "name": "scale_x",
|
||||
# "shortdesc": "Scale.x",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "control": "None",
|
||||
# "default": 1,
|
||||
# "label": "Scale Y",
|
||||
# "longdesc": "The scale of input images on the Y axis",
|
||||
# "max": 2,
|
||||
# "min": 0,
|
||||
# "name": "scale_y",
|
||||
# "shortdesc": "Scale.y",
|
||||
# "step": 0.01,
|
||||
# "type": "float"
|
||||
# },
|
||||
# {
|
||||
# "default": false,
|
||||
# "label": "Variations",
|
||||
# "longdesc": "Check to tile variations of the input",
|
||||
# "name": "variations",
|
||||
# "shortdesc": "Variations",
|
||||
# "type": "boolean"
|
||||
# }
|
||||
# ],
|
||||
|
||||
#----------------------
|
||||
#tiler_color.mmg
|
||||
#Tiles several occurences of an input image while adding randomness.
|
||||
|
||||
#vec3 $(name_uv)_random_color;\n
|
||||
#vec4 $(name_uv)_tiled_output = tiler_$(name)($uv, vec2($tx, $ty), int($overlap), vec2(float($seed)), $(name_uv)_random_color);
|
||||
|
||||
#vec4 tiler_$(name)(vec2 uv, vec2 tile, int overlap, vec2 _seed, out vec3 random_color) {\n\t
|
||||
# vec4 c = vec4(0.0);\n\t
|
||||
# vec3 rc = vec3(0.0);\n\t
|
||||
# vec3 rc1;\n\t
|
||||
#
|
||||
# for (int dx = -overlap; dx <= overlap; ++dx) {\n\t\t
|
||||
# for (int dy = -overlap; dy <= overlap; ++dy) {\n\t\t\t
|
||||
# vec2 pos = fract((floor(uv*tile)+vec2(float(dx), float(dy))+vec2(0.5))/tile-vec2(0.5));\n\t\t\t
|
||||
# vec2 seed = rand2(pos+_seed);\n\t\t\t
|
||||
# rc1 = rand3(seed);\n\t\t\t
|
||||
# pos = fract(pos+vec2($fixed_offset/tile.x, 0.0)*floor(mod(pos.y*tile.y, 2.0))+$offset*seed/tile);\n\t\t\t
|
||||
# float mask = $mask(fract(pos+vec2(0.5)));\n\t\t\t
|
||||
# if (mask > 0.01) {\n\t\t\t\t
|
||||
# vec2 pv = fract(uv - pos)-vec2(0.5);\n\t\t\t\t
|
||||
# seed = rand2(seed);\n\t\t\t\t
|
||||
# float angle = (seed.x * 2.0 - 1.0) * $rotate * 0.01745329251;\n\t\t\t\t
|
||||
# float ca = cos(angle);\n\t\t\t\t
|
||||
# float sa = sin(angle);\n\t\t\t\t
|
||||
# pv = vec2(ca*pv.x+sa*pv.y, -sa*pv.x+ca*pv.y);\n\t\t\t\t
|
||||
# pv *= (seed.y-0.5)*2.0*$scale+1.0;\n\t\t\t\t
|
||||
# pv /= vec2($scale_x, $scale_y);\n\t\t\t\t
|
||||
# pv += vec2(0.5);\n\t\t\t\t
|
||||
# pv = clamp(pv, vec2(0.0), vec2(1.0));\n\t\t\t\t
|
||||
#
|
||||
# $select_inputs\n\t\t\t\t
|
||||
#
|
||||
# vec4 n = $in.variation(pv, $variations ? seed.x : 0.0);\n\t\t\t\t
|
||||
#
|
||||
# seed = rand2(seed);\n\t\t\t\t
|
||||
# float na = n.a*mask*(1.0-$opacity*seed.x);\n\t\t\t\t
|
||||
# float a = (1.0-c.a)*(1.0*na);\n\t\t\t\t
|
||||
#
|
||||
# c = mix(c, n, na);\n\t\t\t\t
|
||||
# rc = mix(rc, rc1, n.a);\n\t\t\t
|
||||
# }\n\t\t
|
||||
# }\n\t
|
||||
# }\n\t
|
||||
#
|
||||
# random_color = rc;\n\t
|
||||
# return c;\n
|
||||
#}
|
||||
|
||||
|
||||
#Inputs:
|
||||
|
||||
#in, rgba, default: 0, - The input image or atlas of 4 or 16 input images
|
||||
#Mask, float, default: 1, - The mask applied to the pattern
|
||||
|
||||
#Outputs:
|
||||
#Output, float, Shows the generated pattern
|
||||
#$(name_uv)_tiled_output
|
||||
|
||||
#Instance map, rgb, Shows a random color for each instance of the input image
|
||||
#$(name_uv)_random_color
|
||||
|
||||
#select_inputs enum
|
||||
#1, " "
|
||||
#4, "pv = clamp(0.5*(pv+floor(rand2(seed)*2.0)), vec2(0.0), vec2(1.0));"
|
||||
#16, "pv = clamp(0.25*(pv+floor(rand2(seed)*4.0)), vec2(0.0), vec2(1.0));"
|
||||
|
||||
#Parameters:
|
||||
#tile, Vector2, default 4, min:1, max:64, step:1 - The number of columns of the tiles pattern
|
||||
#overlap, float, default 1, min 0, max 5, step 1 - The number of neighbour tiles an instance of the input image can overlap. Set this parameter to the lowest value that generates the expected result (where all instances are fully visible) to improve performance.
|
||||
#select_inputs (Inputs), enum, default 0, values 1, 4, 16
|
||||
#scale, Vector2, default 1, min:0, max:2, step:0.01 - "The scale of input images on the X axis
|
||||
#fixed_offset, float, default 0.5, min 0, max 1, step 0.01 - The relative offset of odd rows
|
||||
#offset (rnd_offset), float, default 0.5, min 0, max 1, step 0.01
|
||||
#rotate (rnd_rotate), float, default 0, min 0, max 180, step 0.1
|
||||
#scale (rnd_scale), float, default 0.5, min 0, max 1, step 0.01 - The random scale applied to each image instance
|
||||
#opacity (rnd_opacity), float, default 0, min 0, max 1, step 0.01 - The random greyscale value applied to each image instance
|
||||
#variations, bool, default false, (disabled) - Check to tile variations of the input
|
||||
|
1765
addons/mat_maker_gd/nodes/common/transforms.gd
Normal file
1765
addons/mat_maker_gd/nodes/common/transforms.gd
Normal file
File diff suppressed because it is too large
Load Diff
75
addons/mat_maker_gd/nodes/filter/adjust_hsv.gd
Normal file
75
addons/mat_maker_gd/nodes/filter/adjust_hsv.gd
Normal file
@ -0,0 +1,75 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 Filter.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)
|
125
addons/mat_maker_gd/nodes/filter/blend.gd
Normal file
125
addons/mat_maker_gd/nodes/filter/blend.gd
Normal file
@ -0,0 +1,125 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !input1:
|
||||
input1 = MMNodeUniversalProperty.new()
|
||||
input1.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input1.set_default_value(Color(1, 1, 1, 1))
|
||||
|
||||
input1.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input1.slot_name = ">>> Input1 "
|
||||
|
||||
if !input2:
|
||||
input2 = MMNodeUniversalProperty.new()
|
||||
input2.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input2.set_default_value(Color(1, 1, 1, 1))
|
||||
|
||||
input2.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input2.slot_name = ">>> Input2 "
|
||||
|
||||
if !opacity:
|
||||
opacity = MMNodeUniversalProperty.new()
|
||||
opacity.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.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.SlotTypes.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 = Filter.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 = Filter.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 = Filter.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 = Filter.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 = Filter.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 = Filter.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 = Filter.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 = Filter.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 = Filter.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 = Filter.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 = Filter.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 = Filter.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)
|
220
addons/mat_maker_gd/nodes/filter/blur_gaussian.gd
Normal file
220
addons/mat_maker_gd/nodes/filter/blur_gaussian.gd
Normal file
@ -0,0 +1,220 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color())
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !sigma:
|
||||
sigma = MMNodeUniversalProperty.new()
|
||||
sigma.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
sigma.set_default_value(50)
|
||||
|
||||
sigma.input_slot_type = MMNodeUniversalProperty.SlotTypes.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;
|
64
addons/mat_maker_gd/nodes/filter/brightness_contrast.gd
Normal file
64
addons/mat_maker_gd/nodes/filter/brightness_contrast.gd
Normal file
@ -0,0 +1,64 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 Filter.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)
|
55
addons/mat_maker_gd/nodes/filter/colorize.gd
Normal file
55
addons/mat_maker_gd/nodes/filter/colorize.gd
Normal file
@ -0,0 +1,55 @@
|
||||
tool
|
||||
extends "res://addons/mat_maker_gd/nodes/bases/gradient_base.gd"
|
||||
|
||||
var Gradients = preload("res://addons/mat_maker_gd/nodes/common/gradients.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
input.set_default_value(1)
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 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)
|
78
addons/mat_maker_gd/nodes/filter/combine.gd
Normal file
78
addons/mat_maker_gd/nodes/filter/combine.gd
Normal file
@ -0,0 +1,78 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
input_r.set_default_value(0)
|
||||
|
||||
input_r.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input_r.slot_name = ">>> R "
|
||||
|
||||
if !input_g:
|
||||
input_g = MMNodeUniversalProperty.new()
|
||||
input_g.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
input_g.set_default_value(0)
|
||||
|
||||
input_g.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input_g.slot_name = ">>> G "
|
||||
|
||||
if !input_b:
|
||||
input_b = MMNodeUniversalProperty.new()
|
||||
input_b.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
input_b.set_default_value(0)
|
||||
|
||||
input_b.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input_b.slot_name = ">>> B "
|
||||
|
||||
if !input_a:
|
||||
input_a = MMNodeUniversalProperty.new()
|
||||
input_a.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
input_a.set_default_value(1)
|
||||
|
||||
input_a.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input_a.slot_name = ">>> A "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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)
|
104
addons/mat_maker_gd/nodes/filter/decompose.gd
Normal file
104
addons/mat_maker_gd/nodes/filter/decompose.gd
Normal file
@ -0,0 +1,104 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var NoiseVoronoi = preload("res://addons/mat_maker_gd/nodes/common/noise_voronoi.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !out_r:
|
||||
out_r = MMNodeUniversalProperty.new()
|
||||
out_r.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_r.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_g:
|
||||
out_g = MMNodeUniversalProperty.new()
|
||||
out_g.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_g.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_b:
|
||||
out_b = MMNodeUniversalProperty.new()
|
||||
out_b.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_b.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_a:
|
||||
out_a = MMNodeUniversalProperty.new()
|
||||
out_a.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_a.output_slot_type = MMNodeUniversalProperty.SlotTypes.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()
|
112
addons/mat_maker_gd/nodes/filter/emboss.gd
Normal file
112
addons/mat_maker_gd/nodes/filter/emboss.gd
Normal file
@ -0,0 +1,112 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
input.set_default_value(1)
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.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
|
||||
|
72
addons/mat_maker_gd/nodes/filter/fill_channel.gd
Normal file
72
addons/mat_maker_gd/nodes/filter/fill_channel.gd
Normal file
@ -0,0 +1,72 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color())
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !value:
|
||||
value = MMNodeUniversalProperty.new()
|
||||
value.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
value.set_default_value(1)
|
||||
|
||||
value.input_slot_type = MMNodeUniversalProperty.SlotTypes.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)
|
70
addons/mat_maker_gd/nodes/filter/fill_to_color.gd
Normal file
70
addons/mat_maker_gd/nodes/filter/fill_to_color.gd
Normal file
@ -0,0 +1,70 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Fills = preload("res://addons/mat_maker_gd/nodes/common/fills.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !color_map:
|
||||
color_map = MMNodeUniversalProperty.new()
|
||||
color_map.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
color_map.set_default_value(Color(1, 1, 1, 1))
|
||||
|
||||
color_map.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
color_map.slot_name = ">>> Color Map "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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(Commons.fractv2(Vector2(c.r, c.g) + 0.5 * Vector2(c.b, c.a)))
|
||||
var s : float = Commons.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)
|
68
addons/mat_maker_gd/nodes/filter/fill_to_position.gd
Normal file
68
addons/mat_maker_gd/nodes/filter/fill_to_position.gd
Normal file
@ -0,0 +1,68 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Transforms = preload("res://addons/mat_maker_gd/nodes/common/transforms.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Commons.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)
|
61
addons/mat_maker_gd/nodes/filter/fill_to_random_color.gd
Normal file
61
addons/mat_maker_gd/nodes/filter/fill_to_random_color.gd
Normal file
@ -0,0 +1,61 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Fills = preload("res://addons/mat_maker_gd/nodes/common/fills.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Commons.rand(Vector2(c.r, c.g))
|
||||
var r2 : float = Commons.rand(Vector2(c.b, c.a))
|
||||
var s : float = Commons.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), Commons.rand3(Vector2(1.0 / float(pseed), Commons.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)
|
60
addons/mat_maker_gd/nodes/filter/fill_to_random_grey.gd
Normal file
60
addons/mat_maker_gd/nodes/filter/fill_to_random_grey.gd
Normal file
@ -0,0 +1,60 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Fills = preload("res://addons/mat_maker_gd/nodes/common/fills.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Commons.rand(Vector2(c.r, c.g))
|
||||
var r2 : float = Commons.rand(Vector2(c.b, c.a))
|
||||
var s : float = Commons.step(0.0000001, Vector2(c.b, c.a).dot(Vector2(1, 1)))
|
||||
|
||||
var f : float = lerp(edge_color, Commons.rand(Vector2(1.0 / float(pseed), Commons.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)
|
70
addons/mat_maker_gd/nodes/filter/fill_to_size.gd
Normal file
70
addons/mat_maker_gd/nodes/filter/fill_to_size.gd
Normal file
@ -0,0 +1,70 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Fills = preload("res://addons/mat_maker_gd/nodes/common/fills.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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)
|
62
addons/mat_maker_gd/nodes/filter/fill_to_uv.gd
Normal file
62
addons/mat_maker_gd/nodes/filter/fill_to_uv.gd
Normal file
@ -0,0 +1,62 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Fills = preload("res://addons/mat_maker_gd/nodes/common/fills.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Fills.fill_to_uv_stretch(uv, c, float(pseed))
|
||||
elif mode == 1:
|
||||
r = Fills.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)
|
66
addons/mat_maker_gd/nodes/filter/greyscale.gd
Normal file
66
addons/mat_maker_gd/nodes/filter/greyscale.gd
Normal file
@ -0,0 +1,66 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Filter.grayscale_lightness(Vector3(c.r, c.g, c.b))
|
||||
elif type == 1:
|
||||
f = Filter.grayscale_average(Vector3(c.r, c.g, c.b))
|
||||
elif type == 2:
|
||||
f = Filter.grayscale_luminosity(Vector3(c.r, c.g, c.b))
|
||||
elif type == 3:
|
||||
f = Filter.grayscale_min(Vector3(c.r, c.g, c.b))
|
||||
elif type == 4:
|
||||
f = Filter.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)
|
42
addons/mat_maker_gd/nodes/filter/invert.gd
Normal file
42
addons/mat_maker_gd/nodes/filter/invert.gd
Normal file
@ -0,0 +1,42 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(Resource) var input : Resource
|
||||
|
||||
func _init_properties():
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input1 "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 Filter.invert(c)
|
78
addons/mat_maker_gd/nodes/filter/make_tileable.gd
Normal file
78
addons/mat_maker_gd/nodes/filter/make_tileable.gd
Normal file
@ -0,0 +1,78 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
const Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !input:
|
||||
input = MMNodeUniversalProperty.new()
|
||||
input.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color())
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.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(Commons.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(Commons.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)
|
||||
|
151
addons/mat_maker_gd/nodes/filter/math.gd
Normal file
151
addons/mat_maker_gd/nodes/filter/math.gd
Normal file
@ -0,0 +1,151 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Fills = preload("res://addons/mat_maker_gd/nodes/common/fills.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
a.set_default_value(0)
|
||||
|
||||
a.input_slot_type = MMNodeUniversalProperty.SlotTypes.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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
b.set_default_value(0)
|
||||
|
||||
b.input_slot_type = MMNodeUniversalProperty.SlotTypes.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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
#image.force_override = true
|
||||
|
||||
if !output:
|
||||
output = MMNodeUniversalProperty.new()
|
||||
output.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
output.set_default_value(0)
|
||||
|
||||
output.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Commons.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()
|
56
addons/mat_maker_gd/nodes/filter/quantize.gd
Normal file
56
addons/mat_maker_gd/nodes/filter/quantize.gd
Normal file
@ -0,0 +1,56 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Commons.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)
|
111
addons/mat_maker_gd/nodes/filter/swap_channels.gd
Normal file
111
addons/mat_maker_gd/nodes/filter/swap_channels.gd
Normal file
@ -0,0 +1,111 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Filter = preload("res://addons/mat_maker_gd/nodes/common/filter.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR
|
||||
input.set_default_value(Color(0, 0, 0, 1))
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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)
|
50
addons/mat_maker_gd/nodes/filter/tonality.gd
Normal file
50
addons/mat_maker_gd/nodes/filter/tonality.gd
Normal file
@ -0,0 +1,50 @@
|
||||
tool
|
||||
extends "res://addons/mat_maker_gd/nodes/bases/curve_base.gd"
|
||||
|
||||
var Curves = preload("res://addons/mat_maker_gd/nodes/common/curves.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
input.set_default_value(0)
|
||||
|
||||
input.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_UNIVERSAL
|
||||
input.slot_name = ">>> Input "
|
||||
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
#image.input_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_FLOAT
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Curves.curve(f, points)
|
||||
|
||||
return Color(cf, cf, cf, 1)
|
||||
|
||||
func _curve_changed() -> void:
|
||||
set_dirty(true)
|
60
addons/mat_maker_gd/nodes/gradient/circular_gradient.gd
Normal file
60
addons/mat_maker_gd/nodes/gradient/circular_gradient.gd
Normal file
@ -0,0 +1,60 @@
|
||||
tool
|
||||
extends "res://addons/mat_maker_gd/nodes/bases/gradient_base.gd"
|
||||
|
||||
var Gradients = preload("res://addons/mat_maker_gd/nodes/common/gradients.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(float) var repeat : float = 1
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 Gradients.circular_gradient_type_1(uv, repeat, points)
|
||||
elif interpolation_type == 1:
|
||||
return Gradients.circular_gradient_type_2(uv, repeat, points)
|
||||
elif interpolation_type == 2:
|
||||
return Gradients.circular_gradient_type_3(uv, repeat, points)
|
||||
elif interpolation_type == 3:
|
||||
return Gradients.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 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_repeat() -> float:
|
||||
return repeat
|
||||
|
||||
func set_repeat(val : float) -> void:
|
||||
repeat = val
|
||||
|
||||
set_dirty(true)
|
||||
|
68
addons/mat_maker_gd/nodes/gradient/gradient.gd
Normal file
68
addons/mat_maker_gd/nodes/gradient/gradient.gd
Normal file
@ -0,0 +1,68 @@
|
||||
tool
|
||||
extends "res://addons/mat_maker_gd/nodes/bases/gradient_base.gd"
|
||||
|
||||
var Gradients = preload("res://addons/mat_maker_gd/nodes/common/gradients.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 Gradients.normal_gradient_type_1(uv, repeat, rotate, points)
|
||||
elif interpolation_type == 1:
|
||||
return Gradients.normal_gradient_type_2(uv, repeat, rotate, points)
|
||||
elif interpolation_type == 2:
|
||||
return Gradients.normal_gradient_type_3(uv, repeat, rotate, points)
|
||||
elif interpolation_type == 3:
|
||||
return Gradients.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 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_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)
|
60
addons/mat_maker_gd/nodes/gradient/radial_gradient.gd
Normal file
60
addons/mat_maker_gd/nodes/gradient/radial_gradient.gd
Normal file
@ -0,0 +1,60 @@
|
||||
tool
|
||||
extends "res://addons/mat_maker_gd/nodes/bases/gradient_base.gd"
|
||||
|
||||
var Gradients = preload("res://addons/mat_maker_gd/nodes/common/gradients.gd")
|
||||
|
||||
export(Resource) var image : Resource
|
||||
export(float) var repeat : float = 1
|
||||
|
||||
func _init_properties():
|
||||
if !image:
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 Gradients.radial_gradient_type_1(uv, repeat, points)
|
||||
elif interpolation_type == 1:
|
||||
return Gradients.radial_gradient_type_2(uv, repeat, points)
|
||||
elif interpolation_type == 2:
|
||||
return Gradients.radial_gradient_type_3(uv, repeat, points)
|
||||
elif interpolation_type == 3:
|
||||
return Gradients.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 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_repeat() -> float:
|
||||
return repeat
|
||||
|
||||
func set_repeat(val : float) -> void:
|
||||
repeat = val
|
||||
|
||||
set_dirty(true)
|
||||
|
119
addons/mat_maker_gd/nodes/mm_material.gd
Normal file
119
addons/mat_maker_gd/nodes/mm_material.gd
Normal file
@ -0,0 +1,119 @@
|
||||
tool
|
||||
class_name MMMateial
|
||||
extends Resource
|
||||
|
||||
#threads are implemented using my thread pool engine module.
|
||||
#if you want to use this without that module in your engine set this to false,
|
||||
#and comment out the lines that give errors
|
||||
const USE_THREADS = true
|
||||
|
||||
export(Vector2) var image_size : Vector2 = Vector2(128, 128)
|
||||
export(Array) var nodes : Array
|
||||
|
||||
var initialized : bool = false
|
||||
var rendering : bool = false
|
||||
var queued_render : bool = false
|
||||
var job : ThreadPoolExecuteJob = ThreadPoolExecuteJob.new()
|
||||
|
||||
func initialize():
|
||||
if !initialized:
|
||||
initialized = true
|
||||
|
||||
job.setup(self, "_thread_func")
|
||||
|
||||
for n in nodes:
|
||||
n.connect("changed", self, "on_node_changed")
|
||||
|
||||
func add_node(node : MMNode) -> void:
|
||||
nodes.append(node)
|
||||
|
||||
node.connect("changed", self, "on_node_changed")
|
||||
|
||||
emit_changed()
|
||||
|
||||
func remove_node(node : MMNode) -> void:
|
||||
if !node:
|
||||
return
|
||||
|
||||
for op in node.output_properties:
|
||||
for n in nodes:
|
||||
if n:
|
||||
for ip in n.input_properties:
|
||||
if ip.input_property == op:
|
||||
ip.set_input_property(null)
|
||||
|
||||
nodes.erase(node)
|
||||
|
||||
node.disconnect("changed", self, "on_node_changed")
|
||||
|
||||
emit_changed()
|
||||
|
||||
func render() -> void:
|
||||
if USE_THREADS:
|
||||
render_threaded()
|
||||
else:
|
||||
render_non_threaded()
|
||||
|
||||
func render_non_threaded() -> void:
|
||||
if !initialized:
|
||||
initialize()
|
||||
|
||||
var did_render : bool = true
|
||||
|
||||
while did_render:
|
||||
did_render = false
|
||||
|
||||
for n in nodes:
|
||||
if n && n.render(self):
|
||||
did_render = true
|
||||
|
||||
func render_threaded() -> void:
|
||||
job.cancelled = false
|
||||
|
||||
if rendering:
|
||||
queued_render = true
|
||||
return
|
||||
|
||||
if !initialized:
|
||||
initialize()
|
||||
|
||||
if !ThreadPool.has_job(job):
|
||||
ThreadPool.add_job(job)
|
||||
|
||||
func _thread_func() -> void:
|
||||
if job.cancelled:
|
||||
rendering = false
|
||||
return
|
||||
|
||||
rendering = true
|
||||
job.cancelled = false
|
||||
|
||||
var did_render : bool = true
|
||||
|
||||
while did_render:
|
||||
did_render = false
|
||||
|
||||
for n in nodes:
|
||||
if n && n.render(self):
|
||||
did_render = true
|
||||
|
||||
if job.cancelled:
|
||||
rendering = false
|
||||
return
|
||||
|
||||
rendering = false
|
||||
|
||||
if queued_render:
|
||||
queued_render = false
|
||||
_thread_func()
|
||||
|
||||
func cancel_render_and_wait() -> void:
|
||||
if rendering:
|
||||
ThreadPool.cancel_task_wait(job)
|
||||
|
||||
job.cancelled = false
|
||||
|
||||
pass
|
||||
|
||||
func on_node_changed() -> void:
|
||||
call_deferred("render")
|
121
addons/mat_maker_gd/nodes/mm_node.gd
Normal file
121
addons/mat_maker_gd/nodes/mm_node.gd
Normal file
@ -0,0 +1,121 @@
|
||||
tool
|
||||
class_name MMNode
|
||||
extends Resource
|
||||
|
||||
export(Vector2) var graph_position : Vector2 = Vector2()
|
||||
|
||||
var input_properties : Array
|
||||
var output_properties : Array
|
||||
|
||||
var properties_initialized : bool = false
|
||||
|
||||
var dirty : bool = true
|
||||
|
||||
#MMMateial
|
||||
func render(material) -> bool:
|
||||
if !dirty:
|
||||
return false
|
||||
|
||||
for p in input_properties:
|
||||
if p.input_property && p.input_property.owner.dirty:
|
||||
return false
|
||||
|
||||
_render(material)
|
||||
|
||||
dirty = false
|
||||
|
||||
return true
|
||||
|
||||
#MMMateial
|
||||
func _render(material) -> void:
|
||||
pass
|
||||
|
||||
func render_image(material) -> Image:
|
||||
var image : Image = Image.new()
|
||||
image.create(material.image_size.x, material.image_size.y, false, Image.FORMAT_RGBA8)
|
||||
|
||||
image.lock()
|
||||
|
||||
var w : float = image.get_width()
|
||||
var h : float = image.get_width()
|
||||
|
||||
var pseed : float = randf() + randi()
|
||||
|
||||
for x in range(image.get_width()):
|
||||
for y in range(image.get_height()):
|
||||
var v : Vector2 = Vector2(x / w, y / h)
|
||||
|
||||
var col : Color = get_value_for(v, pseed)
|
||||
|
||||
image.set_pixel(x, y, col)
|
||||
|
||||
image.unlock()
|
||||
|
||||
return image
|
||||
|
||||
func get_value_for(uv : Vector2, pseed : int) -> Color:
|
||||
return Color()
|
||||
|
||||
func init_properties() -> void:
|
||||
if !properties_initialized:
|
||||
properties_initialized = true
|
||||
|
||||
_init_properties()
|
||||
|
||||
func _init_properties() -> void:
|
||||
pass
|
||||
|
||||
func register_methods(mm_graph_node) -> void:
|
||||
init_properties()
|
||||
_register_methods(mm_graph_node)
|
||||
|
||||
func _register_methods(mm_graph_node) -> void:
|
||||
pass
|
||||
|
||||
func get_graph_position() -> Vector2:
|
||||
return graph_position
|
||||
|
||||
func set_graph_position(pos : Vector2) -> void:
|
||||
graph_position = pos
|
||||
|
||||
emit_changed()
|
||||
|
||||
func register_input_property(prop : MMNodeUniversalProperty) -> void:
|
||||
prop.owner = self
|
||||
|
||||
if !prop.is_connected("changed", self, "on_input_property_changed"):
|
||||
prop.connect("changed", self, "on_input_property_changed")
|
||||
|
||||
input_properties.append(prop)
|
||||
|
||||
func unregister_input_property(prop : MMNodeUniversalProperty) -> void:
|
||||
if prop.owner == self:
|
||||
prop.owner = null
|
||||
|
||||
if prop.is_connected("changed", self, "on_input_property_changed"):
|
||||
prop.disconnect("changed", self, "on_input_property_changed")
|
||||
|
||||
input_properties.erase(prop)
|
||||
|
||||
func register_output_property(prop : MMNodeUniversalProperty) -> void:
|
||||
prop.owner = self
|
||||
|
||||
output_properties.append(prop)
|
||||
|
||||
func unregister_output_property(prop : MMNodeUniversalProperty) -> void:
|
||||
if prop.owner == self:
|
||||
prop.owner = null
|
||||
|
||||
output_properties.erase(prop)
|
||||
|
||||
func set_dirty(val : bool) -> void:
|
||||
var changed : bool = val != dirty
|
||||
|
||||
dirty = val
|
||||
|
||||
if changed:
|
||||
emit_changed()
|
||||
|
||||
func on_input_property_changed() -> void:
|
||||
set_dirty(true)
|
||||
emit_changed()
|
316
addons/mat_maker_gd/nodes/mm_node_universal_property.gd
Normal file
316
addons/mat_maker_gd/nodes/mm_node_universal_property.gd
Normal file
@ -0,0 +1,316 @@
|
||||
tool
|
||||
class_name MMNodeUniversalProperty
|
||||
extends Resource
|
||||
|
||||
enum SlotTypes {
|
||||
SLOT_TYPE_NONE = -1,
|
||||
SLOT_TYPE_IMAGE = 0,
|
||||
SLOT_TYPE_INT = 1,
|
||||
SLOT_TYPE_FLOAT = 2,
|
||||
SLOT_TYPE_VECTOR2 = 3,
|
||||
SLOT_TYPE_VECTOR3 = 4,
|
||||
SLOT_TYPE_COLOR = 5,
|
||||
SLOT_TYPE_UNIVERSAL = 6,
|
||||
}
|
||||
|
||||
enum MMNodeUniversalPropertyDefaultType {
|
||||
DEFAULT_TYPE_INT = 0,
|
||||
DEFAULT_TYPE_FLOAT = 1,
|
||||
DEFAULT_TYPE_VECTOR2 = 2,
|
||||
DEFAULT_TYPE_VECTOR3 = 3,
|
||||
DEFAULT_TYPE_COLOR = 4,
|
||||
DEFAULT_TYPE_IMAGE = 5,
|
||||
}
|
||||
|
||||
export(int, "Int,Float,Vector2,Vector3,Color,Image") var default_type : int
|
||||
|
||||
export(int) var default_int : int
|
||||
export(float) var default_float : float
|
||||
export(Vector2) var default_vector2 : Vector2
|
||||
export(Vector3) var default_vector3 : Vector3
|
||||
export(Color) var default_color : Color
|
||||
export(Image) var default_image : Image
|
||||
|
||||
var get_value_from_owner : bool = false
|
||||
var force_override : bool = false
|
||||
#This is not exported on purpose!
|
||||
var override_image : Image
|
||||
|
||||
#Should be a MMNodeUniversalProperty, but can't set it up like that
|
||||
export(Resource) var input_property : Resource
|
||||
|
||||
var input_slot_type : int = SlotTypes.SLOT_TYPE_NONE
|
||||
var output_slot_type : int = SlotTypes.SLOT_TYPE_NONE
|
||||
var slot_name : String
|
||||
var value_step : float = 0.1
|
||||
var value_range : Vector2 = Vector2(-1000, 1000)
|
||||
|
||||
#MMNode
|
||||
var owner
|
||||
|
||||
func _init():
|
||||
if input_property:
|
||||
input_property.connect("changed", self, "on_input_property_changed")
|
||||
|
||||
func get_value(uv : Vector2, skip_owner_val : bool = false):
|
||||
if get_value_from_owner && !skip_owner_val:
|
||||
return get_owner_value(uv)
|
||||
|
||||
if !input_property:
|
||||
return get_default_value(uv)
|
||||
|
||||
if default_type == input_property.default_type:
|
||||
return input_property.get_value(uv)
|
||||
|
||||
if default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT:
|
||||
return to_int(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT:
|
||||
return to_float(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2:
|
||||
return to_vector2(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3:
|
||||
return to_vector3(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR:
|
||||
return to_color(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE:
|
||||
return to_color(input_property.get_value(uv))
|
||||
|
||||
return input_property.get_value(uv)
|
||||
|
||||
func get_owner_value(uv : Vector2):
|
||||
if default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT:
|
||||
return to_int(owner.get_property_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT:
|
||||
return to_float(owner.get_property_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2:
|
||||
return to_vector2(owner.get_property_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3:
|
||||
return to_vector3(owner.get_property_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR:
|
||||
return to_color(owner.get_property_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE:
|
||||
return to_color(owner.get_property_value(uv))
|
||||
|
||||
func get_value_or_zero(uv : Vector2, skip_owner_val : bool = false):
|
||||
if get_value_from_owner && !skip_owner_val:
|
||||
return get_owner_value(uv)
|
||||
|
||||
if !input_property:
|
||||
return get_zero_value()
|
||||
|
||||
if default_type == input_property.default_type:
|
||||
return input_property.get_value(uv)
|
||||
|
||||
if default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT:
|
||||
return to_int(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT:
|
||||
return to_float(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2:
|
||||
return to_vector2(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3:
|
||||
return to_vector3(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR:
|
||||
return to_color(input_property.get_value(uv))
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE:
|
||||
return to_color(input_property.get_value(uv))
|
||||
|
||||
return input_property.get_value(uv)
|
||||
|
||||
func get_value_sdf3d(uv3 : Vector3, skip_owner_val : bool = false) -> Vector2:
|
||||
if get_value_from_owner && !skip_owner_val:
|
||||
return owner.get_property_value_sdf3d(uv3)
|
||||
|
||||
if !input_property:
|
||||
return default_vector2
|
||||
|
||||
return input_property.get_value_sdf3d(uv3)
|
||||
|
||||
func to_int(val) -> int:
|
||||
if val is int:
|
||||
return val
|
||||
|
||||
if val is float:
|
||||
return int(val)
|
||||
|
||||
if val is Vector2:
|
||||
return int(val.x)
|
||||
|
||||
if val is Vector3:
|
||||
return int(val.x)
|
||||
|
||||
if val is Color:
|
||||
return int(val.r)
|
||||
|
||||
return 0
|
||||
|
||||
func to_float(val) -> float:
|
||||
if val is float:
|
||||
return val
|
||||
|
||||
if val is int:
|
||||
return float(val)
|
||||
|
||||
if val is Vector2:
|
||||
return float(val.x)
|
||||
|
||||
if val is Vector3:
|
||||
return float(val.x)
|
||||
|
||||
if val is Color:
|
||||
return float(val.r)
|
||||
|
||||
return 0.0
|
||||
|
||||
func to_vector2(val) -> Vector2:
|
||||
if val is Vector2:
|
||||
return val
|
||||
|
||||
if val is int:
|
||||
return Vector2(val, val)
|
||||
|
||||
if val is float:
|
||||
return Vector2(val, val)
|
||||
|
||||
if val is Vector3:
|
||||
return Vector2(val.x, val.y)
|
||||
|
||||
if val is Color:
|
||||
return Vector2(val.r, val.g)
|
||||
|
||||
return Vector2()
|
||||
|
||||
func to_vector3(val) -> Vector3:
|
||||
if val is Vector3:
|
||||
return val
|
||||
|
||||
if val is int:
|
||||
return Vector3(val, val, val)
|
||||
|
||||
if val is float:
|
||||
return Vector3(val, val, val)
|
||||
|
||||
if val is Vector2:
|
||||
return Vector3(val.x, val.y, 0)
|
||||
|
||||
if val is Color:
|
||||
return Vector3(val.r, val.g, val.b)
|
||||
|
||||
return Vector3()
|
||||
|
||||
func to_color(val) -> Color:
|
||||
if val is Color:
|
||||
return val
|
||||
|
||||
if val is int:
|
||||
return Color(val, val, val, 1)
|
||||
|
||||
if val is float:
|
||||
return Color(val, val, val, 1)
|
||||
|
||||
if val is Vector2:
|
||||
return Color(val.x, val.y, 0, 1)
|
||||
|
||||
if val is Vector3:
|
||||
return Color(val.x, val.y, val.z, 1)
|
||||
|
||||
return Color()
|
||||
|
||||
func set_value(val):
|
||||
if default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE:
|
||||
override_image = val
|
||||
emit_changed()
|
||||
return
|
||||
|
||||
set_default_value(val)
|
||||
|
||||
func get_zero_value():
|
||||
if default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT:
|
||||
return 0
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT:
|
||||
return 0.0
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2:
|
||||
return Vector2()
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3:
|
||||
return Vector3()
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR:
|
||||
return Color()
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE:
|
||||
return Color()
|
||||
|
||||
return null
|
||||
|
||||
func get_default_value(uv : Vector2 = Vector2()):
|
||||
if default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT:
|
||||
return default_int
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT:
|
||||
return default_float
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2:
|
||||
return default_vector2
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3:
|
||||
return default_vector3
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR:
|
||||
return default_color
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE:
|
||||
var image : Image = default_image
|
||||
|
||||
if override_image:
|
||||
image = override_image
|
||||
|
||||
if !image:
|
||||
return default_color
|
||||
|
||||
image.lock()
|
||||
var x : int = uv.x * image.get_width()
|
||||
var y : int = uv.y * image.get_height()
|
||||
|
||||
x = clamp(x, 0, image.get_width() - 1)
|
||||
y = clamp(y, 0, image.get_width() - 1)
|
||||
|
||||
var c : Color = image.get_pixel(x, y)
|
||||
image.unlock()
|
||||
|
||||
return c
|
||||
|
||||
return null
|
||||
|
||||
func set_default_value(val):
|
||||
if default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_INT:
|
||||
default_int = val
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT:
|
||||
default_float = val
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2:
|
||||
default_vector2 = val
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR3:
|
||||
default_vector3 = val
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_COLOR:
|
||||
default_color = val
|
||||
elif default_type == MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE:
|
||||
default_image = val
|
||||
|
||||
emit_changed()
|
||||
|
||||
func get_active_image() -> Image:
|
||||
if !force_override && input_property:
|
||||
return input_property.get_active_image()
|
||||
|
||||
if override_image:
|
||||
return override_image
|
||||
|
||||
return default_image
|
||||
|
||||
func set_input_property(val : MMNodeUniversalProperty) -> void:
|
||||
if input_property == val:
|
||||
return
|
||||
|
||||
if input_property:
|
||||
input_property.disconnect("changed", self, "on_input_property_changed")
|
||||
|
||||
input_property = val
|
||||
|
||||
if input_property:
|
||||
input_property.connect("changed", self, "on_input_property_changed")
|
||||
|
||||
emit_changed()
|
||||
|
||||
func on_input_property_changed() -> void:
|
||||
emit_changed()
|
60
addons/mat_maker_gd/nodes/noise/anisotropic_noise.gd
Normal file
60
addons/mat_maker_gd/nodes/noise/anisotropic_noise.gd
Normal file
@ -0,0 +1,60 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Noises = preload("res://addons/mat_maker_gd/nodes/common/noises.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 Noises.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)
|
52
addons/mat_maker_gd/nodes/noise/color_noise.gd
Normal file
52
addons/mat_maker_gd/nodes/noise/color_noise.gd
Normal file
@ -0,0 +1,52 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Noises = preload("res://addons/mat_maker_gd/nodes/common/noises.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 Noises.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)
|
60
addons/mat_maker_gd/nodes/noise/color_value.gd
Normal file
60
addons/mat_maker_gd/nodes/noise/color_value.gd
Normal file
@ -0,0 +1,60 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var NoisePerlin = preload("res://addons/mat_maker_gd/nodes/common/noise_perlin.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 NoisePerlin.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)
|
99
addons/mat_maker_gd/nodes/noise/fbm_noise.gd
Normal file
99
addons/mat_maker_gd/nodes/noise/fbm_noise.gd
Normal file
@ -0,0 +1,99 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var NoiseFBM = preload("res://addons/mat_maker_gd/nodes/common/noise_fbm.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 NoiseFBM.fbmval(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 1:
|
||||
return NoiseFBM.perlin(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 2:
|
||||
return NoiseFBM.simplex(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 3:
|
||||
return NoiseFBM.cellular(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 4:
|
||||
return NoiseFBM.cellular2(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 5:
|
||||
return NoiseFBM.cellular3(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 6:
|
||||
return NoiseFBM.cellular4(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 7:
|
||||
return NoiseFBM.cellular5(uv, scale, folds, iterations, persistence, ps)
|
||||
elif type == 8:
|
||||
return NoiseFBM.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)
|
52
addons/mat_maker_gd/nodes/noise/noise.gd
Normal file
52
addons/mat_maker_gd/nodes/noise/noise.gd
Normal file
@ -0,0 +1,52 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Noises = preload("res://addons/mat_maker_gd/nodes/common/noises.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Noises.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)
|
163
addons/mat_maker_gd/nodes/noise/voronoi.gd
Normal file
163
addons/mat_maker_gd/nodes/noise/voronoi.gd
Normal file
@ -0,0 +1,163 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var NoiseVoronoi = preload("res://addons/mat_maker_gd/nodes/common/noise_voronoi.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_nodes.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_borders:
|
||||
out_borders = MMNodeUniversalProperty.new()
|
||||
out_borders.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_borders.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_random_color:
|
||||
out_random_color = MMNodeUniversalProperty.new()
|
||||
out_random_color.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_random_color.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_fill:
|
||||
out_fill = MMNodeUniversalProperty.new()
|
||||
out_fill.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_fill.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 = NoiseVoronoi.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 = Commons.rand3(Commons.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 = Commons.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)
|
45
addons/mat_maker_gd/nodes/other/output_image.gd
Normal file
45
addons/mat_maker_gd/nodes/other/output_image.gd
Normal file
@ -0,0 +1,45 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
export(Resource) var image : Resource
|
||||
|
||||
export(String) var postfix : String = ""
|
||||
|
||||
func _init_properties():
|
||||
image = MMNodeUniversalProperty.new()
|
||||
image.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
image.input_slot_type = MMNodeUniversalProperty.SlotTypes.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)
|
113
addons/mat_maker_gd/nodes/pattern/beehive.gd
Normal file
113
addons/mat_maker_gd/nodes/pattern/beehive.gd
Normal file
@ -0,0 +1,113 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Commons = preload("res://addons/mat_maker_gd/nodes/common/commons.gd")
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_main.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_random_color:
|
||||
out_random_color = MMNodeUniversalProperty.new()
|
||||
out_random_color.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_random_color.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_uv_map:
|
||||
out_uv_map = MMNodeUniversalProperty.new()
|
||||
out_uv_map.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_uv_map.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Patterns.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 * Patterns.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 = Commons.rand3(Commons.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 = Commons.rand2(Commons.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)
|
288
addons/mat_maker_gd/nodes/pattern/bricks.gd
Normal file
288
addons/mat_maker_gd/nodes/pattern/bricks.gd
Normal file
@ -0,0 +1,288 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_bricks_pattern.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_random_color:
|
||||
out_random_color = MMNodeUniversalProperty.new()
|
||||
out_random_color.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_random_color.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_position_x:
|
||||
out_position_x = MMNodeUniversalProperty.new()
|
||||
out_position_x.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_position_x.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_position_y:
|
||||
out_position_y = MMNodeUniversalProperty.new()
|
||||
out_position_y.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_position_y.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_brick_uv:
|
||||
out_brick_uv = MMNodeUniversalProperty.new()
|
||||
out_brick_uv.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_brick_uv.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_corner_uv:
|
||||
out_corner_uv = MMNodeUniversalProperty.new()
|
||||
out_corner_uv.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_corner_uv.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_direction:
|
||||
out_direction = MMNodeUniversalProperty.new()
|
||||
out_direction.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_direction.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !mortar:
|
||||
mortar = MMNodeUniversalProperty.new()
|
||||
mortar.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
mortar.set_default_value(0.1)
|
||||
|
||||
mortar.input_slot_type = MMNodeUniversalProperty.SlotTypes.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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
bevel.set_default_value(0.1)
|
||||
|
||||
bevel.input_slot_type = MMNodeUniversalProperty.SlotTypes.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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_FLOAT
|
||||
roundness.set_default_value(0.1)
|
||||
|
||||
roundness.input_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Patterns.bricks_rb(uv, col_row, repeat, offset)
|
||||
elif type == 1:
|
||||
brick_rect = Patterns.bricks_rb2(uv, col_row, repeat, offset)
|
||||
elif type == 2:
|
||||
brick_rect = Patterns.bricks_hb(uv, col_row, repeat, offset)
|
||||
elif type == 3:
|
||||
brick_rect = Patterns.bricks_bw(uv, col_row, repeat, offset)
|
||||
elif type == 4:
|
||||
brick_rect = Patterns.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 = Patterns.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 = Patterns.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 = Patterns.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 = Patterns.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)
|
||||
|
||||
|
40
addons/mat_maker_gd/nodes/pattern/iching.gd
Normal file
40
addons/mat_maker_gd/nodes/pattern/iching.gd
Normal file
@ -0,0 +1,40 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 Patterns.IChingc(uv, size, ps)
|
||||
|
||||
#size
|
||||
func get_size() -> Vector2:
|
||||
return size
|
||||
|
||||
func set_size(val : Vector2) -> void:
|
||||
size = val
|
||||
|
||||
set_dirty(true)
|
72
addons/mat_maker_gd/nodes/pattern/pattern.gd
Normal file
72
addons/mat_maker_gd/nodes/pattern/pattern.gd
Normal file
@ -0,0 +1,72 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Patterns.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)
|
40
addons/mat_maker_gd/nodes/pattern/runes.gd
Normal file
40
addons/mat_maker_gd/nodes/pattern/runes.gd
Normal file
@ -0,0 +1,40 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 Patterns.runesc(uv, size, ps)
|
||||
|
||||
#size
|
||||
func get_size() -> Vector2:
|
||||
return size
|
||||
|
||||
func set_size(val : Vector2) -> void:
|
||||
size = val
|
||||
|
||||
set_dirty(true)
|
82
addons/mat_maker_gd/nodes/pattern/scratches.gd
Normal file
82
addons/mat_maker_gd/nodes/pattern/scratches.gd
Normal file
@ -0,0 +1,82 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 Patterns.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)
|
61
addons/mat_maker_gd/nodes/pattern/sine_wave.gd
Normal file
61
addons/mat_maker_gd/nodes/pattern/sine_wave.gd
Normal file
@ -0,0 +1,61 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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)
|
53
addons/mat_maker_gd/nodes/pattern/truchet.gd
Normal file
53
addons/mat_maker_gd/nodes/pattern/truchet.gd
Normal file
@ -0,0 +1,53 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
image.output_slot_type = MMNodeUniversalProperty.SlotTypes.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 Patterns.truchet1c(uv, size, pseed)
|
||||
elif shape == 1:
|
||||
return Patterns.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)
|
134
addons/mat_maker_gd/nodes/pattern/weave.gd
Normal file
134
addons/mat_maker_gd/nodes/pattern/weave.gd
Normal file
@ -0,0 +1,134 @@
|
||||
tool
|
||||
extends MMNode
|
||||
|
||||
var Patterns = preload("res://addons/mat_maker_gd/nodes/common/patterns.gd")
|
||||
|
||||
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.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_main.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_horizontal_map:
|
||||
out_horizontal_map = MMNodeUniversalProperty.new()
|
||||
out_horizontal_map.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_horizontal_map.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !out_vertical_map:
|
||||
out_vertical_map = MMNodeUniversalProperty.new()
|
||||
out_vertical_map.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_IMAGE
|
||||
|
||||
out_vertical_map.output_slot_type = MMNodeUniversalProperty.SlotTypes.SLOT_TYPE_IMAGE
|
||||
|
||||
if !width:
|
||||
width = MMNodeUniversalProperty.new()
|
||||
width.default_type = MMNodeUniversalProperty.MMNodeUniversalPropertyDefaultType.DEFAULT_TYPE_VECTOR2
|
||||
width.set_default_value(Vector2(0.9, 0.9))
|
||||
|
||||
width.input_slot_type = MMNodeUniversalProperty.SlotTypes.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 = Patterns.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)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user