From pixel to ray

Ray generation

Reverse ray tracing begins by turning each pixel into a ray. The origin is always the camera; the direction comes from where that pixel sits on the image plane. Click a pixel in the little image on the right and watch its ray appear in the scene — and the colour it brings back.

The camera, the image plane, the scene
Drag to orbit
the selected pixel's ray the image plane where it hits
The image being formed

One pixel, one ray. Click any of them. The grid is deliberately coarse so that every square you see corresponds to exactly one ray in the scene above.

Controls the camera
16
55°
1.50
Pixel
Normalised coordinates
Ray direction
What it hit
Why the plane distance does not matter a common confusion

Slide plane distance and watch the image: nothing changes. The image plane is a bookkeeping device, not a physical object — moving it towards or away from the camera scales the plane and the offsets on it by exactly the same factor, and the ray direction comes out identical once normalised.

Field of view is different. It changes how far across the plane a given pixel sits relative to the distance, so it genuinely changes the directions — which is why the picture gets wider or narrower.

Turn on every pixel's ray and the whole frustum fills in. This is the moment reverse ray tracing pays off: every one of those rays is guaranteed to land on a pixel, because it was built from one.

The generation code live, for the selected pixel

    
Where antialiasing comes from. Each pixel here gets exactly one ray, through its centre, so every edge in the little image is a hard staircase. A pixel is not a point though — it is a small square area, and its true colour is the average over that square. Real renderers therefore fire several rays per pixel at jittered positions inside it and average the results. That is the same machinery as Monte Carlo integration, applied to area instead of direction, and it is why the sample count in a path tracer smooths edges as well as reducing noise.