Improve inpaint node preview

This commit is contained in:
luboslenco
2023-03-27 19:34:46 +02:00
parent f97490cdb8
commit beac03486a
3 changed files with 26 additions and 13 deletions
@@ -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;
}
+10 -10
View File
@@ -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() {
+3 -3
View File
@@ -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();