1 / 17

Distributed Ray Tracing Part 1

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 (…)

krista
Télécharger la présentation

Distributed Ray Tracing Part 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Distributed Ray Tracing Part 1 黃聰賢

  2. Overview • Program Framework • Generate Ray • Get Nearest Intersection • Ray-Triangle Intersection • Space Partition • Ray-Box Intersection • Visibility

  3. Framework Model view: only glLoadIdentity() Projection: use glLoadIdentity() and glOrtho(…) For i from 0 to screen_width-1 For j from 0 to screen_height-1 Ray r = GenerateRay( … ); Point p = GetNearestIntersection(r); pixel_color = ComputeColor(p); glBegin(GL_POINTS); glColor3f(pixel_color); glVertex2i(i,j); glEnd();

  4. Generate Ray • 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

  5. pixel(i,j) Top i top H Right j near right Ray (0,0) up eye direction W (W/2,H/2) R2 Screen Resolution : W * H R3 Frustum near, right, top eye Right = normalize(eye direction × up direction) Top = normalize(Right ×eye direction) (P.S. top ≠ up) Raydirection = normalize (near * normalize(eye direction) +[(i-W/2)/(W/2)]*right*Right +[(j-H/2)/(H/2)]*top*Top )

  6. Get Nearest Intersection 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; } }

  7. Ray-Triangle intersection => =>

  8. =>

  9. Space Partition • Octree • KD-Tree

  10. Ray-Box intersection txmax txmin tymax tymax txmax tymin tymin txmin

  11. ac: center of box ai: normalized side direction of box hi: positive half length of box

  12. Visibility • 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.

  13. light pixel d_L d_hit eye p d_L < d_hit , visibility = 1 light d_L eye d_hit d_L > d_hit , visibility = 0

  14. y0 light y1 eye ω0 yi ω1 ωi x

  15. Direct Lighting • Use Phong Lighting Model. • Add the lighting effect if visibility is one. I * (Kd * dot(N, L) + Ks * pow(dot(E, R), Ns) ) N E L R

  16. Indirect Lighting • Use importance sampling to choose direction • If the direction hits a point yi ,compute the yi direct lighting y0 ω0 y1 normal ω1 eye yi ωi x

More Related