Skip to content

Instantly share code, notes, and snippets.

@patriciogonzalezvivo
Created February 17, 2026 18:01
Show Gist options
  • Select an option

  • Save patriciogonzalezvivo/9a5575152acfc7f92a8f50899dc4a78d to your computer and use it in GitHub Desktop.

Select an option

Save patriciogonzalezvivo/9a5575152acfc7f92a8f50899dc4a78d to your computer and use it in GitHub Desktop.
Curl Noise
{
"frag": "\n#ifdef GL_ES\nprecision mediump float;\n#endif\n\nuniform vec2 u_resolution;\nuniform float u_time;\n\n#include \"lygia/math/const.glsl\"\n#include \"lygia/generative/snoise.glsl\"\n#include \"lygia/generative/gnoise.glsl\"\n#include \"lygia/generative/wavelet.glsl\"\n\nfloat gyroid (vec3 p) { return dot(sin(p),cos(p.yzx)); }\n\n#define ROT 5\nfloat ang = TAU / float(ROT);\nmat2 m = mat2( cos(ang), sin(ang),\n -sin(ang), cos(ang));\n\nfloat turb(vec3 p) {\n float result = 0.0, a = 0.5;\n p *= 2.0;\n for (int i = 0; i < ROT; ++i) {\n result += gyroid(p/a)*a;\n p.xy = m * p.xy * 0.75 + result * 0.1;\n p.z += u_time * 0.05;\n a *= 0.5;\n }\n return result;\n}\n\n// #define CURL_FNC(P) turb(P)\n// #define CURL_FNC(P) snoise(vec3((P).xy, (P).z + u_time * 0.5))\n#include \"lygia/generative/curl.glsl\"\n\nvoid main(void) {\n vec4 color = vec4(vec3(0.0), 1.0);\n vec2 pixel = 1.0/u_resolution.xy;\n vec2 st = gl_FragCoord.xy * pixel;\n\n vec2 d2 = curl(vec2(st * 5.0)) * 0.5 + 0.5;\n vec3 d3 = curl(vec3(st * 5.0, u_time * 0.5)) * 0.5 + 0.5;\n \n color.rgb += mix(vec3(d2, 0.0), d3, step(0.5, st.x));\n\n gl_FragColor = color;\n}\n\n",
"vert": "#ifdef GL_ES\nprecision mediump float;\n#endif\n\nattribute vec4 a_position;\nvarying vec4 v_position;\n\nvoid main() {\n v_position = a_position;\n gl_Position = a_position;\n}\n",
"commands": [
"plot,off",
"textures,off",
"buffers,off",
"cubemap,off",
"camera_position,-0,-0,-2",
"camera_look_at,0,0,0",
"camera,default"
],
"assets": {},
"history": [
{
"gistId": "31cd4fb382f6a632a55dc0820b39dc15",
"owner": {
"login": "patriciogonzalezvivo",
"id": 346914,
"avatar_url": "https://avatars.githubusercontent.com/u/346914?v=4"
},
"loadedAt": "2026-02-17T18:01:08.679Z"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment