Photorealism CS 460/560. Shadows Ray Tracing Texture Mapping Radiosity. Computer Graphics. Binghamton University. EngiNet. Thomas J.

Similar documents
Photorealism. Ray Tracing Texture Mapping Radiosity

Photorealism. Photorealism: Ray Tracing. Ray Tracing

Illumination and Reflection in OpenGL CS 460/560. Computer Graphics. Shadows. Photo-Realism: Ray Tracing. Binghamton University.

CS 488. More Shading and Illumination. Luc RENAMBOT

General Hidden Surface Removal Algorithms. Binghamton University. EngiNet. Thomas J. Watson. School of Engineering and Applied Science CS 460/560

Computer Graphics. Lecture 13. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura

Computer Graphics. Lecture 10. Global Illumination 1: Ray Tracing and Radiosity. Taku Komura 12/03/15

Topic 12: Texture Mapping. Motivation Sources of texture Texture coordinates Bump mapping, mip-mapping & env mapping

Announcements. Written Assignment 2 out (due March 8) Computer Graphics

Topic 11: Texture Mapping 11/13/2017. Texture sources: Solid textures. Texture sources: Synthesized

So far, we have considered only local models of illumination; they only account for incident light coming directly from the light sources.

Today. Anti-aliasing Surface Parametrization Soft Shadows Global Illumination. Exercise 2. Path Tracing Radiosity

Topic 11: Texture Mapping 10/21/2015. Photographs. Solid textures. Procedural

9. Illumination and Shading

Local vs. Global Illumination & Radiosity

Graphics for VEs. Ruth Aylett

Computer Graphics. Illumination Models and Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

surface: reflectance transparency, opacity, translucency orientation illumination: location intensity wavelength point-source, diffuse source

Pipeline Operations. CS 4620 Lecture 10

Computer Graphics. Lecture 14 Bump-mapping, Global Illumination (1)

Reflection and Shading

Chapter 10. Surface-Rendering Methods. Somsak Walairacht, Computer Engineering, KMITL

Computer Graphics Global Illumination

Recollection. Models Pixels. Model transformation Viewport transformation Clipping Rasterization Texturing + Lights & shadows

CS 325 Computer Graphics

Global Illumination. CMPT 361 Introduction to Computer Graphics Torsten Möller. Machiraju/Zhang/Möller

03 RENDERING PART TWO

Virtual Reality for Human Computer Interaction

Homework #2. Shading, Ray Tracing, and Texture Mapping

CS770/870 Spring 2017 Radiosity

Graphics for VEs. Ruth Aylett

CS770/870 Spring 2017 Radiosity

CS5620 Intro to Computer Graphics

Chapter 11 Global Illumination. Part 1 Ray Tracing. Reading: Angel s Interactive Computer Graphics (6 th ed.) Sections 11.1, 11.2, 11.

Photorealism: Ray Tracing

Supplement to Lecture 16

Computer Graphics Global Illumination

I have a meeting with Peter Lee and Bob Cosgrove on Wednesday to discuss the future of the cluster. Computer Graphics

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

Questions??? Announcements Assignment 3 due today

Computer Graphics. Ray Tracing. Based on slides by Dianna Xu, Bryn Mawr College

Lecture 15: Shading-I. CITS3003 Graphics & Animation

Lighting and Shading

Ray Tracing. Foley & Van Dam, Chapters 15 and 16

Ray Tracing Foley & Van Dam, Chapters 15 and 16

Problem Set 4 Part 1 CMSC 427 Distributed: Thursday, November 1, 2007 Due: Tuesday, November 20, 2007

CPSC GLOBAL ILLUMINATION

Global Rendering. Ingela Nyström 1. Effects needed for realism. The Rendering Equation. Local vs global rendering. Light-material interaction

The Rendering Equation & Monte Carlo Ray Tracing

Raytracing CS148 AS3. Due :59pm PDT

Lighting. To do. Course Outline. This Lecture. Continue to work on ray programming assignment Start thinking about final project

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

Today s class. Simple shadows Shading Lighting in OpenGL. Informationsteknologi. Wednesday, November 21, 2007 Computer Graphics - Class 10 1

Illumination Models and Surface-Rendering Methods. Chapter 10

Computer Graphics and Image Processing Ray Tracing I

Ray Tracing. Shandong University

The University of Calgary

The feature set you are required to implement in your ray tracer is as follows (by order from easy to hard):

Topic 9: Lighting & Reflection models 9/10/2016. Spot the differences. Terminology. Two Components of Illumination. Ambient Light Source

Motivation. Sampling and Reconstruction of Visual Appearance. Effects needed for Realism. Ray Tracing. Outline

