From 3bb9dd50db97f08aba1ee22da90c6da01aed8adf Mon Sep 17 00:00:00 2001 From: RodZill4 Date: Mon, 19 Nov 2018 23:09:22 +0100 Subject: [PATCH] Generic node updates - Added support for inputs and alternate syntax for parameters ($foo instead of $(foo)) - Added support for default input values ($uv can be used for non uniform defaults) --- addons/material_maker/examples/bricks.ptex | 2 +- .../examples/wood_with_blood.ptex | 2 +- .../material_maker/examples/wooden_floor.ptex | 2 +- addons/material_maker/nodes/adjust_hsv.mmn | 2 +- addons/material_maker/nodes/node_generic.gd | 89 ++++++++++++------- .../widgets/node_editor/input.tscn | 4 +- 6 files changed, 61 insertions(+), 40 deletions(-) diff --git a/addons/material_maker/examples/bricks.ptex b/addons/material_maker/examples/bricks.ptex index df2ab25..2aabb7c 100644 --- a/addons/material_maker/examples/bricks.ptex +++ b/addons/material_maker/examples/bricks.ptex @@ -1 +1 @@ -{"connections":[{"from":"Perlin","from_port":0,"to":"Warp","to_port":1},{"from":"Warp","from_port":0,"to":"colorize_2","to_port":0},{"from":"colorize_2","from_port":0,"to":"blend_0","to_port":2},{"from":"colorize_0","from_port":0,"to":"blend_0","to_port":1},{"from":"blend_0","from_port":0,"to":"Material","to_port":0},{"from":"colorize_2","from_port":0,"to":"colorize_4","to_port":0},{"from":"colorize_4","from_port":0,"to":"Material","to_port":2},{"from":"blend_1","from_port":0,"to":"colorize_1","to_port":0},{"from":"Warp","from_port":0,"to":"blend_2","to_port":0},{"from":"Perlin","from_port":0,"to":"blend_2","to_port":1},{"from":"blend_2","from_port":0,"to":"colorize_3","to_port":0},{"from":"blend_2","from_port":0,"to":"colorize_6","to_port":0},{"from":"Perlin","from_port":0,"to":"blend_1","to_port":0},{"from":"Perlin","from_port":0,"to":"colorize_0","to_port":0},{"from":"uniform_0","from_port":0,"to":"Material","to_port":1},{"from":"colorize_3","from_port":0,"to":"Material","to_port":5},{"from":"uniform_0","from_port":0,"to":"combine_0","to_port":0},{"from":"colorize_4","from_port":0,"to":"combine_0","to_port":1},{"from":"combine_0","from_port":0,"to":"export_0","to_port":0},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"from":"colorize_6","from_port":0,"to":"normal_map_0","to_port":0},{"from":"colorize_1","from_port":0,"to":"adjust_hsv_0","to_port":0},{"from":"adjust_hsv_0","from_port":0,"to":"blend_0","to_port":0},{"from":"switch_0","from_port":0,"to":"Warp","to_port":0},{"from":"switch_0","from_port":1,"to":"blend_1","to_port":1},{"from":"Bricks","from_port":0,"to":"switch_0","to_port":0},{"from":"voronoi_0","from_port":2,"to":"switch_0","to_port":3},{"from":"voronoi_0","from_port":1,"to":"colorize_5","to_port":0},{"from":"colorize_5","from_port":0,"to":"switch_0","to_port":2},{"from":"Bricks","from_port":1,"to":"switch_0","to_port":1}],"nodes":[{"name":"colorize_0","node_position":{"x":560.943665,"y":50},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":0},{"a":1,"b":1,"g":1,"pos":1,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"Material","node_position":{"x":1081,"y":208},"parameters":{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":0,"emission_energy":1,"metallic":1,"normal_scale":1,"resolution":1,"roughness":1},"type":"material"},{"name":"blend_2","node_position":{"x":536,"y":331},"parameters":{"amount":0.5,"blend_type":0},"type":"blend"},{"name":"blend_0","node_position":{"x":836.943726,"y":-71},"parameters":{"amount":0.5,"blend_type":0},"type":"blend"},{"name":"colorize_2","node_position":{"x":544.943665,"y":159},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":0},{"a":1,"b":1,"g":1,"pos":0.1,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"uniform_0","node_position":{"x":764,"y":164},"parameters":{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"}},"type":"uniform"},{"name":"combine_0","node_position":{"x":896,"y":86},"parameters":{},"type":"combine"},{"name":"export_0","node_position":{"x":1050,"y":79},"parameters":{"resolution":1},"suffix":"mr","type":"export"},{"name":"colorize_4","node_position":{"x":711,"y":215},"parameters":{"gradient":{"points":[{"a":1,"b":1,"g":1,"pos":0,"r":1},{"a":1,"b":0.546875,"g":0.546875,"pos":1,"r":0.546875}],"type":"Gradient"}},"type":"colorize"},{"name":"colorize_6","node_position":{"x":708,"y":289},"parameters":{"gradient":{"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":"colorize_3","node_position":{"x":711,"y":361},"parameters":{"gradient":{"points":[{"a":1,"b":0.838542,"g":0.838542,"pos":0.145455,"r":0.838542},{"a":1,"b":1,"g":1,"pos":0.536364,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"normal_map_0","node_position":{"x":881.045654,"y":309.691162},"parameters":{"amount":0.35,"size":4},"type":"normal_map"},{"name":"adjust_hsv_0","node_position":{"x":583.224792,"y":-74.268188},"parameters":{"hue":0,"saturation":1,"value":1},"type":"adjust_hsv"},{"name":"colorize_1","node_position":{"x":406.943665,"y":-80},"parameters":{"gradient":{"points":[{"a":1,"b":0.0016,"g":0.0016,"pos":0,"r":0.307292},{"a":1,"b":0,"g":0.180135,"pos":0.2,"r":0.606771},{"a":1,"b":0,"g":0,"pos":0.345455,"r":0.3125},{"a":1,"b":0,"g":0.19869,"pos":0.545455,"r":0.669271},{"a":1,"b":0.019368,"g":0.060224,"pos":0.745455,"r":0.309896},{"a":1,"b":0,"g":0.180135,"pos":1,"r":0.606771}],"type":"Gradient"}},"type":"colorize"},{"name":"blend_1","node_position":{"x":316,"y":217},"parameters":{"amount":0.5,"blend_type":6},"type":"blend"},{"name":"Perlin","node_position":{"x":32,"y":238},"parameters":{"iterations":6,"persistence":0.85,"scale_x":4,"scale_y":4},"type":"perlin"},{"name":"colorize_5","node_position":{"x":-135.515076,"y":101.237671},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0.027273,"r":0},{"a":1,"b":1,"g":1,"pos":0.2,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"Warp","node_position":{"x":306,"y":55.75},"parameters":{"amount":0.04},"type":"warp"},{"editable":true,"node_position":{"x":107.669189,"y":-338.657043},"type":"remote","widgets":[{"configurations":{"Basket weave":[{"node":"Bricks","value":3,"widget":"pattern"},{"node":"Bricks","value":2,"widget":"repeat"},{"node":"Bricks","value":2,"widget":"rows"},{"node":"Bricks","value":2,"widget":"columns"},{"node":"switch_0","value":0,"widget":"source"},{"node":"voronoi_0","value":8,"widget":"scale_x"},{"node":"voronoi_0","value":8,"widget":"scale_y"}],"Herring bone":[{"node":"Bricks","value":2,"widget":"pattern"},{"node":"Bricks","value":2,"widget":"repeat"},{"node":"Bricks","value":2,"widget":"rows"},{"node":"Bricks","value":2,"widget":"columns"},{"node":"switch_0","value":0,"widget":"source"},{"node":"voronoi_0","value":8,"widget":"scale_x"},{"node":"voronoi_0","value":8,"widget":"scale_y"}],"Running bond 1":[{"node":"Bricks","value":0,"widget":"pattern"},{"node":"Bricks","value":1,"widget":"repeat"},{"node":"Bricks","value":8,"widget":"rows"},{"node":"Bricks","value":4,"widget":"columns"},{"node":"switch_0","value":0,"widget":"source"},{"node":"voronoi_0","value":8,"widget":"scale_x"},{"node":"voronoi_0","value":8,"widget":"scale_y"}],"Running bond 2":[{"node":"Bricks","value":1,"widget":"pattern"},{"node":"Bricks","value":1,"widget":"repeat"},{"node":"Bricks","value":8,"widget":"rows"},{"node":"Bricks","value":4,"widget":"columns"},{"node":"switch_0","value":0,"widget":"source"},{"node":"voronoi_0","value":8,"widget":"scale_x"},{"node":"voronoi_0","value":8,"widget":"scale_y"}],"Spanish bond":[{"node":"Bricks","value":4,"widget":"pattern"},{"node":"Bricks","value":3,"widget":"repeat"},{"node":"Bricks","value":2,"widget":"rows"},{"node":"Bricks","value":2,"widget":"columns"},{"node":"switch_0","value":0,"widget":"source"},{"node":"voronoi_0","value":8,"widget":"scale_x"},{"node":"voronoi_0","value":8,"widget":"scale_y"}],"Uneven":[{"node":"Bricks","value":3,"widget":"pattern"},{"node":"Bricks","value":2,"widget":"repeat"},{"node":"Bricks","value":2,"widget":"rows"},{"node":"Bricks","value":2,"widget":"columns"},{"node":"switch_0","value":1,"widget":"source"},{"node":"voronoi_0","value":8,"widget":"scale_x"},{"node":"voronoi_0","value":8,"widget":"scale_y"}]},"label":"Pattern","linked_widgets":[{"node":"Bricks","widget":"pattern"},{"node":"Bricks","widget":"repeat"},{"node":"Bricks","widget":"rows"},{"node":"Bricks","widget":"columns"},{"node":"switch_0","widget":"source"},{"node":"voronoi_0","widget":"scale_x"},{"node":"voronoi_0","widget":"scale_y"}],"type":"config_control"},{"label":"Hue","linked_widgets":[{"node":"adjust_hsv_0","widget":"hue"}],"type":"linked_control"},{"label":"Saturation","linked_widgets":[{"node":"adjust_hsv_0","widget":"saturation"}],"type":"linked_control"},{"label":"Value","linked_widgets":[{"node":"adjust_hsv_0","widget":"value"}],"type":"linked_control"}]},{"name":"Bricks","node_position":{"x":-233,"y":-131},"parameters":{"bevel":0.2,"columns":2,"mortar":0.05,"pattern":3,"repeat":2,"row_offset":0.5,"rows":2},"type":"bricks"},{"name":"voronoi_0","node_position":{"x":-339.515076,"y":139.237671},"parameters":{"intensity":1,"scale_x":8,"scale_y":8},"type":"voronoi"},{"name":"switch_0","node_position":{"x":113.484924,"y":70.237671},"parameters":{"source":0},"type":"switch"}]} \ No newline at end of file +{"connections":[{"from":"Perlin","from_port":0,"to":"Warp","to_port":1},{"from":"Warp","from_port":0,"to":"colorize_2","to_port":0},{"from":"colorize_2","from_port":0,"to":"blend_0","to_port":2},{"from":"colorize_0","from_port":0,"to":"blend_0","to_port":1},{"from":"blend_0","from_port":0,"to":"Material","to_port":0},{"from":"colorize_2","from_port":0,"to":"colorize_4","to_port":0},{"from":"colorize_4","from_port":0,"to":"Material","to_port":2},{"from":"blend_1","from_port":0,"to":"colorize_1","to_port":0},{"from":"Warp","from_port":0,"to":"blend_2","to_port":0},{"from":"Perlin","from_port":0,"to":"blend_2","to_port":1},{"from":"blend_2","from_port":0,"to":"colorize_3","to_port":0},{"from":"blend_2","from_port":0,"to":"colorize_6","to_port":0},{"from":"Perlin","from_port":0,"to":"blend_1","to_port":0},{"from":"Perlin","from_port":0,"to":"colorize_0","to_port":0},{"from":"uniform_0","from_port":0,"to":"Material","to_port":1},{"from":"colorize_3","from_port":0,"to":"Material","to_port":5},{"from":"uniform_0","from_port":0,"to":"combine_0","to_port":0},{"from":"colorize_4","from_port":0,"to":"combine_0","to_port":1},{"from":"combine_0","from_port":0,"to":"export_0","to_port":0},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"from":"colorize_6","from_port":0,"to":"normal_map_0","to_port":0},{"from":"colorize_1","from_port":0,"to":"adjust_hsv_0","to_port":0},{"from":"adjust_hsv_0","from_port":0,"to":"blend_0","to_port":0},{"from":"switch_0","from_port":0,"to":"Warp","to_port":0},{"from":"switch_0","from_port":1,"to":"blend_1","to_port":1},{"from":"Bricks","from_port":0,"to":"switch_0","to_port":0},{"from":"voronoi_0","from_port":2,"to":"switch_0","to_port":3},{"from":"voronoi_0","from_port":1,"to":"colorize_5","to_port":0},{"from":"colorize_5","from_port":0,"to":"switch_0","to_port":2},{"from":"Bricks","from_port":1,"to":"switch_0","to_port":1}],"nodes":[{"name":"colorize_0","node_position":{"x":560.943665,"y":50},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":0},{"a":1,"b":1,"g":1,"pos":1,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"Material","node_position":{"x":1081,"y":208},"parameters":{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":0,"emission_energy":1,"metallic":1,"normal_scale":1,"resolution":1,"roughness":1},"type":"material"},{"name":"blend_2","node_position":{"x":536,"y":331},"parameters":{"amount":0.5,"blend_type":0},"type":"blend"},{"name":"blend_0","node_position":{"x":836.943726,"y":-71},"parameters":{"amount":0.5,"blend_type":0},"type":"blend"},{"name":"colorize_2","node_position":{"x":544.943665,"y":159},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":0},{"a":1,"b":1,"g":1,"pos":0.1,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"uniform_0","node_position":{"x":764,"y":164},"parameters":{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"}},"type":"uniform"},{"name":"combine_0","node_position":{"x":896,"y":86},"parameters":{},"type":"combine"},{"name":"export_0","node_position":{"x":1050,"y":79},"parameters":{"resolution":1},"suffix":"mr","type":"export"},{"name":"colorize_4","node_position":{"x":711,"y":215},"parameters":{"gradient":{"points":[{"a":1,"b":1,"g":1,"pos":0,"r":1},{"a":1,"b":0.703125,"g":0.703125,"pos":1,"r":0.703125}],"type":"Gradient"}},"type":"colorize"},{"name":"colorize_6","node_position":{"x":708,"y":289},"parameters":{"gradient":{"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":"colorize_3","node_position":{"x":711,"y":361},"parameters":{"gradient":{"points":[{"a":1,"b":0.838542,"g":0.838542,"pos":0.145455,"r":0.838542},{"a":1,"b":1,"g":1,"pos":0.536364,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"normal_map_0","node_position":{"x":881.045654,"y":309.691162},"parameters":{"amount":0.35,"size":4},"type":"normal_map"},{"name":"colorize_1","node_position":{"x":406.943665,"y":-80},"parameters":{"gradient":{"points":[{"a":1,"b":0.0016,"g":0.0016,"pos":0,"r":0.307292},{"a":1,"b":0,"g":0.180135,"pos":0.2,"r":0.606771},{"a":1,"b":0,"g":0,"pos":0.345455,"r":0.3125},{"a":1,"b":0,"g":0.19869,"pos":0.545455,"r":0.669271},{"a":1,"b":0.019368,"g":0.060224,"pos":0.745455,"r":0.309896},{"a":1,"b":0,"g":0.180135,"pos":1,"r":0.606771}],"type":"Gradient"}},"type":"colorize"},{"name":"blend_1","node_position":{"x":316,"y":217},"parameters":{"amount":0.5,"blend_type":6},"type":"blend"},{"name":"Perlin","node_position":{"x":32,"y":238},"parameters":{"iterations":6,"persistence":0.85,"scale_x":4,"scale_y":4},"type":"perlin"},{"name":"colorize_5","node_position":{"x":-135.515076,"y":101.237671},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0.027273,"r":0},{"a":1,"b":1,"g":1,"pos":0.2,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"Warp","node_position":{"x":306,"y":55.75},"parameters":{"amount":0.04},"type":"warp"},{"editable":true,"node_position":{"x":107.669189,"y":-338.657043},"type":"remote","widgets":[{"configurations":{"Basket weave":[{"node":"Bricks","value":3,"widget":"pattern"},{"node":"Bricks","value":2,"widget":"repeat"},{"node":"Bricks","value":2,"widget":"rows"},{"node":"Bricks","value":2,"widget":"columns"},{"node":"switch_0","value":0,"widget":"source"},{"node":"voronoi_0","value":8,"widget":"scale_x"},{"node":"voronoi_0","value":8,"widget":"scale_y"}],"Herring bone":[{"node":"Bricks","value":2,"widget":"pattern"},{"node":"Bricks","value":2,"widget":"repeat"},{"node":"Bricks","value":2,"widget":"rows"},{"node":"Bricks","value":2,"widget":"columns"},{"node":"switch_0","value":0,"widget":"source"},{"node":"voronoi_0","value":8,"widget":"scale_x"},{"node":"voronoi_0","value":8,"widget":"scale_y"}],"Running bond 1":[{"node":"Bricks","value":0,"widget":"pattern"},{"node":"Bricks","value":1,"widget":"repeat"},{"node":"Bricks","value":8,"widget":"rows"},{"node":"Bricks","value":4,"widget":"columns"},{"node":"switch_0","value":0,"widget":"source"},{"node":"voronoi_0","value":8,"widget":"scale_x"},{"node":"voronoi_0","value":8,"widget":"scale_y"}],"Running bond 2":[{"node":"Bricks","value":1,"widget":"pattern"},{"node":"Bricks","value":1,"widget":"repeat"},{"node":"Bricks","value":8,"widget":"rows"},{"node":"Bricks","value":4,"widget":"columns"},{"node":"switch_0","value":0,"widget":"source"},{"node":"voronoi_0","value":8,"widget":"scale_x"},{"node":"voronoi_0","value":8,"widget":"scale_y"}],"Spanish bond":[{"node":"Bricks","value":4,"widget":"pattern"},{"node":"Bricks","value":3,"widget":"repeat"},{"node":"Bricks","value":2,"widget":"rows"},{"node":"Bricks","value":2,"widget":"columns"},{"node":"switch_0","value":0,"widget":"source"},{"node":"voronoi_0","value":8,"widget":"scale_x"},{"node":"voronoi_0","value":8,"widget":"scale_y"}],"Uneven":[{"node":"Bricks","value":3,"widget":"pattern"},{"node":"Bricks","value":2,"widget":"repeat"},{"node":"Bricks","value":2,"widget":"rows"},{"node":"Bricks","value":2,"widget":"columns"},{"node":"switch_0","value":1,"widget":"source"},{"node":"voronoi_0","value":8,"widget":"scale_x"},{"node":"voronoi_0","value":8,"widget":"scale_y"}]},"label":"Pattern","linked_widgets":[{"node":"Bricks","widget":"pattern"},{"node":"Bricks","widget":"repeat"},{"node":"Bricks","widget":"rows"},{"node":"Bricks","widget":"columns"},{"node":"switch_0","widget":"source"},{"node":"voronoi_0","widget":"scale_x"},{"node":"voronoi_0","widget":"scale_y"}],"type":"config_control"},{"label":"Hue","linked_widgets":[{"node":"adjust_hsv_0","widget":"hue"}],"type":"linked_control"},{"label":"Saturation","linked_widgets":[{"node":"adjust_hsv_0","widget":"saturation"}],"type":"linked_control"},{"label":"Value","linked_widgets":[{"node":"adjust_hsv_0","widget":"value"}],"type":"linked_control"}]},{"name":"Bricks","node_position":{"x":-233,"y":-131},"parameters":{"bevel":0.2,"columns":2,"mortar":0.05,"pattern":3,"repeat":2,"row_offset":0.5,"rows":2},"type":"bricks"},{"name":"voronoi_0","node_position":{"x":-339.515076,"y":139.237671},"parameters":{"intensity":1,"scale_x":8,"scale_y":8},"type":"voronoi"},{"name":"switch_0","node_position":{"x":113.484924,"y":70.237671},"parameters":{"source":0},"type":"switch"},{"name":"adjust_hsv_0","node_position":{"x":590.224792,"y":-74.268188},"parameters":{"hue":0,"saturation":1,"value":1},"type":"adjust_hsv"}]} \ No newline at end of file diff --git a/addons/material_maker/examples/wood_with_blood.ptex b/addons/material_maker/examples/wood_with_blood.ptex index f1d60c9..43d0f48 100644 --- a/addons/material_maker/examples/wood_with_blood.ptex +++ b/addons/material_maker/examples/wood_with_blood.ptex @@ -1 +1 @@ -{"connections":[{"from":"bricks_0","from_port":0,"to":"blend_0","to_port":0},{"from":"perlin_0","from_port":0,"to":"blend_0","to_port":1},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"from":"perlin_1","from_port":0,"to":"colorize_2","to_port":0},{"from":"colorize_0","from_port":0,"to":"blend_1","to_port":1},{"from":"perlin_2","from_port":0,"to":"colorize_3","to_port":0},{"from":"colorize_3","from_port":0,"to":"blend_1","to_port":2},{"from":"blend_1","from_port":0,"to":"Material","to_port":0},{"from":"colorize_3","from_port":0,"to":"blend_2","to_port":0},{"from":"blend_2","from_port":0,"to":"Material","to_port":2},{"from":"blend_0","from_port":0,"to":"colorize_0","to_port":0},{"from":"blend_0","from_port":0,"to":"colorize_5","to_port":0},{"from":"colorize_5","from_port":0,"to":"normal_map_0","to_port":0},{"from":"uniform_1","from_port":0,"to":"Material","to_port":1},{"from":"uniform_0","from_port":0,"to":"blend_2","to_port":1},{"from":"perlin_1","from_port":0,"to":"colorize_1","to_port":0},{"from":"combine_0","from_port":0,"to":"export_0","to_port":0},{"from":"uniform_1","from_port":0,"to":"combine_0","to_port":0},{"from":"blend_2","from_port":0,"to":"combine_0","to_port":1},{"from":"colorize_2","from_port":0,"to":"blend_1","to_port":0}],"nodes":[{"name":"Material","node_position":{"x":938,"y":96},"parameters":{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"normal_scale":1,"resolution":1,"roughness":1},"type":"material"},{"name":"colorize_3","node_position":{"x":487.633789,"y":65},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0.518182,"r":0},{"a":1,"b":1,"g":1,"pos":0.709091,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"bricks_0","node_position":{"x":-1,"y":30.5},"parameters":{"bevel":0,"columns":5,"mortar":0.02,"pattern":0,"repeat":1,"row_offset":0.5,"rows":1},"type":"bricks"},{"name":"colorize_0","node_position":{"x":472,"y":-41.5},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0.336914,"pos":0,"r":0.598958},{"a":1,"b":0,"g":0.454102,"pos":0.118182,"r":0.807292},{"a":1,"b":0,"g":0.37793,"pos":0.245455,"r":0.671875},{"a":1,"b":0,"g":0.427734,"pos":0.345455,"r":0.760417},{"a":1,"b":0.017795,"g":0.488254,"pos":0.527273,"r":0.854167},{"a":1,"b":0,"g":0.37793,"pos":0.645455,"r":0.671875},{"a":1,"b":0,"g":0.439453,"pos":0.845455,"r":0.78125},{"a":1,"b":0,"g":0.357422,"pos":1,"r":0.635417}],"type":"Gradient"}},"type":"colorize"},{"name":"perlin_1","node_position":{"x":110.633789,"y":-143.5},"parameters":{"iterations":7,"persistence":0.55,"scale_x":4,"scale_y":4},"type":"perlin"},{"name":"blend_2","node_position":{"x":690.633789,"y":201.5},"parameters":{"amount":0.4,"blend_type":0},"type":"blend"},{"name":"perlin_2","node_position":{"x":232.633789,"y":40},"parameters":{"iterations":6,"persistence":0.65,"scale_x":4,"scale_y":4},"type":"perlin"},{"name":"normal_map_0","node_position":{"x":724.633789,"y":345.5},"parameters":{"amount":0.15,"size":2},"type":"normal_map"},{"name":"blend_1","node_position":{"x":707.633789,"y":-68},"parameters":{"amount":0.5,"blend_type":0},"type":"blend"},{"name":"blend_0","node_position":{"x":271,"y":306.5},"parameters":{"amount":1,"blend_type":2},"type":"blend"},{"name":"colorize_5","node_position":{"x":503,"y":336.5},"parameters":{"gradient":{"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":"uniform_1","node_position":{"x":753,"y":116},"parameters":{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"}},"type":"uniform"},{"name":"uniform_0","node_position":{"x":540,"y":234},"parameters":{"color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"}},"type":"uniform"},{"name":"colorize_2","node_position":{"x":454.633789,"y":-189.5},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":0.515625},{"a":1,"b":0,"g":0,"pos":0.145455,"r":0.25},{"a":1,"b":0,"g":0,"pos":0.445455,"r":0.515625},{"a":1,"b":0.013184,"g":0.013184,"pos":0.745455,"r":0.28125},{"a":1,"b":0,"g":0,"pos":1,"r":0.322917}],"type":"Gradient"}},"type":"colorize"},{"name":"colorize_1","node_position":{"x":461.329102,"y":-116.699997},"parameters":{"gradient":{"points":[{"a":1,"b":0.034912,"g":0.129532,"pos":0,"r":0.203125},{"a":1,"b":0.038791,"g":0.074319,"pos":1,"r":0.114583}],"type":"Gradient"}},"type":"colorize"},{"name":"export_0","node_position":{"x":1090.329102,"y":-76.5},"parameters":{"resolution":1},"suffix":"mr","type":"export"},{"name":"combine_0","node_position":{"x":942.329102,"y":-55.5},"parameters":{},"type":"combine"},{"name":"perlin_0","node_position":{"x":12,"y":243.5},"parameters":{"iterations":6,"persistence":0.7,"scale_x":20,"scale_y":3},"type":"perlin"}]} \ No newline at end of file +{"connections":[{"from":"bricks_0","from_port":0,"to":"blend_0","to_port":0},{"from":"perlin_0","from_port":0,"to":"blend_0","to_port":1},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"from":"perlin_1","from_port":0,"to":"colorize_2","to_port":0},{"from":"colorize_0","from_port":0,"to":"blend_1","to_port":1},{"from":"perlin_2","from_port":0,"to":"colorize_3","to_port":0},{"from":"colorize_3","from_port":0,"to":"blend_1","to_port":2},{"from":"blend_1","from_port":0,"to":"Material","to_port":0},{"from":"colorize_3","from_port":0,"to":"blend_2","to_port":0},{"from":"blend_2","from_port":0,"to":"Material","to_port":2},{"from":"blend_0","from_port":0,"to":"colorize_0","to_port":0},{"from":"blend_0","from_port":0,"to":"colorize_5","to_port":0},{"from":"colorize_5","from_port":0,"to":"normal_map_0","to_port":0},{"from":"uniform_1","from_port":0,"to":"Material","to_port":1},{"from":"uniform_0","from_port":0,"to":"blend_2","to_port":1},{"from":"perlin_1","from_port":0,"to":"colorize_1","to_port":0},{"from":"combine_0","from_port":0,"to":"export_0","to_port":0},{"from":"uniform_1","from_port":0,"to":"combine_0","to_port":0},{"from":"blend_2","from_port":0,"to":"combine_0","to_port":1},{"from":"colorize_2","from_port":0,"to":"blend_1","to_port":0}],"nodes":[{"name":"Material","node_position":{"x":938,"y":96},"parameters":{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"normal_scale":1,"resolution":1,"roughness":1},"type":"material"},{"name":"colorize_3","node_position":{"x":487.633789,"y":65},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0.518182,"r":0},{"a":1,"b":1,"g":1,"pos":0.709091,"r":1}],"type":"Gradient"}},"type":"colorize"},{"name":"bricks_0","node_position":{"x":-1,"y":30.5},"parameters":{"bevel":0.007813,"columns":5,"mortar":0.007813,"pattern":0,"repeat":1,"row_offset":0.5,"rows":1},"type":"bricks"},{"name":"colorize_0","node_position":{"x":472,"y":-41.5},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0.336914,"pos":0,"r":0.598958},{"a":1,"b":0,"g":0.454102,"pos":0.118182,"r":0.807292},{"a":1,"b":0,"g":0.37793,"pos":0.245455,"r":0.671875},{"a":1,"b":0,"g":0.427734,"pos":0.345455,"r":0.760417},{"a":1,"b":0.017795,"g":0.488254,"pos":0.527273,"r":0.854167},{"a":1,"b":0,"g":0.37793,"pos":0.645455,"r":0.671875},{"a":1,"b":0,"g":0.439453,"pos":0.845455,"r":0.78125},{"a":1,"b":0,"g":0.357422,"pos":1,"r":0.635417}],"type":"Gradient"}},"type":"colorize"},{"name":"perlin_1","node_position":{"x":110.633789,"y":-143.5},"parameters":{"iterations":7,"persistence":0.55,"scale_x":4,"scale_y":4},"type":"perlin"},{"name":"blend_2","node_position":{"x":690.633789,"y":201.5},"parameters":{"amount":0.4,"blend_type":0},"type":"blend"},{"name":"perlin_2","node_position":{"x":232.633789,"y":40},"parameters":{"iterations":6,"persistence":0.65,"scale_x":4,"scale_y":4},"type":"perlin"},{"name":"normal_map_0","node_position":{"x":724.633789,"y":345.5},"parameters":{"amount":0.15,"size":4},"type":"normal_map"},{"name":"blend_1","node_position":{"x":707.633789,"y":-68},"parameters":{"amount":0.5,"blend_type":0},"type":"blend"},{"name":"blend_0","node_position":{"x":271,"y":306.5},"parameters":{"amount":1,"blend_type":2},"type":"blend"},{"name":"colorize_5","node_position":{"x":503,"y":336.5},"parameters":{"gradient":{"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":"uniform_1","node_position":{"x":753,"y":116},"parameters":{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"}},"type":"uniform"},{"name":"uniform_0","node_position":{"x":540,"y":234},"parameters":{"color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"}},"type":"uniform"},{"name":"colorize_2","node_position":{"x":454.633789,"y":-189.5},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":0.515625},{"a":1,"b":0,"g":0,"pos":0.145455,"r":0.25},{"a":1,"b":0,"g":0,"pos":0.445455,"r":0.515625},{"a":1,"b":0.013184,"g":0.013184,"pos":0.745455,"r":0.28125},{"a":1,"b":0,"g":0,"pos":1,"r":0.322917}],"type":"Gradient"}},"type":"colorize"},{"name":"colorize_1","node_position":{"x":461.329102,"y":-116.699997},"parameters":{"gradient":{"points":[{"a":1,"b":0.034912,"g":0.129532,"pos":0,"r":0.203125},{"a":1,"b":0.038791,"g":0.074319,"pos":1,"r":0.114583}],"type":"Gradient"}},"type":"colorize"},{"name":"export_0","node_position":{"x":1090.329102,"y":-76.5},"parameters":{"resolution":1},"suffix":"mr","type":"export"},{"name":"combine_0","node_position":{"x":942.329102,"y":-55.5},"parameters":{},"type":"combine"},{"name":"perlin_0","node_position":{"x":12,"y":243.5},"parameters":{"iterations":6,"persistence":0.7,"scale_x":20,"scale_y":3},"type":"perlin"}]} \ No newline at end of file diff --git a/addons/material_maker/examples/wooden_floor.ptex b/addons/material_maker/examples/wooden_floor.ptex index 2d41611..4c757f9 100644 --- a/addons/material_maker/examples/wooden_floor.ptex +++ b/addons/material_maker/examples/wooden_floor.ptex @@ -1 +1 @@ -{"connections":[{"from":"bricks_0","from_port":0,"to":"colorize_0","to_port":0},{"from":"colorize_0","from_port":0,"to":"blend_0","to_port":0},{"from":"blend_0","from_port":0,"to":"Material","to_port":0},{"from":"blend_0","from_port":0,"to":"colorize_1","to_port":0},{"from":"colorize_1","from_port":0,"to":"normal_map_0","to_port":0},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"from":"blend_0","from_port":0,"to":"Material","to_port":2},{"from":"uniform_0","from_port":0,"to":"Material","to_port":1},{"from":"uniform_0","from_port":0,"to":"combine_0","to_port":0},{"from":"blend_0","from_port":0,"to":"combine_0","to_port":1},{"from":"combine_0","from_port":0,"to":"export_0","to_port":0},{"from":"transform_1","from_port":0,"to":"blend_0","to_port":1},{"from":"perlin_0","from_port":0,"to":"transform_1","to_port":0},{"from":"bricks_0","from_port":1,"to":"decompose_0","to_port":0},{"from":"decompose_0","from_port":0,"to":"transform_1","to_port":1},{"from":"decompose_0","from_port":1,"to":"transform_1","to_port":2}],"nodes":[{"name":"colorize_0","node_position":{"x":524,"y":-100.75},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":0},{"a":1,"b":0.213623,"g":0.391325,"pos":0.145455,"r":0.651042}],"type":"Gradient"}},"type":"colorize"},{"name":"normal_map_0","node_position":{"x":740,"y":135.25},"parameters":{"amount":0.5,"size":2},"type":"normal_map"},{"name":"colorize_1","node_position":{"x":710,"y":208.25},"parameters":{"gradient":{"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":"uniform_0","node_position":{"x":718,"y":73},"parameters":{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"}},"type":"uniform"},{"name":"Material","node_position":{"x":930,"y":38},"parameters":{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"normal_scale":1,"resolution":1,"roughness":1},"type":"material"},{"name":"combine_0","node_position":{"x":866,"y":-78},"parameters":{},"type":"combine"},{"name":"export_0","node_position":{"x":1053,"y":-62},"parameters":{"resolution":1},"suffix":"mr","type":"export"},{"name":"perlin_0","node_position":{"x":69,"y":81.25},"parameters":{"iterations":7,"persistence":0.75,"scale_x":4,"scale_y":20},"type":"perlin"},{"name":"decompose_0","node_position":{"x":97,"y":236},"parameters":{},"type":"decompose"},{"name":"bricks_0","node_position":{"x":79,"y":-124.75},"parameters":{"bevel":0,"columns":1,"mortar":0.02,"pattern":0,"repeat":1,"row_offset":0.5,"rows":10},"type":"bricks"},{"name":"transform_1","node_position":{"x":290,"y":120},"parameters":{"repeat":true,"rotate":0,"scale_x":1,"scale_y":1,"translate_x":1,"translate_y":1},"type":"transform"},{"name":"blend_0","node_position":{"x":535,"y":2.25},"parameters":{"amount":0.5,"blend_type":0},"type":"blend"}]} \ No newline at end of file +{"connections":[{"from":"bricks_0","from_port":0,"to":"colorize_0","to_port":0},{"from":"colorize_0","from_port":0,"to":"blend_0","to_port":0},{"from":"blend_0","from_port":0,"to":"Material","to_port":0},{"from":"blend_0","from_port":0,"to":"colorize_1","to_port":0},{"from":"colorize_1","from_port":0,"to":"normal_map_0","to_port":0},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"from":"blend_0","from_port":0,"to":"Material","to_port":2},{"from":"uniform_0","from_port":0,"to":"Material","to_port":1},{"from":"uniform_0","from_port":0,"to":"combine_0","to_port":0},{"from":"blend_0","from_port":0,"to":"combine_0","to_port":1},{"from":"combine_0","from_port":0,"to":"export_0","to_port":0},{"from":"transform_1","from_port":0,"to":"blend_0","to_port":1},{"from":"perlin_0","from_port":0,"to":"transform_1","to_port":0},{"from":"bricks_0","from_port":1,"to":"decompose_0","to_port":0},{"from":"decompose_0","from_port":0,"to":"transform_1","to_port":1},{"from":"decompose_0","from_port":1,"to":"transform_1","to_port":2}],"nodes":[{"name":"colorize_0","node_position":{"x":524,"y":-100.75},"parameters":{"gradient":{"points":[{"a":1,"b":0,"g":0,"pos":0,"r":0},{"a":1,"b":0.213623,"g":0.391325,"pos":0.145455,"r":0.651042}],"type":"Gradient"}},"type":"colorize"},{"name":"normal_map_0","node_position":{"x":740,"y":135.25},"parameters":{"amount":0.3,"size":4},"type":"normal_map"},{"name":"colorize_1","node_position":{"x":710,"y":208.25},"parameters":{"gradient":{"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":"uniform_0","node_position":{"x":718,"y":73},"parameters":{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"}},"type":"uniform"},{"name":"Material","node_position":{"x":930,"y":38},"parameters":{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"normal_scale":1,"resolution":1,"roughness":1},"type":"material"},{"name":"combine_0","node_position":{"x":866,"y":-78},"parameters":{},"type":"combine"},{"name":"export_0","node_position":{"x":1053,"y":-62},"parameters":{"resolution":1},"suffix":"mr","type":"export"},{"name":"perlin_0","node_position":{"x":69,"y":81.25},"parameters":{"iterations":6,"persistence":0.75,"scale_x":4,"scale_y":20},"type":"perlin"},{"name":"decompose_0","node_position":{"x":97,"y":236},"parameters":{},"type":"decompose"},{"name":"bricks_0","node_position":{"x":79,"y":-124.75},"parameters":{"bevel":0,"columns":1,"mortar":0.02,"pattern":0,"repeat":1,"row_offset":0.5,"rows":10},"type":"bricks"},{"name":"transform_1","node_position":{"x":290,"y":120},"parameters":{"repeat":true,"rotate":0,"scale_x":1,"scale_y":1,"translate_x":1,"translate_y":1},"type":"transform"},{"name":"blend_0","node_position":{"x":535,"y":2.25},"parameters":{"amount":0.5,"blend_type":0},"type":"blend"}]} \ No newline at end of file diff --git a/addons/material_maker/nodes/adjust_hsv.mmn b/addons/material_maker/nodes/adjust_hsv.mmn index a980898..04f5a6e 100644 --- a/addons/material_maker/nodes/adjust_hsv.mmn +++ b/addons/material_maker/nodes/adjust_hsv.mmn @@ -1 +1 @@ -{"global":"vec3 rgb_to_hsv(vec3 c) {\n\tvec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n\tvec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy);\n\tvec4 q = c.r < p.x ? vec4(p.xyw, c.r) : vec4(c.r, p.yzx);\n\n\tfloat d = q.x - min(q.w, q.y);\n\tfloat e = 1.0e-10;\n\treturn vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n}\n\nvec3 hsv_to_rgb(vec3 c) {\n\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n\treturn c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n","inputs":[{"default":"vec3(1.0)","label":"","name":"in","type":"rgb"}],"instance":"vec3 $(name)_f(vec3 c) {\n\tvec3 hsv = rgb_to_hsv(c);\n\treturn hsv_to_rgb(vec3(fract(hsv.x+$(hue)), clamp(hsv.y*$(saturation), 0.0, 1.0), clamp(hsv.z*$(value), 0.0, 1.0)));\n}","name":"AdjustHSV","outputs":[{"rgb":"$(name)_f($in($(uv)))"}],"parameters":[{"default":0,"label":"Hue","max":0.5,"min":-0.5,"name":"hue","step":0,"type":"float"},{"default":1,"label":"Saturation","max":2,"min":0,"name":"saturation","step":0,"type":"float"},{"default":1,"label":"Value","max":2,"min":0,"name":"value","step":0,"type":"float"}]} \ No newline at end of file +{"global":"vec3 rgb_to_hsv(vec3 c) {\n\tvec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n\tvec4 p = c.g < c.b ? vec4(c.bg, K.wz) : vec4(c.gb, K.xy);\n\tvec4 q = c.r < p.x ? vec4(p.xyw, c.r) : vec4(c.r, p.yzx);\n\n\tfloat d = q.x - min(q.w, q.y);\n\tfloat e = 1.0e-10;\n\treturn vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n}\n\nvec3 hsv_to_rgb(vec3 c) {\n\tvec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n\tvec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n\treturn c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n","inputs":[{"default":"vec3($uv.x, $uv.y, 0.0)","label":"","name":"in","type":"rgb"}],"instance":"vec3 $(name)_f(vec3 c) {\n\tvec3 hsv = rgb_to_hsv(c);\n\treturn hsv_to_rgb(vec3(fract(hsv.x+$(hue)), clamp(hsv.y*$(saturation), 0.0, 1.0), clamp(hsv.z*$(value), 0.0, 1.0)));\n}","name":"AdjustHSV","outputs":[{"rgb":"$(name)_f($in($(uv)))"}],"parameters":[{"default":0,"label":"Hue","max":0.5,"min":-0.5,"name":"hue","step":0,"type":"float"},{"default":1,"label":"Saturation","max":2,"min":0,"name":"saturation","step":0,"type":"float"},{"default":1,"label":"Value","max":2,"min":0,"name":"value","step":0,"type":"float"}]} \ No newline at end of file diff --git a/addons/material_maker/nodes/node_generic.gd b/addons/material_maker/nodes/node_generic.gd index b87cdd9..ee97367 100644 --- a/addons/material_maker/nodes/node_generic.gd +++ b/addons/material_maker/nodes/node_generic.gd @@ -142,48 +142,72 @@ func update_node(data): if custom_node_buttons != null: move_child(custom_node_buttons, get_child_count()-1) -func replace_input(string, input, type, src, context = null): +func find_keyword_call(string, keyword): + var search_string = "$%s(" % keyword + var position = string.find(search_string) + if position == -1: + return null + var parenthesis_level = 0 + var parameter_begin = position+search_string.length() + var parameter_end = -1 + for i in range(parameter_begin, string.length()): + if string[i] == '(': + parenthesis_level += 1 + elif string[i] == ')': + if parenthesis_level == 0: + return string.substr(parameter_begin, i-parameter_begin) + parenthesis_level -= 1 + return "" + +func replace_input(string, input, type, src, default): var required_defs = "" var required_code = "" - var keyword = "$%s(" % input while true: - var position = string.find(keyword) - if position == -1: + var uv = find_keyword_call(string, input) + if uv == null: break - var parenthesis_level = 0 - var parameter_begin = position+keyword.length() - var parameter_end = -1 - for i in range(parameter_begin, string.length()): - if string[i] == '(': - parenthesis_level += 1 - elif string[i] == ')': - if parenthesis_level == 0: - parameter_end = i - break - else: - parenthesis_level -= 1 - if parameter_end != -1: - var uv = string.substr(parameter_begin, parameter_end-parameter_begin) - var src_code = src.get_shader_code(uv) - required_defs += src_code.defs - required_code += src_code.code - string = string.replace(string.substr(position, parameter_end-position+1), src_code[type]) - else: + elif uv == "": print("syntax error") break + var src_code + if src == null: + src_code = subst(default, "(%s)" % uv) + else: + src_code = src.get_shader_code(uv) + src_code.string = src_code[type] + required_defs += src_code.defs + required_code += src_code.code + string = string.replace("$%s(%s)" % [ input, uv ], src_code.string) return { string=string, defs=required_defs, code=required_code } +func is_word_letter(l): + return "azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN1234567890_".find(l) != -1 + func replace_variable(string, variable, value): string = string.replace("$(%s)" % variable, value) - return string + var keyword_size = variable.length()+1 + var new_string = "" + while !string.empty(): + var pos = string.find("$"+variable) + if pos == -1: + new_string += string + break + new_string += string.left(pos) + string = string.right(pos) + if string.empty() or !is_word_letter(string[0]): + new_string += value + else: + new_string += "$"+variable + string = string.right(keyword_size) + return new_string -func subst(string, uv = "", context = null): +func subst(string, uv = ""): var required_defs = "" var required_code = "" string = replace_variable(string, "name", name) string = replace_variable(string, "seed", str(get_seed())) if uv != "": - string = replace_variable(string, "uv", uv) + string = replace_variable(string, "uv", "("+uv+")") if model_data.has("parameters") and typeof(model_data.parameters) == TYPE_ARRAY: for p in model_data.parameters: if !p.has("name") or !p.has("type"): @@ -204,13 +228,10 @@ func subst(string, uv = "", context = null): for i in range(model_data.inputs.size()): var input = model_data.inputs[i] var source = get_source(i) - if source == null: - string = replace_variable(string, input.name, input.default) - else: - var result = replace_input(string, input.name, input.type, source, context) - string = result.string - required_defs += result.defs - required_code += result.code + var result = replace_input(string, input.name, input.type, source, input.default) + string = result.string + required_defs += result.defs + required_code += result.code return { string=string, defs=required_defs, code=required_code } func _get_shader_code(uv, slot = 0): @@ -227,7 +248,7 @@ func _get_shader_code(uv, slot = 0): generated_variants.append(variant_string) for t in output_info: if output.has(t.field): - var subst_output = subst(output[t.field], uv, rv) + var subst_output = subst(output[t.field], uv) rv.defs += subst_output.defs rv.code += subst_output.code rv.code += "%s %s_%d_%d_%s = %s;\n" % [ t.type, name, slot, variant_index, t.field, subst_output.string ] diff --git a/addons/material_maker/widgets/node_editor/input.tscn b/addons/material_maker/widgets/node_editor/input.tscn index dce2a0a..b82b98a 100644 --- a/addons/material_maker/widgets/node_editor/input.tscn +++ b/addons/material_maker/widgets/node_editor/input.tscn @@ -143,7 +143,7 @@ hint_tooltip = "Default value" focus_mode = 2 mouse_filter = 0 mouse_default_cursor_shape = 1 -size_flags_horizontal = 1 +size_flags_horizontal = 3 size_flags_vertical = 1 text = "0.0" focus_mode = 2 @@ -152,7 +152,7 @@ placeholder_alpha = 0.6 caret_blink = false caret_blink_speed = 0.65 caret_position = 0 -_sections_unfolded = [ "Hint", "Rect" ] +_sections_unfolded = [ "Hint", "Rect", "Size Flags" ] [connection signal="pressed" from="Delete" to="." method="_on_Delete_pressed"]