Alex YAU Important Notes Website for Assignment #2 https://course.cse.ust.hk/comp341/S10/Password_Only/projects/project2/index.html You.

Slides:



Advertisements
Similar presentations
GR2 Advanced Computer Graphics AGR
Advertisements

13.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 13 An Introduction to Ray Tracing.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
3D Graphics Rendering and Terrain Modeling
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Light Issues in Computer Graphics Presented by Saleema Amershi.
1. What is Lighting? 2 Example 1. Find the cubic polynomial or that passes through the four points and satisfies 1.As a photon Metal Insulator.
Illumination Model & Surface-rendering Method 박 경 와.
MC930/MO603 Ray Casting. Light is bouncing photons.
CS 376 Introduction to Computer Graphics 04 / 09 / 2007 Instructor: Michael Eckmann.
CSCE 641: Computer Graphics Ray Tracing Jinxiang Chai.
Ray Casting Ray-Surface Intersections Barycentric Coordinates Reflection and Transmission [Shirley, Ch.9] Ray Tracing Handouts Ray Casting Ray-Surface.
Now Playing: Melody Day Caribou from Andorra Released August 21, 2007.
Parallelizing Raytracing Gillian Smith CMPE 220 February 19 th, 2008.
Objectives Learn to shade objects so their images appear three- dimensional Learn to shade objects so their images appear three- dimensional Introduce.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week.
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.
Ray Tracing Jerry Sui Adam Conner. Part I – Introduction to Ray Tracing Final Product.
1 7M836 Animation & Rendering Global illumination, ray tracing Arjan Kok
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
CIS 310: Visual Programming, Spring 2006 Western State College 310: Visual Programming Ray Tracing.
CS 376 Introduction to Computer Graphics 04 / 04 / 2007 Instructor: Michael Eckmann.
Advanced Computer Graphics (Fall 2010) CS 283, Lecture 2: Basic Ray Tracing Ravi Ramamoorthi Some slides courtesy.
Now Playing: Quicksand Under Carpet New Radiant Storm King from Leftover Blues: Released 2004.
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
Presentation by Dr. David Cline Oklahoma State University
CS 445 / 645 Introduction to Computer Graphics Lecture 18 Shading Shading.
Computer graphics & visualization Ray-Tracing – A Quick review.
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.
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.
Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura Institute for Perception, Action.
Ray Tracer Spring 2008 Help Session. Outline Project Web Resources What do you have to do for this project? Ray Class Isect Class Requirements Tricks.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Basic Ray Tracing CMSC 435/634.
CS 445 / 645 Introduction to Computer Graphics Lecture 15 Shading Shading.
CS380: Computer Graphics Distributed Ray Tracing TA Course URL:
Monte-Carlo Ray Tracing and
CS 325 Introduction to Computer Graphics 04 / 12 / 2010 Instructor: Michael Eckmann.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
VLF Rendering & Implementation Details Virtual Light Field Group University College London GR/R13685/01 Research funded by: Jesper.
Local Illumination and Shading
COMPUTER GRAPHICS CS 482 – FALL 2015 SEPTEMBER 29, 2015 RENDERING RASTERIZATION RAY CASTING PROGRAMMABLE SHADERS.
Render methods. Contents Levels of rendering Wireframe Plain shadow Gouraud Phong Comparison Gouraud-Phong.
More on Ray Tracing Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, April 14, 2004.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
RENDERING : Global Illumination
Ray Tracing I. Reading Hill, Chapter 14, Sections 14.1 to 14.5 Hill, Chapter 14, Sections and
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
Review Ray Tracing III Review. Pseudo codes RayCast-1  Plain ray caster (direct illumination) RayCast-2  RayCast-1 + shadow rays RayTrace-1  Recursive.
Introduction to Ray Tracing Dr. B. Raghu Professor /CSE Sri Ramanujar Engineering College.
Basic Ray Tracing CMSC 435/634.
3D Rendering 2016, Fall.
Shading To determine the correct shades of color on the surface of graphical objects.
Photorealistic Rendering vs. Interactive 3D Graphics
Ray Tracing Forward Ray Tracing
3D Graphics Rendering PPT By Ricardo Veguilla.
RAY TRACING.
Lighting – Light Sources
Image.
An Algorithm of Eye-Based Ray Tracing on MATLAB
GR2 Advanced Computer Graphics AGR
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Illumination Model 고려대학교 컴퓨터 그래픽스 연구실.
Ray Tracer Autumn 2005 Help Session.
Presentation transcript:

Alex YAU

Important Notes Website for Assignment #2 You should use C++ and not use OpenGL Due: Monday 12 April, 12 pm (noon) Demo: 12 and 13 April in 4221 Grouping: You can change your group if you wish

