43
Illumination models are also called lighting or shading models Virendra Singh Kushwah 1

Illumination Virendra

Embed Size (px)

Citation preview

Page 1: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 1/43

Illumination models are also called

lighting or shading models

Virendra Singh Kushwah 1

Page 2: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 2/43

An illumination model is operating on a pixelbasis, while surface rendering works on asurface in its whole

To get realism (summary):

perspective projection and clipping

hidden surface removal

shading/lighting aspects

color/material aspects

Virendra Singh Kushwah 2

Page 3: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 3/43

Virendra Singh Kushwah 3

Page 4: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 4/43

An illumination model is based on optical

properties of surfaces

Typical optical effects (require one or more

light sources): reflection, (can be of different types)

refraction (if transparent objects)

shadows (can be of different types)

Virendra Singh Kushwah 4

Page 5: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 5/43

Virendra Singh Kushwah 5

Page 6: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 6/43

Various optical surface properties have to be

specified, such as:

reflectivity coefficients

degree of transparency index of refraction

For simplicity, we assume opaque (non-

transparent) surfaces

Virendra Singh Kushwah 6

Page 7: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 7/43

Page 8: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 8/43

Point light source

Distributed light

Virendra Singh Kushwah 8

Page 9: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 9/43

A cone is illustrating the light spread from a

spotlight

Virendra Singh Kushwah 9

Page 10: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 10/43

Illumination is primarily of two kinds:

ambient light (background light) all points on a surface have the same intensity

with only ambient light, no realism (e.g. asphere will look like a circle slice

point source light emphasizes 3D

without ambient light, like a spotlight in a darkroom

a light source in VRP => no shadows

Virendra Singh Kushwah 10

Page 11: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 11/43Virendra Singh Kushwah 11

Page 12: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 12/43

The intensity (I) of reflected ambient light fora point on an object surface:

I = Ib.Rb 

where

Ib=the intensity of the ambient light

Rb=the coefficient of reflectionof ambient light for the surface(a material constant, 0-1)

Virendra Singh Kushwah 12

Page 13: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 13/43

Reflected light from a point source is dividedinto:

a) diffuse reflection (especially when dullsurfaces)

* the reflected color is the color of theobject surface

b) specular reflection (especially whenshiny surfaces)

Virendra Singh Kushwah 13

Page 14: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 14/43

Reflection is uniform

in all directions

Intensity isproportional to cos,

the angle of 

incident light

(Lambert’s cosine

law )

Virendra Singh Kushwah 14

Page 15: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 15/43Virendra Singh Kushwah 15

Page 16: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 16/43

Adjust the intensity formula:

I = Ib.Rb + Id

.Rd.cos  

where

Id=the intensity of the light sourceRd=the coefficient of diffuse reflection forthe surface

Id.Rd

.cos can also be written Id.Rd

.(L.N),

(dot product)

Virendra Singh Kushwah 16

Page 17: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 17/43

The intensity of light is known to decrease

with the factor 1/r2 due to energy laws,

where r is the distance from the light source

From experience, the factor 1/r2

is modified to1/(r+k) or something similar, where k is a

constant to prevent the nominator to

approach zero

Virendra Singh Kushwah 17

Page 18: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 18/43

The decreasing intensity factor is called the

attenuation factor 

Thus, the formula is adjusted to:

I = Ib.Rb + Id.Rd.(L.N)/(r+k)

Virendra Singh Kushwah 18

Page 19: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 19/43

Angle of reflection =

angle of incidence

The intensity dependson the position of 

the VRP (cp. the

vector V)

Virendra Singh Kushwah 19

Page 20: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 20/43

Virendra Singh Kushwah 20

Page 21: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 21/43

Described by Phong Bui Tuong, the formula nowis:

I = Ib.Rb + Id

.Rd.(L.N)/(r+k) + Id

.Rs.cosn/(r+k),

whereRs=the coefficient of specular reflection forthe surface (not really a constant but afunction of the angle, W())

cosn (in vector form (R.V)n) determines howshiny the surface is; typically 1≤n≤10000, 

means from dull (chalk) to very shiny (mirror)

Virendra Singh Kushwah 21

Page 22: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 22/43

The understanding of the different values of 

the parameter n (or ns) in the factor cosn:

Virendra Singh Kushwah 22

Page 23: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 23/43

