From b50c07543b09d5dbf213b9e7215d5be65866a95d Mon Sep 17 00:00:00 2001 From: Rodolphe Suescun Date: Tue, 28 Aug 2018 08:33:41 +0200 Subject: [PATCH] Minor fixes Added size parameter to normal map Fixed color of outputs in perlin and voronoi Fixed keyboard shortcuts in graph editor (did not check modifiers) --- .../procedural_material/examples/bricks.ptex | 2 +- .../examples/stone_wall.ptex | 2 +- addons/procedural_material/examples/wood.ptex | 2 +- .../examples/wood_with_blood.ptex | 2 +- addons/procedural_material/graph_edit.gd | 5 +- addons/procedural_material/main_window.tscn | 2 +- .../procedural_material/nodes/compound.tscn | 93 +++++++++++++ addons/procedural_material/nodes/emboss.gd | 4 +- .../procedural_material/nodes/normal_map.gd | 15 ++- .../procedural_material/nodes/normal_map.tscn | 124 +++++++++++++++++- addons/procedural_material/nodes/warp.gd | 9 +- 11 files changed, 238 insertions(+), 22 deletions(-) create mode 100644 addons/procedural_material/nodes/compound.tscn diff --git a/addons/procedural_material/examples/bricks.ptex b/addons/procedural_material/examples/bricks.ptex index 79df2ec..98adb62 100644 --- a/addons/procedural_material/examples/bricks.ptex +++ b/addons/procedural_material/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_1","from_port":0,"to":"blend_0","to_port":0},{"from":"colorize_0","from_port":0,"to":"blend_0","to_port":1},{"from":"blend_0","from_port":0,"to":"Material","to_port":0},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"from":"colorize_2","from_port":0,"to":"colorize_4","to_port":0},{"from":"colorize_4","from_port":0,"to":"Material","to_port":2},{"from":"Bricks","from_port":0,"to":"Warp","to_port":0},{"from":"blend_1","from_port":0,"to":"colorize_1","to_port":0},{"from":"Bricks","from_port":1,"to":"blend_1","to_port":1},{"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":"colorize_6","from_port":0,"to":"normal_map_0","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}],"nodes":[{"gradient":[{"b":0,"g":0,"pos":0,"r":0},{"b":1,"g":1,"pos":1,"r":1}],"name":"colorize_0","node_position":{"x":560.943665,"y":50},"type":"colorize"},{"gradient":[{"b":0.0016,"g":0.0016,"pos":0,"r":0.307292},{"b":0,"g":0.180135,"pos":0.2,"r":0.606771},{"b":0,"g":0,"pos":0.345455,"r":0.3125},{"b":0,"g":0.19869,"pos":0.545455,"r":0.669271},{"b":0.019368,"g":0.060224,"pos":0.745455,"r":0.309896},{"b":0,"g":0.180135,"pos":1,"r":0.606771}],"name":"colorize_1","node_position":{"x":562.943665,"y":-65},"type":"colorize"},{"amount":0.04,"name":"Warp","node_position":{"x":384,"y":10.75},"type":"warp"},{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":0,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":1081,"y":208},"normal_scale":1,"roughness":1,"type":"material"},{"amount":0.5,"blend_type":0,"name":"blend_2","node_position":{"x":536,"y":331},"type":"blend"},{"gradient":[{"b":1,"g":1,"pos":0,"r":1},{"b":0.463542,"g":0.463542,"pos":1,"r":0.463542}],"name":"colorize_4","node_position":{"x":708,"y":224},"type":"colorize"},{"amount":0.5,"blend_type":0,"name":"blend_0","node_position":{"x":836.943726,"y":-71},"type":"blend"},{"gradient":[{"b":0,"g":0,"pos":0,"r":0},{"b":1,"g":1,"pos":0.1,"r":1}],"name":"colorize_2","node_position":{"x":544.943665,"y":159},"type":"colorize"},{"amount":0.5,"blend_type":6,"name":"blend_1","node_position":{"x":349,"y":215},"type":"blend"},{"gradient":[{"b":1,"g":1,"pos":0,"r":1},{"b":0,"g":0,"pos":1,"r":0}],"name":"colorize_6","node_position":{"x":743,"y":291},"type":"colorize"},{"gradient":[{"b":0.510417,"g":0.510417,"pos":0.245455,"r":0.510417},{"b":1,"g":1,"pos":0.536364,"r":1}],"name":"colorize_3","node_position":{"x":753,"y":364},"type":"colorize"},{"amount":0.5,"name":"normal_map_0","node_position":{"x":922,"y":297},"type":"normal_map"},{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"},"name":"uniform_0","node_position":{"x":764,"y":164},"type":"uniform"},{"name":"combine_0","node_position":{"x":896,"y":86},"type":"combine"},{"name":"export_0","node_position":{"x":1050,"y":79},"suffix":"mr","type":"export"},{"bevel":0.2,"columns":3,"mortar":0.05,"name":"Bricks","node_position":{"x":69,"y":-46},"pattern":0,"repeat":1,"row_offset":0.5,"rows":6,"type":"bricks"},{"iterations":6,"name":"Perlin","node_position":{"x":70,"y":192},"persistence":0.85,"scale_x":4,"scale_y":4,"type":"perlin"}]} \ 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_1","from_port":0,"to":"blend_0","to_port":0},{"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":"Bricks","from_port":0,"to":"Warp","to_port":0},{"from":"blend_1","from_port":0,"to":"colorize_1","to_port":0},{"from":"Bricks","from_port":1,"to":"blend_1","to_port":1},{"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}],"nodes":[{"gradient":[{"b":0,"g":0,"pos":0,"r":0},{"b":1,"g":1,"pos":1,"r":1}],"name":"colorize_0","node_position":{"x":560.943665,"y":50},"type":"colorize"},{"gradient":[{"b":0.0016,"g":0.0016,"pos":0,"r":0.307292},{"b":0,"g":0.180135,"pos":0.2,"r":0.606771},{"b":0,"g":0,"pos":0.345455,"r":0.3125},{"b":0,"g":0.19869,"pos":0.545455,"r":0.669271},{"b":0.019368,"g":0.060224,"pos":0.745455,"r":0.309896},{"b":0,"g":0.180135,"pos":1,"r":0.606771}],"name":"colorize_1","node_position":{"x":562.943665,"y":-65},"type":"colorize"},{"amount":0.04,"name":"Warp","node_position":{"x":384,"y":10.75},"type":"warp"},{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":0,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":1081,"y":208},"normal_scale":1,"resolution":1,"roughness":1,"type":"material"},{"amount":0.5,"blend_type":0,"name":"blend_2","node_position":{"x":536,"y":331},"type":"blend"},{"amount":0.5,"blend_type":0,"name":"blend_0","node_position":{"x":836.943726,"y":-71},"type":"blend"},{"gradient":[{"b":0,"g":0,"pos":0,"r":0},{"b":1,"g":1,"pos":0.1,"r":1}],"name":"colorize_2","node_position":{"x":544.943665,"y":159},"type":"colorize"},{"amount":0.5,"blend_type":6,"name":"blend_1","node_position":{"x":349,"y":215},"type":"blend"},{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"},"name":"uniform_0","node_position":{"x":764,"y":164},"type":"uniform"},{"name":"combine_0","node_position":{"x":896,"y":86},"type":"combine"},{"name":"export_0","node_position":{"x":1050,"y":79},"resolution":1,"suffix":"mr","type":"export"},{"bevel":0.2,"columns":3,"mortar":0.05,"name":"Bricks","node_position":{"x":69,"y":-46},"pattern":0,"repeat":1,"row_offset":0.5,"rows":6,"type":"bricks"},{"iterations":6,"name":"Perlin","node_position":{"x":70,"y":192},"persistence":0.85,"scale_x":4,"scale_y":4,"type":"perlin"},{"gradient":[{"b":1,"g":1,"pos":0,"r":1},{"b":0.546875,"g":0.546875,"pos":1,"r":0.546875}],"name":"colorize_4","node_position":{"x":711,"y":215},"type":"colorize"},{"gradient":[{"b":1,"g":1,"pos":0,"r":1},{"b":0,"g":0,"pos":1,"r":0}],"name":"colorize_6","node_position":{"x":708,"y":289},"type":"colorize"},{"gradient":[{"b":0.838542,"g":0.838542,"pos":0.190909,"r":0.838542},{"b":1,"g":1,"pos":0.536364,"r":1}],"name":"colorize_3","node_position":{"x":711,"y":361},"type":"colorize"},{"amount":0.35,"name":"normal_map_0","node_position":{"x":881.045654,"y":309.691162},"size":4,"type":"normal_map"}]} \ No newline at end of file diff --git a/addons/procedural_material/examples/stone_wall.ptex b/addons/procedural_material/examples/stone_wall.ptex index 59884d4..f8b2590 100644 --- a/addons/procedural_material/examples/stone_wall.ptex +++ b/addons/procedural_material/examples/stone_wall.ptex @@ -1 +1 @@ -{"connections":[{"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":"normal_map_0","from_port":0,"to":"Material","to_port":4},{"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":"colorize_6","from_port":0,"to":"normal_map_0","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":"perlin_0","from_port":0,"to":"Warp","to_port":1},{"from":"uniform_0","from_port":0,"to":"Material","to_port":1},{"from":"colorize_3","from_port":0,"to":"Material","to_port":6},{"from":"blend_2","from_port":0,"to":"colorize_4","to_port":0},{"from":"colorize_4","from_port":0,"to":"Material","to_port":5},{"from":"voronoi_0","from_port":1,"to":"colorize_5","to_port":0},{"from":"blend_0","from_port":0,"to":"Material","to_port":0},{"from":"colorize_2","from_port":0,"to":"colorize_7","to_port":0},{"from":"colorize_7","from_port":0,"to":"Material","to_port":2},{"from":"Bricks","from_port":0,"to":"Warp","to_port":0},{"from":"Bricks","from_port":1,"to":"blend_1","to_port":1},{"from":"colorize_1","from_port":0,"to":"blend_0","to_port":0}],"nodes":[{"amount":0.5,"blend_type":0,"name":"blend_2","node_position":{"x":537,"y":264},"type":"blend"},{"amount":0.1,"name":"Warp","node_position":{"x":384,"y":10.75},"type":"warp"},{"intensity":1,"name":"voronoi_0","node_position":{"x":-288,"y":-107},"scale_x":8,"scale_y":8,"type":"voronoi"},{"gradient":[{"b":0,"g":0,"pos":0.027273,"r":0},{"b":1,"g":1,"pos":0.1,"r":1}],"name":"colorize_5","node_position":{"x":-104,"y":-87},"type":"colorize"},{"gradient":[{"b":0,"g":0,"pos":0,"r":0},{"b":1,"g":1,"pos":1,"r":1}],"name":"colorize_0","node_position":{"x":560.943665,"y":50},"type":"colorize"},{"amount":0.5,"blend_type":0,"name":"blend_0","node_position":{"x":762.943726,"y":-15},"type":"blend"},{"gradient":[{"b":0,"g":0,"pos":0,"r":0},{"b":1,"g":1,"pos":0.045455,"r":1}],"name":"colorize_2","node_position":{"x":535.943665,"y":163},"type":"colorize"},{"gradient":[{"b":1,"g":1,"pos":0,"r":1},{"b":0.479167,"g":0.479167,"pos":0.136364,"r":0.479167}],"name":"colorize_7","node_position":{"x":915.356934,"y":148},"type":"colorize"},{"gradient":[{"b":0.119792,"g":0.119792,"pos":0,"r":0.119792},{"b":0,"g":0,"pos":1,"r":0}],"name":"colorize_3","node_position":{"x":757,"y":356},"type":"colorize"},{"gradient":[{"b":0.640625,"g":0.640625,"pos":0.145455,"r":0.640625},{"b":1,"g":1,"pos":0.4,"r":1}],"name":"colorize_4","node_position":{"x":772,"y":288},"type":"colorize"},{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":0.2,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":1141,"y":88},"normal_scale":1,"roughness":1,"type":"material"},{"amount":0.5,"name":"normal_map_0","node_position":{"x":932,"y":214},"type":"normal_map"},{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"},"name":"uniform_0","node_position":{"x":942,"y":102},"type":"uniform"},{"gradient":[{"b":1,"g":1,"pos":0,"r":1},{"b":0,"g":0,"pos":1,"r":0}],"name":"colorize_6","node_position":{"x":742,"y":216},"type":"colorize"},{"iterations":10,"name":"Perlin","node_position":{"x":74,"y":-255},"persistence":0.75,"scale_x":4,"scale_y":4,"type":"perlin"},{"amount":0.5,"blend_type":6,"name":"blend_1","node_position":{"x":293,"y":99},"type":"blend"},{"bevel":0.1,"columns":3,"mortar":0.05,"name":"Bricks","node_position":{"x":-94,"y":17},"pattern":0,"repeat":1,"row_offset":0.5,"rows":6,"type":"bricks"},{"iterations":4,"name":"perlin_0","node_position":{"x":97,"y":211},"persistence":0.75,"scale_x":4,"scale_y":4,"type":"perlin"},{"gradient":[{"b":0.557292,"g":0.557292,"pos":0,"r":0.557292},{"b":0.180664,"g":0.22934,"pos":0.145455,"r":0.234375},{"b":0.585504,"g":0.672174,"pos":0.345455,"r":0.739583},{"b":0.144423,"g":0.184147,"pos":0.545455,"r":0.229167},{"b":0.447537,"g":0.553291,"pos":0.745455,"r":0.588542},{"b":0.199002,"g":0.342478,"pos":1,"r":0.682292}],"name":"colorize_1","node_position":{"x":393.943665,"y":-124},"type":"colorize"}]} \ No newline at end of file +{"connections":[{"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_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_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":"perlin_0","from_port":0,"to":"Warp","to_port":1},{"from":"uniform_0","from_port":0,"to":"Material","to_port":1},{"from":"blend_2","from_port":0,"to":"colorize_4","to_port":0},{"from":"voronoi_0","from_port":1,"to":"colorize_5","to_port":0},{"from":"blend_0","from_port":0,"to":"Material","to_port":0},{"from":"colorize_2","from_port":0,"to":"colorize_7","to_port":0},{"from":"colorize_7","from_port":0,"to":"Material","to_port":2},{"from":"Bricks","from_port":0,"to":"Warp","to_port":0},{"from":"Bricks","from_port":1,"to":"blend_1","to_port":1},{"from":"colorize_1","from_port":0,"to":"blend_0","to_port":0},{"from":"colorize_4","from_port":0,"to":"Material","to_port":5},{"from":"uniform_0","from_port":0,"to":"combine_0","to_port":0},{"from":"colorize_7","from_port":0,"to":"combine_0","to_port":1},{"from":"combine_0","from_port":0,"to":"export_0","to_port":0},{"from":"colorize_6","from_port":0,"to":"normal_map_0","to_port":0},{"from":"normal_map_0","from_port":0,"to":"Material","to_port":4}],"nodes":[{"intensity":1,"name":"voronoi_0","node_position":{"x":-288,"y":-107},"scale_x":8,"scale_y":8,"type":"voronoi"},{"gradient":[{"b":0,"g":0,"pos":0.027273,"r":0},{"b":1,"g":1,"pos":0.1,"r":1}],"name":"colorize_5","node_position":{"x":-104,"y":-87},"type":"colorize"},{"gradient":[{"b":0,"g":0,"pos":0,"r":0},{"b":1,"g":1,"pos":1,"r":1}],"name":"colorize_0","node_position":{"x":560.943665,"y":50},"type":"colorize"},{"iterations":4,"name":"perlin_0","node_position":{"x":97,"y":211},"persistence":0.75,"scale_x":4,"scale_y":4,"type":"perlin"},{"gradient":[{"b":0.557292,"g":0.557292,"pos":0,"r":0.557292},{"b":0.180664,"g":0.22934,"pos":0.145455,"r":0.234375},{"b":0.585504,"g":0.672174,"pos":0.345455,"r":0.739583},{"b":0.144423,"g":0.184147,"pos":0.545455,"r":0.229167},{"b":0.447537,"g":0.553291,"pos":0.745455,"r":0.588542},{"b":0.199002,"g":0.342478,"pos":1,"r":0.682292}],"name":"colorize_1","node_position":{"x":393.943665,"y":-124},"type":"colorize"},{"amount":0.5,"blend_type":6,"name":"blend_1","node_position":{"x":293,"y":99},"type":"blend"},{"iterations":8,"name":"Perlin","node_position":{"x":74,"y":-255},"persistence":0.8,"scale_x":4,"scale_y":4,"type":"perlin"},{"gradient":[{"b":0,"g":0,"pos":0,"r":0},{"b":1,"g":1,"pos":0.045455,"r":1}],"name":"colorize_2","node_position":{"x":535.943665,"y":163},"type":"colorize"},{"bevel":0.15,"columns":3,"mortar":0.05,"name":"Bricks","node_position":{"x":-94,"y":17},"pattern":0,"repeat":1,"row_offset":0.5,"rows":6,"type":"bricks"},{"gradient":[{"b":1,"g":1,"pos":0,"r":1},{"b":0,"g":0,"pos":1,"r":0}],"name":"colorize_6","node_position":{"x":742,"y":216},"type":"colorize"},{"amount":0.5,"blend_type":0,"name":"blend_0","node_position":{"x":763.943726,"y":13},"type":"blend"},{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"},"name":"uniform_0","node_position":{"x":931,"y":95},"type":"uniform"},{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":0.2,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":1161,"y":114},"normal_scale":1,"resolution":1,"roughness":1,"type":"material"},{"name":"combine_0","node_position":{"x":1119.687012,"y":-22.258774},"type":"combine"},{"name":"export_0","node_position":{"x":1268.687012,"y":7.741226},"resolution":1,"suffix":"mr","type":"export"},{"gradient":[{"b":1,"g":1,"pos":0,"r":1},{"b":0.479167,"g":0.479167,"pos":0.136364,"r":0.479167}],"name":"colorize_7","node_position":{"x":915.356934,"y":149},"type":"colorize"},{"gradient":[{"b":0.770833,"g":0.770833,"pos":0,"r":0.770833},{"b":1,"g":1,"pos":0.463636,"r":1}],"name":"colorize_4","node_position":{"x":772,"y":288},"type":"colorize"},{"amount":0.5,"name":"normal_map_0","node_position":{"x":940.587036,"y":225.716217},"size":4,"type":"normal_map"},{"amount":0.1,"name":"Warp","node_position":{"x":384,"y":10.75},"type":"warp"},{"amount":0.5,"blend_type":0,"name":"blend_2","node_position":{"x":537,"y":264},"type":"blend"}]} \ No newline at end of file diff --git a/addons/procedural_material/examples/wood.ptex b/addons/procedural_material/examples/wood.ptex index 6e965ff..47ac618 100644 --- a/addons/procedural_material/examples/wood.ptex +++ b/addons/procedural_material/examples/wood.ptex @@ -1 +1 @@ -{"connections":[{"from":"perlin_0","from_port":0,"to":"warp_0","to_port":0},{"from":"perlin_1","from_port":0,"to":"warp_0","to_port":1},{"from":"perlin_2","from_port":0,"to":"blend_0","to_port":0},{"from":"blend_0","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":"colorize_0","to_port":0},{"from":"colorize_0","from_port":0,"to":"Material","to_port":2},{"from":"blend_0","from_port":0,"to":"Material","to_port":1},{"from":"voronoi_0","from_port":0,"to":"colorize_1","to_port":0},{"from":"warp_0","from_port":0,"to":"warp_1","to_port":0},{"from":"colorize_1","from_port":0,"to":"warp_1","to_port":1},{"from":"warp_1","from_port":0,"to":"blend_0","to_port":1}],"nodes":[{"amount":0.15,"name":"normal_map_0","node_position":{"x":319,"y":265.5},"type":"normal_map"},{"albedo_color":{"a":1,"b":0.113434,"g":0.411451,"r":0.691406,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":544,"y":79},"normal_scale":1,"roughness":1,"type":"material"},{"gradient":[{"b":0.53125,"g":0.53125,"pos":0,"r":0.53125},{"b":0.708333,"g":0.708333,"pos":1,"r":0.708333}],"name":"colorize_0","node_position":{"x":313,"y":176.5},"type":"colorize"},{"amount":0.75,"blend_type":2,"name":"blend_0","node_position":{"x":83,"y":245.5},"type":"blend"},{"iterations":6,"name":"perlin_2","node_position":{"x":-312,"y":2.5},"persistence":1,"scale_x":32,"scale_y":4,"type":"perlin"},{"iterations":3,"name":"perlin_1","node_position":{"x":-400,"y":359.5},"persistence":0.5,"scale_x":4,"scale_y":4,"type":"perlin"},{"iterations":3,"name":"perlin_0","node_position":{"x":-393,"y":203.5},"persistence":0.5,"scale_x":32,"scale_y":4,"type":"perlin"},{"amount":0.3,"name":"warp_0","node_position":{"x":-180,"y":317.5},"type":"warp"},{"gradient":[{"b":0.432292,"g":0.432292,"pos":0,"r":0.432292},{"b":0,"g":0,"pos":0.354545,"r":0}],"name":"colorize_1","node_position":{"x":-194,"y":466.5},"type":"colorize"},{"amount":0.1,"name":"warp_1","node_position":{"x":-31,"y":336.5},"type":"warp"},{"intensity":1,"name":"voronoi_0","node_position":{"x":-381,"y":505.5},"scale_x":5,"scale_y":4,"type":"voronoi"}]} \ No newline at end of file +{"connections":[{"from":"perlin_0","from_port":0,"to":"warp_0","to_port":0},{"from":"perlin_1","from_port":0,"to":"warp_0","to_port":1},{"from":"perlin_2","from_port":0,"to":"blend_0","to_port":0},{"from":"blend_0","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":"colorize_0","to_port":0},{"from":"colorize_0","from_port":0,"to":"Material","to_port":2},{"from":"blend_0","from_port":0,"to":"Material","to_port":1},{"from":"voronoi_0","from_port":0,"to":"colorize_1","to_port":0},{"from":"warp_0","from_port":0,"to":"warp_1","to_port":0},{"from":"colorize_1","from_port":0,"to":"warp_1","to_port":1},{"from":"warp_1","from_port":0,"to":"blend_0","to_port":1},{"from":"combine_0","from_port":0,"to":"export_0","to_port":0},{"from":"colorize_0","from_port":0,"to":"combine_0","to_port":1},{"from":"blend_0","from_port":0,"to":"colorize_2","to_port":0},{"from":"blend_0","from_port":0,"to":"combine_0","to_port":0},{"from":"colorize_2","from_port":0,"to":"Material","to_port":0}],"nodes":[{"amount":0.1,"name":"normal_map_0","node_position":{"x":319,"y":265.5},"type":"normal_map"},{"gradient":[{"b":0.53125,"g":0.53125,"pos":0,"r":0.53125},{"b":0.708333,"g":0.708333,"pos":1,"r":0.708333}],"name":"colorize_0","node_position":{"x":313,"y":176.5},"type":"colorize"},{"iterations":6,"name":"perlin_2","node_position":{"x":-312,"y":2.5},"persistence":1,"scale_x":32,"scale_y":4,"type":"perlin"},{"iterations":3,"name":"perlin_1","node_position":{"x":-400,"y":359.5},"persistence":0.5,"scale_x":4,"scale_y":4,"type":"perlin"},{"iterations":3,"name":"perlin_0","node_position":{"x":-393,"y":203.5},"persistence":0.5,"scale_x":32,"scale_y":4,"type":"perlin"},{"amount":0.3,"name":"warp_0","node_position":{"x":-180,"y":317.5},"type":"warp"},{"gradient":[{"b":0.432292,"g":0.432292,"pos":0,"r":0.432292},{"b":0,"g":0,"pos":0.345455,"r":0}],"name":"colorize_1","node_position":{"x":-194,"y":466.5},"type":"colorize"},{"amount":0.1,"name":"warp_1","node_position":{"x":-31,"y":336.5},"type":"warp"},{"intensity":1,"name":"voronoi_0","node_position":{"x":-381,"y":505.5},"scale_x":5,"scale_y":4,"type":"voronoi"},{"amount":1,"blend_type":2,"name":"blend_0","node_position":{"x":83,"y":245.5},"type":"blend"},{"name":"combine_0","node_position":{"x":515.35144,"y":-15.818176},"type":"combine"},{"name":"export_0","node_position":{"x":656.35144,"y":-20.818176},"suffix":"mr","type":"export"},{"name":"Material","node_position":{"x":544,"y":79},"type":"material"},{"gradient":[{"b":0.071126,"g":0.34877,"pos":0,"r":0.59375},{"b":0.013021,"g":0.144043,"pos":1,"r":0.3125}],"name":"colorize_2","node_position":{"x":305.35144,"y":76.181824},"type":"colorize"}]} \ No newline at end of file diff --git a/addons/procedural_material/examples/wood_with_blood.ptex b/addons/procedural_material/examples/wood_with_blood.ptex index a7773d3..ac51ada 100644 --- a/addons/procedural_material/examples/wood_with_blood.ptex +++ b/addons/procedural_material/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_2","from_port":0,"to":"blend_1","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}],"nodes":[{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":938,"y":96},"normal_scale":1,"roughness":1,"type":"material"},{"gradient":[{"b":0,"g":0,"pos":0.545455,"r":0},{"b":1,"g":1,"pos":0.681818,"r":1}],"name":"colorize_3","node_position":{"x":487.633789,"y":65},"type":"colorize"},{"iterations":6,"name":"perlin_0","node_position":{"x":12,"y":225.5},"persistence":0.7,"scale_x":20,"scale_y":3,"type":"perlin"},{"bevel":0,"columns":5,"mortar":0.05,"name":"bricks_0","node_position":{"x":-1,"y":30.5},"pattern":0,"repeat":1,"row_offset":0.5,"rows":1,"type":"bricks"},{"gradient":[{"b":0,"g":0.336914,"pos":0,"r":0.598958},{"b":0,"g":0.454102,"pos":0.118182,"r":0.807292},{"b":0,"g":0.37793,"pos":0.245455,"r":0.671875},{"b":0,"g":0.427734,"pos":0.345455,"r":0.760417},{"b":0.017795,"g":0.488254,"pos":0.527273,"r":0.854167},{"b":0,"g":0.37793,"pos":0.645455,"r":0.671875},{"b":0,"g":0.439453,"pos":0.845455,"r":0.78125},{"b":0,"g":0.357422,"pos":1,"r":0.635417}],"name":"colorize_0","node_position":{"x":472,"y":-41.5},"type":"colorize"},{"iterations":7,"name":"perlin_1","node_position":{"x":110.633789,"y":-143.5},"persistence":0.55,"scale_x":4,"scale_y":4,"type":"perlin"},{"amount":0.5,"blend_type":0,"name":"blend_2","node_position":{"x":690.633789,"y":201.5},"type":"blend"},{"iterations":6,"name":"perlin_2","node_position":{"x":232.633789,"y":40},"persistence":0.65,"scale_x":4,"scale_y":4,"type":"perlin"},{"gradient":[{"b":0,"g":0,"pos":0,"r":0.515625},{"b":0,"g":0,"pos":0.145455,"r":0.25},{"b":0,"g":0,"pos":0.445455,"r":0.515625},{"b":0.013184,"g":0.013184,"pos":0.745455,"r":0.28125},{"b":0,"g":0,"pos":1,"r":0.322917}],"name":"colorize_2","node_position":{"x":487.633789,"y":-144.5},"type":"colorize"},{"amount":0.4,"name":"normal_map_0","node_position":{"x":724.633789,"y":345.5},"type":"normal_map"},{"amount":0.5,"blend_type":0,"name":"blend_1","node_position":{"x":707.633789,"y":-68},"type":"blend"},{"amount":1,"blend_type":2,"name":"blend_0","node_position":{"x":271,"y":306.5},"type":"blend"},{"gradient":[{"b":1,"g":1,"pos":0,"r":1},{"b":0,"g":0,"pos":1,"r":0}],"name":"colorize_5","node_position":{"x":503,"y":336.5},"type":"colorize"},{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"},"name":"uniform_1","node_position":{"x":753,"y":116},"type":"uniform"},{"color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"name":"uniform_0","node_position":{"x":540,"y":234},"type":"uniform"}]} \ 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":[{"albedo_color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"ao_light_affect":1,"depth_scale":1,"emission_energy":1,"metallic":1,"name":"Material","node_position":{"x":938,"y":96},"normal_scale":1,"resolution":1,"roughness":1,"type":"material"},{"gradient":[{"b":0,"g":0,"pos":0.518182,"r":0},{"b":1,"g":1,"pos":0.709091,"r":1}],"name":"colorize_3","node_position":{"x":487.633789,"y":65},"type":"colorize"},{"bevel":0,"columns":5,"mortar":0.02,"name":"bricks_0","node_position":{"x":-1,"y":30.5},"pattern":0,"repeat":1,"row_offset":0.5,"rows":1,"type":"bricks"},{"gradient":[{"b":0,"g":0.336914,"pos":0,"r":0.598958},{"b":0,"g":0.454102,"pos":0.118182,"r":0.807292},{"b":0,"g":0.37793,"pos":0.245455,"r":0.671875},{"b":0,"g":0.427734,"pos":0.345455,"r":0.760417},{"b":0.017795,"g":0.488254,"pos":0.527273,"r":0.854167},{"b":0,"g":0.37793,"pos":0.645455,"r":0.671875},{"b":0,"g":0.439453,"pos":0.845455,"r":0.78125},{"b":0,"g":0.357422,"pos":1,"r":0.635417}],"name":"colorize_0","node_position":{"x":472,"y":-41.5},"type":"colorize"},{"iterations":7,"name":"perlin_1","node_position":{"x":110.633789,"y":-143.5},"persistence":0.55,"scale_x":4,"scale_y":4,"type":"perlin"},{"amount":0.4,"blend_type":0,"name":"blend_2","node_position":{"x":690.633789,"y":201.5},"type":"blend"},{"iterations":6,"name":"perlin_2","node_position":{"x":232.633789,"y":40},"persistence":0.65,"scale_x":4,"scale_y":4,"type":"perlin"},{"amount":0.4,"name":"normal_map_0","node_position":{"x":724.633789,"y":345.5},"type":"normal_map"},{"amount":0.5,"blend_type":0,"name":"blend_1","node_position":{"x":707.633789,"y":-68},"type":"blend"},{"amount":1,"blend_type":2,"name":"blend_0","node_position":{"x":271,"y":306.5},"type":"blend"},{"gradient":[{"b":1,"g":1,"pos":0,"r":1},{"b":0,"g":0,"pos":1,"r":0}],"name":"colorize_5","node_position":{"x":503,"y":336.5},"type":"colorize"},{"color":{"a":1,"b":0,"g":0,"r":0,"type":"Color"},"name":"uniform_1","node_position":{"x":753,"y":116},"type":"uniform"},{"color":{"a":1,"b":1,"g":1,"r":1,"type":"Color"},"name":"uniform_0","node_position":{"x":540,"y":234},"type":"uniform"},{"gradient":[{"b":0,"g":0,"pos":0,"r":0.515625},{"b":0,"g":0,"pos":0.145455,"r":0.25},{"b":0,"g":0,"pos":0.445455,"r":0.515625},{"b":0.013184,"g":0.013184,"pos":0.745455,"r":0.28125},{"b":0,"g":0,"pos":1,"r":0.322917}],"name":"colorize_2","node_position":{"x":454.633789,"y":-189.5},"type":"colorize"},{"gradient":[{"b":0.034912,"g":0.129532,"pos":0,"r":0.203125},{"b":0.038791,"g":0.074319,"pos":1,"r":0.114583}],"name":"colorize_1","node_position":{"x":461.329102,"y":-116.699997},"type":"colorize"},{"name":"export_0","node_position":{"x":1090.329102,"y":-76.5},"resolution":1,"suffix":"mr","type":"export"},{"name":"combine_0","node_position":{"x":942.329102,"y":-55.5},"type":"combine"},{"iterations":6,"name":"perlin_0","node_position":{"x":12,"y":243.5},"persistence":0.7,"scale_x":20,"scale_y":3,"type":"perlin"}]} \ No newline at end of file diff --git a/addons/procedural_material/graph_edit.gd b/addons/procedural_material/graph_edit.gd index 99c93ec..af5d7ec 100644 --- a/addons/procedural_material/graph_edit.gd +++ b/addons/procedural_material/graph_edit.gd @@ -14,9 +14,10 @@ func _ready(): func _gui_input(event): if event is InputEventKey and event.pressed: - if event.scancode == KEY_C: + var scancode_with_modifiers = event.get_scancode_with_modifiers() + if scancode_with_modifiers == KEY_C: center_view() - elif event.scancode == KEY_DELETE: + elif scancode_with_modifiers == KEY_DELETE: remove_selection() # Misc. useful functions diff --git a/addons/procedural_material/main_window.tscn b/addons/procedural_material/main_window.tscn index d7e53c8..0f8fd97 100644 --- a/addons/procedural_material/main_window.tscn +++ b/addons/procedural_material/main_window.tscn @@ -249,7 +249,7 @@ anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 margin_right = 954.0 -margin_bottom = 23.0 +margin_bottom = 21.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 0 diff --git a/addons/procedural_material/nodes/compound.tscn b/addons/procedural_material/nodes/compound.tscn new file mode 100644 index 0000000..a166e39 --- /dev/null +++ b/addons/procedural_material/nodes/compound.tscn @@ -0,0 +1,93 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://addons/procedural_material/nodes/uniform.gd" type="Script" id=1] + +[sub_resource type="Theme" id=1] + + +[node name="Compound" type="GraphNode" index="0"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 114.0 +margin_bottom = 53.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 1 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +theme = SubResource( 1 ) +title = "Compound" +offset = Vector2( 0, 0 ) +show_close = true +resizable = false +selected = false +comment = false +overlay = 0 +slot/0/left_enabled = false +slot/0/left_type = 0 +slot/0/left_color = Color( 0.5, 0.5, 1, 1 ) +slot/0/right_enabled = true +slot/0/right_type = 0 +slot/0/right_color = Color( 0.5, 0.5, 1, 1 ) +script = ExtResource( 1 ) +_sections_unfolded = [ "Theme", "slot", "slot/0" ] + +[node name="Contents" type="Node" parent="." index="0"] + +[node name="GraphNode" type="GraphNode" parent="Contents" index="0"] + +visible = false +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 17.0 +margin_top = 28.0 +margin_right = 99.0 +margin_bottom = 57.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +title = "" +offset = Vector2( 0, 0 ) +show_close = false +resizable = false +selected = false +comment = false +overlay = 0 + +[node name="SpinBox" type="SpinBox" parent="." index="1"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 16.0 +margin_top = 24.0 +margin_right = 98.0 +margin_bottom = 48.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 1 +size_flags_vertical = 1 +min_value = 0.0 +max_value = 100.0 +step = 1.0 +page = 0.0 +value = 0.0 +exp_edit = false +rounded = false +editable = true +prefix = "" +suffix = "" + + diff --git a/addons/procedural_material/nodes/emboss.gd b/addons/procedural_material/nodes/emboss.gd index 4eef3d6..809da8b 100644 --- a/addons/procedural_material/nodes/emboss.gd +++ b/addons/procedural_material/nodes/emboss.gd @@ -34,14 +34,14 @@ func _ready(): initialize_properties([ $HBoxContainer1/size, $HBoxContainer2/direction ]) func _rerender(): - get_parent().precalculate_shader(input_shader, get_source().get_textures(), 1024, input_texture, self, "pass_1", []) + get_parent().precalculate_shader(input_shader, get_source().get_textures(), int(pow(2, 5+size)), input_texture, self, "pass_1", []) func pass_1(): var convolution = CONVOLUTION convolution.epsilon=1.0/pow(2, 5+size) for i in range(8): convolution.kernel[INDICES[i]] = COEFS[(i+8-int(direction))%8] - get_parent().precalculate_shader(get_convolution_shader(convolution), {input=input_texture}, 1024, final_texture, self, "rerender_targets", []) + get_parent().precalculate_shader(get_convolution_shader(convolution), {input=input_texture}, int(pow(2, 5+size)), final_texture, self, "rerender_targets", []) func get_textures(): var list = {} diff --git a/addons/procedural_material/nodes/normal_map.gd b/addons/procedural_material/nodes/normal_map.gd index 8c1c395..6b40fd2 100644 --- a/addons/procedural_material/nodes/normal_map.gd +++ b/addons/procedural_material/nodes/normal_map.gd @@ -1,6 +1,7 @@ tool extends "res://addons/procedural_material/node_base.gd" +var size = 5 var amount = 0.0 var input_shader = "" @@ -24,17 +25,23 @@ const CONVOLUTION = { } func _ready(): + # init size widget + $HBoxContainer1/size.clear() + for i in range(7): + $HBoxContainer1/size.add_item(str(int(pow(2, 5+i))), i) + $HBoxContainer1/size.selected = size input_texture = ImageTexture.new() final_texture = ImageTexture.new() - initialize_properties([ $amount ]) + initialize_properties([ $HBoxContainer1/size, $HBoxContainer2/amount ]) func _rerender(): - get_parent().precalculate_shader(input_shader, get_source().get_textures(), 1024, input_texture, self, "pass_1", []) + get_parent().precalculate_shader(input_shader, get_source().get_textures(), int(pow(2, 5+size)), input_texture, self, "pass_1", []) func pass_1(): var convolution = CONVOLUTION - convolution.scale_before_normalize = 8.0*amount - get_parent().precalculate_shader(get_convolution_shader(convolution), { input=input_texture}, 1024, final_texture, self, "rerender_targets", []) + convolution.epsilon=1.0/pow(2, 5+size) + convolution.scale_before_normalize = pow(2, size-1)*amount + get_parent().precalculate_shader(get_convolution_shader(convolution), { input=input_texture}, int(pow(2, 5+size)), final_texture, self, "rerender_targets", []) func get_textures(): var list = {} diff --git a/addons/procedural_material/nodes/normal_map.tscn b/addons/procedural_material/nodes/normal_map.tscn index 7a15d43..1f06725 100644 --- a/addons/procedural_material/nodes/normal_map.tscn +++ b/addons/procedural_material/nodes/normal_map.tscn @@ -13,8 +13,8 @@ anchor_right = 0.0 anchor_bottom = 0.0 margin_left = 1.0 margin_top = 1.0 -margin_right = 124.0 -margin_bottom = 54.0 +margin_right = 173.0 +margin_bottom = 75.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 1 @@ -35,10 +35,16 @@ slot/0/left_color = Color( 0.756863, 0.756863, 0.756863, 1 ) slot/0/right_enabled = true slot/0/right_type = 0 slot/0/right_color = Color( 0.5, 0.5, 1, 1 ) +slot/1/left_enabled = false +slot/1/left_type = 0 +slot/1/left_color = Color( 1, 1, 1, 1 ) +slot/1/right_enabled = false +slot/1/right_type = 0 +slot/1/right_color = Color( 1, 1, 1, 1 ) script = ExtResource( 1 ) _sections_unfolded = [ "Theme", "slot", "slot/0" ] -[node name="amount" type="SpinBox" parent="." index="0"] +[node name="HBoxContainer1" type="HBoxContainer" parent="." index="0"] anchor_left = 0.0 anchor_top = 0.0 @@ -46,8 +52,116 @@ anchor_right = 0.0 anchor_bottom = 0.0 margin_left = 16.0 margin_top = 24.0 -margin_right = 107.0 -margin_bottom = 48.0 +margin_right = 156.0 +margin_bottom = 44.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 1 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 3 +size_flags_vertical = 1 +alignment = 0 +_sections_unfolded = [ "Size Flags" ] + +[node name="Label" type="Label" parent="HBoxContainer1" index="0"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_top = 3.0 +margin_right = 61.0 +margin_bottom = 17.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 2 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 3 +size_flags_vertical = 4 +text = "Grid size:" +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 +_sections_unfolded = [ "Anchor", "Margin", "Size Flags" ] + +[node name="size" type="OptionButton" parent="HBoxContainer1" index="1"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 65.0 +margin_right = 140.0 +margin_bottom = 20.0 +rect_min_size = Vector2( 75, 0 ) +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +focus_mode = 2 +mouse_filter = 0 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 11 +size_flags_vertical = 1 +toggle_mode = false +action_mode = 0 +enabled_focus_mode = 2 +shortcut = null +group = null +text = "1024" +flat = false +align = 0 +items = [ "32", null, false, 0, null, "64", null, false, 1, null, "128", null, false, 2, null, "256", null, false, 3, null, "512", null, false, 4, null, "1024", null, false, 5, null, "2048", null, false, 6, null ] +selected = 5 +_sections_unfolded = [ "Anchor", "Caret", "Placeholder", "Rect", "Size Flags" ] + +[node name="HBoxContainer2" type="HBoxContainer" parent="." index="1"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 16.0 +margin_top = 44.0 +margin_right = 156.0 +margin_bottom = 68.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 1 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 3 +size_flags_vertical = 1 +alignment = 0 +_sections_unfolded = [ "Size Flags" ] + +[node name="Label" type="Label" parent="HBoxContainer2" index="0"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_top = 5.0 +margin_right = 62.0 +margin_bottom = 19.0 +rect_pivot_offset = Vector2( 0, 0 ) +rect_clip_content = false +mouse_filter = 2 +mouse_default_cursor_shape = 0 +size_flags_horizontal = 3 +size_flags_vertical = 4 +text = "Amount:" +percent_visible = 1.0 +lines_skipped = 0 +max_lines_visible = -1 +_sections_unfolded = [ "Anchor", "Margin", "Size Flags" ] + +[node name="amount" type="SpinBox" parent="HBoxContainer2" index="1"] + +anchor_left = 0.0 +anchor_top = 0.0 +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_left = 66.0 +margin_right = 140.0 +margin_bottom = 24.0 rect_pivot_offset = Vector2( 0, 0 ) rect_clip_content = false mouse_filter = 0 diff --git a/addons/procedural_material/nodes/warp.gd b/addons/procedural_material/nodes/warp.gd index ee51328..5854f4c 100644 --- a/addons/procedural_material/nodes/warp.gd +++ b/addons/procedural_material/nodes/warp.gd @@ -9,6 +9,7 @@ func _ready(): initialize_properties([ $amount ]) func _get_shader_code(uv): + var epsilon = 0.01 var rv = { defs="", code="" } var src0 = get_source(0) var src1 = get_source(1) @@ -18,10 +19,10 @@ func _get_shader_code(uv): if variant_index == -1: variant_index = generated_variants.size() generated_variants.append(uv) - var src1_code0 = src1.get_shader_code("fract(%s+vec2(0.01, 0.0))" % uv) - var src1_code1 = src1.get_shader_code("fract(%s-vec2(0.01, 0.0))" % uv) - var src1_code2 = src1.get_shader_code("fract(%s+vec2(0.0, 0.01))" % uv) - var src1_code3 = src1.get_shader_code("fract(%s-vec2(0.0, 0.01))" % uv) + var src1_code0 = src1.get_shader_code("fract(%s+vec2(%.9f, 0.0))" % [ uv, epsilon ]) + var src1_code1 = src1.get_shader_code("fract(%s-vec2(%.9f, 0.0))" % [ uv, epsilon ]) + var src1_code2 = src1.get_shader_code("fract(%s+vec2(0.0, %.9f))" % [ uv, epsilon ]) + var src1_code3 = src1.get_shader_code("fract(%s-vec2(0.0, %.9f))" % [ uv, epsilon ]) rv.defs = src1_code0.defs rv.code = src1_code0.code+src1_code1.code+src1_code2.code+src1_code3.code rv.code += "vec2 %s_%d_uv = %s+%.9f*vec2((%s)-(%s), (%s)-(%s));\n" % [ name, variant_index, uv, amount, src1_code0.f, src1_code1.f, src1_code2.f, src1_code3.f ]