CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

49
CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lecture 14 Lighting Lighting

Transcript of CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Page 1: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

CS 445 / 645Introduction to Computer Graphics

Lecture 14Lecture 14

LightingLighting

Lecture 14Lecture 14

LightingLighting

Page 2: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Today we talk about lighting

Typical three-step development processTypical three-step development process

1.1. Understand the real system – how does light work (Physics)Understand the real system – how does light work (Physics)

2.2. Determine what matters to us – what can we sense (Psyc)Determine what matters to us – what can we sense (Psyc)

3.3. Engineer a system that remains true to the portion of reality Engineer a system that remains true to the portion of reality we can appreciatewe can appreciate

Typical three-step development processTypical three-step development process

1.1. Understand the real system – how does light work (Physics)Understand the real system – how does light work (Physics)

2.2. Determine what matters to us – what can we sense (Psyc)Determine what matters to us – what can we sense (Psyc)

3.3. Engineer a system that remains true to the portion of reality Engineer a system that remains true to the portion of reality we can appreciatewe can appreciate

Page 3: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

What can we sense?Review of lecture notes about color

What color do we see the best?What color do we see the best?

• Yellow-green at 550 nmYellow-green at 550 nm

What color do we see the worst?What color do we see the worst?

• Blue at 440 nmBlue at 440 nm

How many fully saturated hues can be distinguished?How many fully saturated hues can be distinguished?

• 128 fully saturated hues128 fully saturated hues

How many saturations can be distinguished for a given hue?How many saturations can be distinguished for a given hue?

• 16 to 23 depending on hue16 to 23 depending on hue

What color do we see the best?What color do we see the best?

• Yellow-green at 550 nmYellow-green at 550 nm

What color do we see the worst?What color do we see the worst?

• Blue at 440 nmBlue at 440 nm

How many fully saturated hues can be distinguished?How many fully saturated hues can be distinguished?

• 128 fully saturated hues128 fully saturated hues

How many saturations can be distinguished for a given hue?How many saturations can be distinguished for a given hue?

• 16 to 23 depending on hue16 to 23 depending on hue

Page 4: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Engineer a SolutionCIE Color Space

International standard for describing a color (1931)International standard for describing a color (1931)

Empirically determined parameterization (X, Y, Z)Empirically determined parameterization (X, Y, Z)

Any pure wavelength Any pure wavelength can be matched perceptually by can be matched perceptually by positive positive combinations combinations of X,Y,Zof X,Y,Z

International standard for describing a color (1931)International standard for describing a color (1931)

Empirically determined parameterization (X, Y, Z)Empirically determined parameterization (X, Y, Z)

Any pure wavelength Any pure wavelength can be matched perceptually by can be matched perceptually by positive positive combinations combinations of X,Y,Zof X,Y,Z

Page 5: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Engineer a SolutionCIE Color Space

The The gamutgamut of all colors perceivable is thus a three- of all colors perceivable is thus a three-dimensional shape in X,Y,Zdimensional shape in X,Y,Z

The The gamutgamut of all colors perceivable is thus a three- of all colors perceivable is thus a three-dimensional shape in X,Y,Zdimensional shape in X,Y,Z

Page 6: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Engineer a SolutionDevices Have Unique Color Gamuts

Since X, Y, and Z are hypothetical light sources, no real Since X, Y, and Z are hypothetical light sources, no real device can produce the entire gamut of perceivable device can produce the entire gamut of perceivable colorcolor

Since X, Y, and Z are hypothetical light sources, no real Since X, Y, and Z are hypothetical light sources, no real device can produce the entire gamut of perceivable device can produce the entire gamut of perceivable colorcolor

Page 7: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Engineer a SolutionRGB Color Space (Color Cube)

Define colors with (r, g, b) amounts of red, green, Define colors with (r, g, b) amounts of red, green, and blueand blue

Define colors with (r, g, b) amounts of red, green, Define colors with (r, g, b) amounts of red, green, and blueand blue

