Ray Tracing Intro Steve Marschner CS 4620 Cornell University Cornell CS4620 Fall 2020 Steve Marschner • 1
Projection • To render an image of a 3D scene, we project it onto a plane • Most common projection type is perspective projection Cornell CS4620 Fall 2020 Steve Marschner • 2
Two approaches to rendering Cornell CS4620 Fall 2020 Steve Marschner • 3
Two approaches to rendering for each object in the scene { for each pixel in the image { if (object affects pixel) { do something } } } object order or rasterization Cornell CS4620 Fall 2020 Steve Marschner • 3
Two approaches to rendering for each object in the scene { for each pixel in the image { for each pixel in the image { for each object in the scene { if (object affects pixel) { if (object affects pixel) { do something do something } } } } } } object order image order or or rasterization ray tracing Cornell CS4620 Fall 2020 Steve Marschner • 3
Two approaches to rendering for each object in the scene { for each pixel in the image { for each pixel in the image { for each object in the scene { if (object affects pixel) { if (object affects pixel) { do something do something } } We will do this first } } } } object order image order or or rasterization ray tracing Cornell CS4620 Fall 2020 Steve Marschner • 3
Ray tracing idea • Start with a pixel—what belongs at that pixel? • Set of points that project to a point in the image: a ray Cornell CS4620 Fall 2020 Steve Marschner • 4
Ray tracing idea • Start with a pixel—what belongs at that pixel? • Set of points that project to a point in the image: a ray Cornell CS4620 Fall 2020 Steve Marschner • 4
Ray tracing idea Cornell CS4620 Fall 2020 Steve Marschner • 5
Ray tracing idea Cornell CS4620 Fall 2020 Steve Marschner • 5
Ray tracing idea Cornell CS4620 Fall 2020 Steve Marschner • 5
Ray tracing idea Cornell CS4620 Fall 2020 Steve Marschner • 5
Ray tracing algorithm for each pixel { compute viewing ray intersect ray with scene compute illumination at visible point put result into image } Cornell CS4620 Fall 2020 Steve Marschner • 6
Eye ray generation • inputs: – camera parameters – a point in the image viewing window • outputs: viewpoint – a viewing ray pixel position viewing ray Cornell CS4620 Fall 2020 Steve Marschner • 7
Ray intersection • inputs: – list of objects in the scene – a ray • outputs: – whether ray intersects anything – parameter of first intersection t – information about surface Cornell CS4620 Fall 2020 Steve Marschner • 8
Shading • inputs: – eye direction – light direction (for each of many lights) – surface normal n l – surface parameters v (color, roughness, …) • outputs: – light reflected towards eye Cornell CS4620 Fall 2020 Steve Marschner • 9
Recommend
More recommend