Skip to content

Commit 9cf4424

Browse files
Add GLSL implementation of fractal noise for p5.strands
- Created src/webgl/shaders/functions/noise.glsl.js - Provides a simple fractal noise function using 3 octaves
1 parent b924d1c commit 9cf4424

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export default /* glsl */ `
2+
float baseNoise(vec2 st) {
3+
return fract(sin(dot(st.xy ,vec2(12.9898,78.233))) * 43758.5453123);
4+
}
5+
6+
float noise(vec2 st) {
7+
float result = 0.0;
8+
for (int i = 0; i < 3; i++) {
9+
float freq = pow(2.0, float(i));
10+
float amp = pow(0.5, float(i));
11+
result += amp * baseNoise(st * freq);
12+
}
13+
return result;
14+
}
15+
`;

0 commit comments

Comments
 (0)