sin()One glyph. One opcode byte. One font table entry. One NEON blob. The polynomial is five terms: x + x³·(-1/6) + x&sup5;·(1/120). Loaded into NEON registers v30 and v31, it processes four sine values simultaneously in ~12 cycles. Scalar sinf() from libm takes ~40 cycles for one.
Traced across 332 source files. Every layer of the project pulses with sin().
fract(sin(dot(p,vec2(127.1,311.7)))*43758.5453)
sin(uTime * f1 + aPhase) * windStr
sin(xz.x * 3.5 + t * 0.55) * sin(xz.y * 2.8 - t * 0.43)
Math.sin(angle0) * r
const breathe = 1.0 + Math.sin(t * 0.7) * 0.025
sin(uTime*(h1*4.+2.)+h1*6.28318)*0.35+0.65
sin(uTime*(2.0+hash(vec2(fs,5.5))*3.0)+phase)*0.4+0.6
float sy=sin(uCamYaw); float sp2=sin(uCamPitch);
sin(uTime*.60)*.015 for camera bob. You see through sine.0.5 + 0.5 * sin(ang * 3.0 + 4.0 * log(max(r, 0.04)) * rot)
fract(sin(dot(p, vec3(127.1, 311.7, 74.7))) * 43758.5453)
sin(uTime * 0.2 * 6.2832 + uPhase) * 0.5 + 0.5
Math.sin(TWO_PI * f * t)
sin(p.x * 25.0 + 3.1) * sin(p.y * 25.0 + 7.2) * sin(p.z * 25.0 + 11.3)
sin(q.y*12.0)*sin(q.x*7.3)*0.025
sin(uTime * 0.06) * 0.5 + 0.5
How many sin() calls happen per frame in a Virgo SDF render. Trace the call chain from the bottom up.
| Stage | Calculation | sin() calls |
|---|---|---|
| sceneSDF per step | ~80–120 (terrain + objects) | ~100 |
| March loop | 96 steps × sceneSDF | ~9,600 per ray |
| Normals (6× sceneSDF) | 6 finite-difference samples | ~600 per hit pixel |
| Soft shadow (8 steps) | 8 × sceneSDF | ~800 per hit pixel |
| AO (5 steps) | 5 × sceneSDF | ~500 per hit pixel |
| Per pixel total | march + normals + shadow + AO + camera + stars + fireflies | ~11,500 |
| Per frame | 921,600 pixels × ~11,500 | ~10.6 billion |
Ten billion sin calls. Per frame. At 60fps: 636 billion per second. The GPU's SFU hardware handles each in 1 cycle, but that is still a significant fraction of the frame budget. On CPU (server-streamed mode), it is the dominant cost.
Lithos computes sin via a 5th-order Chebyshev polynomial evaluated in 4-wide NEON SIMD:
fmul v2.4s, v0.4s, v0.4s x²fmul v3.4s, v2.4s, v0.4s x³fmla v0.4s, v3.4s, v30.4s x + x³·(-1/6) // v30 pre-loaded with -0.16667fmul v4.4s, v2.4s, v3.4s x&sup5;fmla v0.4s, v4.4s, v31.4s x + x³·(-1/6) + x&sup5;·(1/120) // v31 = 0.00833Five instructions. Four sine values. Constants v30 and v31 are loaded once at kernel entry and stay resident for the entire frame. No function call overhead, no branch prediction misses, no libm.
For comparison: GCC's sinf() at -O2 takes ~40 cycles for a single value. It calls into a scalar libm routine that handles the full IEEE 754 edge cases, range reduction, and a longer polynomial. Lithos's polynomial is tuned for SDF-relevant precision (<1 ULP error in [-π, π]) and skips what it does not need.
If sin-family operations account for 20% of frame time (conservative, given the hash→vnoise→fbm chain dominates terrain evaluation), then:
| Scenario | sin fraction | Speedup on sin | Frame time reduction |
|---|---|---|---|
| Conservative | 15% | 16x | ~14% |
| Moderate (terrain-heavy) | 25% | 16x | ~23% |
| Aggressive (FBM-dominated) | 35% | 16x | ~33% |
The savings cascade. Hash calls sin. Vnoise calls hash four times. FBM calls vnoise twice. Terrain calls FBM twice. SceneSDF calls terrain, then rocks call vnoise. March calls sceneSDF 96 times. Accelerating sin at the bottom accelerates every layer above it.
Hills are sine. Wind is sine. Orbits are sine.
Breathing is sine. Stars are sine. The galaxy's spiral arms are sine.
Sound is sine. Water is sine. Light through water is sine.
Making sine 16x faster does not optimize one function.
It accelerates the fundamental frequency of reality in this cosmos.
The sine function is the atom of this universe. The hash function — fract(sin(dot(p, k)) * 43758.5453) — appears 266 times in the source. It is the seed of all procedural content: terrain height, nebula density, star granulation, mineral veins, lichen growth, wind direction, rainfall probability. Every natural-seeming variation in the cosmos traces back to a sin call inside a dot product.
In Lithos notation: ∿ is one glyph, one opcode byte (0x63), one font table entry, one NEON blob. The entire cosmos pulses through this single symbol.
Cosine is sine phase-shifted: cos(x) = sin(x + π/2). Same polynomial, same NEON blob, one addition. Together they form rotation:
Every camera movement. Every orbital calculation. Every wind direction. Every tree twist. Every spiral arm. Every bat wing flap, every bubble wobble, every root sway. All of it is a 2×2 matrix with sin and cos. Accelerating both by 16–17x accelerates all rotation in the universe.
The camera's forward vector is vec3(sin(yaw)*cos(pitch), sin(pitch), cos(yaw)*cos(pitch)). You literally see through a sine/cosine transform. Perception itself is ∿.