Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/EffectTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ class EffectTransform {
* @returns {Uint8ClampedArray} dst filled with the transformed color
*/
static transformColor (drawable, color4b, dst, effectMask) {
const effects = drawable.getEnabledEffects() & effectMask;
// If no effects are enabled, don't get anything, create anything, or set anything; just give back the input.
if (effects === 0) return color4b;

dst = dst || new Uint8ClampedArray(4);
effectMask = effectMask || 0xffffffff;
dst.set(color4b);
Expand All @@ -131,7 +135,6 @@ class EffectTransform {
}

const uniforms = drawable.getUniforms();
const effects = drawable.getEnabledEffects() & effectMask;

if ((effects & ShaderManager.EFFECT_INFO.ghost.mask) !== 0) {
// gl_FragColor.a *= u_ghost
Expand Down Expand Up @@ -187,11 +190,13 @@ class EffectTransform {
* @return {twgl.v3} dst - The coordinate after being transform by effects.
*/
static transformPoint (drawable, vec, dst = twgl.v3.create()) {
const effects = drawable.getEnabledEffects();
// If no effects are enabled, don't get anything, create anything, or set anything; just give back the input.
if (effects === 0) return vec;

twgl.v3.copy(vec, dst);

const uniforms = drawable.getUniforms();
const effects = drawable.getEnabledEffects();

if ((effects & ShaderManager.EFFECT_INFO.mosaic.mask) !== 0) {
// texcoord0 = fract(u_mosaic * texcoord0);
dst[0] = uniforms.u_mosaic * dst[0] % 1;
Expand Down