I am working on a raytracing Java program for fun. Here's one rendering: enter image description here

As you can see I still have to implement anti-aliasing (and there are huge geometry problems I won't get in to). How would one go about this in a raytracing program, where the renderer doesn't really render lines, but individual pixels? Is it even possible? For example, in a scanline rendering, you could apply anti-aliasing after filling a triangle. But in a raytraced rendering, the program works pixel-by-pixel, and doesn't know where object's edges are, or where to smooth things out.


  • $\begingroup$ For raytracing you can just cast multiple rays per pixel to collect multiple samples per pixel. Then average out the results. Now you can end up getting pretty sophisticated in terms of the sampling algorithm itself especially when you get into indirect lighting, but that's the gist of it: just multiple rays/samples per pixel. I've actually seem some raytracers just fudge the ray by a random subpixel value each time it is being cast to produce an antialiased image and the results actually look quite decent. The randomness of the sampling can help pick up razor thin geometry, e.g.... $\endgroup$ – Dragon Energy Dec 27 '17 at 4:47
  • $\begingroup$ ... which a uniform sampling method might miss. That's for offline raytracers that are intended to run for long amounts of time to converge towards a decent production image. If your aim is more realtime approximation with interactive framerates, then maybe uniform sampling would work better, like one that is fixed to project 5 rays per pixel. There are also dirt cheap post-processing techniques on the rendered image like FXAA, but those don't look so great but maybe acceptable if your goal isn't to render production-quality images. $\endgroup$ – Dragon Energy Dec 27 '17 at 4:50