Skip to content

Notes

Notes

Short notes on things I picked up while building. Small, specific and quick to read.

Search

Loading search…

  1. graphics · physics

    A rainbow is always 42° from the point opposite the sun

    To draw a believable rainbow you don't need particles, just geometry. The primary bow sits 40.4°–42.3° from the antisolar point (red outside), the fainter secondary bow sits at 50–53° (colours reversed), and the sky inside the primary is brighter than between the two (Alexander's dark band). It only appears when it's raining and the sun is up but lower than 42°, which is exactly why rainbows are a morning or late-afternoon thing.

  2. 3d · animation

    Motion-capture walk cycles carry root motion, and looping them makes characters snap

    The island's people "flickered" while walking. The walk take moved the hips 1.6 m forward per cycle, and every time the loop restarted, the body jumped back. The fix: subtract the linear drift from the root bone so the cycle plays in place, then measure how fast the take actually travelled (distance ÷ duration) and set timeScale = groundSpeed / takeSpeed. The feet stop sliding and the snap is gone.

  3. apis · licensing · weather

    "Free" weather APIs aren't all free for the same things

    Open-Meteo's free tier is for non-commercial use only. MET Norway's Locationforecast data is CC BY 4.0, so any use is fine as long as you credit them. Their terms are strict, though: send an identifying User-Agent, never re-request before the Expires header, and put a caching proxy in front instead of letting browsers call them directly. My API caches each ~11 km grid cell in DynamoDB, so the weather service never sees a single visitor.

  4. aws · cloudfront · privacy

    CloudFront tells you the visitor's city, with no permission prompt

    With the right origin request policy, CloudFront adds CloudFront-Viewer-Latitude, -Longitude, -City, -Time-Zone and more to each request. That's city-level accuracy from the IP: enough to show each visitor the real sun and weather over their own city. I round the coordinates to ~1 km, send them back only to that visitor, and never store them.

  5. webgl · glsl

    `patch` and `half` are reserved words in GLSL ES 3.00

    float patch = … compiled in my head but not on the GPU: WebGL2 shaders reject patch, half and a few other future-reserved words with a terse "Illegal use of reserved word". Two separate bugs this week, same cause. Rename the variable and move on.

  6. webgl · debugging

    One NaN pixel can turn the whole frame black

    The night scene rendered pure black. The culprit was pow(1.0 - vT, 1.6) with vT slightly above 1: pow of a negative base is NaN, and the bloom pass's blur spread that single NaN across the entire image. Clamp the base, pow(clamp(x, 0.0, 1.0), k), and the frame comes back.

  7. javascript · astronomy

    suncalc 2.x returns degrees, not radians

    suncalc 1.x returned the sun's azimuth and altitude in radians, measured from the south. Version 2 switched to degrees, measured clockwise from north. Treating degrees as radians put the sun in the wrong place and made every shadow point the wrong way. A unit test that checks "10 a.m. sun is in the south-east" would have caught it on day one, so now I have one.

  8. aws · cloudfront · websockets