CS 445: Introduction to Computer Graphics David Luebke University of Virginia Visibility Calculations and Occlusion Culling.

Slides:



Advertisements
Similar presentations
1 Graphics CSCI 343, Fall 2013 Lecture 18 Lighting and Shading.
Advertisements

Komputer Grafik 2 (AK045206) Realisme dan Pencahayaan 1/34 Pencahayaan (Lighting)
Virtual Realism LIGHTING AND SHADING. Lighting & Shading Approximate physical reality Ray tracing: Follow light rays through a scene Accurate, but expensive.
1 Computer Graphics By : Mohammed abu Lamdy ITGD3107 University of Palestine Supervision: Assistant Professor Dr. Sana’a Wafa Al-Sayegh.
Lighting and Illumination Lighting is the major problem in computer graphics, for either realism or real-time compositions- harder than modeling Consider.
Illumination and Shading
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 New Mexico
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 Lighting/Shading II Week.
IMGD 1001: Illumination by Mark Claypool
Computer Graphics (Fall 2005) COMS 4160, Lecture 16: Illumination and Shading 1
Lighting and Shading Wen-Chieh (Steve) Lin
Computer Graphics (Fall 2008) COMS 4160, Lecture 19: Illumination and Shading 2
1 CSCE 641: Computer Graphics Lighting Jinxiang Chai.
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.
6.1 Vis_04 Data Visualization Lecture 6 - A Rough Guide to Rendering.
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 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,
Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006
CS 480/680 Computer Graphics Shading I Dr. Frederick C Harris, Jr.
Illumination.
Fundamentals of Computer Graphics Part 6 Shading prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared with Angel,E.:
CS 445 / 645: Introductory Computer Graphics
Computer Graphics Lighting.
Polygon Shading. Assigning color to a shape to make graphical scenes look realistic, or artistic, or whatever effect we’re attempting to achieve But first.
CS 445 / 645 Introduction to Computer Graphics Lecture 18 Shading Shading.
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.
CSC418 Computer Graphics n Illumination n Lights n Lightinging models.
CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
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.
Steve Sterley. Real World Lighting Physical objects tend to interact with light in three ways: Absorption (black body) Reflection (mirror) Transmission.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Basic Rendering Pipeline and Shading Spring 2012.
Illumination.
Komputer Grafik 2 (AK045206) Shading 1/17 Realisme : Shading.
Illumination and Shading
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
CS 445 / 645 Introduction to Computer Graphics Lecture 15 Shading Shading.
Lecture Fall 2001 Illumination and Shading in OpenGL Light Sources Empirical Illumination Shading Transforming Normals Tong-Yee Lee.
Local Illumination and Shading
Cornell CS465 Spring 2004 Lecture 4© 2004 Steve Marschner 1 Shading CS 465 Lecture 4.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
OpenGL Shading. 2 Objectives Learn to shade objects so their images appear three-dimensional Introduce the types of light-material interactions Build.
Lighting and Reflection Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 CSCE 441: Computer Graphics Lighting Jinxiang Chai.
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
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)
Computer Graphics: Illumination
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
© University of Wisconsin, CS559 Spring 2004
Chapter 14 Shading Models.
Illumination Models Chapter 14 Section 14.1 to 14.2
14th Lecture – Final Lecture
Computer Graphics Material Colours and Lighting
Computer Graphics (Fall 2003)
Chapter 14 Shading Models.
CS 480/680 Computer Graphics Shading.
Presentation transcript:

CS 445: Introduction to Computer Graphics David Luebke University of Virginia Visibility Calculations and Occlusion Culling

Admin l Guest lecture Thursday –Topic: Color –Color is hard and interesting! l Midterm exam March 15 –Covers all lecture topics (including Thursday’s) –Can find many midterm and final exams from previous classes off my web page

Demo l Videos

