17
Distributed Ray Tracing Part 1 黃黃黃

Distributed Ray Tracing Part 1

  • Upload
    krista

  • View
    44

  • Download
    0

Embed Size (px)

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 Presentation

Citation preview

Page 1: Distributed Ray Tracing Part 1

Distributed Ray Tracing Part 1

黃聰賢

Page 2: Distributed Ray Tracing Part 1

Program Framework Generate Ray Get Nearest Intersection

◦ Ray-Triangle Intersection◦ Space Partition◦ Ray-Box Intersection

Visibility

Overview

Page 3: Distributed Ray Tracing Part 1

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

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

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

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

Ray-Triangle intersection

= >

= >

Page 8: Distributed Ray Tracing Part 1

= >

Page 9: Distributed Ray Tracing Part 1
Page 10: Distributed Ray Tracing Part 1

Octree KD-Tree

Space Partition

Page 11: Distributed Ray Tracing Part 1

Ray-Box intersection

tymin

tymax tx

min

txmax

txmax

tymin

tymax

txmin

Page 12: Distributed Ray Tracing Part 1

ac: center of boxai: normalized side direction of boxhi: positive half length of box

Page 13: Distributed Ray Tracing Part 1

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

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

eye

x

y0

y1

yiω0 ω1

ωi

light

Page 16: Distributed Ray Tracing Part 1

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

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