Skip to content

Commit c395dee

Browse files
Alias GLSL mix as p5.strands lerp for shader consistency #7875
1 parent 3eae276 commit c395dee

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/webgl/ShaderGenerator.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,17 @@ function shadergenerator(p5, fn) {
16201620
})
16211621
}
16221622

1623+
// Alias GLSL's mix function as lerp in p5.strands
1624+
// Bridging p5.js lerp and GLSL mix for consistency in shader expressions
1625+
const originalLerp = fn.lerp;
1626+
fn.lerp = function (...args) {
1627+
if (GLOBAL_SHADER?.isGenerating) {
1628+
return fn.mix(...args); // Use mix inside p5.strands
1629+
} else {
1630+
return originalLerp.apply(this, args); // Fallback to normal p5.js lerp
1631+
}
1632+
};
1633+
16231634
export default shadergenerator;
16241635

16251636
if (typeof p5 !== 'undefined') {

0 commit comments

Comments
 (0)