computer vision

42
Computer Vision Computer Vision Chapter 6 Shading Chapter 6 Shading

Upload: sirius

Post on 16-Mar-2016

20 views

Category:

Documents


0 download

DESCRIPTION

Computer Vision. Chapter 6 Shading. Models of received radiation. Model of received radiation. Assuming one distant light source, the intensity that surface element j receives is: n j is the surface normal (a unit vector) s is the illumination direction - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Computer Vision

Computer VisionComputer VisionChapter 6 ShadingChapter 6 Shading

Page 2: Computer Vision

Models of received radiationModels of received radiation

Page 3: Computer Vision

Model of received radiationModel of received radiation Assuming one distant light source, the Assuming one distant light source, the

intensity that surface element j receives is:intensity that surface element j receives is:

nnjj is the surface normal (a unit vector) is the surface normal (a unit vector)s is the illumination directions is the illumination directionnnjj s is the cos of the angle between n s is the cos of the angle between njj and s (dot and s (dot

product) when nproduct) when njj and s are unit vectors and s are unit vectors

otherwise 0

0for

sn

sni

j

jreceived

Page 4: Computer Vision

Model of received radiationModel of received radiation Assuming one distant light source, the Assuming one distant light source, the

intensity that surface element j receives is:intensity that surface element j receives is:

nnjj is the surface normal (a unit vector) is the surface normal (a unit vector)s is the illumination directions is the illumination directionnnjj s is the cos of the angle between n s is the cos of the angle between njj and s (dot and s (dot

product) when nproduct) when njj and s are unit vectors and s are unit vectors

otherwise 0

0for

sn

sni

j

jreceived

Why the restriction (nj o s) > 0?

Page 5: Computer Vision

Dot productDot product a and b are two vectors.a and b are two vectors. It is useful to be able to calculate the angle It is useful to be able to calculate the angle

between a and b.between a and b. That’s where the dot product comes in.That’s where the dot product comes in.

The length of a vector:The length of a vector:(unit vectors have a length=1)(unit vectors have a length=1)

Page 6: Computer Vision

Dot productDot productCalculating the dot product:Calculating the dot product:

Converting the dot product to an Converting the dot product to an angle:angle:

Page 7: Computer Vision

Dot productDot product Calculating the dot product:Calculating the dot product:

– What is the value of cos 90 degrees?What is the value of cos 90 degrees?

– What 2 systems are used to represent What 2 systems are used to represent angles?angles? Degrees and …?Degrees and …?

– What representation is used in Java? C/C++? What representation is used in Java? C/C++? Calculator? Calculator?

Page 8: Computer Vision

Back to our model of Back to our model of received radiationreceived radiation

Page 9: Computer Vision

Extending our modelExtending our model Let’s extend our model to include the Let’s extend our model to include the

viewpoint.viewpoint.

Type of surfaces/surface reflection:Type of surfaces/surface reflection:

1.1.Diffuse (AKA Lambertian) – relatively Diffuse (AKA Lambertian) – relatively viewpoint independentviewpoint independent

2.2.Specular – very viewpoint dependentSpecular – very viewpoint dependent

Page 10: Computer Vision

DIFFUSE (LAMBERTIAN) DIFFUSE (LAMBERTIAN) REFLECTIONREFLECTION

Page 11: Computer Vision

Diffuse reflectionDiffuse reflectionAKA Lambertian (after Johann Heinrich AKA Lambertian (after Johann Heinrich

Lambert (August 26, 1728 – Lambert (August 26, 1728 – September 25, 1777), a Swiss September 25, 1777), a Swiss mathematician, physicist, and mathematician, physicist, and astronomer.)astronomer.)

Page 12: Computer Vision

Diffuse reflectionDiffuse reflection

independentindependent of viewpoint, V of viewpoint, V

– Light reaching a surface element is Light reaching a surface element is reflected evenly in all directions of the reflected evenly in all directions of the hemisphere centered at that surface hemisphere centered at that surface element.element.

Page 13: Computer Vision

Diffuse reflectionDiffuse reflection

AlbedoAlbedo– amount that is diffusely reflectedamount that is diffusely reflected

– Ratio (fraction) of total reflected light to total Ratio (fraction) of total reflected light to total received light (by a surface element).received light (by a surface element).

– Low for dark surfaces (0.04 for charcoal); high Low for dark surfaces (0.04 for charcoal); high for light surfaces (0.9 for fresh snow).for light surfaces (0.9 for fresh snow).

Page 14: Computer Vision

Diffuse Diffuse reflectionreflection

Typically for Typically for “rough” surfaces.“rough” surfaces.

Page 15: Computer Vision

Diffuse reflectionDiffuse reflection

wherewhere j is the particular surface j is the particular surface

element,element, kkjj is the surface albedo, is the surface albedo, nnjj is the surface normal (a unit is the surface normal (a unit

vector), andvector), and v is the viewpoint.v is the viewpoint.

otherwise00for vniki jreceivedjdiffuse

Page 16: Computer Vision

Diffuse reflectionDiffuse reflection

Page 17: Computer Vision

SPECULAR REFLECTIONSPECULAR REFLECTION

Page 18: Computer Vision

Specular reflectionSpecular reflection Mirror-like / smooth / polished surfaces.Mirror-like / smooth / polished surfaces.

Distributes energy in a narrow cone Distributes energy in a narrow cone about the ray of reflection.about the ray of reflection.

Surfaces have a “shininess” Surfaces have a “shininess” associated with them.associated with them.– Values of 100 or more for shiny surfaces.Values of 100 or more for shiny surfaces.

Page 19: Computer Vision
Page 20: Computer Vision

Specular reflectionSpecular reflection Defn. specular reflection = mirror-Defn. specular reflection = mirror-

like reflection.like reflection.

– Wavelength of reflected light is similar Wavelength of reflected light is similar to the source and is to the source and is independentindependent of of surface color.surface color.

Page 21: Computer Vision

Specular reflectionSpecular reflection Defn., highlight = bright spot caused Defn., highlight = bright spot caused

by the specular reflection of a light by the specular reflection of a light source.source.

– Indicates that the object is wavy, Indicates that the object is wavy, metallic, or glassy.metallic, or glassy.

Page 22: Computer Vision
Page 23: Computer Vision

Specular reflectionSpecular reflection

wherewhereR is the reflected ray, andR is the reflected ray, andV is the viewpointV is the viewpoint

Page 24: Computer Vision

Specular reflectionSpecular reflection

wherewhereR is the reflected rayR is the reflected rayV is the viewpointV is the viewpoint

Page 25: Computer Vision

Specular reflectionSpecular reflection

wherewhereR is the reflected rayR is the reflected rayV is the viewpointV is the viewpointN is the surface normalN is the surface normalS is the ray of received illuminationS is the ray of received illumination