The factor cosn does not follow any physical law

but is found out to be useful from experience

Rs is always independant of the color of thereflecting surface

If multiple light sources, then by index j, the

formula is extended to:

Virendra Singh Kushwah 23

Page 24: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 24/43

In a color model, three versions of the

formula need to be used; one for each

primary color, i.e. one for red, one for

green and one for blue in the RGB modelFurthermore, both the intensities and the

material constants in the formula have to

be given separately for each primary color

In theory, every point on an object surface

has to be computed!

Virendra Singh Kushwah 24

Page 25: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 25/43

Usually, several simplifications are used:

assume light sources in an infinite distance

=> parallel light rays and L is constant for all

points the attenuation factor is eliminated

V constant, i.e. VRP at an infinite distance

same model for all three primaries

Virendra Singh Kushwah 25

Page 26: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 26/43

An alternative way of 

defining the vectors

in the model

Virendra Singh Kushwah 26

Page 27: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 27/43

When polygons are used to approximate curved

surfaces (e.g. a sphere), we don’t want to

identify any discontinuities at an edge

between two adjacent polygons.

On the other hand, all surfaces are not curved,

so a simple surface rendering technique may

also be fine.

Virendra Singh Kushwah 27

Page 28: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 28/43

1) Flat Surface Rendering - oneintensity/polygon* the selected point is often chosensomewhere in the middle of the polygon

* fast (+)* can give intensity discontinuities (-)* OK if 

- the object is a polyhedron

- light sources far away- VRP far away

Virendra Singh Kushwah 28

Page 29: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 29/43

Virendra Singh Kushwah 29

Page 30: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 30/43

2) Gouraud Surface Rendering - intensityinterpolation

* linear interpolation of intensities overeach polygon

* a kind of scan-filling

* eliminates possible intensitydiscontinuities

* so called Mach bands can appear(subdivide polygons)

Virendra Singh Kushwah 30

Page 31: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 31/43

Virendra Singh Kushwah 31

Page 32: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 32/43

For each polygon:

calculate the average normal vector ineach vertex

use an illumination model to obtain theintensities in the vertices, e.g. Phong

interpolate the intensities linearly overthe surface

First, vertically along the edges Then, horizontally along each scan-line

Virendra Singh Kushwah 32

Page 33: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 33/43

IqI1y2  ys

y2  y1  I2

ys y1y2  y1

IrI4y3  ys

y3  y4  I3

ys  y4

y3  y4

IpIqxr  xp

xr  xq  Ir

xp  xq

xr  xq

Virendra Singh Kushwah 33

Page 34: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 34/43

The normal in vertex

V is calculated as

the average of N1,N2, N3 and N4 

Notice that vertex V

then will have the

same normal andintensity for all four

polygons joining in V

Nv  Nk

Nk

Virendra Singh Kushwah 34

Page 35: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 35/43

Virendra Singh Kushwah 35

Page 36: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 36/43

Page 37: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 37/43

Virendra Singh Kushwah 37

Page 38: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 38/43

Illumination from point light sources

includes generating shadows, i.e. some

objects will shade other objects.

The problem of identifying shaded surfacesdirectly corresponds to the problem of 

identifying hidden surfaces; those

surfaces that are hidden when viewed

from the light source position are exactlythose shaded (from that particular light

source!)

Virendra Singh Kushwah 38

Page 39: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 39/43

In principle, this means that those surfaces

that are invisible from the light source, but

visible from the view point (VRP), are to be

shaded

Virendra Singh Kushwah 39

Page 40: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 40/43

A pixel intensity is determined by following all rays

emitted from a light source (infinitely many!),

adding the intensities of those rays which are passing

through the pixel area on their way to VRP

Virendra Singh Kushwah 40

Page 41: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 41/43

A better idea is to start in a pixel position and

trace the rays backwards, since most rays

from the light source will not pass through

the current pixel.

Then, only those rays which are traced back to

a light source will result in a contribution of 

the intensity

Virendra Singh Kushwah 41

Page 42: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 42/43

A ray intersecting

with a point on

an object surfaceis divided into (in

general):

* a specular

reflected ray* a refracted ray

(if transparency)

Virendra Singh Kushwah 42

Page 43: Illumination Virendra

8/3/2019 Illumination Virendra

http://slidepdf.com/reader/full/illumination-virendra 43/43