• Nie Znaleziono Wyników

O ´swietlenie i cieniowanie

N/A
N/A
Protected

Academic year: 2021

Share "O ´swietlenie i cieniowanie"

Copied!
31
0
0

Pełen tekst

(1)

Modelowanie i wizualizowanie 3W-grafiki

O ´swietlenie i cieniowanie

Aleksander Denisiuk

denisjuk@matman.uwm.edu.pl

Uniwersytet Warmi ´nsko-Mazurski w Olsztynie Wydział Matematyki i Informatyki

ul. Słoneczna 54

(2)

O ´swietlenie i cieniowanie

Najnowsza wersja tego dokumentu dost ˛epna jest pod

adresem http://wmii.uwm.edu.pl/~denisjuk/uwm

(3)

Opcje o ´swietlenia i cienia

(a) (b)

( ) (d)

(e) (f)

(4)

O ´swietlenie Phonga

Model odbicia ´swiatła

´Zródło ´swiatła — punkt

Swiatło ma trzy składowe, RGB ´

(5)

Odbicie rozproszone

zabarwia ´swiatło na kolor przypisany do obiektu.

Light sour e

FigureIII.2: Di uselyre e tedlightisre e tedequallybrightlyinalldire tions.

Thedoublelineisabeamofin ominglight. Thedottedarrowsindi ateoutgoing

light.

(6)

Odbicie zwierciadlane

Swiatło nie zmienia swojej barwy. ´

Light sour e

Figure III.3: Spe ularly re e ted light is re e ted primarily in the dire tion

with the angle of in iden e equal to the angle of re e tion. The double line is a

beam of in oming light. The dotted arrows indi ate outgoing light; the longer

(7)

Swiatło docieraj ˛ ´ ace do obserwatora

Swiatło odbijane zwierciadlane: I ´ s . Swiatło rozproszone: I ´ d .

Swiatło otoczenia: I ´ a .

Swiatło emitowane powierzchni ˛ ´ a: I e .

I = I s + I d + I a + I e

(8)

Swiatło rozproszone ´

`

n

v



 I

in

d

I

d

Figure III.5: The setup for di use re e tion in the Phong model. The angle of

in iden e is . I in

d

and I

d

are the in oming and outgoing light intensities in

the indi ated dire tions.

Model Lamberta:

I d = ρ d I d In cos θ

(9)

Swiatło odbijane zwierciadlanie ´

`

r n

v

 

' I

in

s

I

s

Figure III.7: The setup for spe ular re e tion in the Phong model. The angle

of in iden e is . The ve tor r points in the dire tion of perfe t mirror-like

re e tion. I in

s

and I

s

are the in oming and outgoing spe ular light intensities

in the indi ated dire tions.

I s = ρ s I s In (cos ϕ) f

(10)

Swiatła otoczenia i emitowane ´

I a = ρ a I a In

I e = Const

(11)

Obliczanie wektora normalgego

trójk ˛ at

powierzchnia parametryzowana

powierzchnia okre´slona równaniem

(12)

Cieniowanie płaskie (flat)

Ka˙zdy bok ma swój kolor.

(13)

Cieniowanie Gourauda

Oblicza si ˛e o´swietlenie w wierzchołkach.

Wektor normalny w wierzchołku jest ´sredni ˛ a

arytmetyczn ˛ a wektorów normalnych wszystkich ´scian, do których ten wierzchołek nale˙zy.

Interpoluje si ˛e na cał ˛ a powierzchni ˛e wieloboku.

v

1

v

2

hi;ji

hi4;ji hi5;ji

(14)

Cieniowanie Gourauda

Mo˙zna straci´c ´swiatło odbijane zwierciadlane na du˙zych wielobokach. (Stosuje si ˛e podział na

mniejsze wieloboki.)

Mo˙ze w ogóle nie zauwa˙zy´c ´swiatła na szerokiej

´scianie.

Wynik zale˙zy od orientacji prostopadłych w

wierzchołkach, od blisko´sci ´swiatła wierzchołkowi.

(15)

Cieniowanie Gourauda

Dobrze działa w wielu przypadkach.

Łatwo do implementacji zarówno programowej jak i sprz˛etowej.

Jest rozpowszechnione.

(16)

Cieniowanie Phonga

Oblicza si ˛e wektor normalny w wierzchołkach.

Wektor normalny interpoluje si ˛e na cał ˛ a powierzchni ˛e wieloboku.

Na tej podstawie oblicza si ˛e kolor w ka˙zdym pikselu

v1

v2

v hi;ji

hi4;ji hi5;ji

(17)

Cieniowanie Phonga

Kosztowne obliczenia: n α = kαn αn 1 1 +(1−α)n +(1−α)n 0 0 k .

Cała informacja o kolorach i kierunkach ´swiatła

powinna przechowywa´c si ˛e do ostatniej stadji oblicze ´n.

Interpolacja we współrz˛ednych ekranowych: mog ˛ a wyst ˛ api´c nieporz ˛ adane efekty przy projekcji

perspektywicznej.

(18)

Cieniowanie Phonga

Małe odbicia zwierciadlane si ˛e nie gubi ˛ a na du˙zych

wielobokach.

(19)

Obserwator lokany i nielokalny

