Skip to content

Commit b546b4e

Browse files
committed
fix(glsl): fix glsl builtin mix function
1 parent eee82b4 commit b546b4e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/glsl/builtin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export class BuiltIn {
167167

168168
mix(x, y, alpha) {
169169
return fastCalc(
170-
(x, y, alpha) => alpha * x + (1 - alpha) * y,
170+
(x, y, alpha) => (1 - alpha) * x + alpha * y,
171171
x, y, alpha
172172
);
173173
}

test/glsl/sim.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ float action(vec2 one, vec2 two) {
293293
it('works when using mix.', () => {
294294
const shader = ({ mix, vec2 }) => {
295295
let bar = vec2(() => {
296-
return mix(vec2(1.0, 0.0), vec2(3.0, 6.0), 0.5);
296+
return mix(vec2(1.0, 0.0), vec2(4.0, 6.0), 0.75);
297297
});
298298
return { bar };
299299
};
@@ -302,8 +302,8 @@ float action(vec2 one, vec2 two) {
302302
const { bar } = js;
303303

304304
const result = bar();
305-
assert.equal(result.x, 2);
306-
assert.equal(result.y, 3);
305+
assert.equal(result.x, 3.25);
306+
assert.equal(result.y, 4.5);
307307
});
308308

309309
it('works fine with sampler2D from array buffer.', () => {

0 commit comments

Comments
 (0)