Computer Vision

advertisement

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: i received

 n j

 s for n j

 s

0

0 otherwise n j is the surface normal (a unit vector) s is the illumination direction n j

 s is the cos of the angle between n j product) when n j and s (dot and s are unit vectors

Model of received radiation

Assuming one distant light source, the intensity that surface element j receives is: i received

 n j

 s for n j

 s

0

Why the restriction

(n j o s) > 0?

0 otherwise n j is the surface normal (a unit vector) s is the illumination direction n j

 s is the cos of the angle between n j product) when n j and s (dot and s are unit vectors

Dot product

 a and b are two vectors.

It is useful to be able to calculate the angle between a and b.

That’s where the dot product comes in.

The length of a vector:

(unit vectors have a length=1)

Dot product

Calculating the dot product:

Converting the dot product to an angle:

Dot product

Calculating the dot product:

– What is the value of cos 90 degrees?

– What 2 systems are used to represent angles?

 Degrees and …?

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

Calculator?

Back to our model of received radiation

Extending our model

Let’s extend our model to include the viewpoint.

Type of surfaces/surface reflection:

1. Diffuse (AKA Lambertian) – relatively viewpoint independent

2. Specular – very viewpoint dependent

DIFFUSE (LAMBERTIAN)

REFLECTION

Diffuse reflection

AKA Lambertian (after Johann Heinrich

Lambert (August 26, 1728 – September

25, 1777), a Swiss mathematician, physicist, and astronomer.)

Diffuse reflection

 independent of viewpoint, V

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

Diffuse reflection

Albedo

– amount that is diffusely reflected

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

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

Diffuse reflection

Typically for

“rough” surfaces.

i diffuse

Diffuse reflection k j

 i received for n j

 v

0 otherwise where

 j is the particular surface element,

 k j is the surface albedo, n j is the surface normal (a unit vector), and

 v is the viewpoint.

0

Diffuse reflection

SPECULAR REFLECTION

Specular reflection

Mirror-like / smooth / polished surfaces.

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

Surfaces have a “shininess”  associated with them.

– Values of 100 or more for shiny surfaces.

Specular reflection

Defn. specular reflection = mirror-like reflection.

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

Specular reflection

Defn., highlight = bright spot caused by the specular reflection of a light source.

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

Specular reflection i specular where

R

R  V

 

R is the reflected ray, and

2 N

N  

S

S

Specular reflection i specular where

R

R  V

 

R is the reflected ray

2 N

N  

S

S

i specular

Specular reflection

R  V

 

R

2 N

N  

S

S where

R is the reflected ray

V is the viewpoint

N is the surface normal

S is the ray of received illumination

(See http://mathworld.wolfram.com/Reflection.html

for derivation of vector R.)

Specular vs. diffuse

Specular

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

– Viewpoint dependent.

Darkening with distance

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

Mercury receives more light from the sun than the earth.

Complications

Surface models of real objects typically have both specular and diffuse components.

– An apple has both specular and diffuse reflective components.

Complications

There are typically many light sources and many inter-surface reflections (referred to as

ambient

light).

THE PHONG SHADING

MODEL

(FROM WIKIPEDIA)

Phong shading model

Three components:

1. ambient

2. diffuse

3. specular

Phong shading model

Flat vs. Phong Shading

Phong shading model

For each light source (there may be many), m:

– the components i m,s and i m,d

, are the intensities (often as RGB values) of the specular and diffuse components of the light sources, respectively.

Phong shading model

A single i a lighting.

term controls the ambient

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

Phong shading model

For each light source, m,

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

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

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

– V is the direction towards the viewer.

Phong shading model

Then the shade value for each surface point

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

I p

 k a i a

  m

 lights k

 d

L m

 N

 i m , d

 k s

R m

 V

  i m , s

 k a

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

Phong shading model

I p

 k a i a

  m

 lights k

 d

L m

 N

 i m , d

 k s

R m

 V

  i m , s

 k d

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

I p

 k a i a

Phong shading model

  m

 lights k

 d

L m

 N

 i m , d

 k s

R m

 V

  i m , s

 k s

: specular reflection constant, the ratio of reflection of the specular term of incoming light

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

Phong shading model

One last feature of the Phong shading model (for smooth shading):

– Vectors are assigned at each polygonal vertex, and shading is interpolated across the surface of the polygon.

Summary

Shading is complicated!

We can model surfaces of objects as (coplanar) polygonal patches.

– Normal vector is very important.

– Each has its own color, specular, and diffuse

(Lambertian) characteristics.

We can have multiple light sources in a scene.

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

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

Download