Page 8: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Engineer a SolutionRGB Color Gamuts

The RGB color cube sits within CIE color space The RGB color cube sits within CIE color space something like this:something like this:

The RGB color cube sits within CIE color space The RGB color cube sits within CIE color space something like this:something like this:

Page 9: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Engineer a SolutionRGB Color Space

RGB may be counter intuitiveRGB may be counter intuitive

• Must think about mixing colorsMust think about mixing colors

• Small changes in RGB value may have large or small perceived Small changes in RGB value may have large or small perceived color changescolor changes

RGB may be counter intuitiveRGB may be counter intuitive

• Must think about mixing colorsMust think about mixing colors

• Small changes in RGB value may have large or small perceived Small changes in RGB value may have large or small perceived color changescolor changes

Page 10: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Engineer a SolutionHSV Color Space

A more intuitive color spaceA more intuitive color space

HSV is an alternative:HSV is an alternative:

• HueHue - The color we see (red, green, purple) - The color we see (red, green, purple)

• SaturationSaturation - How far is the color from gray (pink is less - How far is the color from gray (pink is less saturated than red, sky blue is less saturated than royal blue)saturated than red, sky blue is less saturated than royal blue)

• Brightness (Luminance)Brightness (Luminance) - How bright is the color (how bright - How bright is the color (how bright are the lights illuminating the object?)are the lights illuminating the object?)

A more intuitive color spaceA more intuitive color space

HSV is an alternative:HSV is an alternative:

• HueHue - The color we see (red, green, purple) - The color we see (red, green, purple)

• SaturationSaturation - How far is the color from gray (pink is less - How far is the color from gray (pink is less saturated than red, sky blue is less saturated than royal blue)saturated than red, sky blue is less saturated than royal blue)

• Brightness (Luminance)Brightness (Luminance) - How bright is the color (how bright - How bright is the color (how bright are the lights illuminating the object?)are the lights illuminating the object?)

Page 11: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

HSV Color Space

• H = HueH = Hue

• S = SaturationS = Saturation

• V = Value (or brightness)V = Value (or brightness)

• H = HueH = Hue

• S = SaturationS = Saturation

• V = Value (or brightness)V = Value (or brightness)

ValueSaturation

Hue

Page 12: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Solving the Lighting Problem

• We somewhat understand the perception of light (color)We somewhat understand the perception of light (color)

• We engineered a solution to representing and generating We engineered a solution to representing and generating color using computerscolor using computers

• We need to understand the interplay of light and objectsWe need to understand the interplay of light and objects

• We somewhat understand the perception of light (color)We somewhat understand the perception of light (color)

• We engineered a solution to representing and generating We engineered a solution to representing and generating color using computerscolor using computers

• We need to understand the interplay of light and objectsWe need to understand the interplay of light and objects

Page 13: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Optical Illusion

Page 14: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Lighting

Remember, we know how to Remember, we know how to rasterizerasterize

• Given a 3-D triangle and a 3-D viewpoint, we know which Given a 3-D triangle and a 3-D viewpoint, we know which pixels represent the trianglepixels represent the triangle

But what color should those pixels be?But what color should those pixels be?

Remember, we know how to Remember, we know how to rasterizerasterize

• Given a 3-D triangle and a 3-D viewpoint, we know which Given a 3-D triangle and a 3-D viewpoint, we know which pixels represent the trianglepixels represent the triangle

But what color should those pixels be?But what color should those pixels be?

Page 15: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Lighting

If we’re attempting to create a realistic image, we If we’re attempting to create a realistic image, we need to simulate the need to simulate the lightinglighting of the surfaces in of the surfaces in the scenethe scene

• Fundamentally simulation of Fundamentally simulation of physicsphysics and and opticsoptics

• As you’ll see, we use a lot of approximations (a.k.a As you’ll see, we use a lot of approximations (a.k.a perceptually based hacks) to do this simulation fast enoughperceptually based hacks) to do this simulation fast enough

