diff --git a/armorlab/Shaders/inpaint_preview.frag.glsl b/armorlab/Shaders/inpaint_preview.frag.glsl new file mode 100644 index 00000000..afb6a2e7 --- /dev/null +++ b/armorlab/Shaders/inpaint_preview.frag.glsl @@ -0,0 +1,13 @@ +#version 450 + +uniform sampler2D tex0; +uniform sampler2D texa; + +in vec2 texCoord; +out vec4 FragColor; + +void main() { + vec4 col = textureLod(tex0, texCoord, 0); + float mask = clamp(textureLod(texa, texCoord, 0).r + 0.5, 0.0, 1.0); + FragColor = col * mask; +} diff --git a/armorlab/Sources/arm/App.hx b/armorlab/Sources/arm/App.hx index 49ecc321..e0673605 100644 --- a/armorlab/Sources/arm/App.hx +++ b/armorlab/Sources/arm/App.hx @@ -65,9 +65,9 @@ class App { public static var pipeCopy128: PipelineState; public static var pipeCopyBGRA: PipelineState; public static var pipeCopyRGB: PipelineState = null; - public static var pipeApplyMask: PipelineState; - public static var tex0Mask: TextureUnit; - public static var texaMask: TextureUnit; + public static var pipeInpaintPreview: PipelineState; + public static var tex0InpaintPreview: TextureUnit; + public static var texaInpaintPreview: TextureUnit; public static var tempImage: Image = null; public static var expa: Image = null; public static var expb: Image = null; @@ -704,15 +704,15 @@ class App { pipeCopyB.colorWriteMasksAlpha = [false]; pipeCopyB.compile(); - pipeApplyMask = new PipelineState(); - pipeApplyMask.vertexShader = kha.Shaders.getVertex("pass.vert"); - pipeApplyMask.fragmentShader = kha.Shaders.getFragment("mask_apply.frag"); + pipeInpaintPreview = new PipelineState(); + pipeInpaintPreview.vertexShader = kha.Shaders.getVertex("pass.vert"); + pipeInpaintPreview.fragmentShader = kha.Shaders.getFragment("inpaint_preview.frag"); var vs = new VertexStructure(); vs.add("pos", VertexData.Float2); - pipeApplyMask.inputLayout = [vs]; - pipeApplyMask.compile(); - tex0Mask = pipeApplyMask.getTextureUnit("tex0"); - texaMask = pipeApplyMask.getTextureUnit("texa"); + pipeInpaintPreview.inputLayout = [vs]; + pipeInpaintPreview.compile(); + tex0InpaintPreview = pipeInpaintPreview.getTextureUnit("tex0"); + texaInpaintPreview = pipeInpaintPreview.getTextureUnit("texa"); } public static function makePipeCopyRGB() { diff --git a/armorlab/Sources/arm/logic/InpaintNode.hx b/armorlab/Sources/arm/logic/InpaintNode.hx index 13bb9152..71ce3b32 100644 --- a/armorlab/Sources/arm/logic/InpaintNode.hx +++ b/armorlab/Sources/arm/logic/InpaintNode.hx @@ -74,9 +74,9 @@ class InpaintNode extends LogicNode { if (App.pipeCopy == null) App.makePipe(); if (iron.data.ConstData.screenAlignedVB == null) iron.data.ConstData.createScreenAlignedData(); image.g4.begin(); - image.g4.setPipeline(App.pipeApplyMask); - image.g4.setTexture(App.tex0Mask, source); - image.g4.setTexture(App.texaMask, mask); + image.g4.setPipeline(App.pipeInpaintPreview); + image.g4.setTexture(App.tex0InpaintPreview, source); + image.g4.setTexture(App.texaInpaintPreview, mask); image.g4.setVertexBuffer(iron.data.ConstData.screenAlignedVB); image.g4.setIndexBuffer(iron.data.ConstData.screenAlignedIB); image.g4.drawIndexedVertices();