Skip to content

Commit

Permalink
fix(glsl): fix glsl builtin mix function
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTelanie committed Oct 2, 2023
1 parent eee82b4 commit b546b4e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/glsl/builtin.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export class BuiltIn {

mix(x, y, alpha) {
return fastCalc(
(x, y, alpha) => alpha * x + (1 - alpha) * y,
(x, y, alpha) => (1 - alpha) * x + alpha * y,
x, y, alpha
);
}
Expand Down
6 changes: 3 additions & 3 deletions test/glsl/sim.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ float action(vec2 one, vec2 two) {
it('works when using mix.', () => {
const shader = ({ mix, vec2 }) => {
let bar = vec2(() => {
return mix(vec2(1.0, 0.0), vec2(3.0, 6.0), 0.5);
return mix(vec2(1.0, 0.0), vec2(4.0, 6.0), 0.75);
});
return { bar };
};
Expand All @@ -302,8 +302,8 @@ float action(vec2 one, vec2 two) {
const { bar } = js;

const result = bar();
assert.equal(result.x, 2);
assert.equal(result.y, 3);
assert.equal(result.x, 3.25);
assert.equal(result.y, 4.5);
});

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

0 comments on commit b546b4e

Please sign in to comment.