{
  "id": 5077714,
  "title": "Drawing day and night on a 3D globe: the shader behind my world clock",
  "url": "https://urgent.news/2026/09/02/drawing-day-and-night-on-a-3d-globe-the-shader-behind-my-world-clock",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-02T11:32:14.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/timetate/drawing-day-and-night-on-a-3d-globe-the-shader-behind-my-world-clock-391k"
  },
  "original_language": "en",
  "account": "Every world clock I've ever used is a physical table. You read \"Tokyo +9, São Paulo −3\" and still don't know who is asleep. I wanted something different: a 3D globe showing daylight and darkness, so you can instantly determine if it's appropriate to contact someone. That idea became Timetate - a world clock and meeting planner with a 3D globe interface. This post explains how the daylight/nighttime terminator is drawn and why the initial approach was incorrect.\n\nThe globe consists of three concentric spheres, each with its own purpose: Earth, clouds, and atmosphere. The Earth sphere uses a shader to create the day/night terminator. The cloud sphere is a textured shell with a slightly higher radius and additive blending for an outer rim glow. The atmosphere sphere is rendered with a slightly larger radius and back-facing sides to create a rim effect around the planet. All textures are 1024px WebP maps: day, city lights, clouds, specular, and normal.\n\nTo determine the position of the sun, we calculate the subsolar point using the current date and time. This calculation considers declination (north/south position) and subsolar longitude (east/west position). The resulting sun direction vector is then applied to the Earth shader. Clouds rotate slowly to simulate cloud movement.\n\nThere is one crucial detail that initially caused issues: normal vectors. The vertex shader provides two normals: view space and world space. Initially, the renderer used the view space normal, which led to incorrect shading. Switching to world space normals fixed the problem, resulting in a proper day/night terminator on the globe.",
  "summary": "Every world clock I've used is a table. You read \"Tokyo +9, São Paulo −3\" and you still don't feel who's asleep. I wanted the opposite: look at the Earth, see the daylight band, and know instantly whether it's a reasonable hour to ping someone. That became Timetate — a world clock and meeting planner where the main interface is a 3D globe with a day/night terminator that tracks the real sun. This…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}