So far only one ray is emitted for each pixel, and the intercection of this ray (and induced ray, like secondary ray) with the surfaces in the scene determins the color at that pixel.
One simplest way to do antialiasing is to sample more than one rays for each pixel, and the average of color contribution of all the primary rays is assigned as the final color of that pixel.
Suppose we want to sample 16 primary rays for each pixel, one popular method is jittered sampling, which first cut the pixel square into 4 by 4 smaller squares, and randomly select one primary from each smaller square.
for (int row = 0; row < vReso; row++) for (int col = 0; col < hReso; col++) { Pixel(row, col) = Black; for(int r=0; r<N; r++) for(int c=0; c<N; c++) { double x = col + c/float(N) + drand48()/N - hReso/2, y = row + r/float(N) + drand48()/N - vReso/2; Point hit_pnt; if( hitSphere(radius, center, Point(0,0, eye_at), Point(x,y,0), hit_pnt) ) { Pixel(row, col) += compute_lighting(Red, White, light_pos - hit_pnt, hit_pnt - center); } } Pixel(row, col) /= N*N;
1.3.6