Add dilate pass
This commit is contained in:
+33
-6
@@ -184,17 +184,44 @@ class Layers {
|
||||
public static function makeTempImg() {
|
||||
var l = Project.layers[0];
|
||||
if (imga != null && imga.width != l.texpaint.width) {
|
||||
imga.unload();
|
||||
imgb.unload();
|
||||
imgc.unload();
|
||||
RenderPath.active.renderTargets.get("temptex0").unload();
|
||||
RenderPath.active.renderTargets.get("temptex1").unload();
|
||||
RenderPath.active.renderTargets.get("temptex2").unload();
|
||||
RenderPath.active.renderTargets.remove("temptex0");
|
||||
RenderPath.active.renderTargets.remove("temptex1");
|
||||
RenderPath.active.renderTargets.remove("temptex2");
|
||||
imga = null;
|
||||
imgb = null;
|
||||
imgc = null;
|
||||
}
|
||||
if (imga == null) {
|
||||
imga = Image.createRenderTarget(l.texpaint.width, l.texpaint.height);
|
||||
imgb = Image.createRenderTarget(l.texpaint.width, l.texpaint.height);
|
||||
imgc = Image.createRenderTarget(l.texpaint.width, l.texpaint.height);
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "temptex0";
|
||||
t.width = l.texpaint.width;
|
||||
t.height = l.texpaint.height;
|
||||
t.format = 'RGBA32';
|
||||
var rt = RenderPath.active.createRenderTarget(t);
|
||||
imga = rt.image;
|
||||
}
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "temptex1";
|
||||
t.width = l.texpaint.width;
|
||||
t.height = l.texpaint.height;
|
||||
t.format = 'RGBA32';
|
||||
var rt = RenderPath.active.createRenderTarget(t);
|
||||
imgb = rt.image;
|
||||
}
|
||||
{
|
||||
var t = new RenderTargetRaw();
|
||||
t.name = "temptex2";
|
||||
t.width = l.texpaint.width;
|
||||
t.height = l.texpaint.height;
|
||||
t.format = 'RGBA32';
|
||||
var rt = RenderPath.active.createRenderTarget(t);
|
||||
imgc = rt.image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -312,6 +312,7 @@ class RenderPathDeferred {
|
||||
if (Context.ddirty <= 0) Context.ddirty--;
|
||||
}
|
||||
Inc.endSplit();
|
||||
RenderPathPaint.finishPaint();
|
||||
return;
|
||||
}
|
||||
#end
|
||||
|
||||
@@ -123,6 +123,7 @@ class RenderPathForward {
|
||||
if (Context.ddirty <= 0) Context.ddirty--;
|
||||
}
|
||||
Inc.endSplit();
|
||||
RenderPathPaint.finishPaint();
|
||||
return;
|
||||
}
|
||||
#end
|
||||
|
||||
@@ -25,6 +25,7 @@ class RenderPathPaint {
|
||||
static var visibles:Array<Bool> = null;
|
||||
static var mergedObjectVisible = false;
|
||||
static var savedFov = 0.0;
|
||||
static var dilated = true;
|
||||
|
||||
public static function init(_path:RenderPath) {
|
||||
path = _path;
|
||||
@@ -64,6 +65,7 @@ class RenderPathPaint {
|
||||
}
|
||||
|
||||
path.loadShader("shader_datas/copy_mrt3_pass/copy_mrt3_pass");
|
||||
path.loadShader("shader_datas/dilate_pass/dilate_pass");
|
||||
}
|
||||
|
||||
@:access(iron.RenderPath)
|
||||
@@ -161,11 +163,18 @@ class RenderPathPaint {
|
||||
}
|
||||
#end
|
||||
|
||||
if (Context.tool == ToolBake && UITrait.inst.brushTime == iron.system.Time.delta) {
|
||||
// Clear to black on bake start
|
||||
path.setTarget("texpaint" + tid);
|
||||
path.clearTarget(0xff000000);
|
||||
}
|
||||
|
||||
var blendA = "texpaint_blend0";
|
||||
var blendB = "texpaint_blend1";
|
||||
path.setTarget(blendB);
|
||||
path.bindTarget(blendA, "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
|
||||
var isMask = Context.layerIsMask;
|
||||
var texpaint = isMask ? "texpaint_mask" + tid : "texpaint" + tid;
|
||||
path.setTarget(texpaint, ["texpaint_nor" + tid, "texpaint_pack" + tid, blendA]);
|
||||
@@ -379,6 +388,7 @@ class RenderPathPaint {
|
||||
}
|
||||
|
||||
if (Context.tool == ToolBake) {
|
||||
if (Context.pdirty > 0) dilated = false;
|
||||
if (UITrait.inst.bakeType == 2) { // Normal (Tangent)
|
||||
UITrait.inst.bakeType = 3; // Bake high poly world normals
|
||||
MaterialParser.parsePaintMaterial();
|
||||
@@ -475,6 +485,19 @@ class RenderPathPaint {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function finishPaint() {
|
||||
if (Context.tool == ToolBake && !dilated && UITrait.inst.dilateRadius > 0) {
|
||||
if (Layers.imga == null) Layers.makeTempImg();
|
||||
dilated = true;
|
||||
path.setTarget("temptex0");
|
||||
path.bindTarget("texpaint0", "tex");
|
||||
path.drawShader("shader_datas/copy_pass/copy_pass");
|
||||
path.setTarget("texpaint0");
|
||||
path.bindTarget("temptex0", "tex");
|
||||
path.drawShader("shader_datas/dilate_pass/dilate_pass");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#end
|
||||
|
||||
@@ -95,6 +95,13 @@ class Uniforms {
|
||||
return 1.2;
|
||||
#end
|
||||
}
|
||||
if (link == "_dilateRadius") {
|
||||
#if arm_painter
|
||||
return UITrait.inst.dilateRadius;
|
||||
#else
|
||||
return 8.0;
|
||||
#end
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,9 @@ class BoxPreferences {
|
||||
UITrait.inst.brushBias = ui.slider(Id.handle({value: UITrait.inst.brushBias}), "Paint Bleed", 0.0, 2.0, true);
|
||||
if (ui.isHovered) ui.tooltip("Stretch brush strokes on the uv map to prevent seams");
|
||||
|
||||
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");
|
||||
|
||||
var brush3dHandle = Id.handle({selected: UITrait.inst.brush3d});
|
||||
UITrait.inst.brush3d = ui.check(brush3dHandle, "3D Cursor");
|
||||
if (brush3dHandle.changed) MaterialParser.parsePaintMaterial();
|
||||
|
||||
@@ -200,6 +200,7 @@ class UITrait {
|
||||
public var bakeCurvOffset = 0.0;
|
||||
public var bakeCurvSmooth = 1;
|
||||
public var bakeHighPoly = 0;
|
||||
public var dilateRadius = 8.0;
|
||||
|
||||
public var xray = false;
|
||||
public var symX = false;
|
||||
|
||||
Reference in New Issue
Block a user