No More Visibility l We’ve discussed view-frustum culling, cells & portals –Might touch on more advanced topics (hierarchical z-buffer, occlusion query, etc) in a later lecture –I’ll leave some extra slides on these topics posted if you like this stuff –Take Real-Time Rendering if you like this stuff l Next topic: lighting –Didn’t have time to change slide formatting…

David Luebke 5 10/10/2015 Recap: Rendering Pipeline ● We’ve talked about the rendering pipeline: ■ Geometric transforms: ○ Modeling ○ Viewing ○ Projection ■ Clipping ■ Rasterization ● Net effect: given polygons in 3-D, we can efficiently calculate which pixels they cover on the screen

David Luebke 6 10/10/2015 Lighting ● So…given a 3-D triangle and a 3-D viewpoint, we can set the right pixels ● But what color should those pixels be? ● If we’re attempting to create a realistic image, we need to simulate the lighting of the surfaces in the scene ■ Fundamentally simulation of physics and optics ■ As you’ll see, we use a lot of approximations (a.k.a hacks) to do this simulation fast enough

David Luebke 7 10/10/2015 Definitions ● Illumination: the transport of energy (in particular, the luminous flux of visible light) from light sources to surfaces & points ■ Note: includes direct and indirect illumination ● Lighting: the process of computing the luminous intensity (i.e., outgoing light) at a particular 3-D point, usually on a surface ● Shading: the process of assigning colors to pixels

David Luebke 8 10/10/2015 Definitions ● Illumination models fall into two categories: ■ Empirical: simple formulations that approximate observed phenomenon ■ Physically-based: models based on the actual physics of light interacting with matter ● We mostly use empirical models in interactive graphics for simplicity ● Increasingly, realistic graphics are using physically- based models

David Luebke 9 10/10/2015 Components of Illumination ● Two components of illumination: light sources and surface properties ● Light sources (or emitters) ■ Spectrum of emittance (i.e, color of the light) ■ Geometric attributes ○ Position ○ Direction ○ Shape ■ Directional attenuation

David Luebke 10 10/10/2015 Components of Illumination ● Surface properties ■ Reflectance spectrum (i.e., color of the surface) ■ Geometric attributes ○ Position ○ Orientation ○ Micro-structure ● Common simplifications in interactive graphics ■ Only direct illumination from emitters to surfaces ■ Simplify geometry of emitters to trivial cases

David Luebke 11 10/10/2015 Ambient Light Sources ● Objects not directly lit are typically still visible ■ E.g., the ceiling in this room, undersides of desks ● This is the result of indirect illumination from emitters, bouncing off intermediate surfaces ● Too expensive to calculate (in real time), so we use a hack called an ambient light source ■ No spatial or directional characteristics; illuminates all surfaces equally ■ Amount reflected depends on surface properties

David Luebke 12 10/10/2015 Ambient Light Sources ● For each sampled wavelength, the ambient light reflected from a surface depends on ■ The surface properties ■ The intensity of the ambient light source (constant for all points on all surfaces ) I reflected = k ambient I ambient

David Luebke 13 10/10/2015 Ambient Light Sources ● A scene lit only with an ambient light source:

David Luebke 14 10/10/2015 Directional Light Sources ● For a directional light source we make the simplifying assumption that all rays of light from the source are parallel ■ As if the source is infinitely far away from the surfaces in the scene ■ A good approximation to sunlight ● The direction from a surface to the light source is important in lighting the surface ● With a directional light source, this direction is constant for all surfaces in the scene

David Luebke 15 10/10/2015 Directional Light Sources ● The same scene lit with a directional and an ambient light source (animated gif)animated gif

David Luebke 16 10/10/2015 Point Light Sources ● A point light source emits light equally in all directions from a single point ● The direction to the light from a point on a surface thus differs for different points: ■ So we need to calculate a normalized vector to the light source for every point we light:

David Luebke 17 10/10/2015 Point Light Sources ● Using an ambient and a point light source: ● How can we tell the difference between a point light source and a directional light source on a sphere?

