Advanced computer graphics - Lighting

  • View
    182

  • Download
    3

  • Category

    Science

Preview:

Citation preview

February 5, 2015 1 comp_dep_educ@yahoo.com

February 5, 2015 2

“In trying to improve the quality of the synthetic images, we do

not expect to be able to display the object exactly as it would

appear in reality, with texture, overcast shadows, etc. We

hope only to display an image that approximates the real

object closely enough to provide a certain degree of realism.”

Bui Tuong Phong, 1975

comp_dep_educ@yahoo.com

February 5, 2015 3

Objects are made visible by light. Our visual perception of an object is

determined by the form and quality of the illumination. Lighting defines or

influences color, texture, brightness, contrast, and even the mood of a scene.

Lighting

Light source - There are different types of sources of light, such as point sources

(e.g., a small light at a distance), extended sources (e.g., the sky on a cloudy

day), and secondary reflection (e.g., light that bounces from one surface to

another).

comp_dep_educ@yahoo.com

February 5, 2015 comp_dep_educ@yahoo.com 4

Light Transport

February 5, 2015 comp_dep_educ@yahoo.com 5

What are the patterns of light in this room?

Projector as light source

Light transmitted through windows

Blue light reflecting from screen

Blackboard is matte surface

Edge of screen is shiny surface

Shadows underneath the desks

February 5, 2015 6

If we don’t have lighting effects nothing looks three dimensional,to a great degree

the realism of a three-dimensional object is determined by its lighting.

Some solid objects are virtually impossible to represent without lighting effects.

Figure below shows the enhanced realism that results from lighting effects on a

solid object.

Light

comp_dep_educ@yahoo.com

February 5, 2015 7

Light itself is an electromagnetic wave. Electromagnetic waves are similar to

sound waves in that they contain different frequencies, but are electromagnetic

and can propagate in vacuum. EM waves are thus a signal that's made out of

one or more frequencies, for example the EM waves used by a microwave oven

are very high frequency, while radio waves are very low frequency.

Monochromatic light is light made up of one single pure frequency (this is

certainly not the general case, most light you see is multichromatic).

comp_dep_educ@yahoo.com

Light

February 5, 2015 8

modeled as

electromagnetic waves, radiation

photons

geometric rays

photons

particles

characterized by wavelength (perceived as color in the visible spectrum)

carry energy (inversely proportional to the wavelength)

travel along a straight line at the speed of light

comp_dep_educ@yahoo.com

Light

February 5, 2015 9

The Eye and Color Perception

light falls on the retina, and on the retina are 2 types of cells with photosensitive

chemicals, photoreceptors: rods and cones.

The rods only detect whether or not light is present.

To detect color, you'd need photoreceptors that are sensitive to only a certain

frequency. That's exactly what the cones do:

There are 3 types of cones, those that are sensitive to red, those sensitive to

green, and those sensitive to blue.

comp_dep_educ@yahoo.com

February 5, 2015 comp_dep_educ@yahoo.com 10

Eye

February 5, 2015 11

there are 8 (2^3) main colors one can distinguish:

No cones excited: Black

Red cones excited, but not the Blue and Green ones: Red

Green cones excited, but not the Blue and Red ones: Green

Blue cones excited, but not the Red and Green ones: Blue

Red and Green cones excited, but no the Blue ones: Yellow

Blue and Green cones excited, but no the Red ones: Cyan

Red and Blue cones excited, but no the Green ones: Magenta

All three the cone types excited: White

comp_dep_educ@yahoo.com

Colors

February 5, 2015 12

Radiometric Units

• Light is a form of energy … measured in Joules (J)

• Power: energy per unit time … measured in Joules/sec = Watts (W)

Also called Radiant Flux (Φ)

comp_dep_educ@yahoo.com

February 5, 2015 13

In computer graphics, we traditionally take a simplified view of how light

propagates through space. Photons travel along straight paths until they hit a

surface boundary and are then reflected according to a reflection function of

some sort. A single photon will carry a certain amount of energy, which is

represented by its wavelength.

The relationship between its wavelength λ and the amount of energy it

carries (ΔE) is given by

λ ΔE = 1239.9,

where ΔE is measured in electron volts (eV).

comp_dep_educ@yahoo.com

Radiometric Units

February 5, 2015 14

Radiometric Quantities

radiant energy Q

photons have some radiant energy

radiant flux , radiant power P

rate of flow of radiant energy per unit time:

e. g., overall energy of photons emitted by a source per time

flux density (irradiance, radiant existence)

radiant flux per unit area:

rate at which radiation is incident on, or exiting a flat surface area dA

describes strength of radiation with respect to a surface area

no directional information

comp_dep_educ@yahoo.com

February 5, 2015 15

Radiometric Quantities Irradiance

