import{NOISE_GLSL}from'../../vfx/common.js';// Phoenix shaders (phoenix.js). Two AnalyticRibbons path/shade pairs:// BIRD every ribbon of a bird (body, wing edges, wing feathers, tail streamers, crest) is posed in// the bird's local frame (x right, y up, z forward; metres = local units x scale) from the// per-bird uniform slots, so the CPU writes 5 vec4s per bird per frame and nothing per ribbon.// A flat wing is folded (spread), swept back (dive) and flapped (a rotation about the body// axis that grows and lags towards the tip and the trailing edge), then mirrored for the// left wing. phoenix.js mirrors armFlat/foldW/flapW to place emitters on the wing.// FEATHER stateless burning feathers: ballistic with drag, settling at a terminal speed with a// flutter, tumbling about a random axis, and burning from the tip down.// Both layers share the GLSL: RIBBON_FX (half-res glow + heat haze) vs the full-res core lines.constBIRD_HEAD=/* glsl */`
uniform vec4 uBirdA[4]; // pos xyz, scale (m per local unit)
uniform vec4 uBirdF[4]; // forward xyz, flap phase (rad)
uniform vec4 uBirdU[4]; // up xyz, flap amplitude (rad)
uniform vec4 uBirdW[4]; // spread 0..1, sweep 0..1, dihedral (rad), -
uniform vec4 uBirdT[4]; // tail bend x, y (local, per unit length), -, -
const float SX = 0.12; // shoulder offset from the spine
vec3 armFlat(float s, float k) {
return vec3(SX + 1.4 * s * mix(0.3, 1.0, k), 0.02 * s, 0.1 + 0.2 * sin(3.14159265 * min(s * 1.15, 1.0)) - 0.45 * s * s * s);
}
// fold back in the wing plane about the shoulder (beta > 0 moves the tip backwards)
vec3 foldW(vec3 p, float beta) {
float dx = p.x - SX, dz = p.z - 0.1, c = cos(beta), s = sin(beta);
return vec3(SX + dx * c + dz * s, p.y, 0.1 - dx * s + dz * c);
}
// flap about the body axis through the shoulder; amplitude grows to the tip, phase lags along the
// span and behind the leading edge (lag = metres behind it), so the wing whips instead of hinging
vec3 flapW(vec3 p, float lag, float ph, float amp, float dih) {
float dx = p.x - SX, se = clamp(dx / 1.7, 0.0, 1.0);
float x = ph - 1.1 * se - 1.6 * lag;
float th = dih * (0.6 + 0.4 * se) + amp * (sin(x) + 0.22 * sin(2.0 * x)) * (0.45 + 0.75 * se);
float c = cos(th), s = sin(th);
return vec3(SX + dx * c - p.y * s, dx * s + p.y * c, p.z);
}