University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Lighting/Shading I Week.

Slides:



Advertisements
Similar presentations
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
Advertisements

1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object.
Light Issues in Computer Graphics Presented by Saleema Amershi.
Torrance Sparrow Model of Reflectance + Oren Nayar Model of Reflectance.
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.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Shading I.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Lighting/Shading III Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections I.
Computer Graphics - Class 10
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading III Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections III.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Interpolation Clipping.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Lighting/Shading I Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Transformations II Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Lighting/Shading II Week.
Rendering (彩現 渲染).
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Lighting/Shading II Week.
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
Global Illumination May 7, Global Effects translucent surface shadow multiple reflection.
7M836 Animation & Rendering
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.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Lighting Week 5, Mon 29 Sep 2003 recap: picking, light sources lighting.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Picking and Lighting Week 4, Fri 26 Sep 2003 recap: viewports and picking.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Shading I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Basic Ray Tracing CMSC 435/634. Visibility Problem Rendering: converting a model to an image Visibility: deciding which objects (or parts) will appear.
Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
CS 445 / 645: Introductory Computer Graphics
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Shading (introduction to rendering). Rendering  We know how to specify the geometry but how is the color calculated.
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
12/05/02(c) 2002 University of Wisconsin Last Time Subdivision techniques for modeling Very brief intro to global illumination.
CS 445: Introduction to Computer Graphics David Luebke University of Virginia Visibility Calculations and Occlusion Culling.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
CS447/ Realistic Rendering -- Radiosity Methods-- Introduction to 2D and 3D 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.
David Luebke 1 10/26/2015 Lighting CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Taku KomuraComputer Graphics Local Illumination and Shading Computer Graphics – Lecture 10 Taku Komura Institute for Perception, Action.
Illumination and Shading
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Basic Ray Tracing CMSC 435/634.
Photo-realistic Rendering and Global Illumination in Computer Graphics Spring 2012 Material Representation K. H. Ko School of Mechatronics Gwangju Institute.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Color II, Lighting/Shading.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner Rasterization.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
Local Illumination and Shading
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Rasterization II Week.
Lighting/Shading University of British Columbia
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Vision/Color II, Rasterization Week 6, Mon Feb 8
CPSC 314 LIGHTING AND SHADING UGRAD.CS.UBC.CA/~CS314 slide credits: Mikhail Bessmeltsev et al 1.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
Computer Graphics Ken-Yi Lee National Taiwan University (the slides are adapted from Bing-Yi Chen and Yung-Yu Chuang)
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
Computer Graphics: Illumination
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Basic Ray Tracing CMSC 435/634.
Rasterization Week 6, Mon Feb 12
CS5500 Computer Graphics May 29, 2006
Presentation transcript:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Lighting/Shading I Week 6, Fri Feb 12

2 Correction: W2V vs. V2W M W2V =TR we derived position of camera in world invert for world with respect to camera M V2W =(M W2V ) -1 = R -1 T -1 slide 38 week3.day3 (Fri Jan 22)

3 Correction: W2V vs. V2W M V2W =(M W2V ) -1 = R -1 T -1

4 Correction: Perspective Derivation z axis flip! slide 30 week4.day3 (Fri Jan 29)

5 News P2 due date extended to Tue Mar 2 5pm V2W correction affects Q1 and thus cascades to Q4-Q7 perspective correction affects Q8 TA office hours in lab for P2/H2 questions Fri 2-4 (Garrett)

PPT Fix: Basic Line Drawing assume, slope one octant, other cases symmetric how can we do this more quickly? goals integer coordinates thinnest line with no gaps

7 Clarification/Correction II: Midpoint we're moving horizontally along x direction (first octant) only two choices: draw at current y value, or move up vertically to y+1? check if midpoint between two possible pixel centers above or below line candidates top pixel: (x+1,y+1) bottom pixel: (x+1, y) midpoint: (x+1, y+.5) check if midpoint above or below line below: pick top pixel above: pick bottom pixel other octants: different tests octant II: y loop, check x left/right above: bottom pixel below: top pixel

8 Review: Triangulating Polygons simple convex polygons trivial to break into triangles pick one vertex, draw lines to all others not immediately adjacent OpenGL supports automatically glBegin(GL_POLYGON)... glEnd() concave or non-simple polygons more effort to break into triangles simple approach may not work OpenGL can support at extra cost gluNewTess(), gluTessCallback(),...

9 P Review: Flood Fill simple algorithm draw edges of polygon use flood-fill to draw interior

10 PPT Fix: Flood Fill draw edges run: drawbacks?

11 Review: Scanline Algorithms scanline: a line of pixels in an image set pixels inside polygon boundary along horizontal lines one pixel apart vertically parity test: draw pixel if edgecount is odd optimization: only loop over axis-aligned bounding box of xmin/xmax, ymin/ymax =0 P

12 Review: Bilinear Interpolation interpolate quantity along L and R edges, as a function of y then interpolate quantity as a function of x y P(x,y) P1P1P1P1 P2P2P2P2 P3P3P3P3 PLPLPLPL PRPRPRPR

