diff --git a/Sources/arm/App.hx b/Sources/arm/App.hx index 96b30871..8cc99a8e 100644 --- a/Sources/arm/App.hx +++ b/Sources/arm/App.hx @@ -429,7 +429,7 @@ class App { if (nodeType == "TEX_IMAGE") { return Project.assetNames.length > 0 ? Project.assetNames : [""]; } - else if (nodeType == "LAYER") { + else if (nodeType == "LAYER" || nodeType == "LAYER_MASK") { var layerNames:Array = []; for (l in Project.layers) layerNames.push(l.name); return layerNames; diff --git a/Sources/arm/node/Material.hx b/Sources/arm/node/Material.hx index e96fafb2..455b532e 100644 --- a/Sources/arm/node/Material.hx +++ b/Sources/arm/node/Material.hx @@ -1200,6 +1200,14 @@ class Material { // } } + else if (node.type == 'LAYER_MASK') { + if (socket == node.outputs[0]) { + var l = node.buttons[0].default_value; + curshader.add_uniform("sampler2D texpaint_mask", "_texpaint_mask" + l); + return 'texture(texpaint_mask, texCoord).r'; + } + } + else if (node.type == 'FRESNEL') { var ior = parse_value_input(node.inputs[0]); // var nor = parse_vector_input(node.inputs[1]) diff --git a/Sources/arm/node/NodesMaterial.hx b/Sources/arm/node/NodesMaterial.hx index f2a926e0..244efcc7 100644 --- a/Sources/arm/node/NodesMaterial.hx +++ b/Sources/arm/node/NodesMaterial.hx @@ -174,7 +174,43 @@ class NodesMaterial { type: "VALUE", color: 0xffa1a1a1, default_value: 1.0 - }, + } + ], + buttons: [ + { + name: "Layer", + type: "ENUM", + default_value: 0, + data: "" + } + ] + }, + { + id: 0, + name: "Layer Mask", + type: "LAYER_MASK", // extension + x: 0, + y: 0, + color: 0xff4982a0, + inputs: [ + { + id: 0, + node_id: 0, + name: "Vector", + type: "VECTOR", + color: 0xff6363c7, + default_value: [0.0, 0.0, 0.0] + } + ], + outputs: [ + { + id: 0, + node_id: 0, + name: "Value", + type: "VALUE", + color: 0xffa1a1a1, + default_value: 0.0 + } ], buttons: [ { diff --git a/Sources/arm/render/Uniforms.hx b/Sources/arm/render/Uniforms.hx index f7fb5509..72fcba31 100644 --- a/Sources/arm/render/Uniforms.hx +++ b/Sources/arm/render/Uniforms.hx @@ -304,9 +304,14 @@ class Uniforms { var tid = link.substr(link.length - 1); return RenderPath.active.renderTargets.get("texpaint_pack" + tid).image; } - if (link.startsWith("_texpaint")) { + + if (link == "_texpaint_mask") { + return Context.layer.texpaint_mask; + } + if (link.startsWith("_texpaint_mask")) { var tid = Std.parseInt(link.substr(link.length - 1)); - return Project.layers[tid].texpaint; + trace(tid); + return Project.layers[tid].texpaint_mask; } if (link.startsWith("_texpaint_nor")) { var tid = Std.parseInt(link.substr(link.length - 1)); @@ -316,9 +321,11 @@ class Uniforms { var tid = Std.parseInt(link.substr(link.length - 1)); return Project.layers[tid].texpaint_pack; } - if (link == "_texpaint_mask") { - return Context.layer.texpaint_mask; + if (link.startsWith("_texpaint")) { + var tid = Std.parseInt(link.substr(link.length - 1)); + return Project.layers[tid].texpaint; } + if (link == "_texparticle") { return RenderPath.active.renderTargets.get("texparticle").image; }