This commit is contained in:
unknown
2019-06-02 00:14:47 +02:00
parent 790a8c7c5a
commit 7152f51c03
6 changed files with 20 additions and 74 deletions
+2 -11
View File
@@ -79,7 +79,6 @@ class LayerSlot {
t.width = Config.getTextureRes();
t.height = Config.getTextureRes();
t.format = 'RGBA32';
t.depth_buffer = "paintdb";
texpaint = RenderPath.active.createRenderTarget(t).image;
}
{
@@ -103,11 +102,6 @@ class LayerSlot {
}
public function unload() {
// Set null depth so paintdb stays alive
if (UITrait.inst.layers.length > 0 && UITrait.inst.layers[0] != this) {
texpaint.setDepthStencilFrom(texpaint_nor);
}
texpaint.unload();
texpaint_nor.unload();
texpaint_pack.unload();
@@ -122,8 +116,6 @@ class LayerSlot {
}
public function swap(other:LayerSlot) {
RenderPath.active.renderTargets.get("texpaint" + ext).image.setDepthStencilFrom(other.texpaint);
RenderPath.active.renderTargets.get("texpaint" + ext).image = other.texpaint;
RenderPath.active.renderTargets.get("texpaint_nor" + ext).image = other.texpaint_nor;
RenderPath.active.renderTargets.get("texpaint_pack" + ext).image = other.texpaint_pack;
@@ -274,7 +266,7 @@ class LayerSlot {
return l;
}
public function resize(hasDepth:Bool) {
public function resize() {
var res = Config.getTextureRes();
var rts = RenderPath.active.renderTargets;
@@ -282,8 +274,7 @@ class LayerSlot {
var texpaint_nor = this.texpaint_nor;
var texpaint_pack = this.texpaint_pack;
var depthFormat = hasDepth ? DepthStencilFormat.Depth16 : DepthStencilFormat.NoDepthAndStencil;
this.texpaint = kha.Image.createRenderTarget(res, res, TextureFormat.RGBA32, depthFormat);
this.texpaint = kha.Image.createRenderTarget(res, res, TextureFormat.RGBA32, DepthStencilFormat.NoDepthAndStencil);
this.texpaint_nor = kha.Image.createRenderTarget(res, res, TextureFormat.RGBA32, DepthStencilFormat.NoDepthAndStencil);
this.texpaint_pack = kha.Image.createRenderTarget(res, res, TextureFormat.RGBA32, DepthStencilFormat.NoDepthAndStencil);
+2 -10
View File
@@ -90,16 +90,8 @@ class Layers {
while (UITrait.inst.undoLayers.length > C.undo_steps) { var l = UITrait.inst.undoLayers.pop(); l.unload(); }
}
g.end();
var i = 0;
for (l in UITrait.inst.layers) {
l.resize(i == 0);
if (i > 0) l.texpaint.setDepthStencilFrom(UITrait.inst.layers[0].texpaint);
i++;
}
for (l in UITrait.inst.undoLayers) {
l.resize(false);
l.texpaint.setDepthStencilFrom(UITrait.inst.layers[0].texpaint);
}
for (l in UITrait.inst.layers) l.resize();
for (l in UITrait.inst.undoLayers) l.resize();
var rts = RenderPath.active.renderTargets;
rts.get("texpaint_blend0").image.unload();
rts.get("texpaint_blend0").raw.width = Config.getTextureRes();
+9 -9
View File
@@ -150,7 +150,7 @@ class MaterialBuilder {
frag.write('bsp.x *= aspectRatio;');
frag.write('bsp = bsp * 0.5 + 0.5;');
frag.add_uniform('sampler2D paintdb');
frag.add_uniform('sampler2D gbufferD');
frag.add_out('vec4 fragColor[4]');
@@ -166,9 +166,9 @@ class MaterialBuilder {
decal) {
#if (kha_opengl || kha_webgl)
frag.write('if (sp.z > textureLod(paintdb, vec2(sp.x, 1.0 - sp.y), 0.0).r) { discard; }');
frag.write('if (sp.z > textureLod(gbufferD, vec2(sp.x, 1.0 - sp.y), 0.0).r) { discard; }');
#else
frag.write('if (sp.z > textureLod(paintdb, vec2(sp.x, sp.y), 0.0).r) { discard; }');
frag.write('if (sp.z > textureLod(gbufferD, vec2(sp.x, sp.y), 0.0).r) { discard; }');
#end
if (decal || UITrait.inst.selectedTool == ToolParticle) {
@@ -177,9 +177,9 @@ class MaterialBuilder {
else {
if (UITrait.inst.brush3d) {
#if (kha_opengl || kha_webgl)
frag.write('float depth = textureLod(paintdb, vec2(inp.x, 1.0 - inp.y), 0.0).r;');
frag.write('float depth = textureLod(gbufferD, vec2(inp.x, 1.0 - inp.y), 0.0).r;');
#else
frag.write('float depth = textureLod(paintdb, inp.xy, 0.0).r;');
frag.write('float depth = textureLod(gbufferD, inp.xy, 0.0).r;');
#end
frag.add_uniform('mat4 invVP', '_inverseViewProjectionMatrix');
#if (kha_opengl || kha_webgl)
@@ -197,9 +197,9 @@ class MaterialBuilder {
// Continuos paint
#if (kha_opengl || kha_webgl)
frag.write('float depthlast = textureLod(paintdb, vec2(inplast.x, 1.0 - inplast.y), 0.0).r;');
frag.write('float depthlast = textureLod(gbufferD, vec2(inplast.x, 1.0 - inplast.y), 0.0).r;');
#else
frag.write('float depthlast = textureLod(paintdb, inplast.xy, 0.0).r;');
frag.write('float depthlast = textureLod(gbufferD, inplast.xy, 0.0).r;');
#end
#if (kha_opengl || kha_webgl)
frag.write('vec2 inplast2 = inplast;');
@@ -863,8 +863,8 @@ class MaterialBuilder {
// vert.add_out('vec4 wvpposition');
// vert.write('wvpposition = gl_Position;');
// frag.write('vec2 texCoord = wvpposition.xy / wvpposition.w;');
// frag.add_uniform('sampler2D paintdb');
// frag.write('fragColor *= 1.0 - clamp(distance(textureLod(paintdb, texCoord, 0).r, wvpposition.z), 0.0, 1.0);');
// frag.add_uniform('sampler2D gbufferD');
// frag.write('fragColor *= 1.0 - clamp(distance(textureLod(gbufferD, texCoord, 0).r, wvpposition.z), 0.0, 1.0);');
// Cycles.finalize(con_part);
con_part.data.shader_from_source = true;
+2 -12
View File
@@ -322,18 +322,8 @@ class Project {
UITrait.inst.resHandle.position = Config.getTextureResPos(project.layer_datas[0].res);
if (UITrait.inst.layers[0].texpaint.width != Config.getTextureRes()) {
var i = 0;
for (l in UITrait.inst.layers) {
l.resize(i == 0);
if (i > 0) l.texpaint.setDepthStencilFrom(UITrait.inst.layers[0].texpaint);
i++;
}
if (UITrait.inst.undoLayers != null) {
for (l in UITrait.inst.undoLayers) {
l.resize(false);
l.texpaint.setDepthStencilFrom(UITrait.inst.layers[0].texpaint);
}
}
for (l in UITrait.inst.layers) l.resize();
if (UITrait.inst.undoLayers != null) for (l in UITrait.inst.undoLayers) l.resize();
var rts = iron.RenderPath.active.renderTargets;
rts.get("texpaint_blend0").image.unload();
rts.get("texpaint_blend0").raw.width = Config.getTextureRes();
+3 -7
View File
@@ -35,10 +35,6 @@ class RenderPathDeferred {
path.createRenderTarget(t);
}
{
path.createDepthBuffer("paintdb", "DEPTH16");
}
{
var t = new RenderTargetRaw();
t.name = "texpaint_colorid";
@@ -190,7 +186,7 @@ class RenderPathDeferred {
lastY = mouse.y;
if (!UITrait.inst.dirty()) {
if (mx != lastX || my != lastY || UITrait.inst.ddirty == 0) {
if (mx != lastX || my != lastY || UITrait.inst.ddirty == 0 || mouse.locked) {
UITrait.inst.ddirty--;
path.setTarget("");
path.bindTarget(taaFrame % 2 == 0 ? "taa" : "taa2", "tex");
@@ -422,7 +418,7 @@ class RenderPathDeferred {
#if ((rp_ssgi == "RTGI") || (rp_ssgi == "RTAO"))
{
var ssgi = armory.data.Config.raw.rp_ssgi != false && UITrait.inst.cameraType == 0;
if (ssgi) {
if (ssgi && UITrait.inst.ddirty > 0) {
path.setTarget("singlea");
path.bindTarget("_main", "gbufferD");
path.bindTarget("gbuffer0", "gbuffer0");
@@ -448,7 +444,7 @@ class RenderPathDeferred {
#if rp_voxelao
if (armory.data.Config.raw.rp_gi != false)
{
var voxelize = path.voxelize();
var voxelize = path.voxelize() && UITrait.inst.ddirty > 0;
#if arm_voxelgi_temporal
voxelize = ++RenderPathCreator.voxelFrame % RenderPathCreator.voxelFreq == 0;
+2 -25
View File
@@ -13,18 +13,12 @@ class RenderPathPaint {
var path = RenderPathDeferred.path;
var tid = UITrait.inst.selectedLayer.id;
if (UITrait.inst.depthDirty()) {
path.setTarget("texpaint" + tid);
path.clearTarget(null, 1.0);
path.drawMeshes("depth");
}
if (UITrait.inst.paintDirty()) {
if (UITrait.inst.selectedTool == ToolParticle) {
path.setTarget("texparticle");
path.clearTarget(0x00000000);
path.bindTarget("_paintdb", "paintdb");
path.bindTarget("_main", "gbufferD");
var mo:iron.object.MeshObject = cast iron.Scene.active.getChild(".ParticleEmitter");
mo.visible = true;
@@ -104,14 +98,6 @@ class RenderPathPaint {
path.generateMipmaps("voxels");
}
//
#if (!kha_opengl)
path.setDepthFrom("bufa", "texpaint" + tid); // Unbind depth so we can read it
path.setDepthFrom("texpaint" + tid, "texpaint_nor" + tid);
path.depthToRenderTarget.set("paintdb", path.renderTargets.get("bufa"));
#end
//
var blendA = "texpaint_blend0";
var blendB = "texpaint_blend1";
path.setTarget(blendB);
@@ -120,7 +106,7 @@ class RenderPathPaint {
var isMask = UITrait.inst.selectedLayerIsMask;
var texpaint = isMask ? "texpaint_mask" + tid : "texpaint" + tid;
path.setTarget(texpaint, ["texpaint_nor" + tid, "texpaint_pack" + tid, blendA]);
path.bindTarget("_paintdb", "paintdb");
path.bindTarget("_main", "gbufferD");
path.bindTarget(blendB, "paintmask");
if (UITrait.inst.selectedTool == ToolBake && UITrait.inst.bakeType == 0) { // AO
path.bindTarget("voxels", "voxels");
@@ -138,15 +124,6 @@ class RenderPathPaint {
}
path.drawMeshes("paint");
//
#if (!kha_opengl)
path.setDepthFrom("texpaint" + tid, "bufa"); // Re-bind depth
path.setDepthFrom("bufa", "texpaint_nor" + tid);
var tid0 = UITrait.inst.layers[0].id;
path.depthToRenderTarget.set("paintdb", path.renderTargets.get("texpaint" + tid0));
#end
//
}
}
}