580 likes | 854 Views
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 eyes
E N D
CS 445 / 645Introduction 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 eyes • Warping an image slides pixels around so that features can be located someplace specific • Warping one face image to align with another before cross dissolve eliminates problem of four eyes
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
Mapping p v u p’ Feature-Based Warping • Beier & Neeley use pairs of lines to specify warp • Given p in dst image, where is p’ in source image? v u’ Source image Destination image u is a fraction Why not the sameunits? v is a length (in pixels)
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,q,f,l) ... • describes the intensity of energy, • leaving a light source, … • arriving at location(x,y,z), ... • from direction (q,f), ... • with wavelength l (x,y,z) Light
Empirical Models • Ideally measure irradiant energy for “all” situations • Too much storage • Difficult in practice l
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 illuminationfrom 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
Ambient Light Sources • For each sampled wavelength (R, G, B), the ambient light reflected from a surface depends on • The surface properties,kambient • The intensity, Iambient,of the ambient light source (constant for all points on all surfaces ) • Ireflected = kambient Iambient
Ambient Light Sources • A scene lit only with an ambient light source: Light PositionNot Important Viewer PositionNot Important Surface AngleNot 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 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 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
Directional Light Sources • The same scene lit with a directional and an ambient light source
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: l p
Other Light Sources • Spotlights are point sources whose intensity falls off directionally. • Requires color, pointdirection, falloffparameters • Supported by OpenGL
Other Light Sources • 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?)
Overview • Direct (Local) Illumination • Emission at light sources • Scattering at surfaces • Global illumination • Shadows • Refractions • Inter-object reflections Direct Illumination
Modeling Surface Reflectance • Rs(q,f,g,y,l) ... • describes the amount of incident energy, • arriving from direction (q,f), ... • leaving in direction (g,y), … • with wavelength l l (q,f) (y,l) Surface
Empirical Models • Ideally measure radiant energy for “all” combinations of incident angles • Too much storage • Difficult in practice l (q,f) (y,l) Surface
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?
Diffuse Reflection • How much light is reflected? • Depends on angle of incident light q Surface
Diffuse Reflection • How much light is reflected? • Depends on angle of incident light dL q dA Surface
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
Computing Diffuse Reflection • The angle between the surface normal and the incoming light is the angle of incidence: • Idiffuse = kd Ilightcos • In practice we use vector arithmetic: • Idiffuse = kd Ilight (n • l) l n
Diffuse Lighting Examples • We need only consider angles from 0° to 90° (Why?) • A Lambertian sphere seen at several different lighting angles:
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
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
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)ight = (r)eflection
Specular Reflection • Reflection is strongest near mirror angle • Examples: mirrors, metals N R q q L
Geometry of Reflection N RN(L) L qL qR qL=qR
Geometry of Reflection N (N.L)N RN(L) L cos(qi)N qL qR qL=qR
Geometry of Reflection 2(N.L)N N RN(L) L qL qR qL=qR
Geometry of Reflection 2(N.L)N L N RN(L) L q qL q qR qL=qR
Geometry of Reflection 2(N.L)N L N RN(L) L qL qR qL=qR
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…
Non-Ideal Specular Reflectance: An Empirical Approximation • Hypothesis:most light reflects according to Snell’s Law • But because of microscopic surface variations, some light may be reflected in a direction slightly off the ideal reflected ray • Hypothesis:as we move from the ideal reflected ray, some light is still reflected
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 was suggested by Phong: v • The nshinyterm is a purelyempirical constant that varies the rate of falloff • Though this model has no physical basis, it works (sort of) in practice
Phong Lighting: The nshinyTerm • 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? Viewing angle – reflected angle
Calculating Phong Lighting • The cos term of Phong lighting can be computed using vector arithmetic: • v is the unit vector towards the viewer • ris the ideal reflectance direction v
Phong Examples • These spheres illustrate the Phong model as l and nshiny are varied:
Combining Everything • Simple analytic model: • diffuse reflection + • specular reflection + • emission + • “ambient” Surface
Surface Combining Everything • Simple analytic model: • diffuse reflection + • specular reflection + • emission + • “ambient”
OpenGL Reflectance Model • Sum diffuse, specular, emission, and ambient