Ver Fonte

Add smudge tool

luboslenco há 2 anos atrás
pai
commit
08a1cd18ba

BIN
armorpaint/Assets/icons.png


BIN
armorpaint/Assets/icons2x.png


+ 1 - 0
armorpaint/Assets/keymap_presets/blender.json

@@ -54,6 +54,7 @@
 	"tool_text": "t",
 	"tool_clone": "l",
 	"tool_blur": "u",
+	"tool_smudge": "m",
 	"tool_particle": "p",
 	"tool_colorid": "c",
 	"tool_picker": "v",

+ 1 - 0
armorpaint/Assets/keymap_presets/default.json

@@ -54,6 +54,7 @@
 	"tool_text": "t",
 	"tool_clone": "l",
 	"tool_blur": "u",
+	"tool_smudge": "m",
 	"tool_particle": "p",
 	"tool_colorid": "c",
 	"tool_picker": "v",

+ 1 - 0
armorpaint/Assets/keymap_presets/touch.json

@@ -54,6 +54,7 @@
 	"tool_text": "t",
 	"tool_clone": "l",
 	"tool_blur": "u",
+	"tool_smudge": "m",
 	"tool_particle": "p",
 	"tool_colorid": "c",
 	"tool_picker": "v",

+ 5 - 4
armorpaint/Sources/arm/Enums.hx

@@ -8,11 +8,12 @@ package arm;
 	var ToolText = 4;
 	var ToolClone = 5;
 	var ToolBlur = 6;
-	var ToolParticle = 7;
-	var ToolColorId = 8;
-	var ToolPicker = 9;
-	var ToolGizmo = 10;
+	var ToolSmudge = 7;
+	var ToolParticle = 8;
+	var ToolColorId = 9;
+	var ToolPicker = 10;
 	var ToolBake = 11;
