Drag and drop material onto node canvas
This commit is contained in:
@@ -348,6 +348,16 @@ class App {
|
||||
if (inViewport || inLayers || in2dView) {
|
||||
Layers.createFillLayer();
|
||||
}
|
||||
else if (inNodes) {
|
||||
var index = 0;
|
||||
for (i in 0...Project.materials.length) {
|
||||
if (Project.materials[i] == dragMaterial) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
UINodes.inst.acceptMaterialDrag(index);
|
||||
}
|
||||
dragMaterial = null;
|
||||
}
|
||||
else if (dragLayer != null) {
|
||||
@@ -441,6 +451,11 @@ class App {
|
||||
for (l in Project.layers) layerNames.push(l.name);
|
||||
return layerNames;
|
||||
}
|
||||
else if (nodeType == "MATERIAL") {
|
||||
var materialNames:Array<String> = [];
|
||||
for (m in Project.materials) materialNames.push(UINodes.inst.canvasMap.get(m).name);
|
||||
return materialNames;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -838,6 +838,10 @@ class Material {
|
||||
}
|
||||
}
|
||||
|
||||
else if (node.type == 'MATERIAL') {
|
||||
return 'vec3(0.0, 0.0, 0.0)';
|
||||
}
|
||||
|
||||
else if (node.type == 'NEW_GEOMETRY') {
|
||||
if (socket == node.outputs[0]) { // Position
|
||||
curshader.wposition = true;
|
||||
@@ -1208,6 +1212,10 @@ class Material {
|
||||
}
|
||||
}
|
||||
|
||||
else if (node.type == 'MATERIAL') {
|
||||
return '0.0';
|
||||
}
|
||||
|
||||
else if (node.type == 'FRESNEL') {
|
||||
var ior = parse_value_input(node.inputs[0]);
|
||||
// var nor = parse_vector_input(node.inputs[1])
|
||||
|
||||
@@ -841,8 +841,7 @@ class MaterialBuilder {
|
||||
vert.write_attrib('gl_Position = mul(vec4(pos.xyz, 1.0), WVP);');
|
||||
|
||||
vert.add_out('vec2 texCoord');
|
||||
vert.add_uniform('float brushScale', '_brushScale');
|
||||
vert.write_attrib('texCoord = tex * brushScale;');
|
||||
vert.write_attrib('texCoord = tex;');
|
||||
|
||||
if (heightUsed) {
|
||||
frag.bposition = true;
|
||||
|
||||
@@ -221,6 +221,97 @@ class NodesMaterial {
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
name: "Material",
|
||||
type: "MATERIAL", // extension
|
||||
x: 0,
|
||||
y: 0,
|
||||
color: 0xff4982a0,
|
||||
inputs: [],
|
||||
outputs: [
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: "Base Color",
|
||||
type: "RGBA",
|
||||
color: 0xffc7c729,
|
||||
default_value: [0.0, 0.0, 0.0, 1.0]
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: "Opacity",
|
||||
type: "VALUE",
|
||||
color: 0xffa1a1a1,
|
||||
default_value: 1.0
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: "Occlusion",
|
||||
type: "VALUE",
|
||||
color: 0xffa1a1a1,
|
||||
default_value: 1.0
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: "Roughness",
|
||||
type: "VALUE",
|
||||
color: 0xffa1a1a1,
|
||||
default_value: 1.0
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: "Metallic",
|
||||
type: "VALUE",
|
||||
color: 0xffa1a1a1,
|
||||
default_value: 1.0
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: "Normal Map",
|
||||
type: "VECTOR",
|
||||
color: -10238109,
|
||||
default_value: [0.5, 0.5, 1.0]
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: "Emission",
|
||||
type: "VALUE",
|
||||
color: 0xffa1a1a1,
|
||||
default_value: 1.0
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: "Height",
|
||||
type: "VALUE",
|
||||
color: 0xffa1a1a1,
|
||||
default_value: 1.0
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
node_id: 0,
|
||||
name: "Subsurface",
|
||||
type: "VALUE",
|
||||
color: 0xffa1a1a1,
|
||||
default_value: 1.0
|
||||
}
|
||||
],
|
||||
buttons: [
|
||||
{
|
||||
name: "Material",
|
||||
type: "ENUM",
|
||||
default_value: 0,
|
||||
data: ""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
id: 0,
|
||||
name: "Fresnel",
|
||||
|
||||
@@ -56,6 +56,7 @@ class BrushOutputNode extends LogicNode {
|
||||
!UITrait.inst.ui.isHovered &&
|
||||
!UITrait.inst.ui.isScrolling &&
|
||||
!fillLayer &&
|
||||
(Context.layer.visible || UITrait.inst.paint2d) &&
|
||||
!arm.App.isDragging &&
|
||||
!arm.App.isResizing &&
|
||||
@:privateAccess UITrait.inst.ui.comboSelectedHandle == null &&
|
||||
|
||||
@@ -386,6 +386,12 @@ class UINodes {
|
||||
img = Project.layers[id].texpaint_mask_preview;
|
||||
}
|
||||
}
|
||||
else if (sel.type == "MATERIAL") {
|
||||
var id = sel.buttons[0].default_value;
|
||||
if (id < Project.materials.length) {
|
||||
img = Project.materials[id].image;
|
||||
}
|
||||
}
|
||||
if (img != null) {
|
||||
var tw = 64 * ui.SCALE();
|
||||
var th = tw * (img.height / img.width);
|
||||
@@ -505,6 +511,12 @@ class UINodes {
|
||||
nodes.nodesSelected = [n];
|
||||
}
|
||||
|
||||
public function acceptMaterialDrag(layerIndex:Int) {
|
||||
var n = NodesMaterial.createNode("MATERIAL");
|
||||
n.buttons[0].default_value = layerIndex;
|
||||
nodes.nodesSelected = [n];
|
||||
}
|
||||
|
||||
public static function makeNode(n:TNode, nodes:Nodes, canvas:TNodeCanvas):TNode {
|
||||
var node:TNode = Json.parse(Json.stringify(n));
|
||||
node.id = nodes.getNodeId(canvas.nodes);
|
||||
|
||||
Reference in New Issue
Block a user