` r

h n

v



' I

in

s

I

s

FigureIII.8: Thesetupfor al ulatingthespe ularre e tionusingthehalfway

ve torh,the unitve torhalfwaybetween ` and v.

h = kℓ+vk ℓ+v ,

I s = ρ s I s in cos ψ  f

.

(20)

Normalizacja wektorów

Domy´slnie ka˙zdy wektor jednostkowy powinien by´c normalizowany.

Je˙zeli macierz przekształcenia zawiera skalowanie,

wektory nale˙zy normalizowa´c.

(21)

BRIDF

`

n

v I

;in

I

;out

Figure III.13: The BRIDF fun tion relates the outgoing light intensity and the

in oming light intensity a ording to BRIDF(`;v ;) = I

;out

=I

;in

:

Funkcja rozkładu współczynnika odbicia dwukierunkowego

(Bidirectional Reflected Intesity Distridution Function)

(22)

Powierzchnia mikroluster

I

1

I

2

Figure III.14: A mi rofa et surfa e onsists of small at pie es. The horizontal

line shows the average level of a at surfa e, and the mi rofa ets show the

mi ros opi shape of the surfa e. Dotted lines show the dire tion of light rays.

The in oming light an either be re e ted in the dire tion of perfe t mirror-like

re e tion (I

1

), or an enter the surfa e (I

2

). In the se ond ase, the light is

modeled as eventually exiting the material as di usely re e ted light.

(23)

Model Cooka-Torrance’a (1982)

I = I a + I d + I s = ρ a I a in + ρ d I d in (ℓ · n) + I s , I s = (n · ℓ)

(n · v) s · F · G · D · I s in s — stała,

F (ℓ, v, λ) — współczynnik Fresnela,

G (ℓ, v) — współczynnik tłumienia geometrycznego,

D(ℓ, v) — funkcja rozkładu mikroluster.

(24)

Funkcja Rozkładu Mikroluster

` r

h n

v



' I

in

s

I

s

Figure III.8: The setup for al ulating the spe ular re e tion using the halfway

ve tor h, the unit ve tor halfway between ` and v.

D(ψ) = ce −ψ 2 /m 2 — rozkład Gaussa

(25)

Tłumienie Geometryczne

FigureIII.15: Forthederivationofthegeometri term, G,themi rofa etsare

modeledassymmetri , \V"-shapedgrooveswiththetopsofthe groovesallat

thesameheight. Thehorizontallineshowstheoverallplaneofthe surfa e.

h

0 h

`

v

h

h 0

`

v

(a)Noshadowingormasking. (b)Onlymasking.

v

`

v

(26)

Współczynnik Tłumienia Geometrycznego

G =

 

 

1, v · h ≥ 0 lub n · v ≥ n · ℓ,

2(n·h)(n·v)

h·v , v · h < 0 i h · ℓ ≥ 0,

(n·v)

n·ℓ , v · h < 0, ℓ · h < 0 i n · v < n · ℓ,

(27)

Współczynnik Fresnela

F ≈ F 0 + (1 − F 0 )(1 − cos ψ) 5

Tabela 1: Warto´sci F 0 dla wybranych materiałów

R G B

Złoto: 0,93 0,88 0,38

Srebro: 0,97 0,97 0,96

Platyna: 0,63 0,62 0,57

Mied´z: 0,93 0,80 0,46

(28)

Przykład

(29)

Efekty specjalne. Tłumienie ´swiatła

Współczynnik tłumienia:

1

k c + k l d + k q d 2 ,

gdzie d jest odległo´sci ˛ a

(30)

Efekty specjalne. ´ Swiatło spot

jak ´swiatło punktowe kierunek

k ˛ at obcinania (cutoff), ψ 0 wska´znik tłumienia, p

I = I 0 (cos ψ) p , je˙zeli ψ < ψ 0

0

(31)

Efekty specjalne. ´ Swiatło kierunkowe (Sun)

jak ´swiatło punktowe

˙zródło ´swiata umieszczone jest w niesko ´nczono´sci (x 0 : y 0 : z 0 : 0)

brak tłumienia (czemu?)

Cytaty

Powiązane dokumenty

Use the global angular momentum balance to calculate the time evolution of angular velocity Ω(t) of a rotating lawn sprinkler after the water pressure is turned on.. An arm of a

Rozk³ad stê ¿eñ chlor ków w wo dach powie rz ch nio wych je zio ra Mod³a i rze ce Po ty

With the help of Theorem 7 and the Lemma, we can easily prove Theorem 9.. , be some sequences of complex numbers. .) be an asymptotic sequence. .)... By using the previous Lemma, we

We now apply Petersson’s formula and classical bounds for Kloosterman sums and Bessel functions, supplemented in the second term by the remarks that for m &lt; q we have lq 6= m,

However, this form of volunteering won’t replace the traditional volunteering activities, especially those based upon direct contact with trainees. Keywords:

Jed n e , i drugie przyniosły ze sobą nasiona roślin miejscowych : i oto obok rodowitych afry- kanek zakw itły rośliny z pod Poznania lub G dańska, wzbogacając

(a) Write the following statements in symbolic logic form (i) “If the sun is shining then I will walk to school.”.. (ii) “If I do not walk to school then the sun is

Find the vector equation of the line of intersection of the three planes represented by the following system of equations.. (a) Write the vector equations of the following lines