irradiance measures the overall radiant flux (light flow, photons per unit time)

into a surface element Radiometric

comp_dep_educ@yahoo.com

February 5, 2015 16

Radiometric Quantities Radiant Intensity

radiant intensity

radiant flux per unit solid angle:

radiant flux (light flow, photons per unit time) incident on, emerging

from, or passing through a point in a certain direction

comp_dep_educ@yahoo.com

February 5, 2015 17

Solid Angle

2D angle in 3D space, that an object subtends at a point.

measured in dimensionless unit called steradian (sr).

A steradian is the solid angle subtended at the center of a sphere of radius r

by a portion of the sphere surface with area A=r * r.

It is a measure of how large the object appears to an observer looking from

that point

comp_dep_educ@yahoo.com

February 5, 2015 18

Visible Spectrum

photons are characterized by a wavelength within the visible spectrum

from 390 nm to 750 nm.

light consists of a set of photons

the distribution of wavelengths within this set is referred to as the

spectrum of light.

spectra are perceived as colors.

if the spectrum consists of a dominant wavelength, humans perceive a "rainbow"

color (monochromatic)

if all wavelengths are equally distributed, humans perceive a shade of gray,

ranging from black to white (achromatic).

otherwise, colors "mixed from rainbow colors" are perceived (chromatic)

comp_dep_educ@yahoo.com

February 5, 2015 comp_dep_educ@yahoo.com 19

The Electromagnetic Spectrum

February 5, 2015 comp_dep_educ@yahoo.com 20

The Electromagnetic Spectrum

February 5, 2015 comp_dep_educ@yahoo.com 21

Relationship between frequency ( ) and wavelength ( )

where c is the speed of light

c

Frequency and Wavelength

February 5, 2015 22

Type of light energy Object condition

all the incident light energy is

absorbed

invisible

nearly all the incident light energy

is absorbed

appears black

only a small fraction is absorbed appears white

the incident light energy is nearly

equally reduced for all w.l.

appears gray

the incident light energy is

selectively reduced for all w.l.

appears colored

The amount of energy absorbed, transmitted or reflected depends on the

wavelength (w.l.) of the light

comp_dep_educ@yahoo.com

Frequency and Wavelength

February 5, 2015 23 comp_dep_educ@yahoo.com

Image Acquisition

February 5, 2015 comp_dep_educ@yahoo.com 24

Sampling

f

t

A sampled function

February 5, 2015 comp_dep_educ@yahoo.com 25

Quantization

f

t

3

2

1

0

Quantization

February 5, 2015 comp_dep_educ@yahoo.com 26

February 5, 2015 27

There are a variety of simple light types, but the most basic ones are directional

and point lights.

Directional Light

When light is coming from a distant source (like the sun), the light rays are parallel

and assumed to be of uniform intensity distributed over a large area.

Point Lights

For closer light sources, such as light bulbs, we can’t simply use a direction.

A simple way to model a local light source is as a point light that radiates light in

all directions equally.

Light Types

comp_dep_educ@yahoo.com

February 5, 2015 28

There are two types of illumination — direct and indirect, The illumination that

an object receives from a light-emitting source is direct. The illumination received

from a light-reflecting source is indirect. Figure below shows a polished sphere

illuminated by direct and indirect lighting, and by a combination of both.

comp_dep_educ@yahoo.com

Types of Illumination

February 5, 2015 comp_dep_educ@yahoo.com 29

Global illumination algorithms Both

kinds of sources are considered

Local illumination algorithms Only

direct lights are taken into account

According to how they handle these sources, algorithms can be grouped into:

Local and Global illumination

February 5, 2015 30

Local illumination refers to direct interaction between one light source and

one object surface.

Global illumination refers to the interaction of light between all surfaces in a

scene.

Responsible for shading

Reflection between surfaces

Refraction of surfaces

comp_dep_educ@yahoo.com

Local and Global illumination

February 5, 2015 comp_dep_educ@yahoo.com 31

Scattering

February 5, 2015 comp_dep_educ@yahoo.com 32

Interaction of Light and Matter

February 5, 2015 33

RGB Color Space

three primaries: red, green, blue

comp_dep_educ@yahoo.com

February 5, 2015 34

Operation

Formula

Effect

Negative

255-C

Returns the opposite color, for example white becomes black,

red becomes cyan, ...

Darken

C/p or C-p

Divide the color though some constant (larger than 1), or

subtract a constant from it, to make it darker.

Brighten

C*p or C+p

Multiply the color by some constant (larger than 1), or add a

constant to it, to make it brighter.

Greyscale

(R+G+B)/3

Calculate the average of the 3 channels to get a gray color with

the same brightness.

Remove Channel

R=0, G=0 and/or B=0

By setting one or more channels to 0, you completely remove