If we’re attempting to create a realistic image, we If we’re attempting to create a realistic image, we need to simulate the need to simulate the lightinglighting of the surfaces in of the surfaces in the scenethe scene

• Fundamentally simulation of Fundamentally simulation of physicsphysics and and opticsoptics

• As you’ll see, we use a lot of approximations (a.k.a As you’ll see, we use a lot of approximations (a.k.a perceptually based hacks) to do this simulation fast enoughperceptually based hacks) to do this simulation fast enough

Page 16: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Definitions

IlluminationIllumination: : the transport of energy from light sources the transport of energy from light sources to surfaces & pointsto surfaces & points

• Note: includes Note: includes directdirect and and indirectindirect illuminationillumination

IlluminationIllumination: : the transport of energy from light sources the transport of energy from light sources to surfaces & pointsto surfaces & points

• Note: includes Note: includes directdirect and and indirectindirect illuminationillumination

Images by Henrik Wann Jensen

Page 17: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Definitions

LightingLighting: : the process of computing the luminous the process of computing the luminous intensity (i.e., outgoing light) at a particular 3-D intensity (i.e., outgoing light) at a particular 3-D point, usually on a surfacepoint, usually on a surface

ShadingShading: : the process of assigning colors to pixelsthe process of assigning colors to pixels(why the distinction?)(why the distinction?)

LightingLighting: : the process of computing the luminous the process of computing the luminous intensity (i.e., outgoing light) at a particular 3-D intensity (i.e., outgoing light) at a particular 3-D point, usually on a surfacepoint, usually on a surface

ShadingShading: : the process of assigning colors to pixelsthe process of assigning colors to pixels(why the distinction?)(why the distinction?)

Page 18: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Definitions

Illumination models fall into two categories:Illumination models fall into two categories:

• EmpiricalEmpirical: simple formulations that approximate observed phenomenon: simple formulations that approximate observed phenomenon

• Physically basedPhysically based: models based on the actual physics of light : models based on the actual physics of light interacting with matterinteracting with matter

We mostly use empirical models in interactive graphics We mostly use empirical models in interactive graphics for simplicityfor simplicity

Increasingly, realistic graphics are using physically Increasingly, realistic graphics are using physically based models based models

Illumination models fall into two categories:Illumination models fall into two categories:

• EmpiricalEmpirical: simple formulations that approximate observed phenomenon: simple formulations that approximate observed phenomenon

• Physically basedPhysically based: models based on the actual physics of light : models based on the actual physics of light interacting with matterinteracting with matter

We mostly use empirical models in interactive graphics We mostly use empirical models in interactive graphics for simplicityfor simplicity

Increasingly, realistic graphics are using physically Increasingly, realistic graphics are using physically based models based models

Page 19: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Components of IlluminationTwo components of illumination: Two components of illumination: light sourceslight sources and and surface surface propertiesproperties

Light sources (or Light sources (or emittersemitters))

• Spectrum of emittance (i.e., color of the light)Spectrum of emittance (i.e., color of the light)

• Geometric attributesGeometric attributes

– PositionPosition

– DirectionDirection

– ShapeShape

• Directional attenuationDirectional attenuation

• PolarizationPolarization

Two components of illumination: Two components of illumination: light sourceslight sources and and surface surface propertiesproperties

Light sources (or Light sources (or emittersemitters))

• Spectrum of emittance (i.e., color of the light)Spectrum of emittance (i.e., color of the light)

• Geometric attributesGeometric attributes

– PositionPosition

– DirectionDirection

– ShapeShape

• Directional attenuationDirectional attenuation

• PolarizationPolarization

Page 20: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Components of Illumination

Surface propertiesSurface properties

• Reflectance spectrum (i.e., color of the surface)Reflectance spectrum (i.e., color of the surface)

• Subsurface reflectanceSubsurface reflectance

• Geometric attributesGeometric attributes

– PositionPosition

– OrientationOrientation

