Let’s build a Raytracer, from scratch.

Course description:

“Raytracing” — it’s not as hard as it sounds. We’ll do it in < 500 lines. From scratch.
No OpenGL, no Qt, no licensing shenanigans. Zero third party software. Works on all platforms.
And you won’t need any prior knowledge on graphics or rendering. Pinky promise.
Here’s our final result (spoiler alert!):

Raytracer (example rendering)

 

Course goals:
The participants will acquire deep knowledge about the principles of raytracing, and they will write a codebase offering basic functionality and easy extensibility. Many extensions will be discussed or hinted at during the course.

Required skills:
– A teeny tiny bit of C++
– Would be nice if you know (more or less) what a “vector” is

Language:
German  (English if there is sufficient demand)

Responsible lecturer:
Nikolaus Mayer

Course contents:

“Raytracing”, that is… this ominous black magic… this Hollywood witchery that makes SciFi movies possible… this arcane art used by “renderers” to ensnare us puny mortals with their sorcery, with words like “Maya”, “Blender”, “3ds Max”…
To understand raytracing you must be the absolute turbo nerd, you gotta have a server farm, and oh right you need to sacrifice your soul to bloody Father Nyarlatothep, Hell Lord of GPUs…

wait no. That’s not right at all. None of it!

Truth is: raytracing is completely and entirely easy.

And that’s why we are going to develop our very own raytracer. Because we’re short on time (and because we don’t want to introduce unnecessary complexity) we can’t implement every single feature offered by a “real” raytracing engine: no glass materials, no water, no smoke, no caustics, no Fresnel effect, no bump mapping, no subsurface scattering, no volumetric light…
On the other hand our code will have fewer than 500 lines. And we won’t be using anything except for pure, organic, artisanal C++. That said, of course you are allowed to implement yours in Python. Or Go. Or whatnot. Or Haskell.
On top of this our code is easy to extend. We’ll talk about a bunch of ideas in the course, some easier than others (they all just take too long to fit into the course).

We have a step-by-step plan:

  • Rendering an empty image (hey, gotta start somewhere!)
  • Ground and sky and a virtual camera
  • Rendering a polygon
  • Rendering perfect spheres
  • Lighting the scene, including shadows and highlights
  • Antialiasing, soft shadows, matte surface finishes
  • Depth-of-field blur
  • Textures

Our code will focus on legibility and modularity, not efficiency or raw speed. That’s why we won’t use multithreading or GPU support (even though this application is absolutely embarrassingly parallel).

 

Requirements:

Each participant needs a computer with: graphical interface, a C++ compiler, and internet connection (although technically, internet is not strictly necessary). A weak decade-old laptop is entirely sufficient. Linux is not a must-have (but it is nice).

A GPU (whether dedicated or onboard) is not required.