Ensure correct color attachment formats
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -23,9 +23,9 @@ out vec2 texCoord;
|
|||||||
vec3 getPos(vec2 uv) {
|
vec3 getPos(vec2 uv) {
|
||||||
#ifdef HLSL
|
#ifdef HLSL
|
||||||
float keep = textureLod(texa, vec2(0.0, 0.0), 0.0).r; // direct3d12 unit align
|
float keep = textureLod(texa, vec2(0.0, 0.0), 0.0).r; // direct3d12 unit align
|
||||||
|
float keep2 = pos.x + nor.x;
|
||||||
#endif
|
#endif
|
||||||
#if defined(HLSL) || defined(METAL)
|
#if defined(HLSL) || defined(METAL)
|
||||||
float keep2 = pos.x + nor.x;
|
|
||||||
float depth = textureLod(gbufferD, vec2(uv.x, 1.0 - uv.y), 0.0).r;
|
float depth = textureLod(gbufferD, vec2(uv.x, 1.0 - uv.y), 0.0).r;
|
||||||
#else
|
#else
|
||||||
float depth = textureLod(gbufferD, uv, 0.0).r;
|
float depth = textureLod(gbufferD, uv, 0.0).r;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class Layers {
|
|||||||
public static var pipeMergeB: PipelineState = null;
|
public static var pipeMergeB: PipelineState = null;
|
||||||
public static var pipeMergeA: PipelineState = null;
|
public static var pipeMergeA: PipelineState = null;
|
||||||
public static var pipeCopy: PipelineState;
|
public static var pipeCopy: PipelineState;
|
||||||
|
public static var pipeCopy8: PipelineState;
|
||||||
public static var pipeMask: PipelineState;
|
public static var pipeMask: PipelineState;
|
||||||
public static var tex0: TextureUnit;
|
public static var tex0: TextureUnit;
|
||||||
public static var tex1: TextureUnit;
|
public static var tex1: TextureUnit;
|
||||||
@@ -159,6 +160,22 @@ class Layers {
|
|||||||
pipeCopy.inputLayout = [vs];
|
pipeCopy.inputLayout = [vs];
|
||||||
pipeCopy.compile();
|
pipeCopy.compile();
|
||||||
|
|
||||||
|
#if kha_metal
|
||||||
|
pipeCopy8 = new PipelineState();
|
||||||
|
pipeCopy8.vertexShader = Reflect.field(kha.Shaders, "layer_view_vert");
|
||||||
|
pipeCopy8.fragmentShader = Reflect.field(kha.Shaders, "layer_copy_frag");
|
||||||
|
var vs = new VertexStructure();
|
||||||
|
vs.add("pos", VertexData.Float3);
|
||||||
|
vs.add("tex", VertexData.Float2);
|
||||||
|
vs.add("col", VertexData.Float4);
|
||||||
|
pipeCopy8.inputLayout = [vs];
|
||||||
|
pipeCopy8.colorAttachmentCount = 1;
|
||||||
|
pipeCopy8.colorAttachments[0] = TextureFormat.L8;
|
||||||
|
pipeCopy8.compile();
|
||||||
|
#else
|
||||||
|
pipeCopy8 = pipeCopy;
|
||||||
|
#end
|
||||||
|
|
||||||
pipeMask = new PipelineState();
|
pipeMask = new PipelineState();
|
||||||
pipeMask.vertexShader = Reflect.field(kha.Shaders, "layer_merge_vert");
|
pipeMask.vertexShader = Reflect.field(kha.Shaders, "layer_merge_vert");
|
||||||
pipeMask.fragmentShader = Reflect.field(kha.Shaders, "mask_merge_frag");
|
pipeMask.fragmentShader = Reflect.field(kha.Shaders, "mask_merge_frag");
|
||||||
@@ -175,9 +192,13 @@ class Layers {
|
|||||||
pipeCursor.vertexShader = Reflect.field(kha.Shaders, "cursor_vert");
|
pipeCursor.vertexShader = Reflect.field(kha.Shaders, "cursor_vert");
|
||||||
pipeCursor.fragmentShader = Reflect.field(kha.Shaders, "cursor_frag");
|
pipeCursor.fragmentShader = Reflect.field(kha.Shaders, "cursor_frag");
|
||||||
var vs = new VertexStructure();
|
var vs = new VertexStructure();
|
||||||
|
#if kha_metal
|
||||||
|
vs.add("tex", VertexData.Short2Norm);
|
||||||
|
#else
|
||||||
vs.add("pos", VertexData.Short4Norm);
|
vs.add("pos", VertexData.Short4Norm);
|
||||||
vs.add("nor", VertexData.Short2Norm);
|
vs.add("nor", VertexData.Short2Norm);
|
||||||
vs.add("tex", VertexData.Short2Norm);
|
vs.add("tex", VertexData.Short2Norm);
|
||||||
|
#end
|
||||||
pipeCursor.inputLayout = [vs];
|
pipeCursor.inputLayout = [vs];
|
||||||
pipeCursor.blendSource = BlendingFactor.SourceAlpha;
|
pipeCursor.blendSource = BlendingFactor.SourceAlpha;
|
||||||
pipeCursor.blendDestination = BlendingFactor.InverseSourceAlpha;
|
pipeCursor.blendDestination = BlendingFactor.InverseSourceAlpha;
|
||||||
|
|||||||
@@ -261,13 +261,13 @@ class LayerSlot {
|
|||||||
if (texpaint_mask != null) {
|
if (texpaint_mask != null) {
|
||||||
l.createMask(0, false);
|
l.createMask(0, false);
|
||||||
l.texpaint_mask.g2.begin(false);
|
l.texpaint_mask.g2.begin(false);
|
||||||
l.texpaint_mask.g2.pipeline = Layers.pipeCopy;
|
l.texpaint_mask.g2.pipeline = Layers.pipeCopy8;
|
||||||
l.texpaint_mask.g2.drawImage(texpaint_mask, 0, 0);
|
l.texpaint_mask.g2.drawImage(texpaint_mask, 0, 0);
|
||||||
l.texpaint_mask.g2.pipeline = null;
|
l.texpaint_mask.g2.pipeline = null;
|
||||||
l.texpaint_mask.g2.end();
|
l.texpaint_mask.g2.end();
|
||||||
|
|
||||||
l.texpaint_mask_preview.g2.begin(true, 0x00000000);
|
l.texpaint_mask_preview.g2.begin(true, 0x00000000);
|
||||||
l.texpaint_mask_preview.g2.pipeline = Layers.pipeCopy;
|
l.texpaint_mask_preview.g2.pipeline = Layers.pipeCopy8;
|
||||||
l.texpaint_mask_preview.g2.drawScaledImage(texpaint_mask_preview, 0, 0, texpaint_mask_preview.width, texpaint_mask_preview.height);
|
l.texpaint_mask_preview.g2.drawScaledImage(texpaint_mask_preview, 0, 0, texpaint_mask_preview.width, texpaint_mask_preview.height);
|
||||||
l.texpaint_mask_preview.g2.pipeline = null;
|
l.texpaint_mask_preview.g2.pipeline = null;
|
||||||
l.texpaint_mask_preview.g2.end();
|
l.texpaint_mask_preview.g2.end();
|
||||||
@@ -342,7 +342,7 @@ class LayerSlot {
|
|||||||
this.texpaint_mask = Image.createRenderTarget(res, res, TextureFormat.L8);
|
this.texpaint_mask = Image.createRenderTarget(res, res, TextureFormat.L8);
|
||||||
|
|
||||||
this.texpaint_mask.g2.begin(false);
|
this.texpaint_mask.g2.begin(false);
|
||||||
this.texpaint_mask.g2.pipeline = Layers.pipeCopy;
|
this.texpaint_mask.g2.pipeline = Layers.pipeCopy8;
|
||||||
this.texpaint_mask.g2.drawScaledImage(texpaint_mask, 0, 0, res, res);
|
this.texpaint_mask.g2.drawScaledImage(texpaint_mask, 0, 0, res, res);
|
||||||
this.texpaint_mask.g2.pipeline = null;
|
this.texpaint_mask.g2.pipeline = null;
|
||||||
this.texpaint_mask.g2.end();
|
this.texpaint_mask.g2.end();
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ class ImportArm {
|
|||||||
l.createMask(0, false);
|
l.createMask(0, false);
|
||||||
texpaint_mask = Image.fromBytes(Lz4.decode(ld.texpaint_mask, ld.res * ld.res), ld.res, ld.res, TextureFormat.L8);
|
texpaint_mask = Image.fromBytes(Lz4.decode(ld.texpaint_mask, ld.res * ld.res), ld.res, ld.res, TextureFormat.L8);
|
||||||
l.texpaint_mask.g2.begin(false);
|
l.texpaint_mask.g2.begin(false);
|
||||||
l.texpaint_mask.g2.pipeline = Layers.pipeCopy;
|
l.texpaint_mask.g2.pipeline = Layers.pipeCopy8;
|
||||||
l.texpaint_mask.g2.drawImage(texpaint_mask, 0, 0);
|
l.texpaint_mask.g2.drawImage(texpaint_mask, 0, 0);
|
||||||
l.texpaint_mask.g2.pipeline = null;
|
l.texpaint_mask.g2.pipeline = null;
|
||||||
l.texpaint_mask.g2.end();
|
l.texpaint_mask.g2.end();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class MakePaint {
|
|||||||
// cull_mode: "counter_clockwise",
|
// cull_mode: "counter_clockwise",
|
||||||
cull_mode: "none",
|
cull_mode: "none",
|
||||||
vertex_elements: [{name: "pos", data: "short4norm"}, {name: "nor", data: "short2norm"}, {name: "tex", data: "short2norm"}],
|
vertex_elements: [{name: "pos", data: "short4norm"}, {name: "nor", data: "short2norm"}, {name: "tex", data: "short2norm"}],
|
||||||
color_attachments: ["RGBA32", "RGBA32", "RGBA32", "R8"]
|
color_attachments: [Context.layerIsMask ? "R8" : "RGBA32", "RGBA32", "RGBA32", "R8"]
|
||||||
});
|
});
|
||||||
|
|
||||||
con_paint.data.color_writes_red = [true, true, true, true];
|
con_paint.data.color_writes_red = [true, true, true, true];
|
||||||
|
|||||||
@@ -458,11 +458,19 @@ class RenderPathDeferred {
|
|||||||
|
|
||||||
if (Config.raw.rp_ssr != false) {
|
if (Config.raw.rp_ssr != false) {
|
||||||
if (@:privateAccess path.cachedShaderContexts.get("shader_datas/ssr_pass/ssr_pass") == null) {
|
if (@:privateAccess path.cachedShaderContexts.get("shader_datas/ssr_pass/ssr_pass") == null) {
|
||||||
|
{
|
||||||
|
var t = new RenderTargetRaw();
|
||||||
|
t.name = "bufb";
|
||||||
|
t.width = 0;
|
||||||
|
t.height = 0;
|
||||||
|
t.format = "RGBA64";
|
||||||
|
path.createRenderTarget(t);
|
||||||
|
}
|
||||||
path.loadShader("shader_datas/ssr_pass/ssr_pass");
|
path.loadShader("shader_datas/ssr_pass/ssr_pass");
|
||||||
path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_x");
|
path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_x");
|
||||||
path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_y3_blend");
|
path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_y3_blend");
|
||||||
}
|
}
|
||||||
var targeta = "buf";
|
var targeta = "bufb";
|
||||||
var targetb = "gbuffer1";
|
var targetb = "gbuffer1";
|
||||||
|
|
||||||
path.setTarget(targeta);
|
path.setTarget(targeta);
|
||||||
@@ -596,7 +604,11 @@ class RenderPathDeferred {
|
|||||||
|
|
||||||
public static function drawGbuffer() {
|
public static function drawGbuffer() {
|
||||||
path.setTarget("gbuffer0"); // Only clear gbuffer0
|
path.setTarget("gbuffer0"); // Only clear gbuffer0
|
||||||
|
#if kha_metal
|
||||||
|
path.clearTarget(0x00000000, 1.0);
|
||||||
|
#else
|
||||||
path.clearTarget(null, 1.0);
|
path.clearTarget(null, 1.0);
|
||||||
|
#end
|
||||||
path.setTarget("gbuffer2");
|
path.setTarget("gbuffer2");
|
||||||
path.clearTarget(0xff000000);
|
path.clearTarget(0xff000000);
|
||||||
path.setTarget("gbuffer0", ["gbuffer1", "gbuffer2"]);
|
path.setTarget("gbuffer0", ["gbuffer1", "gbuffer2"]);
|
||||||
|
|||||||
@@ -61,7 +61,11 @@ class RenderPathForward {
|
|||||||
|
|
||||||
static function drawGbuffer() {
|
static function drawGbuffer() {
|
||||||
path.setTarget("gbuffer0");
|
path.setTarget("gbuffer0");
|
||||||
|
#if kha_metal
|
||||||
|
path.clearTarget(0x00000000, 1.0);
|
||||||
|
#else
|
||||||
path.clearTarget(null, 1.0);
|
path.clearTarget(null, 1.0);
|
||||||
|
#end
|
||||||
path.setTarget("gbuffer2");
|
path.setTarget("gbuffer2");
|
||||||
path.clearTarget(0xff000000);
|
path.clearTarget(0xff000000);
|
||||||
path.setTarget("gbuffer0", ["gbuffer1", "gbuffer2"]);
|
path.setTarget("gbuffer0", ["gbuffer1", "gbuffer2"]);
|
||||||
|
|||||||
@@ -127,8 +127,18 @@ class RenderPathPaint {
|
|||||||
UIHeader.inst.headerHandle.redraws = 2;
|
UIHeader.inst.headerHandle.redraws = 2;
|
||||||
}
|
}
|
||||||
else if (Context.tool == ToolPicker) {
|
else if (Context.tool == ToolPicker) {
|
||||||
|
#if kha_metal
|
||||||
|
path.setTarget("texpaint_picker");
|
||||||
|
path.clearTarget(0xff000000);
|
||||||
|
path.setTarget("texpaint_nor_picker");
|
||||||
|
path.clearTarget(0xff000000);
|
||||||
|
path.setTarget("texpaint_pack_picker");
|
||||||
|
path.clearTarget(0xff000000);
|
||||||
|
path.setTarget("texpaint_picker", ["texpaint_nor_picker", "texpaint_pack_picker"]);
|
||||||
|
#else
|
||||||
path.setTarget("texpaint_picker", ["texpaint_nor_picker", "texpaint_pack_picker"]);
|
path.setTarget("texpaint_picker", ["texpaint_nor_picker", "texpaint_pack_picker"]);
|
||||||
path.clearTarget(0xff000000);
|
path.clearTarget(0xff000000);
|
||||||
|
#end
|
||||||
path.bindTarget("gbuffer2", "gbuffer2");
|
path.bindTarget("gbuffer2", "gbuffer2");
|
||||||
tid = Context.layer.id;
|
tid = Context.layer.id;
|
||||||
path.bindTarget("texpaint" + tid, "texpaint");
|
path.bindTarget("texpaint" + tid, "texpaint");
|
||||||
@@ -409,7 +419,11 @@ class RenderPathPaint {
|
|||||||
var helpMat = iron.math.Mat4.identity();
|
var helpMat = iron.math.Mat4.identity();
|
||||||
helpMat.getInverse(Scene.active.camera.VP);
|
helpMat.getInverse(Scene.active.camera.VP);
|
||||||
g.setMatrix(Layers.cursorInvVP, helpMat.self);
|
g.setMatrix(Layers.cursorInvVP, helpMat.self);
|
||||||
|
#if kha_metal
|
||||||
|
g.setVertexBuffer(geom.get([{name: "tex", data: "short2norm"}]));
|
||||||
|
#else
|
||||||
g.setVertexBuffer(geom.vertexBuffer);
|
g.setVertexBuffer(geom.vertexBuffer);
|
||||||
|
#end
|
||||||
g.setIndexBuffer(geom.indexBuffers[0]);
|
g.setIndexBuffer(geom.indexBuffers[0]);
|
||||||
g.drawIndexedVertices();
|
g.drawIndexedVertices();
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class RenderPathPreview {
|
|||||||
path.setTarget("mgbuffer2");
|
path.setTarget("mgbuffer2");
|
||||||
path.clearTarget(0xff000000);
|
path.clearTarget(0xff000000);
|
||||||
|
|
||||||
#if arm_world
|
#if (arm_world || kha_metal)
|
||||||
var clearColor = 0xffffffff;
|
var clearColor = 0xffffffff;
|
||||||
#else
|
#else
|
||||||
var clearColor: Null<Int> = null;
|
var clearColor: Null<Int> = null;
|
||||||
@@ -144,8 +144,9 @@ class RenderPathPreview {
|
|||||||
public static function commandsDecal() {
|
public static function commandsDecal() {
|
||||||
path.setTarget("gbuffer2");
|
path.setTarget("gbuffer2");
|
||||||
path.clearTarget(0xff000000);
|
path.clearTarget(0xff000000);
|
||||||
path.setTarget("gbuffer0", ["gbuffer1", "gbuffer2"]);
|
path.setTarget("gbuffer0");
|
||||||
path.clearTarget(null, 1.0);
|
path.clearTarget(null, 1.0);
|
||||||
|
path.setTarget("gbuffer0", ["gbuffer1", "gbuffer2"]);
|
||||||
path.drawMeshes("mesh");
|
path.drawMeshes("mesh");
|
||||||
|
|
||||||
// ---
|
// ---
|
||||||
|
|||||||
@@ -632,7 +632,7 @@ class UISidebar {
|
|||||||
var source = Context.layerIsMask ? l.texpaint_mask : l.texpaint;
|
var source = Context.layerIsMask ? l.texpaint_mask : l.texpaint;
|
||||||
var g2 = target.g2;
|
var g2 = target.g2;
|
||||||
g2.begin(true, 0x00000000);
|
g2.begin(true, 0x00000000);
|
||||||
g2.pipeline = Layers.pipeCopy;
|
g2.pipeline = Context.layerIsMask ? Layers.pipeCopy8 : Layers.pipeCopy;
|
||||||
g2.drawScaledImage(source, 0, 0, target.width, target.height);
|
g2.drawScaledImage(source, 0, 0, target.width, target.height);
|
||||||
g2.pipeline = null;
|
g2.pipeline = null;
|
||||||
g2.end();
|
g2.end();
|
||||||
|
|||||||
@@ -176,7 +176,11 @@ class RenderUtil {
|
|||||||
Context.textToolImage = null;
|
Context.textToolImage = null;
|
||||||
}
|
}
|
||||||
if (Context.textToolImage == null) {
|
if (Context.textToolImage == null) {
|
||||||
|
#if kha_metal
|
||||||
|
Context.textToolImage = Image.createRenderTarget(texW, texW, TextureFormat.RGBA32);
|
||||||
|
#else
|
||||||
Context.textToolImage = Image.createRenderTarget(texW, texW, TextureFormat.L8);
|
Context.textToolImage = Image.createRenderTarget(texW, texW, TextureFormat.L8);
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
var g2 = Context.textToolImage.g2;
|
var g2 = Context.textToolImage.g2;
|
||||||
g2.begin(true, 0xff000000);
|
g2.begin(true, 0xff000000);
|
||||||
|
|||||||
Reference in New Issue
Block a user