Numerical tecniques for photorealistic image generation

A.Y. 2021/2022
Overall hours
FIS/05 FIS/06
Learning objectives
This course helps the students to develop two abilities: (1) to develop numerical codes that approximate a model of some non-trivial physical phenomenon, and (2) to learn how to properly develop complex software codes, using a number of advanced professional tools to aid the development.
The first ability is declined into the development of a software for the calculation of solutions for the rendering equation. The software will generate more and more photorealistic images of three-dimensional objects, similar to what professional programs like Autodesk 3D Studio do.
The second ability will allow students to develop complex software codes, made by several parts interacting together and strenghtned by internal verification tests. To fulfill this purpose, students will learn how to use advanced tools and procedure that are used nowadays, like performance measurement (both in terms of memory occupation and time), version control systems, bug-tracking systems, unit and integration testing, Continuous Integration (CI) systems, etc.
Expected learning outcomes
At the end of this course, students will have achieved the following abilities:
1. They will be able to develop complex software codes that can approximate the behaviour of a non-trivial physical model;
2. They will know how to describe mathematically the shape of complex three-dimensional objects;
3. They will be able to use omogeneous transformations and quaternions to describe the placement and orientation of objects in space;
4. They will be able to collaborate with other people in the development of software using distributed version-control systems (in the course we will use git) and code review systems;
5. They will know how to use bug-tracking systems to control the quality of their own software;
6. They will be able to use web-platforms to handle and share their codes (in this course we will use GitHub);
7. They will be able to use tools for performance measurement (perf, valgrind, etc.).
Course syllabus and organization

Single session

Lesson period
Second semester
The course might be taught remotely, if there will be limitations caused by the COVID-19 emergency. In this case, theory lessons will be taught asynchronously: this will allow students with poor Internet connections to download the videos and watch them properly. Laboratory lessons will be taught synchronously. Students will be able to use Ariel to ask questions to the teacher in any moment, especially for theory lessons.

Course materials will not change in any case.

If the sanitary crisis will force exams to be held remotely, we will either use Zoom or Jitsi Meet, depending on their availability.
Course syllabus
The following topics will be taught:

- Rendering equation
- Colour spaces
- Encoding of images and video
- Basics of three-dimensional geometry
- Geometrical description of complex objects
- The ray-tracing and global illumination algorithms
- Monte Carlo methods
- Filtering and shading

During lab lessons, students will implement codes to compute formulae described during front lessons. Moreover, the following topics will be taught:

- Version control systems
- Bug-tracking systems
- Measuring code performance
- Use of continuous-integration systems
- Pull requests and code reviews
- How to assign proper version numbers
Prerequisites for admission
This course can be followed by students of «laurea magistrale» in pphysics and in Physics of Data.

Students must already know one programming language at least, like C, C++, D, Objective-C, Pascal, Julia, etc. They have the freedom to pick any language they prefer to implement the codes needed to complete the course. To allow the teacher to test students' codes on his own computers, they must ensure that their programs are able to run on 64-bit machines running Linux. Of course, it is neither forbidden nor discouraged that these codes can be run on other platforms as well.

Some languages, like Fortran or Python, are not suitable for the development of the kind of software needed in this course. Nevertheless, during the first lessons of the course the teacher will provide detailed information and advice about the language chosen by the students.

Mandatory abilities:

- Analisi matematica 1;
- Analisi matematica 2;
- Analisi matematica 3;
- Geometria 1;
- Informatica;
- Laboratorio di trattamento numerico dei dati sperimentali.
Teaching methods
The course is taught using both front lessons and lab sessions. Attendance to both is mandatory. Each week a two-hour front lesson will be taught, followed by a lab session lasting two or three hours, for 12 weeks. (6 CFU: 14 hours of front lessons and 48 hours in the lab.)

Depending on the availability, lab sessions will be held either in the informatics laboratory or in some other room. In any case, students are asked to bring their own laptop to lab sessions. If any student does not own a laptop, the teacher can—provided that it's possible—lend laptops to be used during the session.

In front lessons, the teacher will present the theory that will be used to implement codes in the next lab session. During each of these sessions, students must prepare the structure of the code within the software that they developed in the weeks before. Work is done in groups of 2-4 people using `git` and GitHub (

Since one of the fundamental abilities taught in the course is the proper usage of version control systems, it is mandatory that students complete the list of exercises given during a front lesson before the lab lesson of the _following week_, unless otherwise specified.

During lab sessions, the teacher aids students and, depending on the languages and tools used by each group, he will suggest methods to fulfill the requests of each exercise in the best possible way.
Teaching Resources
- Suffern, Ray-tracing from the ground-up (2007),;
- Pharr, Jakob, Humphreys, Physically based rendering: from theory to implementation (2004),;
- Dutré, Bekaert, Bala, Advanced global illumination (2006),;
- Shirley, Ray tracing in one week end book series,;
- McQuaid, Git in practice (Manning, 2015),;
- Chacon, Straub, Pro Git,;
Assessment methods and Criteria
During the final exam, each student (_not_ group) will give a keynote about the software they developed in front of the teacher and other students. There are no written tests. Grading is a mark from 18 to 30, which considers the weekly work done in lab sessions throughout the semester.

Specific competences that will be used to quantify the final mark are the following:

- Knowledge of the theoretical foundations of the course: geometry, rendering equation, transformations, quaternions, filtering, shading, Monte Carlo methods, etc.
- Ability to reason critically on the project that the student developed;
- Cleanliness of the code;
- Proper usage of the `git` repository;
- Appearance of the GitHub webpage for the project and its
- Quality of the keynote presentation;
- The presence of functionalities in the code that were marked as
«optional» will help students to increase their final mark.
Lessons: 42 hours
Professor: Tomasi Maurizio
Ask the teacher
Laboratorio di Strumentazione Spaziale, Department of physics (via Celoria 16, Milano)