From 3fe791337d6cc6047b0fb6ee3b9684d88c83e1e1 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Tue, 18 Feb 2020 11:47:02 +0100 Subject: [PATCH] Mask for base layer --- Sources/arm/node/MakeMesh.hx | 9 +++++++++ Sources/arm/render/RenderPathPaint.hx | 3 +++ Sources/arm/render/Uniforms.hx | 1 - 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Sources/arm/node/MakeMesh.hx b/Sources/arm/node/MakeMesh.hx index b40b6db8..6938dda7 100644 --- a/Sources/arm/node/MakeMesh.hx +++ b/Sources/arm/node/MakeMesh.hx @@ -183,6 +183,15 @@ class MakeMesh { frag.write('metallic = 0.0;'); } + if (l.texpaint_mask != null) { + frag.add_shared_sampler('sampler2D texpaint_mask'); + frag.write('float maskTexture = textureLodShared(texpaint_mask, texCoord, 0.0).r;'); + frag.write('basecol *= maskTexture;'); + frag.write('occlusion *= maskTexture;'); + frag.write('roughness *= maskTexture;'); + frag.write('metallic *= maskTexture;'); + } + if (l.maskOpacity < 1) { frag.write('basecol *= ${l.maskOpacity};'); frag.write('occlusion *= ${l.maskOpacity};'); diff --git a/Sources/arm/render/RenderPathPaint.hx b/Sources/arm/render/RenderPathPaint.hx index 120d8956..fe51cabb 100644 --- a/Sources/arm/render/RenderPathPaint.hx +++ b/Sources/arm/render/RenderPathPaint.hx @@ -508,6 +508,9 @@ class RenderPathPaint { path.bindTarget("texpaint" + tid, "texpaint"); path.bindTarget("texpaint_nor" + tid, "texpaint_nor"); path.bindTarget("texpaint_pack" + tid, "texpaint_pack"); + if (Project.layers[0].texpaint_mask != null) { + path.bindTarget("texpaint_mask" + tid, "texpaint_mask"); + } for (i in 1...Project.layers.length) { var l = Project.layers[i]; tid = l.id; diff --git a/Sources/arm/render/Uniforms.hx b/Sources/arm/render/Uniforms.hx index 1fb0e3ac..3e204fa8 100644 --- a/Sources/arm/render/Uniforms.hx +++ b/Sources/arm/render/Uniforms.hx @@ -330,7 +330,6 @@ class Uniforms { } if (link.startsWith("_texpaint_mask")) { var tid = Std.parseInt(link.substr(link.length - 1)); - trace(tid); return Project.layers[tid].texpaint_mask; } if (link.startsWith("_texpaint_nor")) {