Skip to content

How it works

Ishiaki edited this page Oct 21, 2026 · 2 revisions

How it works

Every frame the camera's settings are turned into what a lens does, and handed to Keystone's lens (see Keystone's lens), which draws the game's finished picture again through it. The angle of view is 2 atan(sensor height / (2 x focal length)). Something at a distance d, with the lens focused at s, is drawn as a disc f² / (N (s - f)) x |d - s| / d wide on the film (f the focal length, N the f-number), which is what a real lens does; the shutter becomes the part of each frame it is open for, and whatever moved in that time is smeared along the way it went.

Moves

A move that holds the camera (staying, drifting, a path) stops the game's own camera from placing itself and puts it somewhere every frame instead:

  • staying: at a place fixed to the ground (a latitude, a longitude and a height, worked out again every frame, since the game slides its whole world about under a moving ship);
  • drifting: on an orbit of its own, made when the move begins from where the camera is and the ship's velocity, the way the game makes the ship's own orbit from where it is and how fast it goes; every frame the camera is put where that orbit has it at the game's time, as the game does for anything on rails. The camera keeps the roll it had (in space there is no level to come back to) and turns after the ship the more closely the narrower its lens sees;
  • a path: at the place, aim and lens the path has after so much of its time, in the path's frame as it is for the ship just then.

The game's own camera gets the camera back when the move ends, and eases from there to where it had been.

Paths

The points are kept relative to the ship's middle, in the frame the game's own camera was keeping to when the first point was put (north and up in its free camera, the stars in its orbital one, the ship in its locked one, the ship's heading in its chase one). Between points the camera follows a centripetal Catmull-Rom curve through them, which passes through each point and neither overshoots nor loops. Each point's aim is taken against looking at the ship's middle from that point, and that is what goes along the curve: points that all look at the ship give a path that looks at it all the way round. The lens goes from point to point evenly in stops of the angle of view. The path's time is shared equally between the gaps, gathering speed over its first fifth and slowing over its last.

The light meter

While the viewfinder is up, five times a second the finished picture (after the film and the lens) is copied and halved on the graphics card until it is a few thousand dots, and those are read back two frames later, when the card has long finished with them. Each dot's brightness, as light (the shown value to the power 2.2), is weighed, the middle of the picture most (or only the focus bracket, for spot), and the reading is how many stops that is from a middle grey (18% of white). When the camera sets the exposure itself, a change of aperture, shutter or film counts at once, before the next reading.

With the camera on when a flight begins, the viewfinder goes up in the scene's first frames, and the game then shows its new scene's interface by itself, without the event mods are told by: the game's interface and the viewfinder were drawn together (seen on Windows). The camera now puts the interface away again whenever it is showing while the viewfinder is up (once a second at most); F2 still takes the viewfinder down, as before.

The cockpit

The game draws the cockpit's inside with a camera of its own, after the view through the windows. The lens and the meter are put on that camera, so that the whole picture goes through them; its angle of view is read as the focal length; and the focus is found among the cockpit's own pieces, which mostly have nothing a ray can hit: a ray from the kerbal's eye is tried against the boxes round them, and then against the triangles of the few it goes into.

With Smooth Running

Where Smooth Running carries the craft and the camera on between the game's physics steps, a camera left standing on the ground stays standing (Keystone.Motion.KeepCamera); one left drifting in space goes on with the craft it drifts beside, as near as it is to it, and a path flown with the craft goes with the craft (2026-10-18).

The shutter in a film made frame by frame (2026-10-18)

How much of each frame the shutter is open for goes by the frame rate: open for 1/120 s, at 30 frames a second it is open for a quarter of each frame, and the motion blur is that long. It was taken from the game's own frame rate always; in a film made frame by frame (each frame standing for a set time of the film however long the game takes to draw it), the game draws a few frames a second, and the blur came out a tenth of what the shutter said. The film's frame rate is taken there now.

Lamps' flares (since 0.7.0)

A lamp shining into the lens flares, as real lenses do: a soft glare round it (light scattered in the glass and off the barrel), rays from the aperture's blades (eight blades, eight rays: long when the lens is stopped down, barely any wide open, where the aperture is near round), and faint ghosts of the aperture's shape thrown along the line through the middle of the picture, by how much of the lens's character is wanted. Lamps' flare on the page sets how much (0.5; none at 0).

Only lamps one can see flare, for a flare from where nothing is drawn would give it away: a craft's own lamp parts, and Natural Light's floodlights round a pad or a runway (searchlights, their beam some six degrees each side of the line from the glass through the light) and its strobes. Not the lights that only light a place with nothing drawn where they are. How strongly: by how much of the lamp's light reaches the lens (its strength gathered in its beam, some 365 times along a searchlight's middle, over the square of its distance) against how bright the rest of the picture is (by night a picture takes some ten thousand times the light it takes in sunshine, so a lamp hardly flares by day), in tenfolds as film and the eye take light. A lamp hidden behind something does not flare. The sun's flare is the game's own (or Scatterer's, with its ghosts).

Why nothing was seen at first (2026-10-18 and 19). The flares were drawn in five ways (a pass of the camera's own at three points in its drawing, Graphics.DrawMesh, a mesh of their own just before the lens), and nothing of them showed. In the game, one thing at a time: a plain cube held 2 m before the lens showed, with Cinema Camera on and off; a cube drawn with the flares' shader showed; the flares' own squares, given a plain white picture, showed where they belonged, bright. Their picture of shapes was what came out black on the graphics card: made with mipmaps, 384 by 128 pixels (not a power of two on its long side), it is black wherever the game's texture quality is below full. Made without mipmaps, the flares show. They were also made large and bright enough to see: the glare up to a third of the picture's half-height, where it had been a tenth with a bright middle of some five pixels, and each shape drawn at its own strength, not its square. Seen so in the game (2026-10-19, 22:18, at night on the pad, 35 mm, tools/dev/scratch-2026-10-18b/flarecheck.py): the test flare at full strength a star of eight rays round a bright middle; the pad's floodlights, 72 m off and 76 degrees off their beams, a soft glow on their glass with faint rays at f/11, the glow without rays at f/2.8, and nothing with the flares at 0.

Clone this wiki locally