David Luebke 18 10/10/2015 Other Light Sources ● Spotlights are point sources whose intensity falls off directionally. ■ Supported by OpenGL ● Area light sources define a 2-D emissive surface (usually a disc or polygon) ■ Good example: fluorescent light panels ■ Capable of generating soft shadows (why?)

David Luebke 19 10/10/2015 The Physics of Reflection ● Ideal diffuse reflection ■ An ideal diffuse reflector, at the microscopic level, is a very rough surface (real-world example: chalk) ■ Because of these microscopic variations, an incoming ray of light is equally likely to be reflected in any direction over the hemisphere: ■ What does the reflected intensity depend on?

David Luebke 20 10/10/2015 Lambert’s Cosine Law ● Ideal diffuse surfaces reflect according to Lambert’s cosine law: 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 ● These are often called Lambertian surfaces ● Note that the reflected intensity is independent of the viewing direction, but does depend on the surface orientation with regard to the light source

David Luebke 21 10/10/2015 Lambert’s Law

David Luebke 22 10/10/2015 Computing Diffuse Reflection ● The angle between the surface normal and the incoming light is the angle of incidence: I diffuse = k d I light cos  ● In practice we use vector arithmetic: I diffuse = k d I light (n l) nl 

David Luebke 23 10/10/2015 Diffuse Lighting Examples ● We need only consider angles from 0° to 90° (Why?) ● A Lambertian sphere seen at several different lighting angles: ● An animated gifanimated gif

David Luebke 24 10/10/2015 Specular Reflection ● Shiny surfaces exhibit specular reflection ■ Polished metal ■ Glossy car finish ● A light shining on a specular surface causes a bright spot known as a specular highlight ● Where these highlights appear is a function of the viewer’s position, so specular reflectance is view- dependent

David Luebke 25 10/10/2015 The Physics of Reflection ● At the microscopic level a specular reflecting surface is very smooth ● Thus rays of light are likely to bounce off the microgeometry in a mirror-like fashion ● The smoother the surface, the closer it becomes to a perfect mirror ■ Polishing metal example (draw it)

David Luebke 26 10/10/2015 The Optics of Reflection ● Reflection follows Snell’s Laws: ■ The incoming ray and reflected ray lie in a plane with the surface normal ■ The angle that the reflected ray forms with the surface normal equals the angle formed by the incoming ray and the surface normal:  l =  r

David Luebke 27 10/10/2015 Non-Ideal Specular Reflectance ● Snell’s law applies to perfect mirror-like surfaces, but aside from mirrors (and chrome) few surfaces exhibit perfect specularity ● How can we capture the “softer” reflections of surface that are glossy rather than mirror-like? ● One option: model the microgeometry of the surface and explicitly bounce rays off of it ● Or…

David Luebke 28 10/10/2015 Non-Ideal Specular Reflectance: An Empirical Approximation ● In general, we expect most reflected light to travel in direction predicted by Snell’s Law ● But because of microscopic surface variations, some light may be reflected in a direction slightly off the ideal reflected ray ● As the angle from the ideal reflected ray increases, we expect less light to be reflected

David Luebke 29 10/10/2015 Non-Ideal Specular Reflectance: An Empirical Approximation ● An illustration of this angular falloff: ● How might we model this falloff?

David Luebke 30 10/10/2015 Phong Lighting ● The most common lighting model in computer graphics was suggested by Phong: ● The n shiny term is a purely empirical constant that varies the rate of falloff ● Though this model has no physical basis, it works (sort of) in practice

David Luebke 31 10/10/2015 Phong Lighting: The n shiny Term ● This diagram shows how the Phong reflectance term drops off with divergence of the viewing angle from the ideal reflected ray: ● What does this term control, visually?

David Luebke 32 10/10/2015 Calculating Phong Lighting ● The cos term of Phong lighting can be computed using vector arithmetic: ■ V is the unit vector towards the viewer ○ Common simplification: V is constant (implying what?) ■ R is the ideal reflectance direction ● An aside: we can efficiently calculate R

