Skip to content

Instantly share code, notes, and snippets.

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

  • Save patriciogonzalezvivo/22be0e4ae9eaf0b7e0d1093dcd53b66a to your computer and use it in GitHub Desktop.

Select an option

Save patriciogonzalezvivo/22be0e4ae9eaf0b7e0d1093dcd53b66a to your computer and use it in GitHub Desktop.
RYG Palette
{
"frag": "#ifdef GL_ES\nprecision mediump float;\n#endif\n\nuniform vec2 u_resolution;\nuniform vec2 u_mouse;\nuniform float u_time;\n\n#include \"lygia/math/const.glsl\"\n#include \"lygia/math/decimate.glsl\"\n#include \"lygia/math/cubicMix.glsl\"\n#include \"lygia/draw/circle.glsl\"\n\n// #define RYB_FAST\n#define RYB_LERP(A, B, T) cubicMix(A, B, T)\n#include \"lygia/color/hueShiftRYB.glsl\"\n// #define HSV2RYB_FAST\n#include \"lygia/color/space/hsv2ryb.glsl\"\n\n\nvoid main(void) {\n vec4 color = vec4(1.);\n vec2 pixel = 1./u_resolution.xy;\n vec2 st = gl_FragCoord.xy * pixel;\n\n // Color Wheel\n vec2 p = st * 2.0 - 1.0;\n p *= 1.1;\n float a = atan(p.y, -p.x);\n a = decimate(a, 3.0);\n float l = saturate(length(p));\n vec3 w = hsv2ryb(vec3(a/TAU + 0.5, 1.0, decimate( l, 6.0) ));\n color.rgb = mix(color.rgb, w, aastep(l, 1.0));\n\n // Mouse Pointer\n vec2 p_mouse = (u_mouse * pixel) * 2.0 - 1.0;\n float a_mouse = atan(p_mouse.y, -p_mouse.x);\n float l_mouse = length(p_mouse);\n vec3 c_mouse = hsv2ryb(vec3(a_mouse/TAU + 0.5, 1.0, l));\n color.rgb = mix(color.rgb, c_mouse, circle( (p - p_mouse) + 0.5, 0.3));\n color.rgb = mix(color.rgb, vec3(0.0), circle( (p - p_mouse) + 0.5, 0.3, pixel.x * 5.0));\n\n // Complementary\n float a_comp = a_mouse + PI;\n vec2 p_comp = (vec2(cos(a_mouse), -sin(a_mouse))) * l_mouse;\n vec3 c_comp = hueShiftRYB(c_mouse, PI);\n // vec3 c_comp = hsv2ryb(vec3(a_comp/TAU + 0.5, 1.0, l));\n color.rgb = mix(color.rgb, c_comp, circle( (p - p_comp) + 0.5, 0.2));\n color.rgb = mix(color.rgb, vec3(0.0), circle( (p - p_comp) + 0.5, 0.2, pixel.x * 5.0));\n\n gl_FragColor = color;\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": "8e1415fd87a942aced66bd39ac9b4faa",
"owner": {
"login": "patriciogonzalezvivo",
"id": 346914,
"avatar_url": "https://avatars.githubusercontent.com/u/346914?v=4"
},
"loadedAt": "2026-02-17T18:17:34.982Z"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment