Directional brush
This commit is contained in:
@@ -243,13 +243,27 @@ class MakePaint {
|
||||
frag.write('binp_mask.x *= aspectRatio;');
|
||||
frag.write('binp_mask = binp_mask * 0.5 + 0.5;');
|
||||
frag.write('vec2 pa_mask = bsp.xy - binp_mask.xy;');
|
||||
// if (UITrait.inst.brushDirectional) {
|
||||
// frag.add_uniform('vec2 brushDirection', '_brushDirection');
|
||||
// frag.write('pa_mask.xy = vec2(pa_mask.x * brushDirection.x - pa_mask.y * brushDirection.y, pa_mask.x * brushDirection.y + pa_mask.y * brushDirection.x);');
|
||||
// }
|
||||
if (UITrait.inst.brushDirectional) {
|
||||
frag.write('float maskAngle = atan2(-inp.y + inplast.y, inp.x - inplast.x) - 3.141592 / 2;');
|
||||
frag.write('pa_mask.xy = vec2(pa_mask.x * cos(maskAngle) - pa_mask.y * sin(maskAngle), pa_mask.x * sin(maskAngle) + pa_mask.y * cos(maskAngle));');
|
||||
}
|
||||
var angle = UITrait.inst.brushAngle + UITrait.inst.brushNodesAngle;
|
||||
if (angle != 0.0) {
|
||||
var a = angle * (Math.PI / 180);
|
||||
frag.write('pa_mask.xy = vec2(pa_mask.x * ${Math.cos(a)} - pa_mask.y * ${Math.sin(a)}, pa_mask.x * ${Math.sin(a)} + pa_mask.y * ${Math.cos(a)});');
|
||||
}
|
||||
frag.write('pa_mask /= brushRadius;');
|
||||
if (UITrait.inst.brush3d) {
|
||||
frag.add_uniform('vec3 eye', '_cameraPosition');
|
||||
frag.write('pa_mask *= distance(eye, winp.xyz) / 1.5;');
|
||||
}
|
||||
frag.write('pa_mask = pa_mask.xy * 0.5 + 0.5;');
|
||||
frag.write('opacity *= textureLod(texbrushmask, pa_mask, 0.0).r;');
|
||||
frag.write('float4 mask_sample = textureLod(texbrushmask, pa_mask, 0.0);');
|
||||
frag.write('opacity *= mask_sample.r * mask_sample.a;');
|
||||
}
|
||||
|
||||
if (Context.tool == ToolParticle) { // particle mask
|
||||
|
||||
@@ -31,9 +31,18 @@ class MakeTexcoord {
|
||||
|
||||
frag.write_attrib('vec2 texCoord = uvsp * brushScale;');
|
||||
|
||||
var uvRot = Context.layer.material_mask != null ? Context.layer.uvRot : UITrait.inst.brushRot;
|
||||
if (uvRot > 0.0) {
|
||||
var a = uvRot * (Math.PI / 180);
|
||||
// if (UITrait.inst.brushDirectional) {
|
||||
// frag.add_uniform('vec2 brushDirection', '_brushDirection');
|
||||
// frag.write('texCoord = vec2(texCoord.x * brushDirection.x - texCoord.y * brushDirection.y, texCoord.x * brushDirection.y + texCoord.y * brushDirection.x);');
|
||||
// }
|
||||
if (UITrait.inst.brushDirectional) {
|
||||
frag.write('float maskAngleBrush = atan2(-inp.y + inplast.y, inp.x - inplast.x) - 3.141592 / 2;');
|
||||
frag.write('texCoord = vec2(texCoord.x * cos(maskAngleBrush) - texCoord.y * sin(maskAngleBrush), texCoord.x * sin(maskAngleBrush) + texCoord.y * cos(maskAngleBrush));');
|
||||
}
|
||||
var angle = UITrait.inst.brushAngle + UITrait.inst.brushNodesAngle;
|
||||
var uvAngle = Context.layer.material_mask != null ? Context.layer.angle : angle;
|
||||
if (uvAngle != 0.0) {
|
||||
var a = uvAngle * (Math.PI / 180);
|
||||
frag.write('texCoord = vec2(texCoord.x * ${Math.cos(a)} - texCoord.y * ${Math.sin(a)}, texCoord.x * ${Math.sin(a)} + texCoord.y * ${Math.cos(a)});');
|
||||
}
|
||||
}
|
||||
@@ -42,9 +51,10 @@ class MakeTexcoord {
|
||||
vert.add_out('vec2 texCoord');
|
||||
vert.write('texCoord = subtex * brushScale;');
|
||||
|
||||
var uvRot = Context.layer.material_mask != null ? Context.layer.uvRot : UITrait.inst.brushRot;
|
||||
if (uvRot > 0.0) {
|
||||
var a = uvRot * (Math.PI / 180);
|
||||
var angle = UITrait.inst.brushAngle + UITrait.inst.brushNodesAngle;
|
||||
var uvAngle = Context.layer.material_mask != null ? Context.layer.angle : angle;
|
||||
if (uvAngle > 0.0) {
|
||||
var a = uvAngle * (Math.PI / 180);
|
||||
vert.write('texCoord = vec2(texCoord.x * ${Math.cos(a)} - texCoord.y * ${Math.sin(a)}, texCoord.x * ${Math.sin(a)} + texCoord.y * ${Math.cos(a)});');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,22 @@ class NodesBrush {
|
||||
// {
|
||||
// id: 0,
|
||||
// node_id: 0,
|
||||
// name: "Scale",
|
||||
// type: "VALUE",
|
||||
// color: 0xffa1a1a1,
|
||||
// default_value: 1.0
|
||||
// },
|
||||
// {
|
||||
// id: 0,
|
||||
// node_id: 0,
|
||||
// name: "Angle",
|
||||
// type: "VALUE",
|
||||
// color: 0xffa1a1a1,
|
||||
// default_value: 0.0
|
||||
// },
|
||||
// {
|
||||
// id: 0,
|
||||
// node_id: 0,
|
||||
// name: "Opacity",
|
||||
// type: "VALUE",
|
||||
// color: 0xffa1a1a1,
|
||||
@@ -88,14 +104,6 @@ class NodesBrush {
|
||||
// {
|
||||
// id: 0,
|
||||
// node_id: 0,
|
||||
// name: "UV Scale",
|
||||
// type: "VALUE",
|
||||
// color: 0xffa1a1a1,
|
||||
// default_value: 1.0
|
||||
// },
|
||||
// {
|
||||
// id: 0,
|
||||
// node_id: 0,
|
||||
// name: "Stencil",
|
||||
// type: "VALUE",
|
||||
// color: 0xffa1a1a1,
|
||||
@@ -103,7 +111,14 @@ class NodesBrush {
|
||||
// }
|
||||
// ],
|
||||
// outputs: [],
|
||||
// buttons: []
|
||||
// buttons: [
|
||||
// {
|
||||
// name: "Directional",
|
||||
// type: "BOOL",
|
||||
// default_value: false,
|
||||
// output: 0
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
{
|
||||
id: 0,
|
||||
|
||||
@@ -7,6 +7,8 @@ import arm.Tool;
|
||||
@:keep
|
||||
class BrushOutputNode extends LogicNode {
|
||||
|
||||
public var Directional = false; // button 0
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
UITrait.inst.runBrush = run;
|
||||
@@ -19,8 +21,10 @@ class BrushOutputNode extends LogicNode {
|
||||
|
||||
UITrait.inst.paintVec = inputs[0].get();
|
||||
UITrait.inst.brushNodesRadius = inputs[1].get();
|
||||
UITrait.inst.brushNodesScale = inputs[2].get();
|
||||
UITrait.inst.brushNodesAngle = inputs[3].get();
|
||||
|
||||
var opac: Dynamic = inputs[2].get(); // Float or texture name
|
||||
var opac: Dynamic = inputs[4].get(); // Float or texture name
|
||||
if (opac == null) opac = 1.0;
|
||||
if (Std.is(opac, String)) {
|
||||
UITrait.inst.brushNodesOpacity = 1.0;
|
||||
@@ -33,10 +37,9 @@ class BrushOutputNode extends LogicNode {
|
||||
UITrait.inst.brushMaskImage = null;
|
||||
}
|
||||
|
||||
UITrait.inst.brushNodesHardness = inputs[3].get();
|
||||
UITrait.inst.brushNodesScale = inputs[4].get();
|
||||
UITrait.inst.brushNodesHardness = inputs[5].get();
|
||||
|
||||
var stencil: Dynamic = inputs[5].get(); // Float or texture name
|
||||
var stencil: Dynamic = inputs[6].get(); // Float or texture name
|
||||
if (stencil == null) stencil = 1.0;
|
||||
if (Std.is(stencil, String)) {
|
||||
var index = Project.assetNames.indexOf(stencil);
|
||||
@@ -51,6 +54,8 @@ class BrushOutputNode extends LogicNode {
|
||||
lastStencil != UITrait.inst.brushStencilImage) {
|
||||
MaterialParser.parsePaintMaterial();
|
||||
}
|
||||
|
||||
UITrait.inst.brushDirectional = Directional;
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
|
||||
Reference in New Issue
Block a user