– Micro-structureMicro-structure

Surface propertiesSurface properties

• Reflectance spectrum (i.e., color of the surface)Reflectance spectrum (i.e., color of the surface)

• Subsurface reflectanceSubsurface reflectance

• Geometric attributesGeometric attributes

– PositionPosition

– OrientationOrientation

– Micro-structureMicro-structure

Page 21: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Simplifications for Interactive Graphics

• Only Only directdirect illuminationillumination from emitters to surfaces from emitters to surfaces

• Simplify geometry of emitters to trivial casesSimplify geometry of emitters to trivial cases

• Only Only directdirect illuminationillumination from emitters to surfaces from emitters to surfaces

• Simplify geometry of emitters to trivial casesSimplify geometry of emitters to trivial cases

Page 22: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Ambient Light SourcesObjects not directly lit are typically still visibleObjects not directly lit are typically still visible

• e.g., the ceiling in this room, undersides of deskse.g., the ceiling in this room, undersides of desks

This is the result of This is the result of indirect illuminationindirect illumination from emitters, bouncing from emitters, bouncing off intermediate surfacesoff intermediate surfaces

Too expensive to calculate (in real time), so we use a hack called Too expensive to calculate (in real time), so we use a hack called an an ambient light sourceambient light source

• No spatial or directional characteristics; illuminates all surfaces equallyNo spatial or directional characteristics; illuminates all surfaces equally

• Amount reflected depends on surface propertiesAmount reflected depends on surface properties

Objects not directly lit are typically still visibleObjects not directly lit are typically still visible

• e.g., the ceiling in this room, undersides of deskse.g., the ceiling in this room, undersides of desks

This is the result of This is the result of indirect illuminationindirect illumination from emitters, bouncing from emitters, bouncing off intermediate surfacesoff intermediate surfaces

Too expensive to calculate (in real time), so we use a hack called Too expensive to calculate (in real time), so we use a hack called an an ambient light sourceambient light source

• No spatial or directional characteristics; illuminates all surfaces equallyNo spatial or directional characteristics; illuminates all surfaces equally

• Amount reflected depends on surface propertiesAmount reflected depends on surface properties

Page 23: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Ambient Light Sources

For each sampled wavelength (R, G, B), the For each sampled wavelength (R, G, B), the ambient light reflected from a surface depends onambient light reflected from a surface depends on

• The surface properties,The surface properties, kkambientambient

• The intensity, The intensity, IIambient,ambient, of the ambient light source (constant for of the ambient light source (constant for

all points on all surfaces )all points on all surfaces )

IIreflectedreflected = k = kambient ambient IIambientambient

For each sampled wavelength (R, G, B), the For each sampled wavelength (R, G, B), the ambient light reflected from a surface depends onambient light reflected from a surface depends on

• The surface properties,The surface properties, kkambientambient

• The intensity, The intensity, IIambient,ambient, of the ambient light source (constant for of the ambient light source (constant for

all points on all surfaces )all points on all surfaces )

IIreflectedreflected = k = kambient ambient IIambientambient

Page 24: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Ambient Light Sources

A scene lit only with an ambient light source:A scene lit only with an ambient light source:A scene lit only with an ambient light source:A scene lit only with an ambient light source:

Light PositionNot Important

Viewer PositionNot Important

Surface AngleNot Important

Page 25: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Directional Light Sources

For a For a directional light sourcedirectional light source we make simplifying we make simplifying assumptionsassumptions

• Direction is constant for all surfaces in the sceneDirection is constant for all surfaces in the scene

• All rays of light from the source are parallelAll rays of light from the source are parallel

– As if the source were infinitely far away As if the source were infinitely far away from the surfaces in the scenefrom the surfaces in the scene

– A good approximation to sunlightA good approximation to sunlight

The direction from a surface to the light source is The direction from a surface to the light source is important in lighting the surfaceimportant in lighting the surface

For a For a directional light sourcedirectional light source we make simplifying we make simplifying assumptionsassumptions

