Merge branch 'master' into dev-optimize

This commit is contained in:
RodZill4 2020-03-20 07:49:57 +01:00
commit fcfdcef286
18 changed files with 70 additions and 41 deletions

View File

@ -42,6 +42,10 @@ func get_type() -> String:
func get_type_name() -> String:
return label
func set_type_name(l) -> void:
if l !=label:
label = l
emit_hierarchy_changed()
func toggle_editable() -> bool:
editable = !editable

View File

@ -299,7 +299,7 @@ func create_file_from_template(template : String, file_name : String, export_con
var in_file = File.new()
var out_file = File.new()
if in_file.open(mm_loader.STD_GENDEF_PATH+"/"+template, File.READ) != OK:
if in_file.open(OS.get_executable_path().get_base_dir()+"/generators/"+template, File.READ) != OK:
if in_file.open(OS.get_executable_path().get_base_dir()+"/nodes/"+template, File.READ) != OK:
print("Cannot find template file "+template)
return false
Directory.new().remove(file_name)

View File

@ -79,7 +79,7 @@
{
"control": "None",
"default": 0.5,
"label": "Persistance",
"label": "Persistence",
"max": 1,
"min": 0,
"name": "persistence",

View File

@ -52,7 +52,7 @@
},
{
"default": 0.5,
"label": "Persistance",
"label": "Persistence",
"max": 1,
"min": 0,
"name": "persistence",

View File

@ -54,7 +54,7 @@
},
{
"default": 0.5,
"label": "Persistance",
"label": "Persistence",
"max": 1,
"min": 0,
"name": "persistence",

View File

@ -5,12 +5,12 @@
"y": 0
},
"parameters": {
"amount": 1,
"blend_type": 1
"amount": 0,
"blend_type": 8
},
"shader_model": {
"code": "",
"global": "vec3 blend3d_normal(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1 + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_multiply(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1*c2 + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_screen(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*(1.0-(1.0-c1)*(1.0-c2)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_overlay_f(float c1, float c2) {\n\treturn (c1 < 0.5) ? (2.0*c1*c2) : (1.0-2.0*(1.0-c1)*(1.0-c2));\n}\n\nvec3 blend3d_overlay(vec3 c1, vec3 c2, float opacity) {\n\treturn 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}\n\nvec3 blend3d_hard_light(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*0.5*(c1*c2+blend3d_overlay(c1, c2, 1.0)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_soft_light_f(float c1, float c2) {\n\treturn (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}\n\nvec3 blend3d_soft_light(vec3 c1, vec3 c2, float opacity) {\n\treturn 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}\n\nfloat blend3d_burn_f(float c1, float c2) {\n\treturn (c1==0.0)?c1:max((1.0-((1.0-c2)/c1)),0.0);\n}\n\nvec3 blend3d_burn(vec3 c1, vec3 c2, float opacity) {\n\treturn 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}\n\nfloat blend3d_dodge_f(float c1, float c2) {\n\treturn (c1==1.0)?c1:min(c2/(1.0-c1),1.0);\n}\n\nvec3 blend3d_dodge(vec3 c1, vec3 c2, float opacity) {\n\treturn 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}\n\nvec3 blend3d_lighten(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*max(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_darken(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*min(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_difference(vec2 uv, vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*clamp(c2-c1, vec3(0.0), vec3(1.0)) + (1.0-opacity)*c2;\n}\n",
"global": "vec3 blend3d_normal(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1 + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_multiply(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*c1*c2 + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_screen(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*(1.0-(1.0-c1)*(1.0-c2)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_overlay_f(float c1, float c2) {\n\treturn (c1 < 0.5) ? (2.0*c1*c2) : (1.0-2.0*(1.0-c1)*(1.0-c2));\n}\n\nvec3 blend3d_overlay(vec3 c1, vec3 c2, float opacity) {\n\treturn 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}\n\nvec3 blend3d_hard_light(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*0.5*(c1*c2+blend3d_overlay(c1, c2, 1.0)) + (1.0-opacity)*c2;\n}\n\nfloat blend3d_soft_light_f(float c1, float c2) {\n\treturn (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}\n\nvec3 blend3d_soft_light(vec3 c1, vec3 c2, float opacity) {\n\treturn 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}\n\nfloat blend3d_burn_f(float c1, float c2) {\n\treturn (c1==0.0)?c1:max((1.0-((1.0-c2)/c1)),0.0);\n}\n\nvec3 blend3d_burn(vec3 c1, vec3 c2, float opacity) {\n\treturn 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}\n\nfloat blend3d_dodge_f(float c1, float c2) {\n\treturn (c1==1.0)?c1:min(c2/(1.0-c1),1.0);\n}\n\nvec3 blend3d_dodge(vec3 c1, vec3 c2, float opacity) {\n\treturn 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}\n\nvec3 blend3d_lighten(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*max(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_darken(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*min(c1, c2) + (1.0-opacity)*c2;\n}\n\nvec3 blend3d_difference(vec3 c1, vec3 c2, float opacity) {\n\treturn opacity*clamp(c2-c1, vec3(0.0), vec3(1.0)) + (1.0-opacity)*c2;\n}\n",
"inputs": [
{
"default": "vec3($uv.x, 1.0, 1.0)",

View File

@ -90,7 +90,7 @@
{
"control": "None",
"default": 0.5,
"label": "Persistance",
"label": "Persistence",
"max": 1,
"min": 0,
"name": "persistence",

File diff suppressed because one or more lines are too long

View File

@ -352,7 +352,7 @@ func on_ButtonUp_pressed() -> void:
call_deferred("update_view", generator.get_parent())
func _on_Label_text_changed(new_text) -> void:
generator.label = new_text
generator.set_type_name(new_text)
# Create subgraph
@ -393,7 +393,7 @@ func set_last_selected(node) -> void:
func _on_GraphEdit_gui_input(event) -> void:
if event.is_action_pressed("ui_library_popup") && get_rect().has_point(get_local_mouse_position()):
node_popup.rect_global_position = get_global_mouse_position()
node_popup.show()
node_popup.show_popup()
if event is InputEventMouseButton:
call_deferred("check_last_selected")
@ -408,7 +408,7 @@ func request_popup(from, from_slot, release_position) -> void:
else:
# Request the popup
node_popup.rect_global_position = get_global_mouse_position()
node_popup.show()
node_popup.show_popup(mm_io_types.types[node.generator.get_output_defs()[from_slot].type].slot_type)
node_popup.set_quick_connect(from, from_slot)
func check_last_selected() -> void:

View File

@ -132,6 +132,7 @@ func _ready() -> void:
library = layout.get_pane("Library")
preview_2d = layout.get_pane("Preview2D")
preview_3d = layout.get_pane("Preview3D")
preview_3d.connect("need_update", self, "update_preview_3d")
hierarchy = layout.get_pane("Hierarchy")
hierarchy.connect("group_selected", self, "on_group_selected")

View File

@ -17,13 +17,13 @@
<url type="bugtracker">https://github.com/RodZill4/godot-procedural-textures/issues</url>
<screenshots>
<screenshot type="default">
<image type="source">https://raw.githubusercontent.com/RodZill4/godot-procedural-textures/master/addons/material_maker/doc/images/screenshot.png</image>
<image type="source" width="1282" height="752">https://raw.githubusercontent.com/RodZill4/material-maker/master/material_maker/doc/images/screenshot.png</image>
<caption>Editing a procedurally generated texture</caption>
</screenshot>
</screenshots>
<content_rating type="oars-1.1"/>
<releases>
<release version="0.6" date="2019-10-13"/>
<release version="0.9" date="2020-03-15"/>
</releases>
<update_contact>hugo.locurcio@hugo.pro</update_contact>
</component>

View File

@ -5,7 +5,7 @@ func set_generator(g) -> void:
generator.connect("parameter_changed", self, "on_parameter_changed")
update_node()
func on_parameter_changed(p, v) -> void:
func on_parameter_changed(p, _v) -> void:
if p == "__update_all__":
call_deferred("update_node")

View File

@ -6,7 +6,6 @@ var links = {}
onready var grid = $Controls
func add_control(text, control) -> void:
var index = grid.get_child_count() / 4
var label = preload("res://material_maker/widgets/linked_widgets/editable_label.tscn").instance()
label.set_text(text)
label.connect("label_changed", self, "on_label_changed", [ control.name ])

View File

@ -50,7 +50,9 @@ func _on_Rotate_toggled(button_pressed) -> void:
$MaterialPreview/Preview3d/ObjectRotate.stop(false)
func get_materials() -> Array:
if current_object != null:
return [ current_object.get_surface_material(0) ]
return []
func on_gui_input(event) -> void:
if event is InputEventMouseButton:

View File

@ -3,8 +3,6 @@
[ext_resource path="res://material_maker/preview/preview_3d_ui.gd" type="Script" id=1]
[ext_resource path="res://material_maker/icons/icons.svg" type="Texture" id=2]
[sub_resource type="AtlasTexture" id=1]
flags = 4
atlas = ExtResource( 2 )
@ -15,6 +13,9 @@ anchor_right = 1.0
margin_bottom = 20.0
size_flags_horizontal = 3
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Model" type="OptionButton" parent="."]
margin_right = 100.0
@ -26,7 +27,7 @@ selected = 0
[node name="Environment" type="OptionButton" parent="."]
margin_left = 104.0
margin_right = 231.0
margin_right = 219.0
margin_bottom = 22.0
rect_min_size = Vector2( 100, 0 )
text = "Epping Forest"
@ -34,8 +35,8 @@ items = [ "Epping Forest", null, false, 0, null, "Moonless Golf", null, false, 1
selected = 0
[node name="Rotate" type="Button" parent="."]
margin_left = 235.0
margin_right = 263.0
margin_left = 223.0
margin_right = 251.0
margin_bottom = 22.0
rect_pivot_offset = Vector2( -4, 7 )
hint_tooltip = "Rotate object"

View File

@ -4,6 +4,7 @@ var libraries = []
var data = []
onready var itemlist : ItemList = $PanelContainer/VBoxContainer/ItemList
onready var filter_line_edit : LineEdit = $PanelContainer/VBoxContainer/Filter
var quick_connect : int = -1
var insert_position : Vector2
func get_current_graph():
@ -29,7 +30,7 @@ func add_node(data) -> void:
if quick_connect_node != null:
var type = quick_connect_node.get_connection_output_type(quick_connect_slot)
for new_slot in node.get_connection_input_count():
if type == node.get_connection_input_type(new_slot):
#if type == node.get_connection_input_type(new_slot):
#connect the first two slots with the same type
get_current_graph().connect_node(quick_connect_node.name, quick_connect_slot, node.name, new_slot)
break
@ -59,8 +60,9 @@ func hide() -> void:
clear()
func show() -> void:
.show()
func show_popup(qc : int = -1) -> void:
show()
quick_connect = qc
update_list()
filter_line_edit.grab_focus()
var parent_rect = get_parent().get_parent().get_global_rect()
@ -76,6 +78,28 @@ func update_list(filter : String = "") -> void:
for obj in library:
if !obj.has("type"):
continue
if quick_connect != -1:
var ref_obj = obj
if mm_loader.predefined_generators.has(obj.type):
ref_obj = mm_loader.predefined_generators[obj.type]
if ref_obj.has("shader_model"):
if ! ref_obj.shader_model.has("inputs") or ref_obj.shader_model.inputs.empty():
continue
elif mm_io_types.types[ref_obj.shader_model.inputs[0].type].slot_type != quick_connect:
continue
elif ref_obj.has("nodes"):
var input_ports = []
for n in ref_obj.nodes:
if n.name == "gen_inputs":
if input_ports.has("ports"):
input_ports = n.ports
break
if input_ports.empty() or mm_io_types.types[input_ports[0].type].slot_type != quick_connect:
continue
elif ref_obj.type == "comment" or ref_obj.type == "image" or ref_obj.type == "remote":
continue
elif (ref_obj.type == "convolution" or ref_obj.type == "debug" or ref_obj.type == "buffer" or ref_obj.type == "export" ) and quick_connect != 0:
continue
var show : bool = true
for f in filter.to_lower().split(" ", false):
if f != "" && obj.tree_item.to_lower().find(f) == -1:

View File

@ -3,7 +3,7 @@
[ext_resource path="res://material_maker/widgets/add_node_popup.gd" type="Script" id=1]
[node name="AddNodePopup" type="Popup"]
margin_right = 228.0
margin_right = 275.0
margin_bottom = 319.0
mouse_filter = 1
script = ExtResource( 1 )

View File

@ -78,18 +78,16 @@ rect_min_size = Vector2( 112, 17 )
mouse_filter = 2
theme = SubResource( 5 )
[node name="Popup" type="Popup" parent="Gradient"]
margin_left = 47.0
margin_top = 33.0
margin_right = 353.0
margin_bottom = 475.0
[node name="Popup" type="PopupPanel" parent="Gradient"]
visible = true
margin_right = 318.0
margin_bottom = 470.0
[node name="ColorPicker" type="ColorPicker" parent="Gradient/Popup"]
margin_left = 4.0
margin_top = 4.0
margin_right = 4.0
margin_bottom = 4.0
rect_scale = Vector2( 0.75, 0.75 )
margin_right = 314.0
margin_bottom = 466.0
[node name="Interpolation" type="OptionButton" parent="."]
margin_left = 0.418457