David Luebke 33 10/10/2015 Calculating The R Vector ● This is illustrated below:

David Luebke 34 10/10/2015 Phong Examples ● These spheres illustrate the Phong model as L and n shiny are varied:

David Luebke 35 10/10/2015 The Phong Lighting Model ● Our final empirically-motivated model for the illumination at a surface includes ambient, difuse, and specular components: ● Commonly called Phong lighting ■ Note: once per light ■ Note: once per color component ■ Do k a, k d, and k s vary with color component?

David Luebke 36 10/10/2015 Phong Lighting: Intensity Plots

David Luebke 37 10/10/2015 Phong Lighting: OpenGL Implementation ● The final Phong model as we studied it: ● OpenGL variations: ■ Every light has an ambient component ■ Surfaces can have “emissive” component to simulate glow ○ Added directly to the visible reflected intensity ○ Not actually a light source (does not illuminate other surfaces) ■ Show Nate Robin’s OpenGL Lighting tutors

David Luebke 38 10/10/2015 Applying Illumination ● We now have an illumination model for a point on a surface ● Assuming that our surface is defined as a mesh of polygonal facets, which points should we use? ● Keep in mind: ■ It’s a fairly expensive calculation ■ Several possible answers, each with different implications for the visual quality of the result

David Luebke 39 10/10/2015 Applying Illumination ● With polygonal/triangular models: ■ Each facet has a constant surface normal ■ If the light is directional, the diffuse reflectance is constant across the facet ■ If the eyepoint is infinitely far away (constant V), the specular reflectance of a directional light is constant across the facet

David Luebke 40 10/10/2015 Flat Shading ● The simplest approach, flat shading, calculates illumination at a single point for each polygon: ● If an object really is faceted, is this accurate? ● No: ■ For point sources, the direction to light varies across the facet ■ For specular reflectance, direction to eye varies across the facet

David Luebke 41 10/10/2015 Flat Shading ● We can refine it a bit by evaluating the Phong lighting model at each pixel of each polygon, but the result is still clearly faceted: ● To get smoother-looking surfaces we introduce vertex normals at each vertex ■ Usually different from facet normal ■ Used only for shading (as opposed to what?) ■ Think of as a better approximation of the real surface that the polygons approximate (draw it)

David Luebke 42 10/10/2015 Vertex Normals ● Vertex normals may be ■ Provided with the model ■ Computed from first principles ■ Approximated by averaging the normals of the facets that share the vertex

David Luebke 43 10/10/2015 Gouraud Shading ● This is the most common approach ■ Perform Phong lighting at the vertices ■ Linearly interpolate the resulting colors over faces ■ This is what OpenGL does ● Demo at: ■ ■ Requires a VRML browser or plug-in (common on most browsers today) ● Does this eliminate the facets? ● No: we’re still subsampling the lighting parameters (normal, view vector, light vector)

David Luebke 44 10/10/2015 Phong Shading ● Phong shading is not the same as Phong lighting, though they are sometimes mixed up ■ Phong lighting: the empirical model we’ve been discussing to calculate illumination at a point on a surface ■ Phong shading: linearly interpolating the surface normal across the facet, applying the Phong lighting model at every pixel ○ Same input as Gouraud shading ○ Usually very smooth-looking results: ○ But, considerably more expensive

David Luebke 45 10/10/2015 An Aside: Transforming Normals ● Irritatingly, the matrix for transforming a normal vector is not the same as the matrix for the corresponding transformation on points ■ In other words, don’t just treat normals as points:

David Luebke 46 10/10/2015 Transforming Normals ● Some not-too-complicated affine analysis shows : ■ If A is a matrix for transforming points, then (A T ) -1 is the matrix for transforming normals ● When is this the same matrix? ● What is the homogeneous representation of a vector (as opposed to a point?) ● Can use this to simplify the problem: only upper 3x3 matrix matters, so use only it