distributed ray tracing part 1
DESCRIPTION
Distributed Ray Tracing Part 1. 黃聰賢. Overview. Program Framework Generate Ray Get Nearest Intersection Ray-Triangle Intersection Space Partition Ray-Box Intersection Visibility. Framework. Model view: only glLoadIdentity () Projection: use glLoadIdentity () and glOrtho (…) - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/1.jpg)
Distributed Ray Tracing Part 1
黃聰賢
![Page 2: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/2.jpg)
Program Framework Generate Ray Get Nearest Intersection
◦ Ray-Triangle Intersection◦ Space Partition◦ Ray-Box Intersection
Visibility
Overview
![Page 3: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/3.jpg)
Model view: only glLoadIdentity()Projection: use glLoadIdentity() and glOrtho(…)
For i from 0 to screen_width-1For j from 0 to screen_height-1Ray r = GenerateRay( … );Point p = GetNearestIntersection(r);pixel_color = ComputeColor(p);glBegin(GL_POINTS);glColor3f(pixel_color);glVertex2i(i,j);glEnd();
Framework
![Page 4: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/4.jpg)
Input◦ Eye :
position, direction, up direction◦ The position of the pixel in the screen :
(i, j)◦ The screen resolution :
screen_width, screen_height◦ Projection setting:
near, right, left, top, bottom Output
◦ Ray : start position, direction
Generate Ray
![Page 5: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/5.jpg)
Right
Top
eye
up eyedirection
R3 Frustumnear, right, top
R2 ScreenResolution : W * H
Right = normalize(eye direction × up direction)Top = normalize(Right × eye direction)(P.S. top ≠ up)Ray direction = normalize ( near * normalize(eye direction)
+[(i-W/2)/(W/2)]*right*Right+[(j-H/2)/(H/2)]*top*Top )
(0,0)W
H
i
j
pixel(i,j)
right
top
Raynear
(W/2,H/2)
![Page 6: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/6.jpg)
Input : Ray r;Output : Nearest intersection point p;
Point temp_point;float t;float distance = FLT_MAX;For each face f{
t = ray_triangle(&f, &r, &tmp_point);if( t<distance && t > ε){
distance = t; p = temp_point;
}}
Get Nearest Intersection
![Page 7: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/7.jpg)
Ray-Triangle intersection
= >
= >
![Page 8: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/8.jpg)
= >
![Page 9: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/9.jpg)
![Page 10: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/10.jpg)
Octree KD-Tree
Space Partition
![Page 11: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/11.jpg)
Ray-Box intersection
tymin
tymax tx
min
txmax
txmax
tymin
tymax
txmin
![Page 12: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/12.jpg)
ac: center of boxai: normalized side direction of boxhi: positive half length of box
![Page 13: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/13.jpg)
Shoot a ray to the light and try to get the distance to the nearest intersection point.
If the distance > the distance to the light,add the lighting effect
Space partition can speed up the computation.
Visibility
![Page 14: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/14.jpg)
eye
d_L
d_hit
d_L < d_hit , visibility = 1
light
eye
d_L
d_hitd_L > d_hit , visibility = 0
light
pixel
p
![Page 15: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/15.jpg)
eye
x
y0
y1
yiω0 ω1
ωi
light
![Page 16: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/16.jpg)
Use Phong Lighting Model. Add the lighting effect if visibility is one.
Direct Lighting
NE
R L
I * (Kd * dot(N, L) + Ks * pow(dot(E, R), Ns) )
![Page 17: Distributed Ray Tracing Part 1](https://reader030.vdocuments.mx/reader030/viewer/2022033102/56816662550346895dd9ef53/html5/thumbnails/17.jpg)
Use importance sampling to choose direction
If the direction hits a point yi ,compute the yi direct lighting
Indirect Lighting
eye
x
y0
y1
yi
normalω0
ω1
ωi