From d867e62c74b3a354dd06e905ea0f58dd9dc8fbc8 Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Fri, 7 Feb 2020 10:41:30 -0500 Subject: [PATCH 1/2] Don't apply ghost to "touching color" drawables --- src/Drawable.js | 5 +++-- src/EffectTransform.js | 7 ++++--- src/RenderWebGL.js | 5 ++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Drawable.js b/src/Drawable.js index 87876f710..d6d665813 100644 --- a/src/Drawable.js +++ b/src/Drawable.js @@ -679,9 +679,10 @@ class Drawable { * @param {twgl.v3} vec The scratch space [x,y] vector * @param {Drawable} drawable The drawable to sample the texture from * @param {Uint8ClampedArray} dst The "color4b" representation of the texture at point. + * @param {number} [effectMask] A bitmask for which effects to use. Optional. * @returns {Uint8ClampedArray} The dst object filled with the color4b */ - static sampleColor4b (vec, drawable, dst) { + static sampleColor4b (vec, drawable, dst, effectMask) { const localPosition = getLocalPosition(drawable, vec); if (localPosition[0] < 0 || localPosition[1] < 0 || localPosition[0] > 1 || localPosition[1] > 1) { @@ -698,7 +699,7 @@ class Drawable { // : drawable.skin._silhouette.colorAtLinear(localPosition, dst); if (drawable.enabledEffects === 0) return textColor; - return EffectTransform.transformColor(drawable, textColor); + return EffectTransform.transformColor(drawable, textColor, effectMask); } } diff --git a/src/EffectTransform.js b/src/EffectTransform.js index 3d5342c9d..9d778bb3d 100644 --- a/src/EffectTransform.js +++ b/src/EffectTransform.js @@ -118,16 +118,17 @@ class EffectTransform { * Ghost and Color and Brightness effects. * @param {Drawable} drawable The drawable to get uniforms from. * @param {Uint8ClampedArray} inOutColor The color to transform. + * @param {number} [effectMask] A bitmask for which effects to use. Optional. * @returns {Uint8ClampedArray} dst filled with the transformed color */ - static transformColor (drawable, inOutColor) { - + static transformColor (drawable, inOutColor, effectMask) { // If the color is fully transparent, don't bother attempting any transformations. if (inOutColor[3] === 0) { return inOutColor; } - const effects = drawable.enabledEffects; + let effects = drawable.enabledEffects; + if (typeof effectMask === 'number') effects &= effectMask; const uniforms = drawable.getUniforms(); const enableColor = (effects & ShaderManager.EFFECT_INFO.color.mask) !== 0; diff --git a/src/RenderWebGL.js b/src/RenderWebGL.js index 44bb30759..3cd53e216 100644 --- a/src/RenderWebGL.js +++ b/src/RenderWebGL.js @@ -763,6 +763,9 @@ class RenderWebGL extends EventEmitter { const color = __touchingColor; const hasMask = Boolean(mask3b); + // "touching color" ignores ghost effect + const effectMask = ~ShaderManager.EFFECT_INFO.ghost.mask; + // Scratch Space - +y is top for (let y = bounds.bottom; y <= bounds.top; y++) { if (bounds.width * (y - bounds.bottom) * (candidates.length + 1) >= maxPixelsForCPU) { @@ -773,7 +776,7 @@ class RenderWebGL extends EventEmitter { point[0] = x; // if we use a mask, check our sample color... if (hasMask ? - maskMatches(Drawable.sampleColor4b(point, drawable, color), mask3b) : + maskMatches(Drawable.sampleColor4b(point, drawable, color, effectMask), mask3b) : drawable.isTouching(point)) { RenderWebGL.sampleColor3b(point, candidates, color); if (debugCanvasContext) { From aaffc77b23922432955c96975639c4958453e7b9 Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Tue, 24 Mar 2020 10:59:12 -0400 Subject: [PATCH 2/2] Clarify isTouchingColor ghost comment --- src/RenderWebGL.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RenderWebGL.js b/src/RenderWebGL.js index 3cd53e216..5c9580bc1 100644 --- a/src/RenderWebGL.js +++ b/src/RenderWebGL.js @@ -763,7 +763,7 @@ class RenderWebGL extends EventEmitter { const color = __touchingColor; const hasMask = Boolean(mask3b); - // "touching color" ignores ghost effect + // Masked drawable ignores ghost effect const effectMask = ~ShaderManager.EFFECT_INFO.ghost.mask; // Scratch Space - +y is top