Add stencil socket to brush
This commit is contained in:
@@ -1 +1 @@
|
||||
{"name":"Brush","nodes":[{"id":3,"name":"Input","type":"InputNode","x":83,"y":192,"color":-11959648,"inputs":[],"outputs":[{"id":3,"node_id":3,"name":"Position","type":"VECTOR","color":-10238109,"default_value":null}],"buttons":[]},{"id":5,"name":"Brush Output","type":"BrushOutputNode","x":311,"y":192,"color":-11959648,"inputs":[{"id":5,"node_id":5,"name":"Position","type":"VECTOR","color":-10238109,"default_value":[0,0,0]},{"id":5,"node_id":5,"name":"Radius","type":"VALUE","color":-6184543,"default_value":1.0},{"id":5,"node_id":5,"name":"Opacity","type":"VALUE","color":-6184543,"default_value":1},{"id":5,"node_id":5,"name":"Hardness","type":"VALUE","color":-6184543,"default_value":1},{"id":5,"node_id":5,"name":"UV Scale","type":"VALUE","color":-6184543,"default_value":1.0}],"outputs":[],"buttons":[]}],"links":[{"id":0,"from_id":3,"from_socket":0,"to_id":5,"to_socket":0}]}
|
||||
{"name":"Brush","nodes":[{"id":3,"name":"Input","type":"InputNode","x":83,"y":192,"color":-11959648,"inputs":[],"outputs":[{"id":3,"node_id":3,"name":"Position","type":"VECTOR","color":-10238109,"default_value":null}],"buttons":[]},{"id":5,"name":"Brush Output","type":"BrushOutputNode","x":311,"y":192,"color":-11959648,"inputs":[{"id":5,"node_id":5,"name":"Position","type":"VECTOR","color":-10238109,"default_value":[0,0,0]},{"id":5,"node_id":5,"name":"Radius","type":"VALUE","color":-6184543,"default_value":1.0},{"id":5,"node_id":5,"name":"Opacity","type":"VALUE","color":-6184543,"default_value":1},{"id":5,"node_id":5,"name":"Hardness","type":"VALUE","color":-6184543,"default_value":1},{"id":5,"node_id":5,"name":"UV Scale","type":"VALUE","color":-6184543,"default_value":1.0},{"id":5,"node_id":5,"name":"Stencil","type":"VALUE","color":-6184543,"default_value":1.0}],"outputs":[],"buttons":[]}],"links":[{"id":0,"from_id":3,"from_socket":0,"to_id":5,"to_socket":0}]}
|
||||
@@ -75,6 +75,14 @@ class NodesBrush {
|
||||
// type: "VALUE",
|
||||
// color: 0xffa1a1a1,
|
||||
// default_value: 1.0
|
||||
// },
|
||||
// {
|
||||
// id: 0,
|
||||
// node_id: 0,
|
||||
// name: "Stencil",
|
||||
// type: "VALUE",
|
||||
// color: 0xffa1a1a1,
|
||||
// default_value: 1.0
|
||||
// }
|
||||
// ],
|
||||
// outputs: [],
|
||||
|
||||
@@ -14,11 +14,14 @@ class BrushOutputNode extends LogicNode {
|
||||
}
|
||||
|
||||
function parseInputs() {
|
||||
var lastMask = UITrait.inst.brushMaskImage;
|
||||
var lastStencil = UITrait.inst.brushStencilImage;
|
||||
|
||||
UITrait.inst.paintVec = inputs[0].get();
|
||||
UITrait.inst.brushNodesRadius = inputs[1].get();
|
||||
|
||||
var opac: Dynamic = inputs[2].get(); // Float or texture name
|
||||
if (opac == null) opac = 1.0;
|
||||
var lastMask = UITrait.inst.brushMaskImage;
|
||||
if (Std.is(opac, String)) {
|
||||
UITrait.inst.brushNodesOpacity = 1.0;
|
||||
var index = Project.assetNames.indexOf(opac);
|
||||
@@ -29,11 +32,25 @@ class BrushOutputNode extends LogicNode {
|
||||
UITrait.inst.brushNodesOpacity = opac;
|
||||
UITrait.inst.brushMaskImage = null;
|
||||
}
|
||||
if (lastMask != UITrait.inst.brushMaskImage) {
|
||||
MaterialParser.parsePaintMaterial();
|
||||
}
|
||||
|
||||
UITrait.inst.brushNodesHardness = inputs[3].get();
|
||||
UITrait.inst.brushNodesScale = inputs[4].get();
|
||||
|
||||
var stencil: Dynamic = inputs[5].get(); // Float or texture name
|
||||
if (stencil == null) stencil = 1.0;
|
||||
if (Std.is(stencil, String)) {
|
||||
var index = Project.assetNames.indexOf(stencil);
|
||||
var asset = Project.assets[index];
|
||||
UITrait.inst.brushStencilImage = UITrait.inst.getImage(asset);
|
||||
}
|
||||
else {
|
||||
UITrait.inst.brushStencilImage = null;
|
||||
}
|
||||
|
||||
if (lastMask != UITrait.inst.brushMaskImage ||
|
||||
lastStencil != UITrait.inst.brushStencilImage) {
|
||||
MaterialParser.parsePaintMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
|
||||
@@ -173,6 +173,7 @@ class UITrait {
|
||||
public var brushNodesRadius = 1.0;
|
||||
public var brushNodesOpacity = 1.0;
|
||||
public var brushMaskImage: Image = null;
|
||||
public var brushStencilImage: Image = null;
|
||||
public var brushNodesScale = 1.0;
|
||||
public var brushNodesHardness = 1.0;
|
||||
|
||||
@@ -792,16 +793,6 @@ class UITrait {
|
||||
}
|
||||
|
||||
public function renderCursor(g: kha.graphics2.Graphics) {
|
||||
// if (cursorImg == null) {
|
||||
// g.end();
|
||||
// cursorImg = Image.createRenderTarget(256, 256);
|
||||
// cursorImg.g2.begin(true, 0x00000000);
|
||||
// cursorImg.g2.color = 0xffcccccc;
|
||||
// kha.graphics2.GraphicsExtension.drawCircle(cursorImg.g2, 128, 128, 124, 8);
|
||||
// cursorImg.g2.end();
|
||||
// g.begin(false);
|
||||
// }
|
||||
|
||||
g.color = 0xffffffff;
|
||||
|
||||
// Brush
|
||||
@@ -821,6 +812,12 @@ class UITrait {
|
||||
my += lockStartedY - System.windowHeight() / 2;
|
||||
}
|
||||
|
||||
if (brushStencilImage != null && Context.tool != ToolBake && Context.tool != ToolPicker && Context.tool != ToolColorId) {
|
||||
g.color = 0xaaffffff;
|
||||
g.drawImage(brushStencilImage, 0, 0);
|
||||
g.color = 0xffffffff;
|
||||
}
|
||||
|
||||
// Show picked material next to cursor
|
||||
if (Context.tool == ToolPicker && pickerSelectMaterial) {
|
||||
var img = Context.material.imageIcon;
|
||||
|
||||
Reference in New Issue
Block a user