T5 Position and Orient the Camera (Milestone 3)
T5.1 Use Field-of-View angle (camera.h)
class camera {
public:
double aspect_ratio = 1.0; // Ratio of image width over height
int image_width = 100; // Rendered image width in pixel count
int samples_per_pixel = 10;
int max_depth = 10; // Maximum number of ray bounces into scene
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
double vfov = 90; // Vertical view angle (field of view)
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
private:
// ....
void initialize() {
image_height = int(image_width / aspect_ratio);
image_height = (image_height < 1) ? 1 : image_height;
pixel_samples_scale = 1.0 / samples_per_pixel;
center = point3(0, 0, 0);
// Determine viewport dimensions.
auto focal_length = 1.0;
//auto viewport_height = 2.0;
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
auto theta = degrees_to_radians(vfov);
auto h = std::tan(theta/2);
auto viewport_height = 2 * h * focal_length;
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
auto viewport_width = viewport_height * (double(image_width)/image_height);
//...
}
//...
};Test in main() (main.cpp)


T5.2 Position and Orient the Camera (camera.h)
Add lookfrom, lookat, vup, and u, v, w
Revise initialise() to calculate u, v, w of the camera frame from lookfrom, lookat, vup
Revise main() to test camera settings


T5.3 Defocus
choosing random points from the defocus disk
add defocus members in class camera
Add a public method defocus_disk_sample() in class camera
revise camera's initialise()
revise camera's get_ray() to change the ray origin a bit
Set camera defocus parameters in main()
Build and Run

Last updated