Grading Scheme (Total: 100%) Loading scene file (10%) Ray tracing (45%) Scene preparing (5%) Ray-intersection (20%) Shadow casting (5%) Saving output image (10%) Bells and whistles (35%) Posted on the web, please check the details

Outline Overview of Ray Tracing Main Algorithm Loading Scene File How to Define Eye Ray Ray-intersection Lighting Model Saving Output Image Bells and Whistles

Overview of Ray Tracing Load a scene file Ray trace Save output image Input: Scene File Output: Image File

Overview of Ray Tracing Backward ray tracing Efficient Shoot rays from eye to the image plane Capture the scene

Overview of Ray Tracing One level ray tracing Ambient light source Directional light source Shadow casting

Main Algorithm for each pixel in the image create a ray from eye_position to the center of the pixel set nearest_t = infinity set nearest_object = NULL set surface_point = NULL for every objects in the scene if ray intersects this_object and t < nearest_t set nearest_t = t set nearest_object = this_object end if set pixel_color = background color if nearest_object != NULL set surface_point = eye_poistion + t * ray_direction for each light source if this surface_point is not in shadow pixel_color += compute_shading() end if done

Loading Scene File C++ I/O Stream 4 types of data section Viewer Light Sphere Triangle The first line is comment started with # Between each section in the file, there are exactly one blank line as a separator

Loading Scene File # comment line )

Loading Scene File – Viewer 1) VIEWER EYE_POS eye position in 3D VIEW_AT_POS position in 3D viewed by the eye VIEW_UP_VEC view up vector FOVX field of view along x radian) FOVY field of view along y (radian) RESOLUTION resolution of ray traced image

Loading Scene File – Light 2) LIGHT 2 there are two light sources TYPE LS_AMBIENT ambient light source COLOR RGB value [0,1] TYPE LS_DIRECTIONAL directional light source DIR light going from this direction COLOR RGB value [0,1]

Loading Scene File – Sphere 3) SPHERE 3 there are 3 spheres CENTER RADIUS 1.0 KD diffuse component KS specular component N 5.0 shininess...

Loading Scene File – Triangle 4) TRIANGLE 2 there are 2 triangles VERTEX each has three vertices VERTEX VERTEX KD diffuse component KS specular component N 10.0 shininess...

How to Define Eye Ray

Ray-intersection Parametric ray: r(t) = p + t d t ≥ 0 ||d|| = 1, thus t is distance traveled from p in d direction Implicit object: f(x) =0 Intersection occurs when f(r(t)) = 0 Real function of one real variable t So, intersection ≡ root finding

Intersect with Triangle Approach 1: Intersect the ray with the plane containing the triangle Then determine whether or not the intersection point is within the triangle Approach 2: Consider a ray as an origin and a direction vector Define the triangle as a tuple of vertices [v 0, v 1, v 2 ]

Intersect with Triangle Parametric ray: r(t) = p + t d Parametric plane: (x - v 0 ) · (v 1 × v 2 ) = 0 Solve (p + t d - v 0 ) · (v 1 × v 2 ) = 0 Verify x 0 is inside the triangle s 1 × u 1, s 2 × u 2, s 3 × u 3 are pointing at the same direction Hard to implement and inefficient

Intersect with Triangle Barycentric coordinates Any point in a triangle can be defined as P(a, b, c) = c v 0 + a v 1 + b v 2 where, a + b + c = 1 and a, b, c ≥ 0 So, p + t d = (1-a-b) v 0 + a v 1 + b v 2 Solve t, a, b Check 0 ≤ a ≤ 1, 0 ≤ b ≤ 1 and a + b ≤ 1 Easy to implement and efficient

Intersect with Sphere Parametric ray: r(t) = p + t d Parametric sphere: ||x – c|| 2 = r 2 Solve ||p + t d – c|| 2 = r 2 (t d + p – c) · (t d + p – c) – r 2 = 0 Test discriminant Δ to find the number of roots  Test for intersection! Δ = (2 d · (p – c)) 2 – 4 ((d · d)(p – c) · (p – c) – r 2 )

Blinn-Phong Lighting Model

Directional Light Source

L a = intensity of ambient light source Simulate indirect global illumination Does not varies with lighting or viewing direction L i = intensity of the i-th directional light source k d = diffuse material property k s = specular material property

Directional Light Source Diffuse term Simulate reflection occurring on dull surfaces Varies only with lighting direction Specular term: Simulate reflection occurring on smooth surfaces Varies with both lighting and viewing direction

Directional Light Source

Saving Output Image Save output as PPM image View the output using IrfanViewIrfanView Use C++ I/O Stream with binary flag on #include std::ofstream fout; fout.open(“my_image.ppm”,ios::binary); Write binary number to the file stream

PPM File Format P6 Magic number for identification 256 Width, Height 256 Maximum value of a unit... Image as a sequence of R, G, B tuple