• Direction is constant for all surfaces in the sceneDirection is constant for all surfaces in the scene

• All rays of light from the source are parallelAll rays of light from the source are parallel

– As if the source were infinitely far away As if the source were infinitely far away from the surfaces in the scenefrom the surfaces in the scene

– A good approximation to sunlightA good approximation to sunlight

The direction from a surface to the light source is The direction from a surface to the light source is important in lighting the surfaceimportant in lighting the surface

Page 26: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Directional Light Sources

The same scene lit with a directional and an The same scene lit with a directional and an ambient light sourceambient light sourceThe same scene lit with a directional and an The same scene lit with a directional and an ambient light sourceambient light source

Light PositionNot Important

Viewer PositionNot Important

Surface AngleImportant

Page 27: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Point Light Sources

A A point light sourcepoint light source emits light equally in all emits light equally in all directions from a single point directions from a single point

The direction to the light from a point on a surface The direction to the light from a point on a surface thus differs for different points:thus differs for different points:

• So we need to calculate a So we need to calculate a normalized vector to the light normalized vector to the light source for every point we light:source for every point we light:

A A point light sourcepoint light source emits light equally in all emits light equally in all directions from a single point directions from a single point

The direction to the light from a point on a surface The direction to the light from a point on a surface thus differs for different points:thus differs for different points:

• So we need to calculate a So we need to calculate a normalized vector to the light normalized vector to the light source for every point we light:source for every point we light:

p

l

Page 28: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Point Light Sources

Using an ambient and a point light source:Using an ambient and a point light source:Using an ambient and a point light source:Using an ambient and a point light source:

Light PositionImportant

Viewer PositionImportant

Surface AngleImportant

Page 29: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Other Light Sources

SpotlightsSpotlights are point sources whose intensity falls are point sources whose intensity falls off directionally. off directionally.

• Requires color, pointRequires color, pointdirection, falloffdirection, falloffparametersparameters

• Supported by OpenGLSupported by OpenGL

SpotlightsSpotlights are point sources whose intensity falls are point sources whose intensity falls off directionally. off directionally.

• Requires color, pointRequires color, pointdirection, falloffdirection, falloffparametersparameters

• Supported by OpenGLSupported by OpenGL

Page 30: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Other Light Sources

Area light sourcesArea light sources define a 2-D emissive surface define a 2-D emissive surface (usually a disc or polygon)(usually a disc or polygon)

• Good example: fluorescent light panelsGood example: fluorescent light panels

• Capable of generating Capable of generating soft shadowssoft shadows ( (why?why? ))

Area light sourcesArea light sources define a 2-D emissive surface define a 2-D emissive surface (usually a disc or polygon)(usually a disc or polygon)

• Good example: fluorescent light panelsGood example: fluorescent light panels

• Capable of generating Capable of generating soft shadowssoft shadows ( (why?why? ))

Page 31: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Ideal diffuse reflectionIdeal diffuse reflection

• An An ideal diffuse reflectorideal diffuse reflector, at the microscopic level, is a very rough , at the microscopic level, is a very rough surface (real-world example: chalk) surface (real-world example: chalk)

• Because of these microscopic variations, an incoming ray of light is Because of these microscopic variations, an incoming ray of light is equally likely to be reflected in any direction over the hemisphere:equally likely to be reflected in any direction over the hemisphere:

• What does the reflected intensity depend on?What does the reflected intensity depend on?

Ideal diffuse reflectionIdeal diffuse reflection

• An An ideal diffuse reflectorideal diffuse reflector, at the microscopic level, is a very rough , at the microscopic level, is a very rough surface (real-world example: chalk) surface (real-world example: chalk)

• Because of these microscopic variations, an incoming ray of light is Because of these microscopic variations, an incoming ray of light is equally likely to be reflected in any direction over the hemisphere:equally likely to be reflected in any direction over the hemisphere:

