Updated base library and added truchet generator
@ -170,7 +170,7 @@ func create_nodes(data, position : Vector2 = Vector2(0, 0)):
|
||||
return []
|
||||
|
||||
func create_gen_from_type(gen_name):
|
||||
create_nodes({ type=gen_name }, scroll_offset+0.5*rect_size)
|
||||
create_nodes({ type=gen_name, parameters={} }, scroll_offset+0.5*rect_size)
|
||||
|
||||
func load_file(filename):
|
||||
clear_material()
|
||||
|
@ -3,7 +3,7 @@ extends VBoxContainer
|
||||
|
||||
var libraries = []
|
||||
|
||||
onready var tree = $Tree
|
||||
onready var tree : Tree = $Tree
|
||||
|
||||
func _ready():
|
||||
tree.set_column_expand(0, true)
|
||||
@ -15,6 +15,17 @@ func _ready():
|
||||
add_library("user://library/user.json")
|
||||
update_tree()
|
||||
|
||||
func get_selected_item_name():
|
||||
var tree_item : TreeItem = tree.get_selected()
|
||||
var rv = ""
|
||||
while tree_item != null and tree_item != tree.get_root():
|
||||
if rv == "":
|
||||
rv = tree_item.get_text(0)
|
||||
else:
|
||||
rv = tree_item.get_text(0)+"/"+rv
|
||||
tree_item = tree_item.get_parent()
|
||||
return rv
|
||||
|
||||
func add_library(file_name : String, filter : String = ""):
|
||||
var root = tree.get_root()
|
||||
var file = File.new()
|
||||
|
@ -1,31 +1,73 @@
|
||||
{"lib":[
|
||||
{
|
||||
"tree_item":"Generators",
|
||||
"tree_item":"Simple",
|
||||
"collapsed":false
|
||||
},
|
||||
{
|
||||
"tree_item":"Filters",
|
||||
"collapsed":false
|
||||
},
|
||||
{
|
||||
"tree_item":"Miscellaneous",
|
||||
"collapsed":false
|
||||
},
|
||||
{
|
||||
"tree_item":"Generators/Uniform",
|
||||
"tree_item":"Simple/Uniform",
|
||||
"type":"uniform"
|
||||
},
|
||||
{
|
||||
"tree_item":"Generators/Shape",
|
||||
"icon": "polygon",
|
||||
"name": "shape",
|
||||
"parameters": {
|
||||
"edge": 0.051546,
|
||||
"radius": 0.845361,
|
||||
"shape": 1,
|
||||
"sides": 6
|
||||
},
|
||||
"tree_item":"Simple/Shape",
|
||||
"type":"shape"
|
||||
},
|
||||
{
|
||||
"tree_item":"Generators/Image",
|
||||
"type":"image",
|
||||
"file_path":"res://addons/material_maker/nodes/image/godot_logo.png"
|
||||
"icon": "star",
|
||||
"name": "shape",
|
||||
"parameters": {
|
||||
"edge": 0.2,
|
||||
"radius": 0.34375,
|
||||
"shape": 2,
|
||||
"sides": 5
|
||||
},
|
||||
"tree_item": "Simple/Shape/Star",
|
||||
"type": "shape"
|
||||
},
|
||||
{
|
||||
"tree_item":"Generators/Pattern",
|
||||
"icon": "curved_star",
|
||||
"name": "shape",
|
||||
"parameters": {
|
||||
"edge": 0.628866,
|
||||
"radius": 0.546392,
|
||||
"shape": 3,
|
||||
"sides": 6
|
||||
},
|
||||
"tree_item": "Simple/Shape/Curved Star",
|
||||
"type": "shape"
|
||||
},
|
||||
{
|
||||
"icon": "rays",
|
||||
"name": "shape",
|
||||
"parameters": {
|
||||
"edge": 0.628866,
|
||||
"radius": 0.546392,
|
||||
"shape": 4,
|
||||
"sides": 9
|
||||
},
|
||||
"tree_item": "Simple/Shape/Rays",
|
||||
"type": "shape"
|
||||
},
|
||||
{
|
||||
"tree_item":"Simple/Image",
|
||||
"type":"image",
|
||||
"parameters": {
|
||||
"file_path":"res://addons/material_maker/nodes/image/godot_logo.png"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Pattern",
|
||||
"collapsed":false
|
||||
},
|
||||
{
|
||||
"tree_item":"Pattern/Generic",
|
||||
"icon":"pattern",
|
||||
"type":"pattern",
|
||||
"parameters":{
|
||||
@ -37,7 +79,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item": "Generators/Pattern/Checkerboard",
|
||||
"tree_item": "Pattern/Generic/Checkerboard",
|
||||
"type": "pattern",
|
||||
"icon": "checkerboard",
|
||||
"parameters":{
|
||||
@ -49,7 +91,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Generators/Bricks",
|
||||
"tree_item":"Pattern/Bricks",
|
||||
"type":"bricks",
|
||||
"icon":"bricks",
|
||||
"parameters":{
|
||||
@ -61,7 +103,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item": "Generators/Bricks/Tiles",
|
||||
"tree_item": "Pattern/Bricks/Tiles",
|
||||
"type": "bricks",
|
||||
"icon": "tiles",
|
||||
"parameters":{
|
||||
@ -73,7 +115,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item": "Generators/Bricks/BasketWeave",
|
||||
"tree_item": "Pattern/Bricks/BasketWeave",
|
||||
"type": "bricks",
|
||||
"icon": "basketweave",
|
||||
"parameters":{
|
||||
@ -87,7 +129,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item": "Generators/Bricks/HerringBone",
|
||||
"tree_item": "Pattern/Bricks/HerringBone",
|
||||
"type": "bricks",
|
||||
"icon": "herringbone",
|
||||
"parameters":{
|
||||
@ -101,7 +143,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item": "Generators/Bricks/SpanishBond",
|
||||
"tree_item": "Pattern/Bricks/SpanishBond",
|
||||
"type": "bricks",
|
||||
"icon": "spanishbond",
|
||||
"parameters":{
|
||||
@ -115,16 +157,61 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Generators/Noise",
|
||||
"icon": "weave",
|
||||
"name": "weave",
|
||||
"parameters": {
|
||||
"columns": 4,
|
||||
"rows": 4
|
||||
},
|
||||
"tree_item": "Pattern/Weave",
|
||||
"type": "weave"
|
||||
},
|
||||
{
|
||||
"icon": "truchet",
|
||||
"name": "truchet",
|
||||
"parameters": {
|
||||
"Size": 4,
|
||||
"shape": 0,
|
||||
"size": 4,
|
||||
"type": 1
|
||||
},
|
||||
"tree_item": "Pattern/Truchet",
|
||||
"type": "truchet"
|
||||
},
|
||||
{
|
||||
"icon": "runes",
|
||||
"name": "runes",
|
||||
"parameters": {
|
||||
"columns": 4,
|
||||
"rows": 4
|
||||
},
|
||||
"tree_item": "Pattern/Runes",
|
||||
"type": "runes"
|
||||
},
|
||||
{
|
||||
"tree_item":"Noise",
|
||||
"type":"noise",
|
||||
"icon":"noise",
|
||||
"collapsed":false,
|
||||
"parameters":{
|
||||
"size":4,
|
||||
"density":0.5
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Generators/Perlin Noise",
|
||||
"tree_item":"Filter",
|
||||
"collapsed":false
|
||||
},
|
||||
{
|
||||
"tree_item":"Transform",
|
||||
"collapsed":false
|
||||
},
|
||||
{
|
||||
"tree_item":"Miscellaneous",
|
||||
"collapsed":false
|
||||
},
|
||||
{
|
||||
"tree_item":"Noise/Perlin",
|
||||
"type":"perlin",
|
||||
"icon":"perlin",
|
||||
"parameters":{
|
||||
@ -135,7 +222,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Generators/Voronoi Noise",
|
||||
"tree_item":"Noise/Voronoi",
|
||||
"type":"voronoi",
|
||||
"icon":"voronoi",
|
||||
"parameters":{
|
||||
@ -145,11 +232,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Filters/Buffer",
|
||||
"type":"buffer"
|
||||
},
|
||||
{
|
||||
"tree_item":"Filters/AdjustHSV",
|
||||
"tree_item":"Filter/AdjustHSV",
|
||||
"type":"adjust_hsv",
|
||||
"parameters":{
|
||||
"hue":0,
|
||||
@ -158,69 +241,15 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Filters/Colorize",
|
||||
"icon": "colorize",
|
||||
"tree_item":"Filter/Colorize",
|
||||
"type":"colorize",
|
||||
"parameters":{
|
||||
"gradient":[{"b":0,"g":0,"pos":0,"r":0},{"b":1,"g":1,"pos":1,"r":1}]
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Filters/Blend",
|
||||
"type":"blend",
|
||||
"parameters":{
|
||||
"amount":0.5,
|
||||
"blend_type":0
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Filters/Blur",
|
||||
"type":"blur",
|
||||
"parameters":{
|
||||
"sigma":1.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Filters/Combine",
|
||||
"type":"combine"
|
||||
},
|
||||
{
|
||||
"tree_item":"Filters/Decompose",
|
||||
"type":"decompose"
|
||||
},
|
||||
{
|
||||
"tree_item":"Filters/Emboss",
|
||||
"type":"emboss",
|
||||
"parameters":{
|
||||
"direction":0
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Filters/Normal map",
|
||||
"type":"normal_map",
|
||||
"parameters":{
|
||||
"amount":0.5
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Filters/Transform",
|
||||
"type":"transform",
|
||||
"parameters":{
|
||||
"rotate":0,
|
||||
"scale_x":1,
|
||||
"scale_y":1,
|
||||
"translate_x":0,
|
||||
"translate_y":0
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Filters/Warp",
|
||||
"type":"warp",
|
||||
"parameters":{
|
||||
"amount":0.5
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item": "Filters/Colorize/Invert",
|
||||
"tree_item": "Filter/Colorize/Invert",
|
||||
"type": "colorize",
|
||||
"icon": "invert",
|
||||
"parameters":{
|
||||
@ -241,25 +270,139 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Miscellaneous/Comment",
|
||||
"type":"comment"
|
||||
"icon": "rainbow",
|
||||
"name": "colorize",
|
||||
"parameters": {
|
||||
"gradient": {
|
||||
"points": [
|
||||
{
|
||||
"a": 1,
|
||||
"b": 0,
|
||||
"g": 0,
|
||||
"pos": 0,
|
||||
"r": 1
|
||||
},
|
||||
{
|
||||
"tree_item":"Miscellaneous/Export",
|
||||
"type":"export"
|
||||
"a": 1,
|
||||
"b": 0,
|
||||
"g": 0.96875,
|
||||
"pos": 0.254545,
|
||||
"r": 1
|
||||
},
|
||||
{
|
||||
"a": 1,
|
||||
"b": 0.125,
|
||||
"g": 1,
|
||||
"pos": 0.527273,
|
||||
"r": 0
|
||||
},
|
||||
{
|
||||
"a": 1,
|
||||
"b": 1,
|
||||
"g": 0.0625,
|
||||
"pos": 0.772727,
|
||||
"r": 0
|
||||
},
|
||||
{
|
||||
"a": 1,
|
||||
"b": 1,
|
||||
"g": 0,
|
||||
"pos": 1,
|
||||
"r": 0.84375
|
||||
}
|
||||
],
|
||||
"type": "Gradient"
|
||||
}
|
||||
},
|
||||
"tree_item": "Filter/Colorize/Rainbow",
|
||||
"type": "colorize"
|
||||
},
|
||||
{
|
||||
"icon": "blend",
|
||||
"tree_item":"Filter/Blend",
|
||||
"type":"blend",
|
||||
"parameters":{
|
||||
"amount":0.5,
|
||||
"blend_type":0
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Filter/Combine",
|
||||
"type":"combine"
|
||||
},
|
||||
{
|
||||
"tree_item":"Filter/Decompose",
|
||||
"type":"decompose"
|
||||
},
|
||||
{
|
||||
"icon": "normal_map",
|
||||
"tree_item":"Filter/Normal map",
|
||||
"type":"normal_map",
|
||||
"parameters":{
|
||||
"amount":0.5
|
||||
}
|
||||
},
|
||||
{
|
||||
"icon": "transform",
|
||||
"tree_item":"Transform",
|
||||
"type":"transform",
|
||||
"parameters":{
|
||||
"rotate":0,
|
||||
"scale_x":1,
|
||||
"scale_y":1,
|
||||
"translate_x":0,
|
||||
"translate_y":0
|
||||
}
|
||||
},
|
||||
{
|
||||
"icon": "mirror",
|
||||
"name": "mirror",
|
||||
"parameters": {
|
||||
"direction": 0,
|
||||
"offset": 0
|
||||
},
|
||||
"tree_item": "Transform/Mirror",
|
||||
"type": "mirror"
|
||||
},
|
||||
{
|
||||
"icon": "kaleidoscope",
|
||||
"name": "kaleidoscope",
|
||||
"parameters": {
|
||||
"count": 5,
|
||||
"direction": 0,
|
||||
"offset": 0
|
||||
},
|
||||
"tree_item": "Transform/Kaleidoscope",
|
||||
"type": "kaleidoscope"
|
||||
},
|
||||
{
|
||||
"icon": "warp",
|
||||
"tree_item":"Transform/Warp",
|
||||
"type":"warp",
|
||||
"parameters":{
|
||||
"amount":0.5
|
||||
}
|
||||
},
|
||||
{
|
||||
"tree_item":"Miscellaneous/Buffer",
|
||||
"type":"buffer"
|
||||
},
|
||||
{
|
||||
"tree_item":"Miscellaneous/Custom Shader",
|
||||
"type":"custom",
|
||||
"shader_model":{}
|
||||
},
|
||||
{
|
||||
"tree_item":"Miscellaneous/Switch",
|
||||
"type":"switch"
|
||||
},
|
||||
{
|
||||
"tree_item":"Miscellaneous/Custom",
|
||||
"type":"custom",
|
||||
"shader_model":{}
|
||||
},
|
||||
{
|
||||
"tree_item":"Miscellaneous/Remote",
|
||||
"type":"remote",
|
||||
"widgets":[]
|
||||
},
|
||||
{
|
||||
"tree_item":"Miscellaneous/Comment",
|
||||
"type":"comment"
|
||||
}
|
||||
]}
|
BIN
addons/material_maker/library/base/blend.png
Normal file
After Width: | Height: | Size: 371 B |
BIN
addons/material_maker/library/base/colorize.png
Normal file
After Width: | Height: | Size: 282 B |
BIN
addons/material_maker/library/base/curved_star.png
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
addons/material_maker/library/base/kaleidoscope.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
addons/material_maker/library/base/mirror.png
Normal file
After Width: | Height: | Size: 9.9 KiB |
BIN
addons/material_maker/library/base/normal_map.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
addons/material_maker/library/base/polygon.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
addons/material_maker/library/base/rainbow.png
Normal file
After Width: | Height: | Size: 542 B |
BIN
addons/material_maker/library/base/rays.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
BIN
addons/material_maker/library/base/runes.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
addons/material_maker/library/base/star.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
addons/material_maker/library/base/transform.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
addons/material_maker/library/base/truchet.png
Normal file
After Width: | Height: | Size: 607 B |
BIN
addons/material_maker/library/base/warp.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
addons/material_maker/library/base/weave.png
Normal file
After Width: | Height: | Size: 416 B |
@ -278,6 +278,7 @@ func add_to_user_library():
|
||||
var selected_nodes = get_selected_nodes()
|
||||
if !selected_nodes.empty():
|
||||
var dialog = preload("res://addons/material_maker/widgets/line_dialog.tscn").instance()
|
||||
dialog.set_value(library.get_selected_item_name())
|
||||
dialog.set_texts("New library element", "Select a name for the new library element")
|
||||
add_child(dialog)
|
||||
dialog.connect("ok", self, "do_add_to_user_library", [ selected_nodes ])
|
||||
@ -296,12 +297,12 @@ func do_add_to_user_library(name, nodes):
|
||||
dir.make_dir("user://library/user")
|
||||
data.library = "user://library/user.json"
|
||||
data.icon = name.right(name.rfind("/")+1).to_lower()
|
||||
library.add_item(data, name)
|
||||
var result = nodes[0].generator.render(0, renderer, 64)
|
||||
while result is GDScriptFunctionState:
|
||||
result = yield(result, "completed")
|
||||
result.save_to_file("user://library/user/"+data.icon+".png")
|
||||
result.release()
|
||||
library.add_item(data, name, library.get_preview_texture(data))
|
||||
|
||||
func save_user_library():
|
||||
print("Saving user library")
|
||||
|
1
addons/material_maker/nodes/truchet.mmg
Normal file
@ -0,0 +1 @@
|
||||
{"name":"truchet","node_position":{"x":0,"y":0},"parameters":{"Size":4,"shape":1,"size":4,"type":1},"shader_model":{"code":"","global":"float truchet1(vec2 uv, vec2 seed) {\n vec2 i = floor(uv);\n vec2 f = fract(uv)-vec2(0.5);\n return 1.0-abs(abs((2.0*step(rand(i+seed), 0.5)-1.0)*f.x+f.y)-0.5);\n}\n\nfloat truchet2(vec2 uv, vec2 seed) {\n vec2 i = floor(uv);\n vec2 f = fract(uv);\n float random = step(rand(i+seed), 0.5);\n f.x *= 2.0*random-1.0;\n f.x += 1.0-random;\n return 1.0-min(abs(length(f)-0.5), abs(length(1.0-f)-0.5));\n}\n","inputs":[],"instance":"","name":"Truchet","outputs":[{"f":"truchet$shape($uv*$size, vec2($seed, $seed))","type":"f"}],"parameters":[{"default":0,"label":"Shape","name":"shape","type":"enum","values":[{"name":"Line","value":"1"},{"name":"Circle","value":"2"}]},{"default":4,"label":"Size","max":64,"min":2,"name":"size","step":1,"type":"float","widget":"spinbox"}]},"type":"shader"}
|
@ -32,7 +32,7 @@ shader = SubResource( 3 )
|
||||
[node name="Control" type="Control"]
|
||||
margin_right = 120.0
|
||||
margin_bottom = 30.0
|
||||
rect_min_size = Vector2( 120, 30 )
|
||||
rect_min_size = Vector2( 120, 32 )
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Background" type="ColorRect" parent="."]
|
||||
|
@ -3,8 +3,8 @@ extends WindowDialog
|
||||
|
||||
signal ok
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
func set_value(v):
|
||||
$VBoxContainer/LineEdit.text = v
|
||||
|
||||
func set_texts(title, label):
|
||||
window_title = title
|
||||
|