5.1 si31_2001 si31 advanced computer graphics agr lecture 5 a simple reflection model

32
5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

Upload: william-crowley

Post on 28-Mar-2015

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.1si31_2001

SI31Advanced Computer

GraphicsAGR

SI31Advanced Computer

GraphicsAGR

Lecture 5A Simple Reflection Model

Page 2: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.2si31_2001

What is a Reflection Model?

What is a Reflection Model?

A reflection modelreflection model (also called lightinglighting or illuminationillumination model) describes the interaction between light and a surface, in terms of:– surface properties– nature of incident light

Computer graphics uses a simplification of accurate physical models– objective is to mimic reality to an

acceptable degree

Page 3: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.3si31_2001

Phong Reflection ModelPhong Reflection Model

The most common reflection model in computer graphics is due to Bui-Tuong Phong - in 1975

Has proved an acceptable compromise between simplicity and accuracy

Largely empirical

Page 4: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.4si31_2001

Diffuse Reflection and Specular Reflection -

Phong Approach

Diffuse Reflection and Specular Reflection -

Phong Approach

microscopic view

whitelight specular reflection (white)

diffuse reflection(yellow)

yellowpigment particles

Some light reflecteddirectly from surface.

Other light passes intomaterial. Particles ofpigment absorb certainwavelengths fromthe incident light, butalso scatter the lightthrough multiple reflections - somelight emerges backthrough surface as diffuse reflection.

Page 5: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.5si31_2001

Ambient ReflectionAmbient Reflection

In addition to diffuse and specular reflection, a scene will also include ambientambient reflection

This is caused by light falling on an object after reflection off other surfaces– eg in a room with a light above a

table, the floor below the table will not be totally black, despite having no direct illumination - this is reflection of ambient light

Page 6: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.6si31_2001

Reflection Model - Ambient Light

Reflection Model - Ambient Light

surface

I ( )= Ka ( )Ia()Ia = Intensity of ambient lightKa = Ambient-reflection coefficientI = Reflected intensity= wavelength of light

hemisphereof ambientlight

P

Page 7: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.7si31_2001

Ambient LightingAmbient Lighting

Page 8: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.8si31_2001

Reflection Model - Diffuse Reflection

Reflection Model - Diffuse Reflection

Light reflected equally in all directions - intensity dependent on angle between light source and surface normal

Lambert’s cosine law: I = I* cos where I* is intensity of light source

P

lightsource

P

lightsource

lightsourceN

L

surface

Page 9: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.9si31_2001

Reflection Model - Diffuse Reflection

Reflection Model - Diffuse Reflection

I = Kd ( cos ) I*

I* = Intensity of light sourceN = Surface normalL = Direction of light sourceKd = Diffuse-reflection

coefficientI = Reflected intensity

lightsourceN

L

surface

Light reflected equallyin all directions, withintensity depending onangle between light andsurface normal:

Page 10: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.10si31_2001

Reflection Model - Diffuse Reflection

Reflection Model - Diffuse Reflection

The angle between two vectors is given by their dot product: cos = L . N (assume L, N are unit length)

The coefficient Kd depends on the wavelength of the incoming light

lightsourceN

L

surface

I ( ) = Kd() ( L . N ) I*()

Page 11: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.11si31_2001

Ambient and DiffuseAmbient and Diffuse

Page 12: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.12si31_2001

Reflection Model - Specular ReflectionReflection Model -

Specular Reflection

In perfect specular reflection, light is onlyreflected along the unique direction symmetricto the incoming light

P

lightsource

N

R

Page 13: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.13si31_2001

Reflection Model - Specular ReflectionReflection Model -

Specular Reflection

P

lightsource

N

R

In practice, light is reflected within a small angle ofthe perfect reflection direction - the intensity of thereflection tails off at the outside of the cone. Thisgives a narrow highlight for shiny surfaces, and abroad highlight for dull surfaces.

Page 14: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.14si31_2001

Reflection Model - Specular ReflectionReflection Model -

Specular Reflection

Thus we want to model intensity, I, as a function of angle between viewer and R, say , like this:

I

with a sharper peak for shinier surfaces, and broader peakfor dull surfaces.

Page 15: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.15si31_2001

Reflection Model - Specular ReflectionReflection Model -

Specular Reflection

Phong realised this effect can be modelled by:

(cos )n

with a sharper peak for larger n

I

n=1

n=10

Page 16: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.16si31_2001

