Computer Graphics
description
Transcript of Computer Graphics
![Page 1: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/1.jpg)
Computer Graphics
Marco Tarini
Università dell’Insubria
Facoltà di Scienze MFN di Varese
Corso di Laurea in Informatica
Anno Accademico 2006/07
Lezione 10: la L di T&L
![Page 2: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/2.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Lighting
• L’altra metà del rendering• Determinare la luce
– quanta luce– di che colore
che arriva – da un punto della scena – all’occhio
• Problema complesso...
![Page 3: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/3.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Lighting: alcuni fattori
LUCE
OCCHIOOGGETTO
trasmissione (con rifrazione)
assorbimento
riflessione interna
assorbimentoda parte del mezzo
(e.g. nebbia)
scattering sotto la superficie
ALTRA LUCE
blocker
inombra
riflessione
raggio incidente
![Page 4: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/4.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Lighting: alcuni fattori
LUCE
OCCHIOOGGETTO
riflessioni multiple(illuminazione indiretta)
![Page 5: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/5.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Lighting: globale VS locale
– tiene conto solo di:• condizioni di luce
– N. luci– loro pos– loro colore
• pezzetto della superficie da illuminare
– orientamento (normale)– caratteristiche ottiche
» per es, colore
– il resto del mondo non c’è
– riflessioni multiple– ombre– scattering
sottosuperficiale– rifrazione– ...
Illuminazione locale Illuminzione globale
torna molto più
facile da farecon il nostro
Hardware
![Page 6: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/6.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Lighting locale
LUCE
OCCHIOOGGETTO
rifelssione
raggio incidente
![Page 7: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/7.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Cosa è facile fare
• Illuminazione locale:– riflessioni della luce su oggetti
• con proprietà ottiche molto semplici
– con multiple fonti di luci• ma molto semplici: puntiformi
• Illuminazione globale:– riflessioni multiple
• in maniera BRUTALMENTE approssimata
– assorbimento da parte del mezzo• assunzioni semplificanti (nebbia uniforme)
– tutto il resto solo "a fatica"• escogitando algoritmi ad-hoc che si adattano al nostro l'HW
![Page 8: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/8.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
I 3 addendi nel modello di Lighting di OpenGL
luce finale=
ambiente+
riflessione+
emissione
per ogni addendo, ho una componente R, G e B.
definite sia per l'oggetto, (sotto forma di attributi per
vertice)sia per ogni luce che uso
le proprieta ottiche dell'oggetto,
(di solito sono attributi per vertice)
nel loro insieme sono detteil suo "materiale"
terminologia OpenGL
![Page 9: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/9.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente emissione
• LEDs, lampadine...• Non dipende dalle luci
– solo dall'oggetto
• E’ solo una componente additiva – costante per R, G e B
• Nota: non manda luce ad oggetti vicini– non e’ illuminazione globale– per fare cio’, devo aggiungere una altra luce
![Page 10: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/10.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
I 3 addendi nel modello di Lighting di OpenGL
luce finale=
ambiente+
riflessione+
emissione
![Page 11: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/11.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente ambiente
• Modella (grossolanamete)la luce che arriva attraverso rifelssioni multiple
• Assunzione: "un pò di luce raggiunge da tutte le direzioni ogni superficie"– anche quelle in ombra
• Piccola costante additiva– non dipende dalla normale della superficie
![Page 12: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/12.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente ambiente
• prodotto fra:– colore “ambient” del materiale ( RM GM BM)
– colore “ambient” della luce ( RL GL BL)
• Nota: possono essere colori RGB diversi– prodotto componente per componente
![Page 13: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/13.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente ambiente
• Modella (grossolanamete)la luce che arriva da tutte le direzioniattraverso rifelssioni multiple
senza
con
![Page 14: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/14.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
I 3 addendi nel modello di Lighting di OpenGL
luce finale=
ambiente+
riflessione+
emissione
riflessione diffusa
+
riflessione speculare
solo componenteambient
![Page 15: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/15.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
I 4 addendi nel modello di Lighting di OpenGL
luce finale=
ambiente+
riflessione diffusa +
riflessione speculare+
emissione
![Page 16: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/16.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione diffusa
• Esibita nella realtà da (per es):– gesso – legno (quasi)– materiali molto opachi (nel senso di "non
lucidi")
• Detta anche– diffuse reflection– Lambertian reflection
Johann Heinrich Lambert 1728 - 1777
![Page 17: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/17.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione diffusa
• La luce che colpisce una superficie Lambertiana si riflette in tuttele direzioni (nella semisfera)– nello stesso modo
![Page 18: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/18.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione diffusa
• La luce che colpisce una superficie Lambertiana si riflette in tuttele direzioni (nella semisfera)– nello stesso modo
![Page 19: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/19.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione diffusa
• La luce che colpisce una superficie Lambertiana si riflette in tuttele direzioni (nella semisfera)– nello stesso modo
![Page 20: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/20.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione diffusa
• Dipende solo da:– l'orientamento della superficie
• (la "normale")
– la direzione della luce• del raggio incidente
![Page 21: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/21.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione diffusa
• Dipende solo da:– l'orientamento della superficie N
• (cioè la sua "normale")
– la direzione della luce L• (cioé del raggio incidente)
cos diffmaterialedifflucediff kII
R, G, B(spesso, bianco: 1,1,1)
R, G, B(il "colore" dell'oggetto)
moltiplicazione componente per componente
![Page 22: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/22.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
fa parte del"materiale"
(caratteristica dell'oggetto)
Componente riflessione diffusa
• Dipende solo da:– l'orientamento della superficie N
• (cioè la sua "normale")
– la direzione della luce L• (cioé del raggio incidente)
cos diffmaterialedifflucediff kII
![Page 23: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/23.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione diffusa
• Dipende solo da:– l'orientamento della superficie N
• (cioè la sua "normale")
– la direzione della luce L• (cioé del raggio incidente)
cos diffmaterialedifflucediff kII
![Page 24: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/24.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione diffusa
• Dipende solo da:– l'orientamento della superficie N
• (cioè la sua "normale")
– la direzione della luce L• (cioé del raggio incidente)
)L̂N̂( diffmaterialediffluce kI
cos diffmaterialedifflucediff kII
se angolo é compreso fra 0⁰ e 90⁰,else: 0,
(oggetto in ombra di se stesso)
![Page 25: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/25.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione diffusa
L
N
componente diffusapiccola⍬=70⁰
L
N
componente diffusagrande⍬=35⁰
L
N
componente diffusamassima⍬=0⁰
![Page 26: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/26.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione diffusa
L
N
componente diffusaZERO⍬=90⁰
L
N
componente diffusaZERO⍬>90⁰
(la superficieè nella propria stessa ombra)
![Page 27: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/27.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione diffusa
• Proprietà– modello fedele
delle caratteristiche ottichedi alcuni materiali reali
– ma di pochi materiali
– modello fisicamente coerente • per es, conserva l'energia
– molto semplice da calcolare
![Page 28: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/28.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
I 4 fattori che consideriamo
luce finale=
ambiente+
riflessione diffusa +
riflessione speculare+
emissione
![Page 29: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/29.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione speculare
• "Specular" reflection
• Per materiali lucidi– con riflessi brillanti– ("highlights")
senza con
![Page 30: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/30.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione speculare
• Idea base:la luce non viene riflessa da materiali lucidiin maniera eguale in tutte le direzioni
![Page 31: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/31.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione speculare
L: raggio incidenteN: normaleR: raggio riflessoV: dir. di vista
NL R
V
in 3D
![Page 32: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/32.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione speculare
• Phong light model – by Bui-Tuong Phong, 1975
in 3Dcos specmaterialespeclucespec kII
![Page 33: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/33.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione speculare
• Elevando il coseno ad una potenza,si ottengono riflessi piu' piccoli e brillanti
![Page 34: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/34.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
fanno parte del "materiale"(caratteristiche dell'oggetto)
Componente riflessione speculare
• Phong light model – by Bui-Tuong Phong, 1975
in 3D
nspecmaterialespeclucespec kII cos
cos specmaterialespeclucespec kII
![Page 35: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/35.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione speculare
• Phong light model – by Bui-Tuong Phong, 1975
in 3D
nspecmaterialespecluce VRkI )ˆˆ(
cos specmaterialespeclucespec kII
nspecmaterialespeclucespec kII cos
![Page 36: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/36.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione speculare
1n 5n 10n 100n
![Page 37: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/37.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione speculare
• Blinn-Phong light model:• semplificazione del Phong light model• risultati simili, formula diversa:
nspecmaterialespeclucespec VRkII )ˆˆ( phong:
blinn-phong:n
specmaterialespeclucespec NHkII )ˆˆ(
NL R
V
H = L + V / |L+V|
"half-way" vector
![Page 38: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/38.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Componente riflessione speculare
• Blinn-Phong light model:• semplificazione del Phong light model• risultati simili, formula diversa:
Jim Blinn
(MEGA-MEGA-GURU)
nspecmaterialespeclucespec VRkII )ˆˆ( phong:
blinn-phong:n
specmaterialespeclucespec NHkII )ˆˆ(
![Page 39: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/39.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
I 4 fattori che consideriamo
luce finale=
ambiente+
riflessione diffusa +
riflessione speculare+
emissione
![Page 40: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/40.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Equazione di lighting in totale
nspacularmaterialespacularluce NHkI )(
)( NLkI diffusematerialediffuseluce
ambientmaterialeambientluce kI
emissionmaterialek
totI
propretà del materiale propretà della luce
![Page 41: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/41.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Materiali...
![Page 42: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/42.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Equazione di lighting:modellazione delle luci
nspacularmaterialespacularluce NHkI )ˆˆ(
)ˆˆ( NLkI diffusematerialediffuseluce
ambientmaterialeambientluce kI
emissionmaterialek
totI
propretà della luce
VL
VLˆˆ)ˆˆ(
![Page 43: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/43.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Modellazione delle luci
• Come varia L?– costante nella scena: fonti di luci "direzionali"
• buono per fonti di luce molto distanti, e.g. il sole
– varia nella scena: fonti di luci "posizionali" • buono per fonti di luci vicine, e.g. lampadine
![Page 44: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/44.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Modellazione delle luci: luci posizionali
• Nelle luci posizionali, si può attenuare l'intensità in funzione della distanza
• In teoria (per la fisica) intensità = 1 / distanza2
2L
1
dcf luceoneattentuazi
![Page 45: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/45.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Modellazione delle luci: luci posizionali
• In pratica, questo porta ad attenuazioni della luce troppo repentine
• Invece usiamo:
1,1
min2L3L21 dcdcc
f luceoneattentuazi
![Page 46: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/46.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Equazione di lighting
nspacularmaterialespacularluce NHkI )(
)( NLkI diffusematerialediffuseluce
ambientmaterialeambientluce kI
emissionmaterialek
totI luceoneattentuazif
1,1
min2L3L21 dcdcc
f luceoneattentuazi
![Page 47: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/47.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Tipi di luci
• Tipi di luci:– posizionali– direzionali– spot-lights
• (faretti)
![Page 48: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/48.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Spotlights
• Definite da tre parametri:
![Page 49: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/49.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Equazione di Lighting di OpenGL (completa)
nspacularmaterialespacularluce NHkI )ˆˆ(
)ˆˆ( NLkI diffusematerialediffuseluce
ambientmaterialeambientluce kI
emissionmaterialek
totIluceneattenuaziof
1,1
min2L3L21 dcdcc
f luceoneattentuazi
spotlighteffettof
widthbeamAnglecutoffdirectionspotlighteffetto spotspotspotLf ,,,f
caratteristiche della luce
caratteristiche del materialedati dalla scena
![Page 50: Computer Graphics](https://reader036.fdocuments.net/reader036/viewer/2022062500/56814fde550346895dbda7a3/html5/thumbnails/50.jpg)
M a r c o T a r i n i ‧ C o m p u t e r G r a p h I c s ‧ 2 0 0 6 / 0 7 ‧ U n i v e r s i t à d e l l ’ I n s u b r i a
Prossimamente:
Fram
men
ti&
att
rib
uti
in
terp
ola
ti
Vert
ici
& loro
att
rib
uti
Screen buffer
Vert
ici
pori
ett
ati
& a
ttri
bu
ti
com
pu
tati
rasterizer
triangoli
com
puta
zioni
per
fram
mento
set-up
rasterizer
segmenti
set-up
rasterizer
punti
set-up
com
puta
zioni
per
vert
ice
lighting: DOVE?
x
y
z
v0v1
v2
v0v1
v2