From b286935e345b4263fc6600f3b8a106396312e368 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Thu, 23 Jan 2020 18:02:01 +0100 Subject: [PATCH] Fix parsing input sockets for custom nodes --- Assets/plugins/hello_node.js | 19 ++++++++++++++++--- Sources/arm/node/Material.hx | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Assets/plugins/hello_node.js b/Assets/plugins/hello_node.js index d77bba8f..db709d9f 100644 --- a/Assets/plugins/hello_node.js +++ b/Assets/plugins/hello_node.js @@ -18,7 +18,18 @@ let nodes = [ x: 0, y: 0, color: 0xffb34f5a, - inputs: [], + inputs: [ + { + id: 0, + node_id: 0, + name: "Scale", + type: "VALUE", + color: 0xffa1a1a1, + default_value: 1, + min: 0.0, + max: 5.0 + } + ], outputs: [ { id: 0, @@ -35,10 +46,12 @@ let nodes = [ arm.NodesMaterial.list.push(nodes); // Node shader -arm.Material.customNodes.set(nodeType, function() { +arm.Material.customNodes.set(nodeType, function(node) { let frag = arm.Material.frag; + let scale = arm.Material.parse_value_input(node.inputs[0]); + frag.write(` - float my_out = cos(sin(texCoord.x * 200) + cos(texCoord.y * 200)); + float my_out = cos(sin(texCoord.x * 200 * ${scale}) + cos(texCoord.y * 200 * ${scale})); `); return `vec3(my_out, my_out, my_out)`; }); diff --git a/Sources/arm/node/Material.hx b/Sources/arm/node/Material.hx index 0355bbb8..4805c5ce 100644 --- a/Sources/arm/node/Material.hx +++ b/Sources/arm/node/Material.hx @@ -915,7 +915,7 @@ class Material { return to_vec3('$height'); } else if (customNodes.get(node.type) != null) { - return customNodes.get(node.type)(); + return customNodes.get(node.type)(node); } return "vec3(0.0, 0.0, 0.0)"; } @@ -1296,7 +1296,7 @@ class Material { } } else if (customNodes.get(node.type) != null) { - return customNodes.get(node.type)(); + return customNodes.get(node.type)(node); } return "0.0"; }