peter shirley on gerritâ€™s notes
https://www.wessendorf.org/tags/peter-shirley/
Recent content in peter shirley on gerritâ€™s notesHugo -- gohugo.ioen-usSat, 11 Jan 2020 00:00:00 +0000Ray Tracing 010: Metal
https://www.wessendorf.org/ray-tracing/010-metal/
Sat, 11 Jan 2020 00:00:00 +0000https://www.wessendorf.org/ray-tracing/010-metal/Metal Continuing with materials, this chapter will introduce a generic materials class and two first material child classes for diffuse (Lambertian) and reflective/metallic materials.
To do: add more detailed write-up. Updated Files hittable.h
added material class and mat_ptr main.cpp
added material.h addd random.h replaced drand48() with random_double() moved random_in_unit_sphere() to material.h added depth parameter to color() function in color(), update to use new material with depth of 50 calls, moved previous target for diffuse material to class replaced MAXFLOAT with INFINITY in main(), added depth parameter to color(), added material to spheres, added two spheres to list sphere.Ray Tracing 009: Diffuse Materials
https://www.wessendorf.org/ray-tracing/009-diffuse-materials/
Mon, 22 Apr 2019 00:00:00 +0000https://www.wessendorf.org/ray-tracing/009-diffuse-materials/Diffuse Materials The next few chapters will be about materials. This chapter will start with simple diffuse or matte materials.
Diffuse objects take on the color of their surroundings, but they modulate it with their own color.
And light that reflects off a diffuse surface gets reflected in a random direction. If there are two diffuse objects touching each other you can end up with rays that reflect off the first object and never touch the second, or rays that reflect off the first, then the second before they move away from the objects.Ray Tracing 008: Anti-Aliasing
https://www.wessendorf.org/ray-tracing/008-anti-aliasing/
Sun, 21 Apr 2019 00:00:00 +0000https://www.wessendorf.org/ray-tracing/008-anti-aliasing/Anti-Aliasing The pictures in the previous episodes looked a little rough and pixelated around the edges. Pictures taken with a real camera look smoother because the edge pixels are a blend of some foreground and some background. In this episode I’ll add anti-aliasing to give my rendered images smoother edges.
This effect can be achieved by averaging a number of random samples inside each pixel. This will produce a color that consists of part background, part foreground.Ray Tracing 007: Multiple Objects
https://www.wessendorf.org/ray-tracing/007-hittable/
Sat, 20 Apr 2019 00:00:00 +0000https://www.wessendorf.org/ray-tracing/007-hittable/Multiple Objects So far the scene included only a single sphere set in the center. In this episode we’re going to add support for multiple objects in a scene. This could be done with an array of sphere objects, but a cleaner solution is to use an abstract class for anything a ray can hit, may it be a single sphere, a list of spheres, triangles, boxes, etc.
The hittable abstract class has a hit function that takes the ray r, a range of t from $t_{min}$ and $t_{max}$ and a hit_record structure.Ray Tracing 006: Surface Normals
https://www.wessendorf.org/ray-tracing/006-surface-normals/
Fri, 19 Apr 2019 00:00:00 +0000https://www.wessendorf.org/ray-tracing/006-surface-normals/Surface Normals The sphere I added in the last episode was rendered as a flat red circle. In the following step I’m going to add a surface normal to shade the sphere.
Surface normals are used for several purposes in graphics, primarily for lighting. A surface normal is a vector that is perpendicular to the surface at a given point. This vector can either point outward or inward. They usually point outward by convention, but inward pointing normals can be useful, for example, to distinguish between solid spheres and spherical bubbles.Ray Tracing 005: Adding a Sphere
https://www.wessendorf.org/ray-tracing/005-sphere/
Thu, 18 Apr 2019 00:00:00 +0000https://www.wessendorf.org/ray-tracing/005-sphere/Adding a Sphere Episode 4 introduced a ray class. Now it’s time to let the ray hit the first object: a sphere.
The equation of a sphere centered at the origin is[1]
\[ x^2 + y^2 + z^2 = R^2 \]
which is essentially derived from Pythagoras’ Theorem extended to three dimensions.[2]
For any \( (x,y,z) \), if \( x^2 + y^2 + z^2 = R^2 \) then \( (x,y,z) \) is on the sphere, otherwise it’s not.Ray Tracing 004: The Ray Class
https://www.wessendorf.org/ray-tracing/004-ray/
Wed, 17 Apr 2019 00:00:00 +0000https://www.wessendorf.org/ray-tracing/004-ray/The Ray Class In episode 3 I added a vec3 class to help with 3-dimensional vector calculations.
This chapter moves it one step further by introducing a new ray class. A ray can be thought of as a function
\[ p(t) = A + t * B \]
where p is a 3D position along a line, A is the ray origin, B is the ray direction, and t is the ray parameter which moves p(t) along the ray.Ray Tracing 003: The vec3 Class
https://www.wessendorf.org/ray-tracing/003-vec3/
Tue, 16 Apr 2019 00:00:00 +0000https://www.wessendorf.org/ray-tracing/003-vec3/The vec3 Class In episode 1 I made a simple image by assigning rgb values to individual variables in a loop across the x- and y-coordinates.
This example produces the same image, but it introduces the vec3 class to perform calculations with 3-dimensional vectors. To keep it simple, this class can be used for x, y, z-coordinates as well as r, g, b-color values. There are getter methods for both x, y, and z as well as r, g, b.Ray Tracing 002: Other Image Formats
https://www.wessendorf.org/ray-tracing/002-stb/
Mon, 15 Apr 2019 00:00:00 +0000https://www.wessendorf.org/ray-tracing/002-stb/Other Image Formats with stb_image.h The stb_image.h single-file library makes it pretty easy to write and convert images to other file formats. I love the simplicity of the PPM format, but it’s not very web-friendly. If you want to share the image you will likely end up having to convert it to a different format.
Here’s a sample in C++:
// stb-example.cpp #include <iostream> #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.Ray Tracing 001: Introduction
https://www.wessendorf.org/ray-tracing/001-intro/
Sun, 14 Apr 2019 00:00:00 +0000https://www.wessendorf.org/ray-tracing/001-intro/Introduction This section is dedicated to my journey to learning how to build a ray tracer. Each post in this series will document one step in this journey.
I will begin with Peter Shirley’s excellent book Ray Tracing in a Weekend and his following two volumes Ray Tracing - The Next Week and Ray Tracing - The Rest of Your Life. I found the first book on Amazon Kindle some time ago, but it’s now available for free at raytracing.