GLSL and Shadertoy shader skills for Claude Code, Codex, Cursor, Copilot and Gemini CLI. 186 functions, SDF raymarching, procedural terrain, water, clouds and generative art, with a bundler, checker and 11 examples.
Python agent-skillsclaude-codecodexcomputer-graphicscursorgemini-cligenerative-artgithub-copilotglslnoiseprocedural-artprocedural-generationraymarchingshadersshadertoysigned-distance-functionsterrain-generationwebglwebgl2
//! water: finite-depth wave dispersion, analytic wave derivatives, exact dielectric Fresnel and RGB attenuation.
//! Units must agree: wavelength/depth/path in meters, gravity in m/s^2, extinction in 1/m. No textures or scene state.
/// Angular frequency sqrt(g*k*tanh(k*depth)) for finite-depth gravity waves. Nonpositive inputs are clamped.
/// @use shallow coasts, ocean swell, lake waves with depth-dependent speed
/// @range nonnegative
/// @see MIT Marine Hydrodynamics lecture 20: https://ocw.mit.edu/courses/2-20-marine-hydrodynamics-13-021-spring-2005/5d48a5937971d973fd8ca90c051a83f8_lecture20.pdf
float waterDispersion(float k, float depth, float gravity) {
k = max(k,0.0);
float e = exp(-2.0*k*max(depth,0.0));
return sqrt(max(gravity,0.0)*k*(1.0-e)/(1.0+e));
}
/// One sinusoidal wave: vec4(height, dh/dx, dh/dz, Laplacian). Direction is normalized internally; zero uses +X.
/// wavelength > 0, amplitude in meters. footprint filters waves below 2-6 pixels; derivatives hold it constant.
/// @use analytic water normals, layered swell/chop, curvature foam, finite-depth lake and coastal waves
/// @see Mark Finch, GPU Gems chapter 1, "Effective Water Simulation from Physical Models"
vec4 waterWaveD(vec2 xz, float time, vec2 direction, float wavelength, float amplitude, float depth, float footprint) {
float dl = length(direction);
vec2 dir = dl>0.000001 ? direction/dl : vec2(1.0,0.0);
float lengthM = max(wavelength,0.0001);
float k = TAU/lengthM;
float keep = smoothstep(2.0,6.0,lengthM/max(footprint,0.000001));
float phase = k*dot(dir,xz)-waterDispersion(k,depth,9.81)*time;
float h = amplitude*keep*sin(phase);
return vec4(h, amplitude*keep*k*cos(phase)*dir, -k*k*h);
}
/// Exact unpolarized dielectric Fresnel for a positive incident cosine and positive refractive indices.
/// Returns 1 for total internal reflection. Caller chooses etaIncident/etaTransmitted for the ray's side.
/// @use air-water interfaces (1.0,1.333), underwater views (1.333,1.0), glass
/// @range [0,1]
/// @see https://www.pbr-book.org/4ed/Reflection_Models/Specular_Reflection_and_Transmission
float fresnelDielectric(float cosIncident, float etaIncident, float etaTransmitted) {
float ci = clamp(abs(cosIncident),0.0,1.0);
float ei = max(etaIncident,0.000001), et = max(etaTransmitted,0.000001);
if (abs(ei-et)<0.0000001) return 0.0;
float sinT2 = (ei*ei)/(et*et)*max(0.0,1.0-ci*ci);
if (sinT2>=1.0) return 1.0;
float ct = sqrt(max(0.0,1.0-sinT2));
float rs = (ei*ci-et*ct)/max(ei*ci+et*ct,0.000001);
float rp = (et*ci-ei*ct)/max(et*ci+ei*ct,0.000001);
return clamp(0.5*(rs*rs+rp*rp),0.0,1.0);
}
/// Beer-Lambert RGB transmittance exp(-extinction*pathLength). Negative extinction/path is clamped to zero.
/// Use the refracted optical path, not vertical water depth. Attenuation alone does not add scattered light.
/// @use depth-colored water, underwater visibility, tinted glass, homogeneous fog
/// @range [0,1]
/// @see https://www.pbr-book.org/4ed/Volume_Scattering/Transmittance
vec3 beerTransmittance(vec3 extinction, float pathLength) {
return exp(-max(extinction,vec3(0.0))*max(pathLength,0.0));
}