Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.

Slides:



Advertisements
Similar presentations
Exploration of advanced lighting and shading techniques
Advertisements

Projective Texture Mapping
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
3D Graphics Rendering and Terrain Modeling
Part I: Basics of Computer Graphics
Ray Tracing & Radiosity Dr. Amy H. Zhang. Outline  Ray tracing  Radiosity.
 Engineering Graphics & Introductory Design 3D Graphics and Rendering REU Modeling Course – June 13 th 2014.
Light Issues in Computer Graphics Presented by Saleema Amershi.
Christian Lauterbach COMP 770, 2/11/2009
Rasterization and Ray Tracing in Real-Time Applications (Games) Andrew Graff.
CS 325 Introduction to Computer Graphics 04 / 09 / 2010 Instructor: Michael Eckmann.
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Object-Order vs. Screen-Order Rendering April 24, 2003.
CS 376 Introduction to Computer Graphics 04 / 09 / 2007 Instructor: Michael Eckmann.
Computer Graphics (Fall 2005) COMS 4160, Lecture 21: Ray Tracing
RAY TRACING.
(conventional Cartesian reference system)
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 14: Ray Tracing
Ray Tracing Outline For each pixel { Shoot ray r from eye to center of pixel with trace( r ) } function trace( r ) For each object { Find object with closest.
CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Ray Tracing.
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
COMP 175: Computer Graphics March 24, 2015
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
CS 376 Introduction to Computer Graphics 04 / 11 / 2007 Instructor: Michael Eckmann.
Project Raytracing. Content Goals Idea of Raytracing Ray Casting – Therory – Practice Raytracing – Theory – Light model – Practice Output images Conclusion.
Ray Tracing Chapter CAP4730: Computational Structures in Computer Graphics.
University of Texas at Austin CS384G - Computer Graphics Fall 2008 Don Fussell Ray Tracing.
1 Dr. Scott Schaefer Ray Tracing. 2/42 Ray Tracing Provides rendering method with  Refraction/Transparent surfaces  Reflective surfaces  Shadows.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
CS-378: Game Technology Lecture #4: Texture and Other Maps Prof. Okan Arikan University of Texas, Austin V Lecture #4: Texture and Other Maps.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
Gene Au-yeung, Daniel Quach, Jeffrey Su, Albert Wang, Jessica Wang, David Woo.
Computer Graphics 2 Lecture 7: Texture Mapping Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.

Intro. to Advanced Lighting, Basic Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Monday, April.
Recursion and Data Structures in Computer Graphics Ray Tracing 1.
Parallel Ray Tracer Computer Systems Lab Presentation Stuart Maier.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
04/30/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling We are now all done with modeling, the standard hardware pipeline.
Basic Ray Tracing CMSC 435/634.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Computer Graphics Lecture 08 Fasih ur Rehman. Last Class Ray Tracing.
CS380: Computer Graphics Distributed Ray Tracing TA Course URL:
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
CSCE 441: Computer Graphics Ray Tracing
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
RENDERING : Global Illumination
RAYTRACER PART I OF II.  Loosely based on the way we perceive the world around us (visually)  A (near) infinite number of photons are emitted by a light.
CS 325 Introduction to Computer Graphics 04 / 07 / 2010 Instructor: Michael Eckmann.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
CS552: Computer Graphics Lecture 36: Ray Tracing.
Basic Ray Tracing CMSC 435/634.
CSE 167 [Win 17], Lecture 15: Ray Tracing Ravi Ramamoorthi
Photorealistic Rendering vs. Interactive 3D Graphics
3D Graphics Rendering PPT By Ricardo Veguilla.
Mike Merchant Nicholas Hilbert
© University of Wisconsin, CS559 Fall 2004
(c) 2002 University of Wisconsin
Lighting.
CS5500 Computer Graphics May 29, 2006
Presentation transcript:

Ray tracing

New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering

Ray tracing Using ray tracing you can achieve photorealistic effects You can achieve many complex lighting effects, such as shadows, refraction and reflection. It is incredibly hard, if not impossible to achieve these accurate effects with the standard rendering pipeline. While you get a huge advance in visual quality, it comes with the price of very long rendering times.

Camera Rays First you shoot rays from the camera out into the scene. Pixels can be rendered in any order, but in this lab we will go from top to bottom left to right. We loop over the pixels and generate an initial primary ray (eye ray) The ray origin is just the camera’s position The direction is computed by first finding the 4 corners of a virtual image in world space, then interpolating to the correct spot, and finally computing a normalized direction from the camera to the virtual pixel.

Ray Intersection The eye ray is then tested for intersection against every object in the scene. If there is no intersection then we just color that pixel the specified ‘background’ color. If there is a hit, then we want to find out what the closest object hit was. At the intersection, we need to know the position, normal, color, texture coordinates, material etc…about that exact location. If the hit is inside a triangle, then all that information is just interpolated from the vertex data.

Lighting Once we have the key intersection information, we can apply any lighting model we want. This can include procedural shaders, lighting computations, texture lookups, bump mapping etc… Many of the most interesting forms of lighting involve spawning additional rays and tracing them recursively. (Which we will be doing in this lab for shadows) The result of the lighting equation is a color which is used to color the pixel.

Shadows Shadows are really easy to achieve Just trace another ray from a hit point to every light in the scene, if you hit an object before you hit the light, then that light cannot contribute to the color. Shadow rays only need to know if something is hit, where as normal rays need to know position, color, normal, etc. When we spawn new rays off of a surface, it is a good idea to add a bit of an offset to the origin. That is to push it up slightly (0.0001) along the normal of the surface. –This prevents the ray from intersecting with the object it spawned off of.

Reflection Rays Reflections are another awesome and easy to do effect with ray tracing. Instead of calculating the lighting equation at a particular hit point, you just trace a secondary ray, called the reflection ray, and trace it into the scene. Reflection rays, like shadow rays, should also be nudged up a bit.

Reflection Rays If the reflection ray hits a normal material, we compute the illumination and use that as the final color. But if the reflection hits another mirror, then we just recursively generate a new reflection ray and trace it. To prevent the system from getting trapped in an infinite loop, you can set a limit to the depth of the recursion. 10 is a good number…

Intersection Test For this lab, everything has been created by using triangles, so you will only have to write an intersection test for ray-triangle intersections. Once we know a ray hits a triangle at a point q we must verify that q lies inside the 3 edges of the triangle. We do this by calculating the barycentric coordinates. –q’ = q-v0 –e1 = v1 - v0 –e2 = v2- v0 –b1 = (q’ * e2)/(e1 * e2) –b2 = (q’ * e1)/(e1 * e2) –Reject if b1 1

File Overview Camera.[cpp h] : You will do most of the work in these files, including writing the actual RayTrace algorithm, and all the code for producing eye rays. Image.[cpp h] : All the functions for drawing, and setting the screen pixels. You don’t have to write any code here Light.[cpp h] : All the information for the lights. You don’t have to write any code. Model.[cpp h] : You will have to write the triangle and model intersection code here Ray.h : Has the structures for ray’s and intersections defined here Vector.h : All of the vector manipulation stuff. Scene.[cpp h] : The scene is defined in here Raytracer.cpp : this is the main file.

Requirements Complete the ray tracer so that you end up with an image that has shadows and mirror reflections. Similar to this:

Implementation Suggestions MAKE SURE YOU LOOK THROUGH ALL THE FILES AND UNDERSTAND THEM There is a TODO in every function where you need to write code. “grep TODO *” <--- type that in the terminal It helps to have a function like bool inShadow(…) You will probably have to write a function called Trace() !!! The first thing your gonna have to work on is writing the intersection functions and the eyeray generating function. Work on this every day.

Resources There are resources on the webpage. PLEASE download them, there are helpful pictures, and information on eye ray generation.