(See (See http://mathworld.wolfram.com/Reflection.html for derivation of vector R.) for derivation of vector R.)

SSNNR

VRispecular

2

Page 26: Computer Vision

Specular vs. diffuseSpecular vs. diffuseSpecularSpecular

– Wavelength of reflected light is similar Wavelength of reflected light is similar to the source and is independent of to the source and is independent of surface color.surface color.

– Viewpoint dependent.Viewpoint dependent.

Page 27: Computer Vision

Darkening with distanceDarkening with distance

The intensity of light energy reaching The intensity of light energy reaching a surface decreases with the a surface decreases with the distance of that surface from the distance of that surface from the light source.light source.

Mercury receives more light from the Mercury receives more light from the sun than the earth.sun than the earth.

Page 28: Computer Vision
Page 29: Computer Vision

ComplicationsComplications Surface models of real objects Surface models of real objects

typically have both specular and typically have both specular and diffuse components.diffuse components.– An apple has both specular and diffuse An apple has both specular and diffuse

reflective components.reflective components.

Page 30: Computer Vision

ComplicationsComplications There are typically many light There are typically many light

sources and many inter-surface sources and many inter-surface reflections (referred to as reflections (referred to as ambientambient light).light).

Page 31: Computer Vision

THE PHONG SHADING THE PHONG SHADING MODELMODEL(FROM WIKIPEDIA)(FROM WIKIPEDIA)

Page 32: Computer Vision

Phong shading modelPhong shading modelThree components:Three components:

1.1. ambientambient2.2. diffusediffuse3.3. specularspecular

Page 33: Computer Vision

Phong shading modelPhong shading model

Page 34: Computer Vision

Flat vs. Phong ShadingFlat vs. Phong Shading

Page 35: Computer Vision

Phong shading modelPhong shading model For each light sourceFor each light source (there may be (there may be

many), m:many), m:

– the components ithe components im,sm,s and i and im,dm,d, are the , are the intensities (often as RGB values) of the intensities (often as RGB values) of the specular and diffuse components of the specular and diffuse components of the light sources, respectively.light sources, respectively.

Page 36: Computer Vision

Phong shading modelPhong shading model A single iA single iaa term controls the ambient term controls the ambient

lighting.lighting.

It is sometimes computed as a sum It is sometimes computed as a sum of contributions from the light of contributions from the light sources.sources.

Page 37: Computer Vision

Phong shading modelPhong shading modelFor each light source, m,For each light source, m,

– LLmm is the direction vector from the point on the is the direction vector from the point on the surface toward each light source,surface toward each light source,

– N is the normal at this point of the surface,N is the normal at this point of the surface,

– RRmm is the direction that a perfectly reflected ray of is the direction that a perfectly reflected ray of light (represented as a vector) would take from this light (represented as a vector) would take from this point of the surface, andpoint of the surface, and

– V is the direction towards the viewer.V is the direction towards the viewer.

Page 38: Computer Vision

Phong shading modelPhong shading modelThen the shade value for each surface point Then the shade value for each surface point

IIpp is calculated using this equation, which is calculated using this equation, which is the Phong reflection model:is the Phong reflection model:

kkaa: ambient reflection constant, the ratio of : ambient reflection constant, the ratio of reflection of the ambient term present in reflection of the ambient term present in all points in the scene renderedall points in the scene rendered

lights

,,m

smmsdmmdaap iVRkiNLkikI

Page 39: Computer Vision

Phong shading modelPhong shading model

kkdd: diffuse reflection constant, the ratio : diffuse reflection constant, the ratio of reflection of the diffuse term of of reflection of the diffuse term of incoming light (Lambertian incoming light (Lambertian reflectance)reflectance)

lights

,,m

smmsdmmdaap iVRkiNLkikI

Page 40: Computer Vision

Phong shading modelPhong shading model

kkss: specular reflection constant, the ratio of : specular reflection constant, the ratio of reflection of the specular term of incoming reflection of the specular term of incoming lightlight: is a shininess constant for this material, : is a shininess constant for this material,

which decides how "evenly" light is reflected which decides how "evenly" light is reflected from a shiny spot, and is very large for most from a shiny spot, and is very large for most surfaces, on the order of 50, getting larger the surfaces, on the order of 50, getting larger the more mirror-like they are. more mirror-like they are.

lights

,,m

smmsdmmdaap iVRkiNLkikI

Page 41: Computer Vision

Phong shading modelPhong shading model One last feature of the Phong One last feature of the Phong

shading model (for smooth shading):shading model (for smooth shading):– Vectors are assigned at each polygonal Vectors are assigned at each polygonal

vertex, and shading is interpolated vertex, and shading is interpolated across the surface of the polygon.across the surface of the polygon.

Page 42: Computer Vision

SummarySummary Shading is complicated!Shading is complicated! We can model surfaces of objects as (coplanar) We can model surfaces of objects as (coplanar)

polygonal patches.polygonal patches.– Normal vector is very important.Normal vector is very important.– Each has its own color, specular, and diffuse Each has its own color, specular, and diffuse

(Lambertian) characteristics.(Lambertian) characteristics. We can have multiple light sources in a scene.We can have multiple light sources in a scene.

– Each may have its own: intensity, location, color, and Each may have its own: intensity, location, color, and direction.direction.

The Phong model includes 3 components: The Phong model includes 3 components: specular, diffuse, and ambient.specular, diffuse, and ambient.