• What does the reflected intensity depend on?What does the reflected intensity depend on?

The Physics of Reflection

Page 32: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Lambert’s Cosine Law

Ideal diffuse surfaces reflect according to Ideal diffuse surfaces reflect according to Lambert’s cosine lawLambert’s cosine law::

The energy reflected by a small portion of a surface from a light source in a 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 given direction is proportional to the cosine of the angle between that direction and the surface normaland the surface normal

These are often called These are often called Lambertian surfacesLambertian surfaces

Note that the Note that the reflectedreflected intensity is independent of intensity is independent of the the viewingviewing direction, but does depend on the direction, but does depend on the surface orientation with regard to the light sourcesurface orientation with regard to the light source

Ideal diffuse surfaces reflect according to Ideal diffuse surfaces reflect according to Lambert’s cosine lawLambert’s cosine law::

The energy reflected by a small portion of a surface from a light source in a 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 given direction is proportional to the cosine of the angle between that direction and the surface normaland the surface normal

These are often called These are often called Lambertian surfacesLambertian surfaces

Note that the Note that the reflectedreflected intensity is independent of intensity is independent of the the viewingviewing direction, but does depend on the direction, but does depend on the surface orientation with regard to the light sourcesurface orientation with regard to the light source

Page 33: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Lambert’s Law

Page 34: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Computing Diffuse ReflectionThe angle between the surface normal and the The angle between the surface normal and the incoming light is the incoming light is the angle of incidence:angle of incidence:

IIdiffusediffuse = k = kdd I Ilightlight cos cos

In practice we use vector arithmetic:In practice we use vector arithmetic:

IIdiffusediffuse = k = kdd I Ilightlight ( (n • ln • l))

The angle between the surface normal and the The angle between the surface normal and the incoming light is the incoming light is the angle of incidence:angle of incidence:

IIdiffusediffuse = k = kdd I Ilightlight cos cos

In practice we use vector arithmetic:In practice we use vector arithmetic:

IIdiffusediffuse = k = kdd I Ilightlight ( (n • ln • l))

nl

Page 35: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Diffuse Lighting Examples

We need only consider angles from 0° to 90° We need only consider angles from 0° to 90° ((Why?Why?))

A Lambertian sphere seen at several different A Lambertian sphere seen at several different lighting angles:lighting angles:

We need only consider angles from 0° to 90° We need only consider angles from 0° to 90° ((Why?Why?))

A Lambertian sphere seen at several different A Lambertian sphere seen at several different lighting angles:lighting angles:

Page 36: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Specular Reflection

Shiny surfaces exhibit Shiny surfaces exhibit specular reflectionspecular reflection

• Polished metalPolished metal

• Glossy car finishGlossy car finish

A light shining on a specular surface causes a bright spot A light shining on a specular surface causes a bright spot known as a known as a specular highlightspecular highlight

Where these highlights appear is a function of the viewer’s Where these highlights appear is a function of the viewer’s position, so specular reflectance is view dependentposition, so specular reflectance is view dependent

Shiny surfaces exhibit Shiny surfaces exhibit specular reflectionspecular reflection

• Polished metalPolished metal

• Glossy car finishGlossy car finish

A light shining on a specular surface causes a bright spot A light shining on a specular surface causes a bright spot known as a known as a specular highlightspecular highlight

Where these highlights appear is a function of the viewer’s Where these highlights appear is a function of the viewer’s position, so specular reflectance is view dependentposition, so specular reflectance is view dependent

Page 37: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

The Physics of Reflection

At the microscopic level a specular reflecting At the microscopic level a specular reflecting surface is very smoothsurface is very smooth

Thus rays of light are likely to bounce off the Thus rays of light are likely to bounce off the microgeometry in a mirror-like fashionmicrogeometry in a mirror-like fashion

The smoother the surface, the closer it becomes The smoother the surface, the closer it becomes to a perfect mirrorto a perfect mirror

At the microscopic level a specular reflecting At the microscopic level a specular reflecting surface is very smoothsurface is very smooth

