Skip to content

Commit b3bcbe4

Browse files
committed
Don't apply ghost to "touching color" drawables
1 parent 4da0f3c commit b3bcbe4

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/Drawable.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,10 @@ class Drawable {
677677
* @param {twgl.v3} vec The scratch space [x,y] vector
678678
* @param {Drawable} drawable The drawable to sample the texture from
679679
* @param {Uint8ClampedArray} dst The "color4b" representation of the texture at point.
680+
* @param {number} [effectMask] A bitmask for which effects to use. Optional.
680681
* @returns {Uint8ClampedArray} The dst object filled with the color4b
681682
*/
682-
static sampleColor4b (vec, drawable, dst) {
683+
static sampleColor4b (vec, drawable, dst, effectMask) {
683684
const localPosition = getLocalPosition(drawable, vec);
684685
if (localPosition[0] < 0 || localPosition[1] < 0 ||
685686
localPosition[0] > 1 || localPosition[1] > 1) {
@@ -696,7 +697,7 @@ class Drawable {
696697
// : drawable.skin._silhouette.colorAtLinear(localPosition, dst);
697698

698699
if (drawable.enabledEffects === 0) return textColor;
699-
return EffectTransform.transformColor(drawable, textColor);
700+
return EffectTransform.transformColor(drawable, textColor, effectMask);
700701
}
701702
}
702703

src/EffectTransform.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,17 @@ class EffectTransform {
118118
* Ghost and Color and Brightness effects.
119119
* @param {Drawable} drawable The drawable to get uniforms from.
120120
* @param {Uint8ClampedArray} inOutColor The color to transform.
121+
* @param {number} [effectMask] A bitmask for which effects to use. Optional.
121122
* @returns {Uint8ClampedArray} dst filled with the transformed color
122123
*/
123-
static transformColor (drawable, inOutColor) {
124-
124+
static transformColor (drawable, inOutColor, effectMask) {
125125
// If the color is fully transparent, don't bother attempting any transformations.
126126
if (inOutColor[3] === 0) {
127127
return inOutColor;
128128
}
129129

130-
const effects = drawable.enabledEffects;
130+
let effects = drawable.enabledEffects;
131+
if (typeof effectMask === 'number') effects &= effectMask;
131132
const uniforms = drawable.getUniforms();
132133

133134
const enableColor = (effects & ShaderManager.EFFECT_INFO.color.mask) !== 0;

src/RenderWebGL.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,9 @@ class RenderWebGL extends EventEmitter {
765765
const color = __touchingColor;
766766
const hasMask = Boolean(mask3b);
767767

768+
// "touching color" ignores ghost effect
769+
const effectMask = ~ShaderManager.EFFECT_INFO.ghost.mask;
770+
768771
// Scratch Space - +y is top
769772
for (let y = 0; y < bounds.height; ++y) {
770773
if (bounds.width * y * (candidates.length + 1) >= maxPixelsForCPU) {
@@ -775,7 +778,7 @@ class RenderWebGL extends EventEmitter {
775778
point[1] = bounds.top - y; // bounds.bottom < point[1] <= bounds.top ("flipped")
776779
// if we use a mask, check our sample color...
777780
if (hasMask ?
778-
maskMatches(Drawable.sampleColor4b(point, drawable, color), mask3b) :
781+
maskMatches(Drawable.sampleColor4b(point, drawable, color, effectMask), mask3b) :
779782
drawable.isTouching(point)) {
780783
RenderWebGL.sampleColor3b(point, candidates, color);
781784
if (debugCanvasContext) {

0 commit comments

Comments
 (0)