Mirror paint
This commit is contained in:
+15
-1
@@ -515,7 +515,16 @@ class UINodes extends iron.Trait {
|
||||
frag.write('vec2 pa = bsp.xy - binp.xy, ba = binplast.xy - binp.xy;');
|
||||
frag.write('float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0);');
|
||||
frag.write('float dist = length(pa - ba * h);');
|
||||
frag.write('if (dist > brushRadius) { discard; return; }');
|
||||
if (!UITrait.inst.mirrorX) {
|
||||
frag.write('if (dist > brushRadius) { discard; return; }');
|
||||
}
|
||||
else {
|
||||
frag.write('vec2 binp2 = vec2(0.5 - (binp.x - 0.5), binp.y), binplast2 = vec2(0.5 - (binplast.x - 0.5), binplast.y);');
|
||||
frag.write('vec2 pa2 = bsp.xy - binp2.xy, ba2 = binplast2.xy - binp2.xy;');
|
||||
frag.write('float h2 = clamp(dot(pa2, ba2) / dot(ba2, ba2), 0.0, 1.0);');
|
||||
frag.write('float dist2 = length(pa2 - ba2 * h2);');
|
||||
frag.write('if (dist > brushRadius && dist2 > brushRadius) { discard; return; }');
|
||||
}
|
||||
//
|
||||
|
||||
// frag.write('float dist = distance(bsp.xy, binp.xy);');
|
||||
@@ -592,6 +601,11 @@ class UINodes extends iron.Trait {
|
||||
if (eraser) frag.write(' float str = 1.0 - brushOpacity;');
|
||||
else frag.write(' float str = clamp(brushOpacity * (brushRadius - dist) * brushStrength, 0.0, 1.0);');
|
||||
|
||||
if (UITrait.inst.mirrorX && !eraser) {
|
||||
frag.write('str += clamp(brushOpacity * (brushRadius - dist2) * brushStrength, 0.0, 1.0);');
|
||||
frag.write('str = clamp(str, 0.0, 1.0);');
|
||||
}
|
||||
|
||||
frag.write(' fragColor[0] = vec4(basecol, str);');
|
||||
frag.write(' fragColor[1] = vec4(nortan, 1.0);');
|
||||
// frag.write(' fragColor[1] = vec4(nortan, str);');
|
||||
|
||||
+18
-2
@@ -304,6 +304,7 @@ class UITrait extends iron.Trait {
|
||||
public var paintHeight = false;
|
||||
|
||||
public var paintVisible = true;
|
||||
public var mirrorX = false;
|
||||
|
||||
function linkFloat(object:Object, mat:MaterialData, link:String):Null<kha.FastFloat> {
|
||||
|
||||
@@ -1276,14 +1277,12 @@ class UITrait extends iron.Trait {
|
||||
#end
|
||||
}
|
||||
|
||||
|
||||
function renderUI(g:kha.graphics2.Graphics) {
|
||||
if (!show) return;
|
||||
|
||||
if (!arm.App.uienabled && ui.inputRegistered) ui.unregisterInput();
|
||||
if (arm.App.uienabled && !ui.inputRegistered) ui.registerInput();
|
||||
|
||||
// var brushImg = bundled.get('brush.jpg');
|
||||
var envThumb = bundled.get('env_thumb.jpg');
|
||||
var cursorImg = bundled.get('cursor.png');
|
||||
var mouse = iron.system.Input.getMouse();
|
||||
@@ -1307,6 +1306,17 @@ class UITrait extends iron.Trait {
|
||||
else {
|
||||
var psize = Std.int(cursorImg.width * (brushRadius * brushNodesRadius));
|
||||
g.drawScaledImage(cursorImg, mx - psize / 2, my - psize / 2, psize, psize);
|
||||
|
||||
if (mirrorX) {
|
||||
var cx = iron.App.w() / 2;
|
||||
var nx = cx + (cx - mx);
|
||||
// Separator line
|
||||
g.color = 0x66ffffff;
|
||||
g.fillRect(cx - 1, 0, 2, iron.App.h());
|
||||
// Cursor
|
||||
g.drawScaledImage(cursorImg, nx - psize / 2, my - psize / 2, psize, psize);
|
||||
g.color = 0xffffffff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1666,7 +1676,13 @@ class UITrait extends iron.Trait {
|
||||
UINodes.inst.parsePaintMaterial();
|
||||
}
|
||||
|
||||
ui.row([1/2,1/2]);
|
||||
paintVisible = ui.check(Id.handle({selected: paintVisible}), "Visible Only");
|
||||
mirrorX = ui.check(Id.handle({selected: mirrorX}), "Mirror");
|
||||
if (ui.changed) {
|
||||
UINodes.inst.updateCanvasMap();
|
||||
UINodes.inst.parsePaintMaterial();
|
||||
}
|
||||
}
|
||||
|
||||
if (ui.panel(Id.handle({selected: true}), "Material")) {
|
||||
|
||||
Reference in New Issue
Block a user