Thus rays of light are likely to bounce off the Thus rays of light are likely to bounce off the microgeometry in a mirror-like fashionmicrogeometry in a mirror-like fashion

The smoother the surface, the closer it becomes The smoother the surface, the closer it becomes to a perfect mirrorto a perfect mirror

Page 38: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

The Optics of Reflection

Reflection follows Reflection follows Snell’s Laws:Snell’s Laws:

• The incoming ray and reflected ray lie in a plane with the The incoming ray and reflected ray lie in a plane with the surface normalsurface normal

• The angle that the reflected ray forms with the surface The angle that the reflected ray forms with the surface normal equals the angle formed by the incoming ray and the normal equals the angle formed by the incoming ray and the surface normal:surface normal:

Reflection follows Reflection follows Snell’s Laws:Snell’s Laws:

• The incoming ray and reflected ray lie in a plane with the The incoming ray and reflected ray lie in a plane with the surface normalsurface normal

• The angle that the reflected ray forms with the surface The angle that the reflected ray forms with the surface normal equals the angle formed by the incoming ray and the normal equals the angle formed by the incoming ray and the surface normal:surface normal:

(l)ight = (r)eflection

Page 39: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Non-Ideal Specular Reflectance

Snell’s law applies to perfect mirror-like surfaces, but aside Snell’s law applies to perfect mirror-like surfaces, but aside from mirrors (and chrome) few surfaces exhibit perfect from mirrors (and chrome) few surfaces exhibit perfect specularityspecularity

How can we capture the “softer” How can we capture the “softer” reflections of surface that are glossy reflections of surface that are glossy rather than mirror-like?rather than mirror-like?

One option: model the microgeometry of the surface and One option: model the microgeometry of the surface and explicitly bounce rays off of itexplicitly bounce rays off of it

Or… Or…

Snell’s law applies to perfect mirror-like surfaces, but aside Snell’s law applies to perfect mirror-like surfaces, but aside from mirrors (and chrome) few surfaces exhibit perfect from mirrors (and chrome) few surfaces exhibit perfect specularityspecularity

How can we capture the “softer” How can we capture the “softer” reflections of surface that are glossy reflections of surface that are glossy rather than mirror-like?rather than mirror-like?

One option: model the microgeometry of the surface and One option: model the microgeometry of the surface and explicitly bounce rays off of itexplicitly bounce rays off of it

Or… Or…

Page 40: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Non-Ideal Specular Reflectance: An Empirical Approximation

In general, we expect most reflected light to travel in In general, we expect most reflected light to travel in direction predicted by Snell’s Lawdirection predicted by Snell’s Law

But because of microscopic surface variations, some But because of microscopic surface variations, some light may be reflected in a direction slightly off the ideal light may be reflected in a direction slightly off the ideal reflected rayreflected ray

As the angle from the ideal reflected ray increases, we As the angle from the ideal reflected ray increases, we expect less light to be reflectedexpect less light to be reflected

In general, we expect most reflected light to travel in In general, we expect most reflected light to travel in direction predicted by Snell’s Lawdirection predicted by Snell’s Law

But because of microscopic surface variations, some But because of microscopic surface variations, some light may be reflected in a direction slightly off the ideal light may be reflected in a direction slightly off the ideal reflected rayreflected ray

As the angle from the ideal reflected ray increases, we As the angle from the ideal reflected ray increases, we expect less light to be reflectedexpect less light to be reflected

Page 41: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Non-Ideal Specular Reflectance: An Empirical Approximation

An illustration of this angular falloff:An illustration of this angular falloff:

How might we model this falloff?How might we model this falloff?

An illustration of this angular falloff:An illustration of this angular falloff:

How might we model this falloff?How might we model this falloff?

Page 42: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Phong Lighting

The most common lighting model in computer graphics The most common lighting model in computer graphics was suggested by Phong:was suggested by Phong:The most common lighting model in computer graphics The most common lighting model in computer graphics was suggested by Phong:was suggested by Phong:

