More layers
This commit is contained in:
@@ -67,7 +67,15 @@ class LayerSlot {
|
||||
texpaint.unload();
|
||||
texpaint_nor.unload();
|
||||
texpaint_pack.unload();
|
||||
if (texpaint_opt != null) texpaint_opt.unload();
|
||||
|
||||
RenderPath.active.renderTargets.remove("texpaint" + ext);
|
||||
RenderPath.active.renderTargets.remove("texpaint_nor" + ext);
|
||||
RenderPath.active.renderTargets.remove("texpaint_pack" + ext);
|
||||
|
||||
if (texpaint_opt != null) {
|
||||
texpaint_opt.unload();
|
||||
RenderPath.active.renderTargets.remove("texpaint_opt" + ext);
|
||||
}
|
||||
}
|
||||
|
||||
public function swap(other:LayerSlot) {
|
||||
|
||||
+29
-19
@@ -421,7 +421,7 @@ class UINodes extends iron.Trait {
|
||||
}
|
||||
|
||||
function make_paint(data:CyclesShaderData, matcon:TMaterialContext):CyclesShaderContext {
|
||||
var layered = UITrait.inst.layers.length > 1 && UITrait.inst.selectedLayer == UITrait.inst.layers[1];
|
||||
var layered = UITrait.inst.selectedLayer.id > 0;
|
||||
var eraser = UITrait.inst.brushType == 1;
|
||||
var context_id = 'paint';
|
||||
var con_paint:CyclesShaderContext = data.add_context({
|
||||
@@ -916,27 +916,37 @@ class UINodes extends iron.Trait {
|
||||
frag.write('specular = 1.0;');
|
||||
}
|
||||
|
||||
if (UITrait.inst.layers.length > 1 && UITrait.inst.layers[1].visible) {
|
||||
frag.add_uniform('sampler2D texpaint1');
|
||||
frag.add_uniform('sampler2D texpaint_nor1');
|
||||
frag.add_uniform('sampler2D texpaint_pack1');
|
||||
// frag.add_uniform('sampler2D texpaint_opt1');
|
||||
if (UITrait.inst.layers.length > 1) {
|
||||
frag.write('float factor0;');
|
||||
frag.write('float factorinv0;');
|
||||
frag.write('vec4 col_tex0;');
|
||||
// frag.write('vec4 col_nor0;');
|
||||
// frag.write('vec3 n0;');
|
||||
frag.write('vec4 pack0;');
|
||||
for (i in 1...UITrait.inst.layers.length) {
|
||||
if (!UITrait.inst.layers[i].visible) continue;
|
||||
var id = UITrait.inst.layers[i].id;
|
||||
frag.add_uniform('sampler2D texpaint' + id);
|
||||
frag.add_uniform('sampler2D texpaint_nor' + id);
|
||||
frag.add_uniform('sampler2D texpaint_pack' + id);
|
||||
// frag.add_uniform('sampler2D texpaint_opt' + id);
|
||||
|
||||
frag.write('vec4 col_tex1 = texture(texpaint1, texCoord);');
|
||||
// frag.write('vec4 col_nor1 = texture(texpaint_nor1, texCoord);');
|
||||
frag.write('col_tex0 = texture(texpaint' + id + ', texCoord);');
|
||||
// frag.write('col_nor0 = texture(texpaint_nor' + id + ', texCoord);');
|
||||
|
||||
frag.write('float factor = col_tex1.a;');
|
||||
frag.write('float factorinv = 1.0 - factor;');
|
||||
frag.write('factor0 = col_tex0.a;');
|
||||
frag.write('factorinv0 = 1.0 - factor0;');
|
||||
|
||||
frag.write('basecol = basecol * factorinv + pow(col_tex1.rgb, vec3(2.2)) * factor;');
|
||||
|
||||
// frag.write('vec3 n2 = texture(texpaint_nor1, texCoord).rgb * 2.0 - 1.0;');
|
||||
// frag.write('n2 = normalize(TBN * normalize(n2));');
|
||||
// frag.write('n *= n2;');
|
||||
frag.write('vec4 pack2 = texture(texpaint_pack1, texCoord);');
|
||||
frag.write('occlusion = occlusion * factorinv + pack2.r * factor;');
|
||||
frag.write('roughness = roughness * factorinv + pack2.g * factor;');
|
||||
frag.write('metallic = metallic * factorinv + pack2.b * factor;');
|
||||
frag.write('basecol = basecol * factorinv0 + pow(col_tex0.rgb, vec3(2.2)) * factor0;');
|
||||
|
||||
// frag.write('n0 = texture(texpaint_nor' + id + ', texCoord).rgb * 2.0 - 1.0;');
|
||||
// frag.write('n0 = normalize(TBN * normalize(n0));');
|
||||
// frag.write('n *= n0;');
|
||||
frag.write('pack0 = texture(texpaint_pack' + id + ', texCoord);');
|
||||
frag.write('occlusion = occlusion * factorinv0 + pack0.r * factor0;');
|
||||
frag.write('roughness = roughness * factorinv0 + pack0.g * factor0;');
|
||||
frag.write('metallic = metallic * factorinv0 + pack0.b * factor0;');
|
||||
}
|
||||
}
|
||||
|
||||
frag.write('n /= (abs(n.x) + abs(n.y) + abs(n.z));');
|
||||
|
||||
+13
-17
@@ -1773,14 +1773,12 @@ void main() {
|
||||
}
|
||||
if (i > 0) {
|
||||
if (ui.button("Apply")) {
|
||||
if (layers.length > 1 && selectedLayer == layers[1]) {
|
||||
iron.App.notifyOnRender(applySelectedLayer);
|
||||
}
|
||||
selectedLayer = layers[i];
|
||||
iron.App.notifyOnRender(applySelectedLayer);
|
||||
}
|
||||
if (ui.button("Delete")) {
|
||||
if (layers.length > 1 && selectedLayer == layers[1]) {
|
||||
deleteSelectedLayer();
|
||||
}
|
||||
selectedLayer = layers[i];
|
||||
deleteSelectedLayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1791,19 +1789,17 @@ void main() {
|
||||
drawList(Id.handle(), l, j);
|
||||
}
|
||||
|
||||
if (layers.length == 1) {
|
||||
if (layers.length < 4) { // TODO: Samplers limit in Kore, use arrays
|
||||
ui.row([1/2, 1/2]);
|
||||
if (ui.button("New")) {
|
||||
if (layers.length < 2) {
|
||||
selectedLayer = new LayerSlot();
|
||||
layers.push(selectedLayer);
|
||||
ui.g.end();
|
||||
UINodes.inst.parseMeshMaterial();
|
||||
UINodes.inst.parsePaintMaterial();
|
||||
ui.g.begin(false);
|
||||
ddirty = 2;
|
||||
iron.App.notifyOnRender(clearLastLayer);
|
||||
}
|
||||
selectedLayer = new LayerSlot();
|
||||
layers.push(selectedLayer);
|
||||
ui.g.end();
|
||||
UINodes.inst.parseMeshMaterial();
|
||||
UINodes.inst.parsePaintMaterial();
|
||||
ui.g.begin(false);
|
||||
ddirty = 2;
|
||||
iron.App.notifyOnRender(clearLastLayer);
|
||||
}
|
||||
}
|
||||
if (ui.button("2D View")) show2DView();
|
||||
|
||||
@@ -699,12 +699,12 @@ class RenderPathDeferred {
|
||||
path.bindTarget("texpaint_nor" + tid, "texpaint_nor");
|
||||
path.bindTarget("texpaint_pack" + tid, "texpaint_pack");
|
||||
if (arm.UITrait.inst.paintHeight) path.bindTarget("texpaint_opt" + tid, "texpaint_opt");
|
||||
if (arm.UITrait.inst.layers.length > 1) {
|
||||
tid = arm.UITrait.inst.layers[1].id;
|
||||
path.bindTarget("texpaint" + tid, "texpaint1");
|
||||
path.bindTarget("texpaint_nor" + tid, "texpaint_nor1");
|
||||
path.bindTarget("texpaint_pack" + tid, "texpaint_pack1");
|
||||
if (arm.UITrait.inst.paintHeight) path.bindTarget("texpaint_opt" + tid, "texpaint_opt1");
|
||||
for (i in 1...arm.UITrait.inst.layers.length) {
|
||||
tid = arm.UITrait.inst.layers[i].id;
|
||||
path.bindTarget("texpaint" + tid, "texpaint" + tid);
|
||||
path.bindTarget("texpaint_nor" + tid, "texpaint_nor" + tid);
|
||||
path.bindTarget("texpaint_pack" + tid, "texpaint_pack" + tid);
|
||||
if (arm.UITrait.inst.paintHeight) path.bindTarget("texpaint_opt" + tid, "texpaint_opt" + tid);
|
||||
}
|
||||
//
|
||||
|
||||
|
||||
Reference in New Issue
Block a user