




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Techniques for managing a collection of photons and using them for illumination in ray tracing. It covers storing photons in a list or maxheap, finding the closest photons using the distance formula, and tracing photons from various types of lights. It also introduces the use of a kdtree for storing photons and finding the closest ones. The document also touches on the topic of bending photons through a transparent surface and creating a projection map for tracing refractive objects.
Typology: Assignments
1 / 120
This page cannot be seen from the preview
Don't miss anything!





























































































Algorithms and Data Structures
T(N) = O(f(N)) if there are positive constants c and n 0 such that T(N) ≤ cf(N) when N >= n 0.
T(N) = Ω (g(N)) if there are positive constants c and n 0 such that T(N) ≥ cg(N) when N >= n 0.
T(N) = Θ(h(N)) if and only if T(N)= O(h(N)) and T(N) = Ω (g(N)).
T(N) = o(p(N)) if for all constants c there exists an n 0 such that T(N) < cp(N) when N > n 0.
Each object in the scene is mathematically defined.
For example, a sphere has a radius, center point (location), and at least one color.
For each pixel, a ray is traced from the eye point toward the pixel. The color of that pixel is determined by which object is intersected first.
The actual color of the pixel is based on the object’s ambient, diffuse, and specular lighting.
The scenes are mathematically defined using cartesian coordinates (x, y, z) locations.
x defines left and right locations
y defines high and low locations
z defines near and far locations
We are using the "right-handed” coordinates
If your index finger (right hand) points to +x,
your middle finger to +y, then your thumb points to +z.
Goal: compute illumination based on randomly placed photons.
A photon is a packet of light. We will use photons to provide improved illumination for the scene.
A photon is represented by a Color value and a location. tip one: Color class defines a way to store RGB together. tip two: Point class defines a way to store XYZ values together.
First we must find a way to store a collection of photons. To define a photon, we can use a structure or a class: struct photon { // Define a color and a location for the photons }; typedef struct { } photon;
class photon { // define color and location };
We may then store the photons in an array, a linked list, or another advanced structure.
A stack is an example of an abstract data type.
A stack has data that is in the stack.
A stack has operations that can be performed on the stack (pop, push, peek/top).
The stack is an Abstract Data Types (ADT), meaning that it is a data type that is defined separate from implementation.
The behavior and operations of a stack may be implemented in various ways, but the concepts remain the same.
Algorithm: Find the closest N photons that are within a minimum distance.
Example: Find the youngest 3 minors.
Daniel, Chris, Sam, Jeremy, John, Nick, Clay Daniel: 18 Chris: 17 Sam: 15 Jeremy: Nick: 14 Clay: 16
Given N closest photons,
Sum the colors all the closest photons, channel by channel (red with red, green with green, blue with blue). Divide by the area of the circle holding photons ( π r^2 ), where r is the distance to the farthest photon in the closest photon collection. If r is a square distance, do not square it again. Return the resulting color.
Needs:
Total photons collection: Ability to quickly find near photons. Closest photons collection: Ability to quickly locate the current farthest photon. Ability to quickly determine the number of photons currently being held. Ability to quickly remove and add.
Ideas
Sorted array, linked list Search tree Heap
The collection with all the photons traced for the scene should hold a point and color for each photon.
The collection of the closest photons should be size num_photons and hold photons with distances.
The closest photons array may hold just addresses of the photons to their locations in the entire array.
In CS, log N is usually log 2 N.
A problem is usually logarithmic if it takes a constant amount of time to divide the problem by a fraction (typically ½).
O(N) < O (N log N) , for large values of N
O (log N ) < O (N) , for large values of N
Examples: Log 2 = 1 Log 16 = 4 Log 256 = 8
Example: a binary search is O(log N) because the problem is divided in half at each pass (each time we inspect an element).
If the image is 800 by 600 pixels (480,000 pixels), then we are looping through all the photons (50,000) 480,000 times.
Really once per pixel? It may be computed multiple times for reflections and transparencies.
When we choose the closest photons, they are inserted in sorted order into a separate array.