lecture15

lecture15 - CS 445 645 Introduction to Computer Graphics...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 445 / 645 Introduction to Computer Graphics Lecture 15 Lighting Beier & Neely Morphing Key point: • Cross dissolve by itself fails when features are not aligned – Intermediate blend of two faces may appear to have four Intermediate eyes eyes • Warping an image slides pixels around so that features can Warping be located someplace specific be – Warping one face image to align with another before cross Warping dissolve eliminates problem of four eyes dissolve Beier & Neely Example Image0 Warp0 Result Image1 Warp1 Beier & Neeley Example Image0 Warp0 Result Image1 Warp1 Image Morphing The warping step is the hard one • Aim to align features in images H&B Figure 16.9 Feature-Based Warping Beier & Neeley use pairs of lines to specify warp • Given p in dst image, where is p’ in source image? Mapping u’ p v v p’ Source image Why not the same Why not the same units? units? u Destination image u is a fraction v is a length (in pixels) Unique element of paper Illumination How do we compute radiance for a sample ray? Angel Figure 6.2 Goal Must derive computer models for ... • Emission at light sources • Scattering at surfaces • Reception at the camera Desirable features … • Concise • Efficient to compute • “Accurate” Overview Direct (Local) Illumination • Emission at light sources • Scattering at surfaces Global illumination • Shadows • Refractions • Inter-object reflections Direct Illumination Modeling Light Sources IL(x,y,z,θ,φ ,λ ) ... ... • describes the intensity of energy, describes • leaving a light source, … (x,y,z) • arriving at location(x,y,z), ... • from direction (θ,φ), ... • with wavelength λ with Light Empirical Models Ideally measure irradiant energy for “all” Ideally situations situations • Too much storage • Difficult in practice λ 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 This indirect off intermediate surfaces off Too expensive to calculate (in real time), so we use a hack called Too an ambient light source ambient • No spatial or directional characteristics; illuminates all surfaces equally • Amount reflected depends on surface properties Ambient Light Sources For each sampled wavelength (R, G, B), the For ambient light reflected from a surface depends on ambient • The surface properties, kambient • The intensity, Iambient, of the ambient light source (constant for The all points on all surfaces ) all Ireflected = kambient Iambient ambient Ambient Light Sources A scene lit only with an ambient light source: Light Position Not Important Viewer Position Not Important Surface Angle Not Important Ambient Term Represents reflection of all indirect illumination This is a total hack (avoids complexity of global illumination)! Directional Light Sources For a directional light source we make simplifying For directional assumptions assumptions • Direction is constant for all surfaces in the scene • All rays of light from the source are parallel – As if the source were infinitely far away As from the surfaces in the scene from – A good approximation to sunlight The direction from a surface to the light source is The important in lighting the surface important Directional Light Sources The same scene lit with a directional and an The ambient light source ambient Point Light Sources A point light source emits light equally in all point directions from a single point The direction to the light from a point on a surface thus differs for different points: thus l • So we need to calculate a So normalized vector to the light source for every point we light: source p Other Light Sources Spotlights are point sources whose intensity falls off directionally. • Requires color, point direction, falloff parameters • Supported by OpenGL Other Light Sources Area light sources define a 2-D emissive surface (usually a disc or polygon) (usually • Good example: fluorescent light panels • Capable of generating soft shadows (why? ) Capable soft Overview Direct (Local) Illumination • Emission at light sources • Scattering at surfaces Global illumination • Shadows • Refractions • Inter-object reflections Direct Illumination Modeling Surface Reflectance Rs(θ,φ ,γ ,ψ,λ ) ... ... • describes the amount of incident energy, describes λ • arriving from direction (θ,φ), ... • leaving in direction (γ ,ψ), … (θ,φ) • with wavelength λ with (ψ,λ) Surface Empirical Models Ideally measure radiant energy for “all” Ideally combinations of incident angles • Too much storage λ • Difficult in practice (θ,φ) (ψ,λ) Surface The Physics of Reflection Ideal diffuse reflection Ideal • An ideal diffuse reflector, at the microscopic level, is a very rough An ideal at surface (real-world example: chalk) • Because of these microscopic variations, an incoming ray of light Because is equally likely to be reflected in any direction over the hemisphere: hemisphere: • What does the reflected intensity depend on? Diffuse Reflection How much light is reflected? • Depends on angle of incident light θ Surface Diffuse Reflection How much light is reflected? • Depends on angle of incident light dL = dA cos Θ θ dA Surface dL Lambert’s Cosine Law Ideal diffuse surfaces reflect according to Ideal Lambert’s cosine law: Lambert’s The energy reflected by a small portion of a surface from a light source in a The given direction is proportional to the cosine of the angle between that direction and the surface normal and These are often called Lambertian surfaces These Lambertian Note that the reflected intensity is independent of Note reflected the viewing direction, but does depend on the viewing surface orientation with regard to the light source surface Lambert’s Law Computing Diffuse Reflection The angle between the surface normal and the The incoming light is the angle of incidence: angle l n θ Idiffuse = kd Ilight cos θ In practice we use vector arithmetic: Idiffuse = kd Ilight (n • l) Diffuse Lighting Examples We need only consider angles from 0° to 90° We (Why?) A Lambertian sphere seen at several different Lambertian lighting angles: lighting Specular Reflection Shiny surfaces exhibit specular reflection Shiny specular • Polished metal • Glossy car finish A light shining on a specular surface causes a bright spot light known as a specular highlight specular Where these highlights appear is a function of the viewer’s Where position, so specular reflectance is view dependent position, The Physics of Reflection At the microscopic level a specular reflecting At surface is very smooth surface Thus rays of light are likely to bounce off the Thus microgeometry in a mirror-like fashion microgeometry The smoother the surface, the closer it becomes The to a perfect mirror to The Optics of Reflection Reflection follows Snell’s Laws: Reflection Snell’s • The incoming ray and reflected ray lie in a plane with the The surface normal surface • The angle that the reflected ray forms with the surface The normal equals the angle formed by the incoming ray and the surface normal: surface θ(l)ight = θ(r)eflection Specular Reflection Reflection is strongest near mirror angle • Examples: mirrors, metals N R θ θ L Geometry of Reflection N RN(L) L θL θR θL=θR Geometry of Reflection N L (N.L)N cos(θi)N θL θR θL=θR RN(L) Geometry of Reflection 2(N.L)N N RN(L) L θL θR θL=θR Geometry of Reflection 2(N.L)N L N RN(L) L θL θR θL=θR Geometry of Reflection RN L L 2(N.L)N L R N RN(L) L θL θR θL=θR N ¢L N N ¢L N ¡ L Non-Ideal Specular Reflectance Snell’s law applies to perfect mirror-like surfaces, but aside Snell’s from mirrors (and chrome) few surfaces exhibit perfect specularity specularity How can we capture the “softer” How reflections of surface that are glossy rather than mirror-like? rather One option: model the microgeometry of the surface and One explicitly bounce rays off of it explicitly Or… Or… Non-Ideal Specular Reflectance: An Empirical Approximation Hypothesis: most light reflects according to Snell’s Law Snell’s • But because of microscopic surface variations, some light But may be reflected in a direction slightly off the ideal reflected ray ray Hypothesis: as we move from the ideal reflected ray, some light is still reflected ray, Non-Ideal Specular Reflectance: An Empirical Approximation An illustration of this angular falloff: How might we model this falloff? Phong Lighting The most common lighting model in computer graphics The was suggested by Phong: was Ispecular = ksIlight ( cos φ ) nshiny The nshiny term is a purely The term empirical constant that empirical varies the rate of falloff varies Though this model has no Though physical basis, it works (sort of) in practice (sort v Phong Lighting: The nshiny Term This diagram shows how the Phong reflectance term This drops off with divergence of the viewing angle from the ideal reflected ray: ideal Viewing angle – reflected angle What does this term control, visually? Calculating Phong Lighting The cos term of Phong lighting can be computed The cos using vector arithmetic: using Ispecular = ksIlight ( v ⋅ r ) • v is the unit vector towards the viewer • r is the ideal reflectance direction is nshiny v Phong Examples These spheres illustrate the Phong model as l and These nshiny are varied: Combining Everything Simple analytic model: Simple • diffuse reflection + • specular reflection + • emission + • “ambient” Surface Combining Everything Simple analytic model: Simple • diffuse reflection + • specular reflection + • emission + • “ambient” Surface OpenGL Reflectance Model Sum diffuse, specular, emission, and ambient The Final Combined Equation Single light source: N Viewer R α θ θ L V I = I E + K A I AL + K D ( N • L) I L + K S (V • R ) n I L Final Combined Equation Multiple light sources: N Viewer L1 L2 V I = I E + K A I AL + ∑i ( K D ( N • Li ) I i + K S (V • Ri ) n I i ) Overview Direct (Local) Illumination • Emission at light sources • Scattering at surfaces Global illumination • Shadows • Refractions • Inter-object reflections Direct Illumination Global Illumination We’ve glossed over how light really works And we will continue to do so… One step better Global Illumination • The notion that a point is illuminated by more than light from local The lights; it is illuminated by all the emitters and reflectors in the global scene global The ‘Rendering Equation’ Jim Kajiya (Current head of Microsoft Research) developed this in Jim 1986 1986 I ( x, x') = g ( x, x ') ε ( x, x') + ∫ ρ( x, x' , x' ') I ( x' , x' ') dx ' ' S I(x, x’) = total intensity from point x’ to x total g(x, x’) = 0 when x/x’ are occluded when = 1/d2 otherwise (d = distance between x and x’) ε (x, x’) = intensity emitted by x’ to x intensity ρ (x, x’,x’’) = intensity of light reflected from x’’ to x through x’ intensity S = all points on all surfaces all The ‘Rendering Equation’ The light that hits x from x’ is the direct The illumination from x’ and all the light reflected by x’ from all x’’ x’ To implement: • Must handle recursion effectively • Must support diffuse and specular light • Must model object shadowing ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online