Illumination & Shading I

Topic 9: Lighting & Reflection models. Lighting & reflection The Phong reflection model diffuse component ambient component specular component

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

CS559 Computer Graphics Fall 2015

Today. Global illumination. Shading. Interactive applications. Rendering pipeline. Computergrafik. Shading Introduction Local shading models

CS3500 Computer Graphics Module: Lighting and Shading

CEng 477 Introduction to Computer Graphics Fall 2007

Illumination Modelling

Ray Tracer Due date: April 27, 2011

Ray Tracing. Brian Curless CSEP 557 Fall 2016

Computer Graphics 1. Chapter 7 (June 17th, 2010, 2-4pm): Shading and rendering. LMU München Medieninformatik Andreas Butz Computergraphik 1 SS2010

CHAPTER 1 Graphics Systems and Models 3

Ray Tracing. Outline. Ray Tracing: History

Computer Graphics I Lecture 11

Deferred Rendering Due: Wednesday November 15 at 10pm

Introduction to Ray-tracing Objectives

Homework #2. Shading, Projections, Texture Mapping, Ray Tracing, and Bezier Curves

Ray Tracing. Kjetil Babington

Ray Casting. Outline. Similar to glulookat derivation. Foundations of Computer Graphics

Photorealistic 3D Rendering for VW in Mobile Devices

COMPLETION OF Z-buffer Graphics Pipeline

Volume Rendering. Computer Animation and Visualisation Lecture 9. Taku Komura. Institute for Perception, Action & Behaviour School of Informatics

Ray Tracing COMP575/COMP770

