/ghibli-threejs:threejs-webgl-realistic-waterfrom ghibli-threejs
Builds physically lit, painterly-realistic river/lake/pond water in three.js WebGL with depth-aware refraction, Beer-Lambert absorption, planar reflection, sun glints, caustics, and Voronoi pebble riverbed. Use when a three.js or React Three Fiber scene has flat or milky water.
Ships in ghibli-threejs. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A water surface that reads as clear, deep and alive from max zoom-out to eye level: you see the bed
through it, the banks mirror in it at grazing angles, tree shadows dapple it, sun glints bloom off
ripples, and submerged stones carry a dancing caustic web. Proven on a three.js r186
WebGLRenderer + EffectComposer scene (vanilla, single HTML file); everything is built by
patching stock materials with onBeforeCompile, so it works the same inside R3F
(material.onBeforeCompile / useFrame for the pre-passes).
The water is a MeshStandardMaterial (roughness ≈ 0.1, side: DoubleSide) so it inherits
three's shadowed sun lighting and fog, and the final colour is composed yourself at
#include <opaque_fragment>.
threejs-webgl-underwater-effect; waves and floating
objects → threejs-boat-buoyancy-steering; night water → threejs-ghibli-night-mode.Enhance the water in
{{entry file, e.g. index.html}}. The look to match is{{reference image path}}— {{style: e.g. "Ghibli-painterly but physically lit"}}. Water surface is the planey = {{0}}; the terrain/bed height function is{{terrainHeight(x,z)}}. Keep every tunable as a named constant at the top of the script and in a lil-gui "Tune" panel. After each section, open the page in a browser, screenshot close-up, eye-level and max-zoom-out views, compare against the reference, and fix what's wrong before moving on.Replace any flat/transparent water with a
MeshStandardMaterial(roughness ≈ 0.1, DoubleSide) patched viaonBeforeCompile: a refraction pre-pass with a realDepthTexture(true thickness along the view ray), Beer–Lambert absorption(0.95, 0.24, 0.20)/m plus turquoise in-scatter scaled by the shadowed sun arriving at the surface, a half-res planar reflection mixed by Schlick Fresnel (F0 = 0.02),directSpecularglints ×~0.3, ripple normals from a precomputed mipmapped tileable slope map (4 octaves drifting downstream, faded with distance), avec4ripple-source array, and a soft waterline. Inject a chromatic caustic web into submerged materials, and make the bed read as pebbles set in sand (domain-warped Voronoi, one rounded stone per cell). Report frame cost per pass at the end.
HalfFloatType target with a
DepthTexture (UnsignedIntType). Keep above-water-only foliage on layer 1 and render this
pass with camera.layers.set(0), then restore the saved camera.layers.mask (not
layers.enable(1), which drops any other layer the camera had).bias(0.5) × mirrorCam.projection × mirrorCam.matrixWorldInverse. Keep only what's above the
surface (Plane((0,1,0), 0.015)) by making that plane the mirror camera's near plane
(Lengyel's oblique projection, as three's Reflector does) — not with
renderer.clippingPlanes, which compiles a second variant of every shader in the scene (see
Pitfalls). Build the texture matrix from the plain projection first, then skew it: rows x, y
and w don't change. Copy the main camera's projection into the mirror camera every frame, so
the skew never accumulates.renderer.shadowMap.autoUpdate = false, needsUpdate = true once per frame.The reflection draws the whole scene a second time. Put the densest ground cover (grass, foreground flowers) on a layer of its own that the main camera and the sun's shadow camera enable, and disable it on the mirror camera below the top quality tier: half-resolution blades at the bank edge are not worth the cost of the whole meadow again.
See references/water-passes.js (render loop + mirror camera + oblique near plane + slope-map generator).
#include <opaque_fragment>)linZ(d) = 2nf / (f+n − (2d−1)(f−n)).
thick = (sceneZ − surfZ) · |viewPos| / viewPos.z → true path length along the ray.off = N.xz · uRefr · clamp(thick0·2.5, 0, 1) / (1 + surfZ·0.06) — shallows
barely distort, distance calms it. If the offset sample is in front of the surface
(sceneZ < surfZ) fall back to the un-offset UV so above-water objects never leak in.
Sample R/G/B at ruv ± off·0.12 for dispersion.T = exp(-thick·absorb), absorb ≈ (0.95, 0.24, 0.20)/m (reds fade first).
under = refr·T + scatter·(1 − exp(-thick·0.9))·(0.15 + 0.65·sunLit).
sunLit = luminance of reflectedLight.directDiffuse (white albedo) · π / (sunLum · N·L) —
the lit/shadowed light arriving at the surface, so canopy shadows dapple the water.rc.xy/rc.w + N.xz·0.06/(1 + surfZ·0.04);
F = 0.02 + 0.98(1 − N·V)^5; col = mix(under, refl, F).col += reflectedLight.directSpecular · ~0.3 — already GGX and shadowed; bloom does the rest.col = mix(refr, col, smoothstep(0, 0.035, thick)) — no hard edge at the bank.[[4,1],[8,.55],[16,.32],[32,.17],[64,.09]], soft swells for P ≤ 8 and ridged 1−|2n−1| above,
stored as RG slopes (central differences × 18), generateMipmaps, LinearMipmapLinearFilter,
max anisotropy..075, .19, .52, 1.45,
weights .55, .38, .22, .10), multiply by uNStr / (1 + dist·0.035).uniform vec4 uRipples[8] (x, z, strength, w). w < 0 → steady rings
(sin(L·36 − t·5.2)·exp(−L·4.5), feet/posts); w = startTime → expanding ring
R = age·0.32, envelope exp(−((L−R)·16)²)·exp(−age·0.9) (a fish kiss, a thrown stone).normalize(vec3(-sl.x, 1, -sl.y)), flipped for back faces, then to view space in
normal_fragment_maps so three's lighting uses it.See references/water-material.glsl.js for the full onBeforeCompile patch.
Inject into #include <emissivemap_fragment> of bed, rocks, fish, posts:
causticF, 4 iterations, tiles every 2π),cp = wp.xz·0.42 + (sunDir.xz/sunDir.y)·wp.y·0.42,smoothstep(0.02, −0.08, y) · exp(y·1.2) · smoothstep(0.02, 0.22, −y),totalEmissiveRadiance += albedo · c · sunColour·1.1.See references/caustics.glsl.
Domain-warped Voronoi (warp = (fbm(wp·1.7), fbm(wp·1.7+5.3)) − .5)·0.9) at two scales — gravel
(×8.5) and cobble patches (×3.6) picked by step(.58, fbm(wp·.35)). One rounded stone per cell
with jittered radius 0.30 + 0.16·hash, set in sand so sand shows in the gaps; dome shading
sqrt(1 − (dc/r)²), a speckle, a contact-shadow ring on the sand, algae thinning on stone
crowns. Perturb the view-space normal by the vector to the cell centre (× pebMask × 2.2) so each
pebble catches light. See references/riverbed-pebbles.glsl.
| Constant | Value |
|---|---|
| roughness | 0.11 |
| absorb (/m) | (0.95, 0.24, 0.20) |
| F0 | 0.02 |
| glint gain | 0.28 |
| refraction offset | < 0.05 |
| ripple distance fade | 1/(1 + d·0.035) |
| waterline blend | smoothstep(0, 0.035, thick) |
sin() → infinities → black speckles. Clamp the
denominators to ±1e-3 and the output to ≤ 4.onBeforeCompile, inject helper GLSL before any code that calls it.readPixels(RGBA, UNSIGNED_BYTE) on a HalfFloat target is INVALID_OPERATION — time passes on
the default framebuffer (see threejs-webgl-performance-profiling).renderer.clippingPlanes for the reflection pass doubles the shader programs (~540 instead of
~270 here): every material compiles a clipping variant, which costs seconds of compile on
Windows and phones. The oblique near plane needs one variant and no per-pixel work; A/B'd against
the clipping plane it gave the same image, bar sub-pixel depth ties in foliage.renderer.info.programs.length after the first frames: it must not double when the
reflection pass is switched on.threejs-webgl-underwater-effect · threejs-boat-buoyancy-steering · threejs-webgl-wake-simulation
· threejs-webgl-waterfall-effect · threejs-ghibli-night-mode · threejs-webgl-rain-effect
· threejs-fish-school-boids · threejs-postprocessing-anime-grade · threejs-webgl-performance-profiling
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
water-shader, webgl, threejs, realistic-water, caustics, refraction
Other plugins' skills for the same job
31 skills in this plugin
/threejs-blender-glb-pipelineBuilds a reference-image-driven asset pipeline from headless Blender to GLB for a three.js scene — an asset contract (units, axes, grounding, required mesh/material names, budgets, attachment numbers), one parallel subagent per asset group writing craft_<slug>.py generators, preview renders compared against the reference, measured-bounding-box placement in the web scene, Draco compression, and a scored asset quality pass. Use when the user has a reference picture and wants a 3D scene from it, asks to model props/trees/characters in Blender for three.js, export GLBs, fix glTF export issues (vertex-colour alpha, UV flip, axes, custom normals), compress models, or rate and improve every asset in a scene./threejs-boat-buoyancy-steeringFloats a boat (or any buoyant prop) on three.js water with Gerstner waves generated from one JS table that feeds both the GLSL vertex shader and a CPU waveHeight(), four-probe heave/pitch/roll damped springs, an arc-length drift lane that bends round rocks, click-to-steer W/A/S/D rowing with momentum and drag, an autopilot that pursues the lane back, and a chase camera that keeps the orbit. Use when the user wants a drifting or steerable boat, buoyancy, objects bobbing on waves, Gerstner waves on a river/lake, a boat autopilot, or a follow/chase camera behind a vehicle on water.npx claudepluginhub nicksonthc/ghibli-threejs --plugin ghibli-threejs