Reflection Model - Specular ReflectionReflection Model -

Specular Reflection

I = Ks( cos )n I*

I* = Intensity of light sourceV = View directionR = Direction of perfect

reflected lightKs = Specular-reflection

coefficientI = Reflected intensity

n varies with materiallarge n : shinysmall n : dull

Intensity depends onangle between eye andreflected light ray:

V

lightsourceN

LR

eye

surface

Page 17: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.17si31_2001

Reflection Model - Specular ReflectionReflection Model -

Specular Reflection

V

lightsourceN

LR

eye

surface

Using cos = R . V (R, V unit vectors), we have:

I () = Ks ( R . V )n I()*

Note: Ks does not depend on the wavelength - hencecolour of highlight is same as source

Note: intensityforms ‘ellipse’ shape

Page 18: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.18si31_2001

Ambient, Diffuse and Specular

Ambient, Diffuse and Specular

Page 19: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.19si31_2001

Reflection Model -Ambient, Diffuse and

Specular

Reflection Model -Ambient, Diffuse and

Specular

lightsource

I() = Ka()Ia() + ( Kd()( L . N ) + Ks( R . V )n ) I*()

N

LR

Veye

surface

Page 20: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.20si31_2001

Example - Ambient Reflection

Example - Ambient Reflection

Page 21: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.21si31_2001

Example - Ambient and Diffuse

Example - Ambient and Diffuse

Page 22: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.22si31_2001

Ambient, Diffuse and Specular

Ambient, Diffuse and Specular

Page 23: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.23si31_2001

Reflection Model - Effect of Distance

Reflection Model - Effect of Distance

lightsource

surface

d

The intensity of light reaching a surface decreases with distance - so we use typically:

I*

K1 + K2*d + K3*d2K1, K2, K3 constant- often K2=1, K3=0

Page 24: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.24si31_2001

Final Reflection ModelFinal Reflection Model

lightsourceN

LR

Veye

surfaced

I() = Ka()Ia() + ( Kd()( L . N ) + Ks( R . V )n ) I*()

K1 + K2*d + K3*d2

This needs to be applied for every light source in the scene

Page 25: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.25si31_2001

Phong illumination model: Ks 0.0 to 1.0, Kd 0.0 to 1.0(Ka = 0.7, n = 10.0)

Ks

Kd

Page 26: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.26si31_2001

Phong Illumination Model: Ks 0.0 to 1.0; n = 10.0 to 810.0(Ka = 0.7, Kd = 1.0)

n

Ks

Page 27: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.27si31_2001

Phong Model in PracticePhong Model in Practice

In practice, some simplifications are made to the model for sake of efficiency

For example, ambient light is sometimes assumed to be a constant

Other simplifications are:– lights at infinity– simple colour model

Page 28: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.28si31_2001

Practicalities - Effect of Distance

Practicalities - Effect of Distance

There are advantages in assuming light source and viewer are at infinity– L and V are then fixed for whole

scene and calculations become simpler

Lights at infinity are called directionaldirectional lights

Lights at a specified position are called positionalpositional, or point point, lights

Page 29: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.29si31_2001

Practicalities - Calculating R

Practicalities - Calculating R

R + L = 2 ( N.L ) NhenceR = 2 ( N.L )N - L In practice,

implementations often compute H = ( L + V ) / 2

and replace (R.V) with (H.N) – these are not the same, but

compensation is made with choice of n (angle between N and H is half angle between R and V - if vectors coplanar)

N

LR

R

L

V

R

HN

Page 30: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.30si31_2001

Practicalities - Calculating R

Practicalities - Calculating R

As noted, if viewer and light source both sufficiently far from surface, then V and L are constant over scene - and so H = (L+V)/2 just needs to be calculated once

H is often called the ‘halfway’ vector

Page 31: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.31si31_2001

Practicalities - Effect of Colour

Practicalities - Effect of Colour

The Phong reflection model gives reflection for each wavelength in visible spectrum

In practice, we assume light to be composed as a mixture of RGB (red, green, blue) components - and reflection model is applied for each component

Coefficients of ambient-reflection (Ka) and diffuse-reflection (Kd) have separate components for RGB

Coefficient of specular-reflection (Ks) is independent of colour

Page 32: 5.1 si31_2001 SI31 Advanced Computer Graphics AGR Lecture 5 A Simple Reflection Model

5.32si31_2001

AcknowledgementsAcknowledgements

Thanks to Alan Watt for the images