Brush preview
This commit is contained in:
@@ -4,18 +4,19 @@ uniform mat4 invVP;
|
||||
uniform vec2 mouse;
|
||||
uniform vec2 texStep;
|
||||
uniform float radius;
|
||||
uniform vec3 cameraRight;
|
||||
uniform sampler2D gbufferD;
|
||||
in vec4 pos;
|
||||
in vec2 nor;
|
||||
in vec2 tex;
|
||||
out vec2 texCoord;
|
||||
mat3 rotAxis(vec3 axis, float a) {
|
||||
float c = cos(a);
|
||||
vec3 as = axis * sin(a);
|
||||
mat3 p = mat3(axis.x * axis, axis.y * axis, axis.z * axis);
|
||||
mat3 q = mat3(c, -as.z, as.y, as.z, c, -as.x, -as.y, as.x, c);
|
||||
return p * (1.0 - c) + q;
|
||||
}
|
||||
// mat3 rotAxis(vec3 axis, float a) {
|
||||
// float c = cos(a);
|
||||
// vec3 as = axis * sin(a);
|
||||
// mat3 p = mat3(axis.x * axis, axis.y * axis, axis.z * axis);
|
||||
// mat3 q = mat3(c, -as.z, as.y, as.z, c, -as.x, -as.y, as.x, c);
|
||||
// return p * (1.0 - c) + q;
|
||||
// }
|
||||
vec3 getPos(vec2 uv) {
|
||||
float depth = textureLod(gbufferD, uv, 0.0).r;
|
||||
vec4 wpos = vec4(uv * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);
|
||||
@@ -27,6 +28,10 @@ vec3 getNormal(vec3 p0, vec2 uv) {
|
||||
vec3 p2 = getPos(uv + vec2(0, texStep.y * 4));
|
||||
return normalize(cross(p2 - p0, p1 - p0));
|
||||
}
|
||||
void createBasis(vec3 normal, out vec3 tangent, out vec3 binormal) {
|
||||
tangent = normalize(cameraRight - normal * dot(cameraRight, normal));
|
||||
binormal = cross(tangent, normal);
|
||||
}
|
||||
void main() {
|
||||
texCoord = tex;
|
||||
vec3 wpos = getPos(mouse);
|
||||
@@ -39,12 +44,19 @@ void main() {
|
||||
getNormal(wpos1, uv1) +
|
||||
getNormal(wpos2, uv2)
|
||||
);
|
||||
float ax = acos(dot(vec3(1,0,0), vec3(n.x,0,0)));
|
||||
float az = acos(dot(vec3(0,0,1), vec3(0,0,n.z)));
|
||||
float sy = -sign(n.y);
|
||||
wpos +=
|
||||
rotAxis(vec3(1,0,0), -az * sy + 3.14/2) *
|
||||
rotAxis(vec3(0,0,1), ax + 3.14/2) *
|
||||
(pos.xyz * radius);
|
||||
// float ax = acos(dot(vec3(1,0,0), vec3(n.x,0,0)));
|
||||
// float az = acos(dot(vec3(0,0,1), vec3(0,0,n.z)));
|
||||
// float sy = -sign(n.y);
|
||||
// wpos +=
|
||||
// rotAxis(vec3(1,0,0), -az * sy + 3.14/2) *
|
||||
// rotAxis(vec3(0,0,1), ax + 3.14/2) *
|
||||
// (pos.xyz * radius);
|
||||
vec3 n_tan;
|
||||
vec3 n_bin;
|
||||
createBasis(n, n_tan, n_bin);
|
||||
if (gl_VertexID == 0) wpos += normalize(-n_tan - n_bin) * 0.7 * radius;
|
||||
else if (gl_VertexID == 1) wpos += normalize( n_tan - n_bin) * 0.7 * radius;
|
||||
else if (gl_VertexID == 2) wpos += normalize( n_tan + n_bin) * 0.7 * radius;
|
||||
else if (gl_VertexID == 3) wpos += normalize(-n_tan + n_bin) * 0.7 * radius;
|
||||
gl_Position = VP * vec4(wpos, 1.0);
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -3,17 +3,20 @@ uniform float4x4 invVP;
|
||||
uniform float2 mouse;
|
||||
uniform float2 texStep;
|
||||
uniform float radius;
|
||||
uniform float3 cameraRight;
|
||||
Texture2D<float4> texa; // direct3d12 unit align
|
||||
SamplerState _texa_sampler; // direct3d12 unit align
|
||||
Texture2D<float4> gbufferD;
|
||||
SamplerState _gbufferD_sampler;
|
||||
float3x3 rotAxis(float3 axis, float a) {
|
||||
float c = cos(a);
|
||||
float3 as = axis * sin(a).xxx;
|
||||
float3x3 p = float3x3(axis.xxx * axis, axis.yyy * axis, axis.zzz * axis);
|
||||
float3x3 q = float3x3(c, -as.z, as.y, as.z, c, -as.x, -as.y, as.x, c);
|
||||
return p * (1.0 - c) + q;
|
||||
}
|
||||
|
||||
// float3x3 rotAxis(float3 axis, float a) {
|
||||
// float c = cos(a);
|
||||
// float3 as = axis * sin(a).xxx;
|
||||
// float3x3 p = float3x3(axis.xxx * axis, axis.yyy * axis, axis.zzz * axis);
|
||||
// float3x3 q = float3x3(c, -as.z, as.y, as.z, c, -as.x, -as.y, as.x, c);
|
||||
// return p * (1.0 - c) + q;
|
||||
// }
|
||||
|
||||
float3 getPos(float2 uv) {
|
||||
float2 uvinv = float2(uv.x, 1.0 - uv.y);
|
||||
float depth = gbufferD.SampleLevel(_gbufferD_sampler, uvinv, 0).r;
|
||||
@@ -21,13 +24,21 @@ float3 getPos(float2 uv) {
|
||||
wpos = mul(wpos, invVP);
|
||||
return wpos.xyz / wpos.w;
|
||||
}
|
||||
|
||||
float3 getNormal(float3 p0, float2 uv) {
|
||||
float3 p1 = getPos(uv + float2(texStep.x, 0));
|
||||
float3 p2 = getPos(uv + float2(0, texStep.y));
|
||||
return normalize(cross(p2 - p0, p1 - p0));
|
||||
}
|
||||
|
||||
void createBasis(float3 normal, out float3 tangent, out float3 binormal) {
|
||||
// Project vector onto plane
|
||||
tangent = normalize(cameraRight - normal * dot(cameraRight, normal));
|
||||
binormal = cross(tangent, normal);
|
||||
}
|
||||
|
||||
struct SPIRV_Cross_Output { float2 texCoord : TEXCOORD0; float4 gl_Position : SV_Position; };
|
||||
SPIRV_Cross_Output main(float2 nor : TEXCOORD0, float4 pos : TEXCOORD1, float2 tex : TEXCOORD2) {
|
||||
SPIRV_Cross_Output main(float2 nor : TEXCOORD0, float4 pos : TEXCOORD1, float2 tex : TEXCOORD2, uint gl_VertexID : SV_VertexID) {
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.texCoord = tex;
|
||||
float3 wpos = getPos(mouse);
|
||||
@@ -42,11 +53,21 @@ SPIRV_Cross_Output main(float2 nor : TEXCOORD0, float4 pos : TEXCOORD1, float2 t
|
||||
getNormal(wpos1, uv1) +
|
||||
getNormal(wpos2, uv2)
|
||||
);
|
||||
float ax = acos(dot(float3(1,0,0), float3(n.x,0,0)));
|
||||
float az = acos(dot(float3(0,0,1), float3(0,0,n.z)));
|
||||
float sy = -sign(n.y);
|
||||
wpos += mul(mul(pos.xyz * radius.xxx, rotAxis(float3(0,0,1), ax + 3.14/2)),
|
||||
rotAxis(float3(1,0,0), -az * sy + 3.14/2));
|
||||
|
||||
// float ax = acos(dot(float3(1,0,0), float3(n.x,0,0)));
|
||||
// float az = acos(dot(float3(0,0,1), float3(0,0,n.z)));
|
||||
// float sy = -sign(n.y);
|
||||
// wpos += mul(mul(pos.xyz * radius.xxx, rotAxis(float3(0,0,1), ax + 3.14/2)),
|
||||
// rotAxis(float3(1,0,0), -az * sy + 3.14/2));
|
||||
|
||||
float3 n_tan;
|
||||
float3 n_bin;
|
||||
createBasis(n, n_tan, n_bin);
|
||||
if (gl_VertexID == 0) wpos += normalize(-n_tan - n_bin) * 0.7 * radius;
|
||||
else if (gl_VertexID == 1) wpos += normalize( n_tan - n_bin) * 0.7 * radius;
|
||||
else if (gl_VertexID == 2) wpos += normalize( n_tan + n_bin) * 0.7 * radius;
|
||||
else if (gl_VertexID == 3) wpos += normalize(-n_tan + n_bin) * 0.7 * radius;
|
||||
|
||||
stage_output.gl_Position = mul(float4(wpos, 1.0), VP);
|
||||
stage_output.gl_Position.z = (stage_output.gl_Position.z + stage_output.gl_Position.w) * 0.5;
|
||||
return stage_output;
|
||||
|
||||
@@ -41,6 +41,7 @@ class Layers {
|
||||
public static var cursorMouse: ConstantLocation;
|
||||
public static var cursorTexStep: ConstantLocation;
|
||||
public static var cursorRadius: ConstantLocation;
|
||||
public static var cursorCameraRight: ConstantLocation;
|
||||
public static var cursorTex: TextureUnit;
|
||||
public static var cursorGbufferD: TextureUnit;
|
||||
|
||||
@@ -168,6 +169,7 @@ class Layers {
|
||||
cursorMouse = pipeCursor.getConstantLocation("mouse");
|
||||
cursorTexStep = pipeCursor.getConstantLocation("texStep");
|
||||
cursorRadius = pipeCursor.getConstantLocation("radius");
|
||||
cursorCameraRight = pipeCursor.getConstantLocation("cameraRight");
|
||||
cursorGbufferD = pipeCursor.getTextureUnit("gbufferD");
|
||||
cursorTex = pipeCursor.getTextureUnit("tex");
|
||||
}
|
||||
|
||||
@@ -2,11 +2,16 @@ package arm.node;
|
||||
|
||||
import arm.ui.UITrait;
|
||||
import arm.node.MaterialShader;
|
||||
import arm.Tool;
|
||||
|
||||
class MakeBrush {
|
||||
|
||||
public static function run(vert: MaterialShader, frag: MaterialShader) {
|
||||
if (UITrait.inst.brush3d) {
|
||||
|
||||
if (Context.tool == ToolDecal || Context.tool == ToolText || Context.tool == ToolParticle) {
|
||||
frag.write('float dist = 0.0;');
|
||||
}
|
||||
else if (UITrait.inst.brush3d) {
|
||||
#if (kha_opengl || kha_webgl)
|
||||
frag.write('float depth = textureLod(gbufferD, vec2(inp.x, 1.0 - inp.y), 0.0).r;');
|
||||
#else
|
||||
|
||||
@@ -119,12 +119,7 @@ class MakePaint {
|
||||
#end
|
||||
}
|
||||
|
||||
if (decal || Context.tool == ToolParticle) {
|
||||
frag.write('float dist = 0.0;');
|
||||
}
|
||||
else {
|
||||
MakeBrush.run(vert, frag);
|
||||
}
|
||||
MakeBrush.run(vert, frag);
|
||||
}
|
||||
else { // Fill, Bake
|
||||
frag.write('float dist = 0.0;');
|
||||
|
||||
@@ -27,7 +27,7 @@ class MakeTexcoord {
|
||||
|
||||
frag.write_attrib('uvsp += vec2(0.5, 0.5);');
|
||||
|
||||
frag.write_attrib('if (uvsp.x < 0.01 || uvsp.y < 0.01 || uvsp.x > 0.99 || uvsp.y > 0.99) discard;');
|
||||
frag.write_attrib('if (uvsp.x < 0.0001 || uvsp.y < 0.0001 || uvsp.x > 0.9999 || uvsp.y > 0.9999) discard;');
|
||||
}
|
||||
else {
|
||||
frag.write_attrib('uvsp.x *= aspectRatio;');
|
||||
|
||||
@@ -303,37 +303,9 @@ void getSkinningDualQuat(const ivec4 bone, vec4 weight, out vec4 A, inout vec4 B
|
||||
";
|
||||
#end
|
||||
|
||||
// Created by Inigo Quilez
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
public static var str_udQuad = "
|
||||
float dot2(vec3 v) { return dot(v, v); }
|
||||
float udQuad(vec3 p, vec3 a, vec3 b, vec3 c, vec3 d) {
|
||||
vec3 ba = b - a; vec3 pa = p - a;
|
||||
vec3 cb = c - b; vec3 pb = p - b;
|
||||
vec3 dc = d - c; vec3 pc = p - c;
|
||||
vec3 ad = a - d; vec3 pd = p - d;
|
||||
vec3 nor = cross(ba, ad);
|
||||
return sqrt(
|
||||
(sign(dot(cross(ba, nor), pa)) +
|
||||
sign(dot(cross(cb, nor), pb)) +
|
||||
sign(dot(cross(dc, nor), pc)) +
|
||||
sign(dot(cross(ad, nor), pd)) < 3.0)
|
||||
?
|
||||
min(min(min(
|
||||
dot2(ba * clamp(dot(ba, pa) / dot2(ba), 0.0, 1.0) - pa),
|
||||
dot2(cb * clamp(dot(cb, pb) / dot2(cb), 0.0, 1.0) - pb)),
|
||||
dot2(dc * clamp(dot(dc, pc) / dot2(dc), 0.0, 1.0) - pc)),
|
||||
dot2(ad * clamp(dot(ad, pd) / dot2(ad), 0.0, 1.0) - pd))
|
||||
:
|
||||
dot(nor, pa) * dot(nor, pa) / dot2(nor));
|
||||
}
|
||||
";
|
||||
|
||||
public static var str_createBasis = "
|
||||
void createBasis(vec3 normal, out vec3 tangent, out vec3 binormal) {
|
||||
vec3 v1 = cross(normal, vec3(1.0, 0.0, 0.0));
|
||||
vec3 v2 = cross(normal, vec3(0.0, 1.0, 0.0));
|
||||
tangent = length(v1) > length(v2) ? v1 : v2;
|
||||
tangent = normalize(cameraRight - normal * dot(cameraRight, normal));
|
||||
binormal = cross(tangent, normal);
|
||||
}
|
||||
";
|
||||
|
||||
@@ -568,6 +568,9 @@ class RenderPathDeferred {
|
||||
RenderPathPaint.bindLayers();
|
||||
#end
|
||||
path.drawMeshes("mesh");
|
||||
#if arm_painter
|
||||
RenderPathPaint.unbindLayers();
|
||||
#end
|
||||
}
|
||||
|
||||
static function drawSplit() {
|
||||
|
||||
@@ -69,6 +69,9 @@ class RenderPathForward {
|
||||
RenderPathPaint.bindLayers();
|
||||
#end
|
||||
path.drawMeshes("mesh");
|
||||
#if arm_painter
|
||||
RenderPathPaint.unbindLayers();
|
||||
#end
|
||||
}
|
||||
|
||||
static function drawForward() {
|
||||
|
||||
@@ -26,6 +26,11 @@ class RenderPathPaint {
|
||||
static var savedFov = 0.0;
|
||||
static var dilated = true;
|
||||
static var baking = false;
|
||||
static var liveLayer: arm.data.LayerSlot = null;
|
||||
static var liveLayerDrawn = 0;
|
||||
static var _texpaint: RenderTarget;
|
||||
static var _texpaint_nor: RenderTarget;
|
||||
static var _texpaint_pack: RenderTarget;
|
||||
|
||||
public static function init(_path: RenderPath) {
|
||||
path = _path;
|
||||
@@ -238,6 +243,70 @@ class RenderPathPaint {
|
||||
}
|
||||
}
|
||||
|
||||
static function useLiveLayer(use: Bool) {
|
||||
var tid = Context.layer.id;
|
||||
if (use) {
|
||||
_texpaint = path.renderTargets.get("texpaint" + tid);
|
||||
_texpaint_nor = path.renderTargets.get("texpaint_nor" + tid);
|
||||
_texpaint_pack = path.renderTargets.get("texpaint_pack" + tid);
|
||||
path.renderTargets.set("texpaint" + tid, path.renderTargets.get("texpaint_live"));
|
||||
path.renderTargets.set("texpaint_nor" + tid, path.renderTargets.get("texpaint_nor_live"));
|
||||
path.renderTargets.set("texpaint_pack" + tid, path.renderTargets.get("texpaint_pack_live"));
|
||||
}
|
||||
else {
|
||||
path.renderTargets.set("texpaint" + tid, _texpaint);
|
||||
path.renderTargets.set("texpaint_nor" + tid, _texpaint_nor);
|
||||
path.renderTargets.set("texpaint_pack" + tid, _texpaint_pack);
|
||||
}
|
||||
}
|
||||
|
||||
public static function commandsLiveBrush() {
|
||||
|
||||
if (liveLayer == null) {
|
||||
liveLayer = new arm.data.LayerSlot("_live");
|
||||
}
|
||||
|
||||
var tid = Context.layer.id;
|
||||
path.setTarget("texpaint_live", ["texpaint_nor_live", "texpaint_pack_live"]);
|
||||
path.bindTarget("texpaint" + tid, "tex0");
|
||||
path.bindTarget("texpaint_nor" + tid, "tex1");
|
||||
path.bindTarget("texpaint_pack" + tid, "tex2");
|
||||
path.drawShader("shader_datas/copy_mrt3_pass/copy_mrt3_pass");
|
||||
|
||||
useLiveLayer(true);
|
||||
liveLayerDrawn = 2;
|
||||
|
||||
var mx = Input.getMouse().viewX / iron.App.w();
|
||||
var my = 1.0 - (Input.getMouse().viewY / iron.App.h());
|
||||
if (UITrait.inst.brushLocked) {
|
||||
mx = (UITrait.inst.lockStartedX - iron.App.x()) / iron.App.w();
|
||||
my = 1.0 - (UITrait.inst.lockStartedY - iron.App.y()) / iron.App.h();
|
||||
}
|
||||
|
||||
var _x = UITrait.inst.paintVec.x;
|
||||
var _y = UITrait.inst.paintVec.y;
|
||||
var _lastX = UITrait.inst.lastPaintVecX;
|
||||
var _lastY = UITrait.inst.lastPaintVecY;
|
||||
var _pdirty = Context.pdirty;
|
||||
UITrait.inst.paintVec.x = mx;
|
||||
UITrait.inst.paintVec.y = 1.0 - my;
|
||||
UITrait.inst.lastPaintVecX = mx;
|
||||
UITrait.inst.lastPaintVecY = 1.0 - my;
|
||||
Context.pdirty = 2;
|
||||
Context.rdirty = 2;
|
||||
UITrait.inst.sub = 0;
|
||||
|
||||
commandsPaint();
|
||||
|
||||
useLiveLayer(false);
|
||||
|
||||
UITrait.inst.paintVec.x = _x;
|
||||
UITrait.inst.paintVec.y = _y;
|
||||
UITrait.inst.lastPaintVecX = _lastX;
|
||||
UITrait.inst.lastPaintVecY = _lastY;
|
||||
Context.pdirty = _pdirty;
|
||||
}
|
||||
|
||||
@:access(iron.RenderPath)
|
||||
public static function commandsCursor() {
|
||||
var tool = Context.tool;
|
||||
@@ -246,8 +315,6 @@ class RenderPathPaint {
|
||||
tool != ToolClone &&
|
||||
tool != ToolBlur &&
|
||||
tool != ToolParticle) {
|
||||
// tool != ToolDecal &&
|
||||
// tool != ToolText) {
|
||||
return;
|
||||
}
|
||||
if (!App.uienabled ||
|
||||
@@ -277,6 +344,8 @@ class RenderPathPaint {
|
||||
g.setFloat2(Layers.cursorMouse, mx, my);
|
||||
g.setFloat2(Layers.cursorTexStep, 1 / gbuffer0.width, 1 / gbuffer0.height);
|
||||
g.setFloat(Layers.cursorRadius, UITrait.inst.brushRadius / 3.4);
|
||||
var right = Scene.active.camera.rightWorld().normalize();
|
||||
g.setFloat3(Layers.cursorCameraRight, right.x, right.y, right.z);
|
||||
g.setMatrix(Layers.cursorVP, Scene.active.camera.VP.self);
|
||||
var helpMat = iron.math.Mat4.identity();
|
||||
helpMat.getInverse(Scene.active.camera.VP);
|
||||
@@ -295,6 +364,13 @@ class RenderPathPaint {
|
||||
History.paint();
|
||||
}
|
||||
|
||||
if (liveLayerDrawn > 0) liveLayerDrawn--;
|
||||
|
||||
if (UITrait.inst.brushLive && Context.pdirty <= 0 && Context.ddirty <= 0 && UITrait.inst.brushTime == 0) {
|
||||
// Depth is unchnaged, draw before gbuffer gets updated
|
||||
commandsLiveBrush();
|
||||
}
|
||||
|
||||
// 2D paint
|
||||
if (UITrait.inst.paint2d) {
|
||||
// Set plane mesh
|
||||
@@ -345,13 +421,18 @@ class RenderPathPaint {
|
||||
}
|
||||
|
||||
public static function end() {
|
||||
if (UITrait.inst.brush3d) RenderPathPaint.commandsCursor();
|
||||
if (UITrait.inst.brush3d) commandsCursor();
|
||||
Context.ddirty--;
|
||||
Context.pdirty--;
|
||||
Context.rdirty--;
|
||||
}
|
||||
|
||||
public static function draw() {
|
||||
if (UITrait.inst.brushLive && Context.pdirty <= 0 && Context.ddirty > 0 && UITrait.inst.brushTime == 0) {
|
||||
// gbuffer has been updated now but brush will lag 1 frame
|
||||
commandsLiveBrush();
|
||||
}
|
||||
|
||||
if (History.undoLayers != null) {
|
||||
// Symmetry
|
||||
if (UITrait.inst.symX || UITrait.inst.symY || UITrait.inst.symZ) {
|
||||
@@ -363,37 +444,37 @@ class RenderPathPaint {
|
||||
if (UITrait.inst.symX) {
|
||||
t.scale.set(-sx, sy, sz);
|
||||
t.buildMatrix();
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
}
|
||||
if (UITrait.inst.symY) {
|
||||
t.scale.set(sx, -sy, sz);
|
||||
t.buildMatrix();
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
}
|
||||
if (UITrait.inst.symZ) {
|
||||
t.scale.set(sx, sy, -sz);
|
||||
t.buildMatrix();
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
}
|
||||
if (UITrait.inst.symX && UITrait.inst.symY) {
|
||||
t.scale.set(-sx, -sy, sz);
|
||||
t.buildMatrix();
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
}
|
||||
if (UITrait.inst.symX && UITrait.inst.symZ) {
|
||||
t.scale.set(-sx, sy, -sz);
|
||||
t.buildMatrix();
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
}
|
||||
if (UITrait.inst.symY && UITrait.inst.symZ) {
|
||||
t.scale.set(sx, -sy, -sz);
|
||||
t.buildMatrix();
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
}
|
||||
if (UITrait.inst.symX && UITrait.inst.symY && UITrait.inst.symZ) {
|
||||
t.scale.set(-sx, -sy, -sz);
|
||||
t.buildMatrix();
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
}
|
||||
t.scale.set(sx, sy, sz);
|
||||
t.buildMatrix();
|
||||
@@ -412,7 +493,7 @@ class RenderPathPaint {
|
||||
var _visible = highPoly.visible;
|
||||
highPoly.visible = true;
|
||||
Context.selectPaintObject(highPoly);
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
highPoly.visible = _visible;
|
||||
UITrait.inst.sub--;
|
||||
if (pushUndoLast) History.paint();
|
||||
@@ -422,7 +503,7 @@ class RenderPathPaint {
|
||||
UITrait.inst.bakeType = _bakeType;
|
||||
MaterialParser.parsePaintMaterial();
|
||||
Context.pdirty = 1;
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
Context.pdirty = 0;
|
||||
iron.App.removeRender(_renderFinal);
|
||||
baking = false;
|
||||
@@ -431,7 +512,7 @@ class RenderPathPaint {
|
||||
UITrait.inst.bakeType = BakeHeight;
|
||||
MaterialParser.parsePaintMaterial();
|
||||
Context.pdirty = 1;
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
Context.pdirty = 0;
|
||||
UITrait.inst.sub--;
|
||||
if (pushUndoLast) History.paint();
|
||||
@@ -451,7 +532,7 @@ class RenderPathPaint {
|
||||
|
||||
for (p in Project.paintObjects) {
|
||||
Context.selectPaintObject(p);
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
}
|
||||
|
||||
UITrait.inst.layerFilter = _layerFilter;
|
||||
@@ -467,11 +548,11 @@ class RenderPathPaint {
|
||||
}
|
||||
#end
|
||||
else {
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
}
|
||||
}
|
||||
else { // Paint
|
||||
RenderPathPaint.commandsPaint();
|
||||
commandsPaint();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,6 +585,9 @@ class RenderPathPaint {
|
||||
}
|
||||
|
||||
public static function bindLayers() {
|
||||
|
||||
if (UITrait.inst.brushLive && liveLayerDrawn > 0) useLiveLayer(true);
|
||||
|
||||
var tid = Project.layers[0].id;
|
||||
path.bindTarget("texpaint" + tid, "texpaint");
|
||||
path.bindTarget("texpaint_nor" + tid, "texpaint_nor");
|
||||
@@ -523,6 +607,10 @@ class RenderPathPaint {
|
||||
}
|
||||
}
|
||||
|
||||
public static function unbindLayers() {
|
||||
if (UITrait.inst.brushLive && liveLayerDrawn > 0) useLiveLayer(false);
|
||||
}
|
||||
|
||||
public static function finishPaint() {
|
||||
if (Context.tool == ToolBake && !dilated && UITrait.inst.dilateRadius > 0) {
|
||||
Layers.makeTempImg();
|
||||
|
||||
@@ -111,6 +111,9 @@ class BoxPreferences {
|
||||
UITrait.inst.dilateRadius = ui.slider(Id.handle({value: UITrait.inst.dilateRadius}), "Dilate Radius", 0.0, 64.0, true, 1);
|
||||
if (ui.isHovered) ui.tooltip("Dilate baked textures to prevent seams");
|
||||
|
||||
UITrait.inst.brushLive = ui.check(Id.handle({selected: UITrait.inst.brushLive}), "Live Brush Preview");
|
||||
if (ui.isHovered) ui.tooltip("Draw live brush preview in viewport");
|
||||
|
||||
var brush3dHandle = Id.handle({selected: UITrait.inst.brush3d});
|
||||
UITrait.inst.brush3d = ui.check(brush3dHandle, "3D Cursor");
|
||||
if (brush3dHandle.changed) MaterialParser.parsePaintMaterial();
|
||||
|
||||
@@ -190,6 +190,7 @@ class UITrait {
|
||||
public var brushBias = 1.0;
|
||||
public var brushPaint = UVMap;
|
||||
public var brush3d = true;
|
||||
public var brushLive = false;
|
||||
public var brushDepthReject = true;
|
||||
public var brushAngleReject = true;
|
||||
public var brushAngleRejectDot = 0.5;
|
||||
@@ -846,7 +847,7 @@ class UITrait {
|
||||
my > UINodes.inst.wy && my < UINodes.inst.wy + UINodes.inst.wh;
|
||||
var decal = Context.tool == ToolDecal || Context.tool == ToolText;
|
||||
|
||||
if (!brush3d || in2dView || decal) {
|
||||
if (!brush3d || in2dView || (decal && !brushLive)) {
|
||||
if (decal && !inNodes) {
|
||||
var psizex = Std.int(256 * (brushRadius * brushNodesRadius * brushScaleX));
|
||||
var psizey = Std.int(256 * (brushRadius * brushNodesRadius));
|
||||
|
||||
Reference in New Issue
Block a user