+	var ToolGizmo = 12;
 }
 
 @:enum abstract SpaceType(Int) from Int to Int {

+ 1 - 0
armorpaint/Sources/arm/KeymapFormat.hx

@@ -25,6 +25,7 @@ import arm.KeymapBaseFormat;
 	public var tool_text: String;
 	public var tool_clone: String;
 	public var tool_blur: String;
+	public var tool_smudge: String;
 	public var tool_particle: String;
 	public var tool_colorid: String;
 	public var tool_picker: String;

+ 5 - 2
armorpaint/Sources/arm/render/RenderPathPaint.hx

@@ -303,7 +303,8 @@ class RenderPathPaint {
 				// Read texcoords from gbuffer
 				var readTC = (Context.raw.tool == ToolFill && Context.raw.fillTypeHandle.position == FillFace) ||
 							  Context.raw.tool == ToolClone ||
-							  Context.raw.tool == ToolBlur;
+							  Context.raw.tool == ToolBlur ||
+							  Context.raw.tool == ToolSmudge;
 				if (readTC) {
 					path.bindTarget("gbuffer2", "gbuffer2");
 				}
@@ -376,7 +377,8 @@ class RenderPathPaint {
 			tool != ToolClone &&
 			tool != ToolDecal &&
 			tool != ToolText &&
-			tool != ToolBlur) {
+			tool != ToolBlur &&
+			tool != ToolSmudge) {
 				return;
 		}
 
@@ -444,6 +446,7 @@ class RenderPathPaint {
 			tool != ToolEraser &&
 			tool != ToolClone &&
 			tool != ToolBlur &&
+			tool != ToolSmudge &&
 			tool != ToolParticle &&
 			!decalMask) {
 				return;

+ 1 - 1
armorpaint/Sources/arm/shader/MakeBlur.hx

@@ -36,7 +36,7 @@ class MakeBlur {
 		frag.add_uniform('vec2 texpaintSize', '_texpaintSize');
 		frag.write('vec2 texpaintSizeLocal = texpaintSize;'); // TODO: spirv workaround
 		frag.write('float blur_step = 1.0 / texpaintSizeLocal.x;');
-		if (Context.raw.blurDirectional) {
+		if (Context.raw.tool == ToolSmudge) {
 			#if (kha_direct3d11 || kha_direct3d12 || kha_metal)
 			frag.write('const float blur_weight[7] = {1.0 / 28.0, 2.0 / 28.0, 3.0 / 28.0, 4.0 / 28.0, 5.0 / 28.0, 6.0 / 28.0, 7.0 / 28.0};');
 			#else

+ 4 - 2
armorpaint/Sources/arm/shader/MakePaint.hx

@@ -107,6 +107,7 @@ class MakePaint {
 			Context.raw.tool == ToolEraser ||
 			Context.raw.tool == ToolClone  ||
 			Context.raw.tool == ToolBlur   ||
+			Context.raw.tool == ToolSmudge   ||
 			Context.raw.tool == ToolParticle ||
 			decal) {
 
@@ -174,7 +175,7 @@ class MakePaint {
 
 		MakeTexcoord.run(vert, frag);
 
-		if (Context.raw.tool == ToolClone || Context.raw.tool == ToolBlur) {
+		if (Context.raw.tool == ToolClone || Context.raw.tool == ToolBlur || Context.raw.tool == ToolSmudge) {
 			frag.add_uniform('sampler2D gbuffer2');
 			frag.add_uniform('vec2 gbufferSize', '_gbufferSize');
 			frag.add_uniform('sampler2D texpaint_undo', '_texpaint_undo');
@@ -184,7 +185,7 @@ class MakePaint {
 			if (Context.raw.tool == ToolClone) {
 				MakeClone.run(vert, frag);
 			}
-			else { // Blur
+			else { // Blur, Smudge
 				MakeBlur.run(vert, frag);
 			}
 		}
@@ -258,6 +259,7 @@ class MakePaint {
 			Context.raw.tool == ToolFill ||
 			Context.raw.tool == ToolClone  ||
 			Context.raw.tool == ToolBlur   ||
+			Context.raw.tool == ToolSmudge   ||
 			Context.raw.tool == ToolParticle ||
 			decal)) {
 			frag.add_uniform('sampler2D texbrushstencil', '_texbrushstencil');

+ 1 - 9
armorpaint/Sources/arm/ui/UIHeader.hx

@@ -257,6 +257,7 @@ class UIHeader {
 					 Context.raw.tool == ToolText ||
 					 Context.raw.tool == ToolClone ||
 					 Context.raw.tool == ToolBlur ||
+					 Context.raw.tool == ToolSmudge ||
 					 Context.raw.tool == ToolParticle) {
 
 				var decal = Context.raw.tool == ToolDecal || Context.raw.tool == ToolText;
@@ -418,15 +419,6 @@ class UIHeader {
 					ui._w = _w;
 				}
 
-				if (Context.raw.tool == ToolBlur) {
-					ui._x += 10 * ui.SCALE();
-					var dirHandle = Id.handle({ selected: false });
-					Context.raw.blurDirectional = ui.check(dirHandle, tr("Directional"));
-					if (dirHandle.changed) {
-						MakeMaterial.parsePaintMaterial();
-					}
-				}
-
 				#if arm_physics
 				if (Context.raw.tool == ToolParticle) {
 					ui._x += 10 * ui.SCALE();

+ 4 - 0
armorpaint/Sources/arm/ui/UISidebar.hx

@@ -280,6 +280,7 @@ class UISidebar {
 					else if (Operator.shortcut(Config.keymap.tool_text)) Context.selectTool(ToolText);
 					else if (Operator.shortcut(Config.keymap.tool_clone)) Context.selectTool(ToolClone);
 					else if (Operator.shortcut(Config.keymap.tool_blur)) Context.selectTool(ToolBlur);
+					else if (Operator.shortcut(Config.keymap.tool_smudge)) Context.selectTool(ToolSmudge);
 					else if (Operator.shortcut(Config.keymap.tool_particle)) Context.selectTool(ToolParticle);
 					else if (Operator.shortcut(Config.keymap.tool_picker)) Context.selectTool(ToolPicker);
 					else if (Operator.shortcut(Config.keymap.swap_brush_eraser)) Context.selectTool(Context.raw.tool == ToolBrush ? ToolEraser : ToolBrush);
@@ -292,6 +293,7 @@ class UISidebar {
 					Context.raw.tool == ToolText   ||
 					Context.raw.tool == ToolClone  ||
 					Context.raw.tool == ToolBlur   ||
+					Context.raw.tool == ToolSmudge   ||
 					Context.raw.tool == ToolParticle) {
 					if (Operator.shortcut(Config.keymap.brush_radius) ||
 						Operator.shortcut(Config.keymap.brush_opacity) ||
@@ -981,6 +983,7 @@ class UISidebar {
 					Context.raw.tool == ToolEraser ||
 					Context.raw.tool == ToolClone  ||
 					Context.raw.tool == ToolBlur   ||
+					Context.raw.tool == ToolSmudge   ||
 					Context.raw.tool == ToolParticle ||
 					(decalMask && !Config.raw.brush_3d) ||
 					(decalMask && Context.in2dView())) {
@@ -1001,6 +1004,7 @@ class UISidebar {
 				 Context.raw.tool == ToolText ||
 				 Context.raw.tool == ToolClone ||
 				 Context.raw.tool == ToolBlur ||
+				 Context.raw.tool == ToolSmudge ||
 				 Context.raw.tool == ToolParticle)) {
 				g.fillRect(mx - 1, my - 1, 2, 2);
 				var mx = Context.raw.brushLazyX * App.w() + App.x();

+ 7 - 5
armorpaint/Sources/arm/ui/UIToolbar.hx

@@ -26,13 +26,14 @@ class UIToolbar {
 		_tr("Text"),
 		_tr("Clone"),
 		_tr("Blur"),
+		_tr("Smudge"),
 		_tr("Particle"),
 		_tr("ColorID"),
 		_tr("Picker"),
 		_tr("Gizmo"),
 		_tr("Bake")
 	];
-	var toolCount = [10, 2, 1, 1];
+	var toolCount = [11, 2, 1, 1];
 
 	public function new() {
 		inst = this;
@@ -69,6 +70,7 @@ class UIToolbar {
 					"(" + Config.keymap.tool_text + ") - " + tr("Hold {key} to use the text as a mask", ["key" => Config.keymap.decal_mask]),
 					"(" + Config.keymap.tool_clone + ") - " + tr("Hold {key} to set source", ["key" => Config.keymap.set_clone_source]),
 					"(" + Config.keymap.tool_blur + ")",
+					"(" + Config.keymap.tool_smudge + ")",
 					"(" + Config.keymap.tool_particle + ")",
 					"(" + Config.keymap.tool_colorid + ")",
 					"(" + Config.keymap.tool_picker + ")"
@@ -80,7 +82,7 @@ class UIToolbar {
 					var rect = Res.tile50(img, i, 0);
 					var _y = ui._y;
 					if (ui.image(img, iconAccent, null, rect.x, rect.y, rect.w, rect.h) == State.Started) Context.selectTool(i);
-					if (i == 8 && Context.raw.colorIdPicked) {
+					if (i == ToolColorId && Context.raw.colorIdPicked) {
 						ui.g.drawScaledSubImage(RenderPath.active.renderTargets.get("texpaint_colorid").image, 0, 0, 1, 1, 0, _y + 1.5 * ui.SCALE(), 5 * ui.SCALE(), 34 * ui.SCALE());
 					}
 					if (ui.isHovered) ui.tooltip(tr(toolNames[i]) + " " + keys[i]);
@@ -98,7 +100,7 @@ class UIToolbar {
 			else if (UIHeader.inst.worktab.position == SpaceMaterial) {
 				ui._x += 2;
 				if (Context.raw.tool == ToolPicker) ui.fill(-1, 2, size + 2, size + 2, ui.t.HIGHLIGHT_COL);
-				if (ui.image(img, iconAccent, null, imgw * 9, 0, imgw, imgw) == State.Started) Context.selectTool(ToolPicker);
+				if (ui.image(img, iconAccent, null, imgw * ToolPicker, 0, imgw, imgw) == State.Started) Context.selectTool(ToolPicker);
 				if (ui.isHovered) ui.tooltip(tr("Picker") + " (V)");
 				ui._x -= 2;
 				ui._y += 2;
@@ -106,14 +108,14 @@ class UIToolbar {
 			else if (UIHeader.inst.worktab.position == SpaceBake) {
 				ui._x += 2;
 				if (Context.raw.tool == ToolBake) ui.fill(-1, 2, size + 2, size + 2, ui.t.HIGHLIGHT_COL);
-				if (ui.image(img, iconAccent, null, imgw * 11, 0, imgw, imgw) == State.Started) Context.selectTool(ToolBake);
+				if (ui.image(img, iconAccent, null, imgw * ToolBake, 0, imgw, imgw) == State.Started) Context.selectTool(ToolBake);
 				if (ui.isHovered) ui.tooltip(tr("Bake") + " (K)");
 				ui._x -= 2;
 				ui._y += 2;
 
 				ui._x += 2;
 				if (Context.raw.tool == ToolPicker) ui.fill(-1, 2, size + 2, size + 2, ui.t.HIGHLIGHT_COL);
-				if (ui.image(img, iconAccent, null, imgw * 9, 0, imgw, imgw) == State.Started) Context.selectTool(ToolPicker);
+				if (ui.image(img, iconAccent, null, imgw * ToolPicker, 0, imgw, imgw) == State.Started) Context.selectTool(ToolPicker);
 				if (ui.isHovered) ui.tooltip(tr("Picker") + " (V)");
 				ui._x -= 2;
 				ui._y += 2;

+ 0 - 1
base/Sources/arm/ContextBaseFormat.hx

@@ -84,7 +84,6 @@ import arm.ContextBaseFormat;
 	@:optional public var cloneDeltaX = 0.0;
 	@:optional public var cloneDeltaY = 0.0;
 
-	@:optional public var blurDirectional = false;
 	@:optional public var showCompass = true;
 	@:optional public var projectType = ModelRoundedCube;
 	@:optional public var projectAspectRatio = 0; // 1:1, 2:1, 1:2

+ 1 - 1
base/Sources/arm/render/RenderPathBase.hx

@@ -130,7 +130,7 @@ class RenderPathBase {
 		}
 
 		// Match projection matrix jitter
-		var skipTaa = Context.raw.splitView || ((Context.raw.tool == ToolClone || Context.raw.tool == ToolBlur) && Context.raw.pdirty > 0);
+		var skipTaa = Context.raw.splitView || ((Context.raw.tool == ToolClone || Context.raw.tool == ToolBlur || Context.raw.tool == ToolSmudge) && Context.raw.pdirty > 0);
 		@:privateAccess Scene.active.camera.frame = skipTaa ? 0 : RenderPathBase.taaFrame;
 		@:privateAccess Scene.active.camera.projectionJitter();
 		Scene.active.camera.buildMatrix();