specular reflection

24
Specular Reflection Lecture 27 Mon, Nov 10, 2003

Upload: alyssa-obrien

Post on 02-Jan-2016

102 views

Category:

Documents


9 download

DESCRIPTION

Specular Reflection. Lecture 27 Mon, Nov 10, 2003. Specular Reflection. The intensity of specular reflected light varies with direction. The maximum intensity is in the “ideal” direction. Angle of reflection = angle of incidence. Specular Reflection. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Specular Reflection

Specular Reflection

Lecture 27Mon, Nov 10, 2003

Page 2: Specular Reflection

Specular Reflection

The intensity of specular reflected light varies with direction.The maximum intensity is in the “ideal” direction. Angle of reflection = angle of

incidence.

Page 3: Specular Reflection

Specular Reflection

Specular reflection creates the appearance of “shininess.”Surfaces with a high specular reflection appear very shiny.Surfaces with a low specular reflection appear matte.

Page 4: Specular Reflection

Example

LampShader.exe

Page 5: Specular Reflection

Blinn and Phong Lighting

OpenGL uses the Blinn lighting model of specular reflection.However, we will first study the Phong lighting model since it seems more natural.

Page 6: Specular Reflection

Phong Lighting

The intensity of the reflection is a function of the angle between the viewer and the ideal direction r of reflection of light from the light source off the surface.

Page 7: Specular Reflection

Phong Lighting

P

s

n

v

LightSource

Eye

Surface

r

IdealDirection

Page 8: Specular Reflection

Phong Lighting

To compute r, note that r + s equals twice the projection of s onto n.

sn

r

r s

Page 9: Specular Reflection

Phong Lighting

The projection of s onto n is(s n)/(n n)n = (s n)n

Therefore,r + s = 2(s n)n

andr = –s + 2(s n)n

Page 10: Specular Reflection

Computing Specular Reflection

According to the Phong lighting model, the specular reflection is proportional to the cosine of the angle between v and r, raised to a power (called “shiny”).This is calculated as

(r v)shiny

Page 11: Specular Reflection

Computing Specular Reflection

Two other factors are Intensity of the incident light.

0 Ls 1.

Specular property of the surface. 0 ms 1.

The formula for specular reflection is

rs = Lsms(r v)shiny

Page 12: Specular Reflection

Computing Specular Reflection

Of course, if s n < 0 or if r v < 0, then rs = 0.

Why?

Page 13: Specular Reflection

Blinn Lighting

A slightly more efficient method is the Blinn lighting model.Let h be the halfway vector, the unit vector halfway between s and v.Use h n instead of r v.

rs = Lsms(h n)shiny

Page 14: Specular Reflection

Blinn Lighting

P

s

n

v

LightSource

Eye

Surface

h

Halfway

Page 15: Specular Reflection

Blinn Lighting

How does h n compare to s v? If s, n, and v are coplanar, then the

angle between h and n is half of the angle between s and v.

Why is Blinn lighting more efficient? h is computed as h = (s + v)/|s + v|. This is more efficient to compute than r.

Page 16: Specular Reflection

Emissive Lighting

Emissive lighting is light that emitted by the surface itself.It is used for objects that are meant to glow.It is independent of all light sources and directions.Let me be the intensity of the emissive light.

Page 17: Specular Reflection

Computing the Shade of a Surface

The total reflection from a point is the sum of the ambient, diffuse, and specular reflections and the emissive light.

sama + Lama + Ldmd(s n) + Lsms(h n)shiny + me

Page 18: Specular Reflection

Lighting in OpenGL

Since the diffuse and specular reflections depend on light sources, there is a separate contribution for each light source.OpenGL provides up to 8 light sources.Furthermore, there is a separate color component for each type of light. Red, green, blue.

Page 19: Specular Reflection

The Lighting Model

The complete formula for n lights is

I = (sarmar + sagmag + sabmab)

+ 0…n(Larmar + Lagmag + Lagmag)

+ 0…n(Ldrmdr + Ldgmdg + Ldbmdb)(s n)

+ 0…n(Lsrmsr + Lsgmsg + Lsbmsb)(h n)shiny

+ (mer + meg + meb).

Page 20: Specular Reflection

The Lighting Model

For each color, the computed value is “clamped” to the interval [0, 1]. If the value exceeds 1, then it is set to

1.

Page 21: Specular Reflection

Gouraud Shading vs. Phong Shading

Gouraud shading computes the specular reflection only at the vertices and then interpolates.This guarantees that the brightest reflection will be at a vertex (or along an edge).

Page 22: Specular Reflection

Gouraud Shading vs. Phong Shading

Phong shading interpolates (and normalizes) the normal vectors and then uses them to compute the specular reflection at each vertex.Phong shading is much more realistic. much less efficient.

Page 23: Specular Reflection

Gouraud Shading vs. Phong Shading

dimreflection

dimreflection

diminterpolated

reflection

Gouraud shading.

Page 24: Specular Reflection

Gouraud Shading vs. Phong Shading

brightreflection

Phong shading.

interpolated vectors

dimreflection

dimreflection