Docsity

Raytracing - Computer Graphics - Lecture Slides, Slides of Computer Graphics

Partial preview of the text

Download Raytracing - Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!

Computer Graphics Raytracing (Part I)

Raytracing

n Global illumination-based rendering method n Simulates rays of light, natural lighting effects n Because light path is traced, handles some effects that are tough for openGL: n Shadows n Multiple inter-reflections n Transparency n Refraction n Texture mapping n Newer variations… e.g. photon mapping (caustics, participating media, smoke) n Note: raytracing can be whole semester graduate course n Today: start with high-level description

How Raytracing Works

n OpenGL is object space rendering n start from world objects, rasterize them n Ray tracing is image space method n Start from pixel, what do you see through this pixel? n Looks through each pixel (e.g. 640 x 480) n Determines what eye sees through pixel n Basic idea: n Trace light rays: eye -> pixel (image plane) -> scene n If a ray intersect any scene object in this direction

  • Yes? render pixel using object color
  • No? it uses the background color n Automatically solves hidden surface removal problem

Case A: Ray misses all objects

Case B: Ray hits an object

ß Ray hits object: Check if hit point is in shadow, build secondary ray (shadow ray) towards light sources.

Case B: Ray hits an object

ß If shadow ray hits another object before light source: first intersection point is in shadow of the second object. Otherwise, collect light contributions

Reflected Ray

ß When a ray hits an object, a reflected ray is generated which is tested against all of the objects in the scene.

Reflection: Contribution from the reflected ray

Transparency: Contribution from transmitted ray

Reflected rays can generate other reflected rays that can generate other reflected rays, etc. Case A: Scene with no reflection rays

Reflected Ray: Recursion

Case C: Scene with two layers of reflection

Reflected Ray: Recursion

Ray Tree

n Reflective and/or transmitted rays are continually generated until ray leaves the scene without hitting any object or a preset recursion level has been reached.

Ray-Object Intersections

n Dependent on parametric equations of object n Ray-Sphere Intersections n Ray-Plane Intersections n Ray-Polygon Intersections n Ray-Box Intersections n Ray-Quadric Intersections (cylinders, cones, ellipsoids, paraboloids )

Writing a RayTracer

n The first step is to create the model of the objects

n One should NOT hardcode objects into the program, but instead use an input file.

n This is called retained mode graphics

n We will use SDL

n Ray trace SDL files

n The output image/file will consist of three intensity values (Red, Green, and Blue) for each pixel.