Skip to content

Commit f300fcf

Browse files
Enhance strands noise() to support noise(x, y) and add fractal octaves
1 parent e4ad5ee commit f300fcf

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/webgl/ShaderGenerator.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,8 +1641,20 @@ function shadergenerator(p5, fn) {
16411641

16421642
GLOBAL_SHADER.output.vertexDeclarations.add(noiseGLSL);
16431643
GLOBAL_SHADER.output.fragmentDeclarations.add(noiseGLSL);
1644-
return fnNodeConstructor('noise', args, { args: ['vec2'], returnType: 'float' });
1644+
// Handle noise(x, y) as noise(vec2)
1645+
let nodeArgs;
1646+
if (args.length === 2) {
1647+
nodeArgs = [fn.vec2(args[0], args[1])];
1648+
} else {
1649+
nodeArgs = args;
1650+
}
1651+
1652+
return fnNodeConstructor('noise', nodeArgs, {
1653+
args: ['vec2'],
1654+
returnType: 'float'
1655+
});
16451656
};
1657+
16461658
}
16471659

16481660

0 commit comments

Comments
 (0)