shinynlightsspecular IkI cos

The The nnshinyshiny term is a purelyterm is a purely

empirical constant that empirical constant that varies the rate of falloffvaries the rate of falloff

Though this model has no Though this model has no physical basis, it works physical basis, it works (sort of) in practice(sort of) in practice

v

Page 43: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Phong Lighting: The nshiny Term

This diagram shows how the Phong reflectance term drops This diagram shows how the Phong reflectance term drops off with divergence of the viewing angle from the ideal off with divergence of the viewing angle from the ideal reflected ray:reflected ray:

What does this term control, visually?What does this term control, visually?

This diagram shows how the Phong reflectance term drops This diagram shows how the Phong reflectance term drops off with divergence of the viewing angle from the ideal off with divergence of the viewing angle from the ideal reflected ray:reflected ray:

What does this term control, visually?What does this term control, visually?

Viewing angle – reflected angle

Page 44: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Calculating Phong Lighting

The The coscos term of Phong lighting can be computed using term of Phong lighting can be computed using vector arithmetic:vector arithmetic:

• VV is the unit vector towards the viewer is the unit vector towards the viewer

• RR is the ideal reflectance directionis the ideal reflectance direction

An aside: we can efficiently calculate r?An aside: we can efficiently calculate r?

The The coscos term of Phong lighting can be computed using term of Phong lighting can be computed using vector arithmetic:vector arithmetic:

• VV is the unit vector towards the viewer is the unit vector towards the viewer

• RR is the ideal reflectance directionis the ideal reflectance direction

An aside: we can efficiently calculate r?An aside: we can efficiently calculate r?

shinynlightsspecular rvIkI

lnlnr 2

v

Page 45: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Calculating The R Vector

This is illustrated below:This is illustrated below:This is illustrated below:This is illustrated below:

nlnlr 2

lnlnr 2

Page 46: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Phong Examples

These spheres illustrate the Phong model as These spheres illustrate the Phong model as ll and and nnshinyshiny are varied: are varied:These spheres illustrate the Phong model as These spheres illustrate the Phong model as ll and and nnshinyshiny are varied: are varied:

Page 47: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

The Phong Lighting Model

Let’s combine ambient, diffuse, and specular Let’s combine ambient, diffuse, and specular components:components:

Commonly called Commonly called Phong lightingPhong lighting

• Note: once per lightNote: once per light

• Note: once per color componentNote: once per color component

• Do Do kkaa, , kkdd, and , and kkss vary with color component? vary with color component?

Let’s combine ambient, diffuse, and specular Let’s combine ambient, diffuse, and specular components:components:

Commonly called Commonly called Phong lightingPhong lighting

• Note: once per lightNote: once per light

• Note: once per color componentNote: once per color component

• Do Do kkaa, , kkdd, and , and kkss vary with color component? vary with color component?

lights

i

nisidiambientatotal

shinyrvklnkIIkI#

1

Page 48: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Phong Lighting: Intensity Plots

Page 49: CS 445 / 645 Introduction to Computer Graphics Lecture 14 Lighting Lighting.

Lighting Review

Lighting ModelsLighting Models• Ambient Ambient

– Normals don’t matterNormals don’t matter

• Lambert/Diffuse Lambert/Diffuse

– Angle between surface normal and lightAngle between surface normal and light

• Phong/Specular Phong/Specular

– Surface normal, light, and viewpointSurface normal, light, and viewpoint

Next Class, Shading Models…Next Class, Shading Models…

Lighting ModelsLighting Models• Ambient Ambient

– Normals don’t matterNormals don’t matter

• Lambert/Diffuse Lambert/Diffuse

– Angle between surface normal and lightAngle between surface normal and light

• Phong/Specular Phong/Specular

– Surface normal, light, and viewpointSurface normal, light, and viewpoint

Next Class, Shading Models…Next Class, Shading Models…