that color component from the picture.

Swap Channels

R=G, G=R, ...

Swap the values of two color channels to get an image with a

completely different color.

RGB Arithmetic

comp_dep_educ@yahoo.com

February 5, 2015 35

Two models are usually mentioned in the context of lighting: the illumination

model and the reflection model. The illumination model refers to the nature

of light and its intensity distribution. The reflection model describes the

interaction of light within a surface. Both are important in developing light-

rendering algorithms.

A- Illumination Model

The simplest illumination model is one in which each polygon that forms the

object is displayed in a single shade of its own color. The result is a flat

monochromatic rendering in the circular disk on the left-side of Figure, is an

example of rendering without lighting effects.

comp_dep_educ@yahoo.com

Light models

February 5, 2015 comp_dep_educ@yahoo.com 36

B- Reflection Model

Most of the lighting effects result from reflection. Ambient illumination is

light that has been scattered to such a degree that it is no longer

possible to determine its direction. the case in the right-hand sphere

in Figure below. Ambient light and matte surfaces produce diffuse

reflection. Point sources and polished surfaces produce specular

reflection.

Light models

February 5, 2015 37

Lighting vs. Shading

Commonly misused terms.

What’s the difference?

Lighting designates the interaction between materials and light sources.

Shading is the process of determining the color of a pixel (i.e. Computer Graphics).

Usually determined by lighting.

Could use other methods: random color, NPR, etc.

comp_dep_educ@yahoo.com

February 5, 2015 38

Illumination Models

comp_dep_educ@yahoo.com

February 5, 2015 comp_dep_educ@yahoo.com 39

Reflected Lights

February 5, 2015 40

The character of the light reflected or transmitted... depends on:

• The surface orientation

• Composition of the light source

• Geometry of the light source

• The surface properties of the object

• Direction of the light source

comp_dep_educ@yahoo.com

Reflected Lights

February 5, 2015 41

1- ambient light 2- point sources 3- spotlights 4- distant light

1-Ambient Light

A surface that is not exposed to direct light may still be lit up by reflections

from other nearby objects.

A much simpler way to model all of the background reflected light is to

assume that it is just some constant color shining from every direction

equally ,This is referred to as ambient

2- Point Sources

intensity depends on the distance from the light source

Light Sources

comp_dep_educ@yahoo.com

Light is spreading steadily and with equal

intensity in all directions

It is emitting light in all directions equally. You have

to define a position and some attenuation

parameters which will affect the intensity of light

depending on the distance to the lit object.

February 5, 2015 42

3- Spotlight

To turn a point light source into a spotlight we simply add a vector

direction and an angular limit

comp_dep_educ@yahoo.com

The spot light is the most

expensive light source to

compute. It is similar to a point

light in that it has colors,

attenuation and a position, but

spot lights have an additional

direction and angle which will

define the area that is lit.

Light Sources

February 5, 2015 43

4- Distant Light Sources

infinite distance to light source, light rays considered parallel, like sun

light on earth.

comp_dep_educ@yahoo.com

Light Sources

February 5, 2015 44

Each light in the scene needs to have

- its type specified

- other relevant properties (color, position, direction…).

- Geometric properties are usually specified in world space, getting

transformed to camera space or depending on the implementation

- a set of materials define properties such as: diffuse color, specular color,

and shininess

- a bunch of triangles, Each triangle has a material assigned to it, can also

specify a normal for each vertex

comp_dep_educ@yahoo.com

February 5, 2015 45

Objects have an inherent material color which is the color that the object

reflects, The material gets its color because the reflectivity varies with the

wavelength of light.

In CG, we usually don’t represent color as a continuous spectrum. Instead,

we just represent it is a combination of red, green, and blue, Light-Material

Interactions as follow

comp_dep_educ@yahoo.com

Material Colors

February 5, 2015 46 comp_dep_educ@yahoo.com

February 5, 2015 47

Some useful definitions

comp_dep_educ@yahoo.com

February 5, 2015 48

The concept of normal is essential to lighting, in computer graphics, it is most

common to specify normal and perform lighting at the vertices. This gives us a

method of modeling smooth surfaces as a mesh of triangles with ‘shared’ normal at

the vertices. It is often very convenient if normal are unit length

Normal Transformations

Lighting requires accurate measurement of distances and angles, so we want

to compute lighting in a regular 3D space this leaves object space, world

space, or camera space as our most natural options.

To light in object space, we would have to transform the lights from world

space into each object’s space

Lighting in world space require transforming the object into world space.

To light in camera space, as we will probably want to perform clipping & some

culling in this space as well, A normal transforms as a direction, not a

position.

comp_dep_educ@yahoo.com

Normal

February 5, 2015 49 comp_dep_educ@yahoo.com

Recommended