Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(EOD).Software topics.pdf
Скачиваний:
18
Добавлен:
23.08.2013
Размер:
1.55 Mб
Скачать

page 140

sumR, sumG, and sumB are the sums of the color components of the colors that have been mapped to the node,

colorindex is the index assigned to the color in the node when the colormap is made.

Each node holds pointers to eight children. If the node is a leaf node, these pointers must be NULL pointers.

A list is used to hold octree positions for the representative colors in the colormap. The list is sorted in ascending order to facilitate finding the most closely related colors when it becomes necessary to reduce the number of colors to the maximum size allowed in the colormap.

list[256]

• The colormap is a 3 by 256 array to hold the red, green, and blue color intensities.

colormap[3][256]

When colors are to be displayed, the color intensities for the pixels are obtained with an index into the colormap. The module which displays the ray tracer image also uses this data structure.

The RGB color vectors formed when reading the color intensities from the input file into the color quantizer are stored in an array:

pict[]

• The color vectors are used initially as representative colors to establish the colormap and a second time to obtain the indices for the original colors.

12.7 DITHERING

Sometimes we want to display color images in black and white. (a very common use is when printing shaded images).

The average pixel is composed of the Additive colors Red-Green-Blue (RGB)

We assume that the intensity (brightness) of the RGB value can be used as a reasonable approximation. Unfortunately, colors like RED and BLUE may appear to be the same with this method.

The intensity is then used to set a few pixels ON or OFF in a grid. This is assuming a Black, and White device.

page 141

3 by 3 pixels

Pixel

Picture (10 by 10

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Dither Map

 

 

 

(3 by 3)

Dithered Picture

 

 

 

 

 

(30 by 30 black

color pixels)

and white pixels)

• Say the Dither Map is 2 by 2, In this scheme there are 5 different intensity levels.

Pixel OFF - Dark

Pixel ON - Light

Dark

Dim

Normal

Bright

Intense

• In dithering the dot patterns are made to be at 45 degree angles. This is because if the pattern were horizontal, or vertical, the human eye would detect the repeated pattern easily (this is also done with newspaper pictures).

12.7.1 A Model for Light Ray Reflection

• When light strikes a surface it is often reflected. The reflection model is quite simple. In this case a simple fraction of the incoming light will be used. More sophisticated models may be constructed using information about particular materials.

page 142

 

 

 

Iir, Iig, Iib

R

N

 

I

Ir, Ig, Ib

 

 

 

 

 

 

Assumed Simplified

φ

 

φ

Model

 

Ir = Iir Krr

 

 

 

 

 

 

Ig = Iig Krg

 

 

 

Ib = Iib Krb

Reflection of an Incident Light Beam

12.7.2 A Model for Light Ray Refraction:

• When light enters or exits material, its path changes. There are also optical adjustments based on the transparency of the specific material. The path change is determined by Snell’s law, and the change in optical properties are considered by a simplified formula.

I

N

 

 

 

 

 

 

 

 

 

 

n1

 

n2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

------------

= ------------

 

 

 

 

 

 

 

sin θ 1

sin θ

2

 

 

 

 

 

θ 1

 

T = n

it

I + [n

C

i

- sqrt(1 + n

it

2(C 2

- 1))]N

 

 

 

it

 

 

i

 

 

 

nit = n1/n2

 

 

 

 

 

 

n1

 

Ci = cos θ 1

 

 

 

 

 

 

n2

 

 

 

 

 

 

 

 

 

 

 

 

T

 

 

 

 

 

 

 

 

 

 

θ 2

 

 

 

 

 

 

 

 

Refraction of an Incident Light Beam

 

 

 

• After the collision vector has been calculated, the object’s transparency must be taken into account. This is done by using a transparency coefficient ‘t’. When ‘t’ has a value of 1 the object is opaque, and all light originates from the surface. If the object has a ‘t’ value of 0, then all light is from refraction.

page 143

Ir, Ig, Ib

Ifr, Ifg, Ifb

 

N

 

Ir = t Ifr + (1 - t) Ibr

 

Ig = t Ifg + (1 - t) Ibg

 

Ib = t Ifb + (1 - t) Ibb

 

Ibr, Ibg, Ibb

Light Transmission in the Presence of Transparency

12.7.3 A Model for Specular Reflection of Point Light

• The highlights which often appear on an illuminated object can be estimated also. In this case the Phong model is used. This model includes an estimate of how ‘fuzzy’ the light patch appears. This is not done if the collision point lies in a shadow.

 

 

 

 

 

Ipr, Ipg, Ipb

R

 

 

 

 

 

 

N

L

 

 

 

 

 

 

 

 

 

 

 

 

 

θ

φ

φ

Ir = Ipr Ks cosn θ

 

V

 

 

I

= I

K

 

cosn

θ

 

 

 

s

 

 

 

g

pg

 

cosn

 

 

 

 

I

= I

K

s

θ

Ir, Ig, Ib

 

 

b

pb

 

 

 

 

 

 

 

 

 

 

 

Specular Reflection of Light

Соседние файлы в предмете Электротехника