Lighting and Shading Computer Graphics I Lecture 7. Light Sources Phong Illumination Model Normal Vectors [Angel, Ch

Rendering Part I (Basics & Ray tracing) Lecture 25 December 1, 2015

Reading. 18. Projections and Z-buffers. Required: Watt, Section , 6.3, 6.6 (esp. intro and subsections 1, 4, and 8 10), Further reading:

Previously... contour or image rendering in 2D

Interpolation using scanline algorithm

Ray Tracing. CSCI 420 Computer Graphics Lecture 15. Ray Casting Shadow Rays Reflection and Transmission [Ch ]

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

Topics and things to know about them:

Simple Lighting/Illumination Models

Texture. Texture Mapping. Texture Mapping. CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

Assignment 6: Ray Tracing

CS 475 / CS 675 Computer Graphics. Lecture 11 : Texture

Introduction to Visualization and Computer Graphics

Lecture 11: Ray tracing (cont.)

Raytracing. COSC 4328/5327 Scott A. King

Introduction to Computer Graphics 7. Shading

Transcription:

Binghamton University EngiNet State University of New York EngiNet Thomas J. Watson School of Engineering and Applied Science WARNING All rights reserved. No Part of this video lecture series may be reproduced in any form or by any electronic or mechanical means, including the use of information storage and retrieval systems, without written approval from the copyright owner. 2008 The Research Foundation of the State University of New York CS 460/560 Computer Graphics Professor Richard Eckert May 1, 2008 Photorealism Shadows Ray Tracing Texture Mapping Radiosity 1

Shadows Very important to our perception of depth Shadow position/orientation give information as to how objects relate to each other in space Sharp Shadows from Point Sources Soft Shadows from Extended Sources Shadows from Point Sources Look at shadows from point sources If a point is in shadow, set Phong Ip to 0 Source gets no light from point source So no reflection from point source Still must include ambient term Lots of algorithms One of simplest: Shadow Z-Buffer Shadow Z-Buffer Algorithm A two-stage process 1. Take Light Source as viewpoint & compute depths Store results in shadow Z-buffer Z [x ][y ] Each Z [x ][y ] will contain distance of closest surface to light source 2. Normal Z-Buffer rendering But if (x,y) is closest to viewer (visible), transform to light space coordinates (x,y,z ) If z > Z [x ][y ] point is in shadow Some object is closer to light & will block it So only include ambient term in computation 2

Shadow Z-Buffer Set up shadow Z-Buffer, Z [x ][y ], using coordinate system whose origin is at light source (same code as Z-Buffer, but using different origin) Z-buf [x][y]=infinity for all x,y // regular Z-buffer for each polygon for each pixel x,y calculate z if z < Z-buf [x][y] transform x,y,z to light coord space x,y,z if z > Z [x ][y ] reduce intensity (include only ambient) Z-buf [x][y]=z; FB[x][y]=intensity Photorealism Photorealism-- Taking into Account Global Illumination Light can arrive at surfaces indirectly This light called global illumination To now we ve approximated it with a constant, diffuse ambient term This is wrong Need to take into account all the multiply reflected light in the scene Two different approaches: Ray Tracing -- specularly reflected light Radiosity -- diffusely reflected light Photorealism: Ray Tracing See CS-460/560 Notes at: http://www.cs.binghamton.edu/~reckert/460/raytrace.htm http://www.cs.binghamton.edu/~reckert/460/texture.htm Persistence of Vision Ray Tracer (free): http://povray.org/ Ray Tracing What is seen by viewer depends on: rays of light that arrive at his/her eye So to get correct results: Follow all rays of light from all light sources Each time one hits an object, compute the reflected color/intensity Store results for those that go through projection plane pixels into observer s eye Paint each pixel in the resulting color 3

Forward Ray Tracing Infinite number of rays from each source At each intersection with an object could have an infinite number of reflected rays Completely intractable Would take geological times to compute Backward Ray Tracing Look only at rays observer sees Follow rays backwards from eye point through pixels on screen Eye rays Check if they intersect objects If so, can intersection point see a light source? If so, compute intensity of reflected light If not, point is in the shadow If object has reflectivity/transparency Follow reflected/transmission rays Treat these rays as eye rays So it s a recursive algorithm Recursive Ray Tracing Algorithm depth = 0 for each pixel (x,y) Calculate direction from eyepoint to pixel TraceRay (eyepoint, direction, depth, *color) FrameBuf [x,y] = color TraceRay (start_pt, direction_vector, recur_depth, *color) if (recur_depth > MAXDEPTH) color = Background_color else // Intersect ray with all objects // Find int. point that is closest to start_point // Hidden surface removal is built in if (no intersection) color = Background_color else // Send out shadow rays toward light sources local_color = contribution of illumination model at int. pt. // Calculate direction of reflection ray TraceRay (int_pt, refl_dir., depth+1, *refl_color) // Calculate direction of transmitted ray TraceRay (int_pt., trans_dir., depth+1, *trans_color) color = Combine (local_color, refl_color, trans_color) 4

Combining Color from Reflection Ray Add attenuated reflected color intensity to local color intensity: color = local_color + k * refl_color hererefl_color is I(r,g,b) - color returned by reflection ray local_color is I(r,g,b) - color computed by illumination model at intersection point k is an attenuation factor (<1) Combining Color from Transmission Ray Observer sees a mixture of light reflected off surface and light transmitted through surface So combine colors (interpolate) I(r,g,b) = k *I local (r,g,b) + (1 - k )*I transmitted (r,g,b) k is opacity factor coefficient k =0 => perfectly transparent, k =1 ==> perfectly opaque Ray Tracing Intersection Calculations Parametric Equations for Eye Ray: x = x0 + (x1-x0)*t x = x0 +? x*t y = y0 + (y1-y0)*t y = y0 +? y*t z = z0 + (z1-z0)*t z = z0 +? z*t Equation of a sphere of radius r, centered at (a,b,c) (x-a) 2 + (y-b) 2 + (z-c) 2 = r 2 Substitute ray parametric equations: (x0+? x*t-a) 2 + (y0+?y*t-b) 2 + (z0+? z*t-c) 2 = r 2 Rearrange terms: (? x 2 +? y 2 +? z 2 )t 2 + 2[? x(x0-a)+?y(y0-b)+? z(z0-c)]t +(x0-a) 2 + (y0-b) 2 + (z0-c) 2 - r 2 = 0 This is a quadratic in parameter t Solution(s): value(s) of t where ray intersects sphere Three cases No real roots ==> no intersection point 1 real root ==> ray grazes sphere 2 real roots ==> ray passes thru sphere Select smaller t (closer to source) 5

Sphere Normal Computation To apply illumination model at intersection point P, need surface normal Can show: N = ( (x-a)/r, (y-b)/r, (z-c)/r ) Intersections with other Objects Handled in similar fashion May be difficult to come up with equations for their surfaces Sometimes approximation methods must be used to compute intersections of rays with surfaces A Ray-Traced Image Disadvantages of Ray Tracing Computationally intensive But there are several acceleration techniques Bad for scenes with lots of diffuse reflection But can be combined with other algorithms that handle diffuse reflection well Prone to aliasing One sample per pixel can give ugly artifacts But there are anti-aliasing techniques Persistence of Vision Ray Tracer POVRay free software Lots of capabilities Great for playing around with ray tracing http://povray.org/ An Algorithm Animation of a Ray Tracer Ray Tracing Algorithm Animator in VC++ (with David Goldman) See: http://www.cs.binghamton.edu/~reckert/3daape_paper.htm Ray Tracing Algorithm Animation Java Applet and Paper (with Brian Maltzan) See: http://www.cs.binghamton.edu/~reckert/brian/index.html 6

Pattern/Texture Mapping Adding details or features to surfaces (variations in color or texture) General Texture Mapping Pattern Mapping Technique Modulate surface color calculated by reflection model according to a pattern defined by a texture function ( wrap pattern around surface) 2-D Texture function: T(u,v) Define in a 2-D texture space (u,v) Could be a digitized image Or a procedurally-defined pattern Inverse Pixel Mapping (Screen Scanning) For each pixel on screen (xs,ys) Compute pt (x,y,z) on closest surface projecting to pixel (e.g., ray tracing) Determine color (e.g., apply illumination/reflection model) Compute (u,v) corresponding to (x,y,z) (inverse mapping) Modulate color of ( xs,ys ) according to value of T(u,v) at (u,v) Inverse Mapping a Sphere Lines of longitude: constant u, corresponds to theta Lines of latitude: constant v, corresponds to phi Ex: Inverse Mapping a Polygon Choose axis S (unit vector) along a polygon edge will align with u-axis in texture space Choose a polygon vertex Po(xo,yo,zo) will correspond to origin in texture space Choose a scaling factor k k = max dimension of polygon 0-k in object space --> 0-1 in texture space Want to map point P(x,y,z) on polygon to (u,v) Construct vector V = P - Po V. S = k*u, projection of P onto S So u = V. S/k Choose orthogonal axis T in polygon plane (T=NxS) v=v. T/k 7

There are lots of other Texture Mapping Techniques See Section 10-17 of your text book Radiosity Methods Alternative to ray tracing for handling global illumination Two kinds of illumination at each reflective surface Local: from point sources Global: light reflected from other surfaces in scene (multiple reflections) Ray tracing handles specularly reflected global illumination But not diffusely reflected global illumination Radiosity Approach Compute global illumination All light energy coming off a surface is the sum of: Light emitted by the surface Light from other surfaces reflected off the surface Divide scene into patches that are perfect diffuse reflectors... Reflected light is non-directional and/or emitters Definitions Radiosity (B): Total light energy per unit area leaving a surface patch per unit time--sum of emitted and reflected energy (Brightness) Emission (E): Energy per unit area emitted by the surface itself per unit time (Surfaces having nonzero E are light sources) Reflectivity (? ): Fraction of light reflected from a surface (a number between 0 and 1) Form Factor (Fij): Fraction of light energy leaving patch i which arrives at patch j Function only of geometry of environment Conservation of energy for patch i: Total energy out = Energy emitted + Sum of energy from other patches reflected by patch i: Bi*Ai = Ei*Ai +? i?? Bj*Aj*Fji Bi = Ei +? i?? (Bj*Aj/Ai)*Fji j 8

Principle of Reciprocity for Form Factors Reversing role of emitters and receivers: Fraction of energy emitted by one and received by other would be same as fraction of energy going the other way Fij*Ai = Fji*Aj ==> Fji = (Ai/Aj) Fij So: Bi = Ei +? i?? Bj*Fij Bi -? i?? Bj*Fij = Ei Need to solve this system of equations for the radiosities Bi Gauss-Seidel Solution Computing Form Factors Problem: getting form factors? FF =? (cos? i cos? j?a j ) / (?r 2 ), approximately Hemicube Approximation Hemicube Pixel Computations? F = cos? i *cos? p *?A / (??r 2 ) a. (top)? F =? A / [?*(x 2 + y 2 + 1) 2 ] b. (sides)? F = z*?a / [?*(y 2 + z 2 + 1) 2 ] 9

Hemicube Form Factor Algorithm Compute & stroreall hemicube delta Form Factors:?FF[k] Zero all the Form Factors: Fij For all patches i Place unit hemicube at center of patch i For each cell k on hemicube dist[k] = infinity For each patch j (j!= i) If line from origin through cell k intersects patch j compute distance d to intersection point if d < dist[k] dist[k] = d store j in item_buf[k] For each cell k on hemicube j = item_buf [k] Fij = Fij +?FF[k] Video of Radiosity Form Factor Computation Steps in Applying Radiosity Method Three Simple Radiosity Images After 1 st Gauss- Seidel Iteration No Gouraud Shading Gouraud Shading Radiosity Summary Good for scenes with lots of diffuse reflection Not good for scenes with lots of specular reflection Complementary to Ray Tracing But can be combined with Ray Tracing Very computationally intensive Can take very long times for complex scenes but once patch intensities are computed, scene walkthroughs are fast Gauss-Seidel is very memory intensive There are other approaches Progressive Refinement 10