Efficient Photon Management and Illumination Techniques for Ray Tracing, Assignments of Algorithms and Programming

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

Pre 2010

Uploaded on 07/28/2009

koofers-user-ot5-3
koofers-user-ot5-3 🇺🇸

10 documents

1 / 120

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CPSC212 SPRING 2008
Algorithms and Data Structures
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Efficient Photon Management and Illumination Techniques for Ray Tracing and more Assignments Algorithms and Programming in PDF only on Docsity!

CPSC 212 SPRING 2008

Algorithms and Data Structures

ALGORITHM ANALYSIS

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.

RAYTRACING BACKGROUND

 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.

3D SCENES

 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.

ASSIGNMENT PHASE 1

 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.

COLLECTION OF PHOTONS

 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.

ABSTRACT DATA TYPES

 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.

ILLUMINATION

 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

ILLUMINATION ALGORITHM

  1. Skip photons that are out of range.
  2. Add photons that are in range as long as the maximum number have not been found.
  3. When the maximum number have been, compare next photon’s distance to the farthest photon and replace if closer.
  4. Now we have the closest N photons. If there are less than a minimum number of photons (8), return black.
  5. Compute illumination.

COMPUTING ILLUMINATION

 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.

DATA STRUCTURES

 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

DATA STRUCTURES (CONT.)

 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.

EXPLANATION OF LOG N

 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 = 1Log 16 = 4Log 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).

DISCUSSION OF EFFICIENCY

 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.