13 Review: Barycentric Coordinates non-orthogonal coordinate system based on triangle itself origin: P 1, basis vectors: (P 2 -P 1 ) and (P 3 -P 1 )       P = P 1 +  (P 2 -P 1 )+  (P 3 -P 1 ) P = (1-  P 1 +  P 2 +  P 3 P =  P 1 +  P 2 +  P 3  +  +  = 1  <=    <= 1 (  ) = (0,1,0) (1,0,0) (0,0,1)

14 Using Barycentric Coordinates weighted combination of vertices smooth mixing speedup compute once per triangle demo (  ) = (1,0,0) (0,1,0) (0,0,1) “convex combination of points” for points inside triangle

15 Computing Barycentric Coordinates 2D triangle area half of parallelogram area from cross product A =  P1 +  P2 +  P3  P1 /A  P2 /A  P3 /A (  ) = (1,0,0) (0,1,0) (0,0,1)

16 P2P2P2P2 P3P3P3P3 P1P1P1P1 PLPLPLPL PRPRPRPR P d 2 : d 1 Deriving Barycentric From Bilinear from bilinear interpolation of point P on scanline

17 Deriving Barycentric From Bilineaer similarly b 1 : b 2 P2P2P2P2 P3P3P3P3 P1P1P1P1 PLPLPLPL PRPRPRPR P d 2 : d 1

18 b 1 : b 2 P2P2P2P2 P3P3P3P3 P1P1P1P1 PLPLPLPL PRPRPRPR P d 2 : d 1 c 1 : c 2 Deriving Barycentric From Bilinear combining gives

19 Deriving Barycentric From Bilinear thus P =  P 1 +  P 2 +  P 3 with can verify barycentric properties

20 Lighting I

21 Rendering Pipeline Geometry Database Geometry Database Model/View Transform. Model/View Transform. Lighting Perspective Transform. Perspective Transform. Clipping Scan Conversion Scan Conversion Depth Test Depth Test Texturing Blending Frame- buffer Frame- buffer

22 Projective Rendering Pipeline OCS - object/model coordinate system WCS - world coordinate system VCS - viewing/camera/eye coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device/display/screen coordinate system OCS O2W VCS CCS NDCS DCSmodelingtransformationviewingtransformation projectiontransformation viewporttransformation perspective divide objectworld viewing device normalized device clipping W2VV2C N2D C2N WCS

23 Goal simulate interaction of light and objects fast: fake it! approximate the look, ignore real physics get the physics (more) right BRDFs: Bidirectional Reflection Distribution Functions local model: interaction of each object with light global model: interaction of objects with each other

24 Photorealistic Illumination [electricimage.com] transport of energy from light sources to surfaces & points global includes direct and indirect illumination – more later Henrik Wann Jensen

25 Illumination in the Pipeline local illumination only models light arriving directly from light source no interreflections or shadows can be added through tricks, multiple rendering passes light sources simple shapes materials simple, non-physical reflection models

26 Light Sources types of light sources glLightfv(GL_LIGHT0,GL_POSITION,light[]) directional/parallel lights real-life example: sun infinitely far source: homogeneous coord w=0 point lights same intensity in all directions spot lights limited set of directions: point+direction+cutoff angle

27 Light Sources area lights light sources with a finite area more realistic model of many light sources not available with projective rendering pipeline (i.e., not available with OpenGL)

28 Light Sources ambient lights no identifiable source or direction hack for replacing true global illumination (diffuse interreflection: light bouncing off from other objects)

29 Diffuse Interreflection

30 Ambient Light Sources scene lit only with an ambient light source Light Position Not Important Viewer Position Not Important Surface Angle Not Important

31 Directional Light Sources scene lit with directional and ambient light Light Position Not Important Viewer Position Not Important Surface Angle Important

32 Point Light Sources scene lit with ambient and point light source Light Position Important Viewer Position Important Surface Angle Important

33 Light Sources geometry: positions and directions standard: world coordinate system effect: lights fixed wrt world geometry demo: alternative: camera coordinate system effect: lights attached to camera (car headlights) points and directions undergo normal model/view transformation illumination calculations: camera coords

34 Types of Reflection specular (a.k.a. mirror or regular) reflection causes light to propagate without scattering. diffuse reflection sends light in all directions with equal energy. mixed reflection is a weighted combination of specular and diffuse.

35 Specular Highlights

36 Types of Reflection retro-reflection occurs when incident energy reflects in directions close to the incident direction, for a wide range of incident directions. gloss is the property of a material surface that involves mixed reflection and is responsible for the mirror like appearance of rough surfaces.

37 Reflectance Distribution Model most surfaces exhibit complex reflectances vary with incident and reflected directions. model with combination + + = specular + glossy + diffuse = reflectance distribution

38 Surface Roughness at a microscopic scale, all real surfaces are rough cast shadows on themselves “mask” reflected light: shadow Masked Light

39 Surface Roughness notice another effect of roughness: each “microfacet” is treated as a perfect mirror. incident light reflected in different directions by different facets. end result is mixed reflectance. smoother surfaces are more specular or glossy. random distribution of facet normals results in diffuse reflectance.

40 Physics of Diffuse Reflection ideal diffuse reflection very rough surface at the microscopic level real-world example: chalk microscopic variations mean incoming ray of light equally likely to be reflected in any direction over the hemisphere what does the reflected intensity depend on?

41 Lambert’s Cosine Law ideal diffuse surface reflection the energy reflected by a small portion of a surface from a light source in a given direction is proportional to the cosine of the angle between that direction and the surface normal reflected intensity independent of viewing direction depends on surface orientation wrt light often called Lambertian surfaces

42 Lambert’s Law intuitively: cross-sectional area of the “beam” intersecting an element of surface area is smaller for greater angles with the normal.

43 Computing Diffuse Reflection depends on angle of incidence: angle between surface normal and incoming light I diffuse = k d I light cos  in practice use vector arithmetic I diffuse = k d I light (n l) always normalize vectors used in lighting!!! n, l should be unit vectors scalar (B/W intensity) or 3-tuple or 4-tuple (color) k d : diffuse coefficient, surface color I light : incoming light intensity I diffuse : outgoing light intensity (for diffuse reflection) nl 

44 Diffuse Lighting Examples Lambertian sphere from several lighting angles: need only consider angles from 0° to 90° why? demo: Brown exploratory on reflection ploratories/applets/reflection2D/reflection_2d_java_browser.html