View
4
Download
0
Category
Preview:
Citation preview
c
�
Illu
min
atio
nan
dsh
adin
g
Obj
ects
with
and
with
outs
hadi
ngef
fect
s
Sh
adin
g:
Col
our
orin
tens
itym
odifi
catio
nsof
asu
rfac
eby
illum
inat
ion
effe
cts.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
1/81
c
�
Illu
min
atio
nm
od
els
Mor
ere
alis
ticim
ages
requ
irede
taile
dco
mpu
tatio
nof
illum
inat
ion
effe
cts
(refl
ectio
n,sh
adin
g,sh
adow
s,
�
�
�
).
From
ath
eore
tical
poin
tofv
iew
,the
com
puta
tions
for
shad
ing
desc
ribed
inth
efo
llow
ing
sect
ions
wou
ldha
veto
beca
rrie
dou
tfor
each
wav
elen
gth
ofth
elig
htin
divi
dual
ly.
From
apr
actic
alpo
into
fvie
w,t
heco
mpu
tatio
nsw
illal
way
sbe
rest
ricte
dto
the
thre
epr
imar
yco
lour
sre
d,gr
een
and
blue
inor
der
tode
term
ine
the
RG
B-v
alue
sfo
rth
ere
pres
enta
tion.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
2/81
c
�
Lig
ht
sou
rces
�
Am
bie
nt
ligh
tdo
esno
tcom
efr
oma
spec
ific
light
sour
cean
dha
sno
dire
ctio
n.It
repr
esen
tsth
elig
htth
atis
mor
eor
less
ever
ywhe
rein
the
scen
e,or
igin
atin
gfr
omm
ultip
lere
flect
ions
oflig
htat
vario
ussu
rfac
es.
Am
bien
thas
only
aco
lour
.
�
Dir
ecti
on
allig
ht
sou
rces
isus
edto
mod
ellig
htco
min
gfr
oma
sour
cein
alm
osti
nfini
tedi
stan
ce,
for
inst
ance
sunl
ight
.T
helig
htra
ysar
eal
lpar
alle
l.In
addi
tion
toth
eco
lour
,the
light
rays
have
adi
rect
ion.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
3/81
c
�
Lig
ht
sou
rces
�
Ala
mp
ism
odel
led
asa
po
int
ligh
tso
urc
e.
�
Poi
ntlig
htso
urce
have
aco
lour
and
apo
sitio
n.
�
The
inte
nsity
ofth
elig
htde
crea
ses
with
incr
easi
ngdi
stan
ce( a
tten
uat
ion).
The
inte
nsity
decr
ease
squ
adra
tical
lyw
ithth
edi
stan
ce.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
4/81
c
�
Lig
ht
sou
rces
The
oret
ical
appr
oach
:M
ultip
lyth
ein
tens
ityby
the
fact
or
����
whe
nth
elig
hthi
tsth
esu
rfac
eof
anob
ject
atdi
stan
ce
� .
Dra
stic
effe
ct:
���
� inte
nsity
��
Mod
ified
mod
el:
� att
� �
�
� �
�� �
��� �
�� ��
The
linea
rte
rmca
nm
odel
atm
osp
her
icat
ten
uat
ion.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
5/81
c
�
Lig
ht
sou
rces
�
Sp
otl
igh
t:A
poin
tlig
htso
urce
who
selig
htis
only
emitt
edin
toon
edi
rect
ion
inth
efo
rmof
aco
ne.
Als
oqu
adra
ticde
crea
seof
the
inte
nsity
with
incr
easi
ngdi
stan
ce.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
6/81
c
�
Lig
ht
sou
rces
Inte
nsity
ofth
elig
htis
smal
ler
clos
eto
the
boun
dary
ofth
eco
neof
light
than
atth
ece
ntre
.
Inte
nsity
oflig
htat
the
poin
ton
the
surf
ace
com
ing
from
the
spot
light
(War
nm
odel
):
�
����
� att
������
�
����
� att
��
���
���
�
n
ll'
g
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
7/81
c
�
Java
3D:
Lig
ht
sou
rces
Am
bie
nt
ligh
t:AmbientLight
ambLight
=new
AmbientLight(ambColour);
ambLight.setInfluencingBounds(bounds);
gene
rate
dam
bien
tlig
htw
ithth
eco
lour
(Color3f
)ambColour
.A
sal
read
yin
the
case
ofInterpolator
sfo
ran
imat
ion,
alig
htso
urce
mus
tals
oof
are
gion
whe
reit
“shi
nes”
.T
hem
etho
dsetInfluencingBounds(bounds)
defin
esth
isre
gion
.bounds
isa
BoundingSphere
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
8/81
c
�
Java
3D:
Lig
ht
sou
rces
Dir
ecti
on
allig
ht:DirectionalLight
dirLight
=new
DirectionalLight(lightColour,
lightDir);
gene
rate
sdi
rect
iona
llig
htof
the
colo
urlightColour
with
light
rays
para
llelt
oth
edi
rect
ion
give
nby
Vector3f
lightDir
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
9/81
c
�
Java
3D:
Lig
ht
sou
rces
Po
int
ligh
tso
urc
e:PointLight
pLight
=new
PointLight(lightColour,
location,
attenuation);
defin
esa
poin
tlig
htso
urce
inth
epo
int(Point3f
)location
with
colo
urlightColour
.
attenuation
isan
inst
ance
ofth
ecl
ass
Point3f
who
seth
ree
com
pone
nts
spec
ifyth
eco
effic
ient
sof
the
poly
nom
iali
nth
ede
nom
inat
orof
the
atte
nuat
ion
form
ula.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
10/8
1
c
�
Java
3D:
Lig
ht
sou
rces
Sp
ot
ligh
t:A
poin
tlig
htso
urce
emits
light
inal
ldi
rect
ions
.
The
clas
sSpotLight
exte
nds
the
clas
sPointLight
.
ASpotLight
need
sa
dire
ctio
nin
whi
chth
elig
htco
neis
orie
nted
.
SpotLight
spLight
=new
SpotLight(lightColour,
location,
attenuation,
direction,
angle,
concentration);
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
11/8
1
c
�
Java
3D:
Lig
ht
sou
rces
The
first
thre
epa
ram
eter
sha
veth
esa
me
mea
ning
asfo
rPointLight
.
The
Vector3f
direction
spec
ifies
the
dire
ctio
nin
whi
chth
esp
otlig
htsh
ines
.
The
float
-val
ueangle
defin
esth
ean
gula
rlim
itco
rres
pond
ing
toha
lfof
the
open
ing
angl
eof
the
cone
oflig
ht.
The
float
-val
ueconcentration
betw
een
0an
d12
0de
term
ines
how
muc
hth
esp
otlig
htis
focu
ssed
toth
ece
ntre
axis
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
12/8
1
c
�
Java
3D:
Lig
ht
sou
rces
�
All
light
sour
ces
shou
ldbe
assi
gned
toth
eBranchGroup
bgLight
byaddChild
(�
�
�
).
�
bgLight
mus
tbe
assi
gned
toth
eSimpleUniverse
byth
em
etho
daddBranchGraph
(�
�
�
).
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
13/8
1
c
�
Java
3D:
Lig
ht
sou
rces
Mov
ing
light
sour
ces:
�
Do
nota
ssig
nth
elig
htso
urce
dire
ctly
toth
eBranchGroup
bgLight
.
�
Gen
erat
ea
tran
sfor
mat
ion
grou
pfo
rth
em
ovem
ent.
�
Ass
ign
the
light
sour
ceto
this
tran
sfor
mat
ion
grou
p.
�
Ass
ign
this
tran
sfor
mat
ion
grou
ptobgLight
.
(see
MovingLight.java
)
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
14/8
1
c
�
Java
3D:
Lig
ht
sou
rces
�
Ligh
tsou
rces
them
selv
esar
ein
visi
ble.
�
Inor
der
tom
odel
ala
mp,
aco
rres
pond
ing
obje
ctm
ustb
ecr
eate
dan
das
sign
edto
the
scen
e.
�
The
corr
espo
ndin
glig
htso
urce
can
beas
sign
edto
the
tran
sfor
mat
ion
grou
pof
the
obje
ctin
stea
dof
bgLight
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
15/8
1
c
�
Lig
ht
emit
tin
go
bje
cts
Obj
ects
emitt
ing
light
:
Equ
atio
nfo
rth
ein
tens
ity(f
orsh
adin
g):
����
Inde
tail:
� (red
)
� (r
ed)
�
� (gre
en)
� (g
reen
)�
� (blu
e)
� (b
lue)
�
An
obje
ctem
ittin
glig
htis
notc
onsi
dere
das
alig
htso
urce
inth
esc
ene
and
will
noti
llum
inat
eot
her
obje
cts.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
16/8
1
c
�
Refl
ecti
on
Inte
nsity
ata
pixe
lillu
min
ated
bya
light
sour
ce:
�
� lig
htso
urce
�� pi
xel�
�
� light
sour
ceis
the
inte
nsity
ofth
elig
htco
min
gfr
omth
elig
htso
urce
.
�
� pixe
lis
afa
ctor
that
depe
nds
onva
rious
para
met
ers.
The
colo
urof
the
surf
ace,
itssh
inin
ess,
the
dist
ance
toth
elig
htso
urce
inca
seat
tenu
atio
nm
ustb
eta
ken
into
acco
unt,
and
the
angl
eat
whi
chth
elig
hthi
tsth
esu
rfac
ein
the
cons
ider
edpi
xel.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
17/8
1
c
�
Refl
ecti
on
Illum
inat
ion
equa
tion
for
ambi
entl
ight
:
�
�
�
����
�� :
refle
ctio
nco
effic
ient
ofth
esu
rfac
e(f
oram
bien
tlig
ht).
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
18/8
1
c
�
Dif
fuse
refl
ecti
on
Ligh
tint
ensi
tyde
pend
ing
onth
ean
gle
inw
hich
the
light
hits
the
surf
ace.
Lam
bert
’sco
sine
law
: �
���
��������
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
19/8
1
c
�
Dif
fuse
refl
ecti
on
nql
For
norm
alis
edve
ctor
s:
�
���
� ��
��
��
�
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
20/8
1
c
�
Sp
ecu
lar
refl
ecti
on
specu
lar refle
ction
diffuse
refle
ction
ground co
lour
varnish la
yer
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
21/8
1
c
�
Sp
ecu
lar
refl
ecti
on
nr
v
l
a
nr
l
ss
�
��������
�
�
�������
�
�
��
�������
�
�
��
��
���
�
�
Pre
cond
ition
:��
�
�
�
��� ,i
.e.
���
��
�
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
22/8
1
c
�
Sp
ecu
lar
refl
ecti
on
Idea
lmirr
or:
Spe
cula
rre
flect
ion
only
inth
edi
rect
ion
ofth
eve
ctor
� .
Shi
nysu
rfac
e,bu
tnot
perf
ectm
irror
:S
pecu
lar
refle
ctio
nar
ound
� .
Ph
on
gill
um
inat
ion
mo
del
:
�
���
����
�������� �
��
���
�
� :Fr
actio
nof
the
light
tow
hich
spec
ular
refle
ctio
nap
plie
sfo
rlig
htun
der
the
angl
e
� .
� :S
pec
ula
rre
flec
tio
nco
effi
cien
t,
��� :
Idea
lmirr
or.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
23/8
1
c
�
Ph
on
gill
um
inat
ion
mo
del
�
���
����
��
��
� �
0
0.2
0.4
0.6
0.81
00.
20.
40.
60.
81
1.2
1.4
������
�� �������
� �������� �����
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
24/8
1
c
�
Mo
d.P
ho
ng
illu
min
atio
nm
od
el
Alte
rnat
ive
mea
sure
for
the
stre
ngth
ofsp
ecul
arre
flect
ion:
Dev
iatio
nof
the
norm
alve
ctor
�
from
halfw
ayve
ctor
�
betw
een
� and
� .
nr
l
v
b
a
h
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
25/8
1
c
�
Mo
d.P
ho
ng
illu
min
atio
nm
od
el
Mod
ified
Pho
ngill
umin
atio
nm
odel
:U
se����
inst
ead
of
���
� :
���
�
�
��
�
whe
re
�
��
�
���
�
�
Adv
anta
ge:
Inca
seof
dire
ctio
nall
ight
and
para
llel
proj
ectio
n,th
eha
lfway
vect
or
�
does
notc
hang
e.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
26/8
1
c
�
Mu
ltip
lelig
ht
sou
rces
�
� self_
emis
sion
�� am
bien
t_lig
ht
��
�
�
�
� ��
� att
�� co
ne
��� ��
��
��
� ��� sr
��
��
�
�� �
��
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
27/8
1
c
�
Def
erre
dS
had
ing
Hig
hco
mpu
tatio
nalc
osts
for
the
� -buf
fer
algo
rithm
whe
nm
ore
than
one
ortw
olig
htso
urce
sar
epr
esen
t.
Com
plex
com
puta
tions
for
shad
ing,
even
for
obje
cts
whi
chw
illbe
over
writ
ten
inth
e
� -buf
fer
byot
her
obje
cts.
Def
erre
dS
had
ing
:
�
Run
the
� -buf
fer
algo
rithm
once
and
fillo
nly
the
� -buf
fer.
�
Inth
ese
cond
run
(whe
real
soth
efr
ame
buffe
ris
fille
d),o
nly
thos
eob
ject
sar
esh
aded
who
se
� -coo
rdin
ate
isen
tere
din
the
� -buf
fer
and
that
need
tobe
shad
ed.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
28/8
1
c
�
Java
3D:
Su
rfac
ep
rop
erti
es
AnAppearance
isas
sign
edto
each
obje
ctpr
ovid
ing
info
rmat
ion
abou
tthe
appe
aran
ceof
the
obje
ct’s
surf
ace.
An
impo
rtan
tattr
ibut
eofAppearance
isth
eMaterial
.
Material
defin
esco
lour
and
refle
ctio
npr
oper
ties
ofth
esu
rfac
e.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
29/8
1
c
�
Java
3D:
Su
rfac
ep
rop
erti
es
Con
stru
ctor
forMaterial
:
Material
ma
=new
Material(ambientColour,
emissiveColour,
diffuseColour,
specularColour,
shininessValue);
�
ambientColour
isa
colo
urte
lling
how
muc
ham
bien
tlig
htis
refle
cted
byth
esu
rfac
e.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
30/8
1
c
�
Java
3D:
Su
rfac
ep
rop
erti
es
�
emissiveColour
isth
ein
tens
ity(c
olou
r)of
the
self-
emitt
ing
light
ofth
esu
rfac
e.
The
obje
ctw
illoc
cur
inth
isco
lour
,whe
nth
ere
isno
othe
rlig
ht.
The
obje
ctw
illill
umin
ate
othe
rob
ject
s.
�
diffuseColour
isth
eco
lour
for
diffu
sere
flect
ion.
�
specularColour
isth
eco
lour
for
spec
ular
refle
ctio
n.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
31/8
1
c
�
Java
3D:
Su
rfac
ep
rop
erti
es
�
The
valu
eshininessValue
isth
esp
ecul
arre
flect
ion
expo
nent
inth
eP
hong
illum
inat
ion
mod
el.
Appearance
app
=new
Appearance();
gene
rate
sa
newAppearance
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
32/8
1
c
�
Java
3D:
Su
rfac
ep
rop
erti
es
app.setMaterial(ma);
assi
gns
surf
ace
prop
ertie
sto
theAppearance
that
are
defin
edin
theMaterial
ma
.
AnAppearance
app
can
beas
sign
edto
any
elem
enta
ryge
omet
ricob
ject
( Box,
Sphere,
Cylinder,
Cone
)orShape3D
with
inth
eco
nstr
ucto
ror
byth
em
etho
dsetAppearance(app)
.
(see
LightingExample.java
and
LightingExample2.java
)
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
33/8
1
c
�
Sh
adin
g
Ben
tsur
face
sar
eap
prox
imat
edby
poly
gons
.
A(p
lana
r)po
lygo
nha
sth
esa
me
norm
alve
ctor
inea
chpo
int.
Co
nst
antor
flat
shad
ing
:
For
apo
lygo
n,th
eco
lour
isde
term
ined
only
for
asi
ngle
pixe
lbas
edon
one
norm
alve
ctor
.A
llot
her
pixe
lsre
sulti
ngfr
omth
epr
ojec
tion
ofth
epo
lygo
nob
tain
the
sam
eco
lour
,lea
ding
toa
hom
ogen
eous
colo
urfo
rth
epr
ojec
tion
ofth
epo
lygo
n. Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
34/8
1
c
�
Co
nst
ant
shad
ing
Impl
icit
assu
mpt
ions
:
�
The
light
sour
ceis
inin
finite
dist
ance
soth
at
���
�
isco
nsta
nt.
Thi
sap
plie
son
lyto
dire
ctio
nall
ight
sour
ces.
�
The
view
eris
inin
finite
dist
ance
soth
at
���
�
isco
nsta
nt.
Thi
sis
true
for
para
llelp
roje
ctio
ns.
�
The
poly
gon
repr
esen
tsth
ere
alsu
rfac
eof
the
obje
ctan
dis
notj
usta
nap
prox
imat
ion
ofa
curv
edsu
rfac
e.
�
No
spec
ular
refle
ctio
noc
curs
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
35/8
1
c
�
Co
nst
ant
vs.G
ou
rau
d
Con
stan
tsha
ding
lead
sto
face
tson
onbe
ntsu
rfac
es.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
36/8
1
c
�
Inte
rpo
late
dsh
adin
g
Inte
rpo
late
dsh
adin
gre
quire
sth
ede
finiti
onof
indi
vidu
alno
rmal
vect
ors
inth
eve
rtic
esof
apo
lygo
nor
tria
ngle
.
The
norm
alve
ctor
sca
nbe
deriv
edfr
omth
eor
igin
alsu
rfac
ew
hich
isap
prox
imat
edby
the
tria
ngle
s.
Ifth
etr
iang
les
are
notd
eriv
edfr
oma
free
form
surf
ace,
butw
here
spec
ified
man
ually
,diff
eren
tnor
mal
vect
ors
inth
eve
rtic
esof
the
tria
ngle
can
still
beco
mpu
ted.
Inea
chve
rtex
,the
stan
dard
norm
alve
ctor
sto
the
tria
ngle
sth
atsh
are
the
vert
exar
ein
terp
olat
ed.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
37/8
1
c
�
Go
ura
ud
shad
ing
Go
ura
ud
shad
ing
com
pute
sth
eco
lour
inea
chof
the
thre
eve
rtic
esof
atr
iang
leba
sed
onth
eco
rres
pond
ing
norm
alve
ctor
s.
The
shad
ing
ofth
eot
her
poin
tsin
the
tria
ngle
isba
sed
onco
lour
inte
rpol
atio
nde
rived
from
the
thre
eve
rtic
es.
Thi
sle
ads
toa
linea
rco
lour
grad
ient
over
the
tria
ngle
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
38/8
1
c
�
Go
ura
ud
shad
ing
Giv
enth
eth
ree
vert
ices
�� � �� � �� �
and
thei
ras
soci
ated
inte
nsiti
es
� �
(
�
� �� �� ),
any
poin
tin
the
tria
ngle
can
bere
pres
ente
din
the
form
� ��
�� � �� � �� ��
�� �
��� �
�� �
��
�� ��
�� � �� � �� �
whe
re
� �
���
�� �
� ,
� � ��� �
� �
�
� .
The
n
� ��
� �
��� �
� ��
� ��
� �
isth
ein
tens
ityas
sign
edto
the
cons
ider
edpo
int.
Inte
rpol
ated
inte
nsity
ison
lyan
appr
oxim
atio
nof
the
true
inte
nsity
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
39/8
1
c
�
Go
ura
ud
shad
ing
I
I
I
II
I
y
y y yy1
3
2
1 3 2s
ab
psc
an li
ne
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
40/8
1
c
�
Go
ura
ud
shad
ing
� �
� �
�� �
� �
� �
��
� �
��
���
� �
�� �
� �
� �
��
� �
� �
� �
���
����
� �
� �
� �
� �
�
�
Bec
ause
ofth
elin
ear
inte
rpol
atio
nsc
hem
efo
rG
oura
udsh
adin
g,th
em
inim
uman
dm
axim
umin
tens
ityon
atr
iang
lew
illal
way
sbe
inon
eof
the
vert
ices
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
41/8
1
c
�
Ph
on
gsh
adin
g
Ph
on
gsh
adin
gin
terp
olat
esth
eno
rmal
vect
ors
inth
eve
rtic
esin
stea
dof
the
colo
urin
tens
ities
.
Thi
sm
eans
that
the
illum
inat
ion
equa
tion
mus
tbe
eval
uate
dfo
rea
chpo
int(
pixe
l)in
the
tria
ngle
,not
only
for
the
vert
ices
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
42/8
1
c
�
Java
3D:
Sh
adin
g
Java
3Dap
plie
sG
oura
udsh
adin
gby
defa
ult.
Java
3Dof
fers
the
choi
cebe
twee
nSHADEGOURAUD
andSHADEFLAT
.
SHADEFLAT
refe
rsto
cons
tant
shad
ing.
The
shad
ing
algo
rithm
can
bech
osen
inth
eAppearance
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
43/8
1
c
�
Java
3D:
Sh
adin
g
Appearance
app
=new
Appearance();
ColoringAttributes
ca=
new
ColoringAttributes(
new
Color3f(1.0f,1.0f,1.0f),
ColoringAttributes.SHADE_FLAT);
app.setColoringAttributes(ca);
(see
ShadingExample.java
)
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
44/8
1
c
�
Sh
adow
s
“Cas
ting
ash
adow
”is
nota
nac
tive
mat
ter,
buts
impl
yth
ela
ckof
light
from
alig
htso
urce
that
does
notr
each
the
obje
ct’s
surf
ace
with
the
shad
owon
it.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
45/8
1
c
�
Sh
adow
s
Illum
inat
ion
equa
tion
incl
udin
gsh
adow
s:
�
� self_
emis
sion
�� am
bien
t_lig
ht
��
�
�
�
� ��
� ��
� att
�� co
ne
������
��
��
� ��� sr
��
��
�
�� �
�
whe
re
� �
� ����� �����
�
ifth
elig
htfr
omlig
htso
urce
�
reac
hes
the
surf
ace
�ot
herw
ise
(sha
dow
). Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
46/8
1
c
�
Two
-pas
s
� -bu
ffer
alg
ori
thm
1.A
pply
the
stan
dard
� -buf
fer
algo
rithm
for
each
light
sour
ce.
Con
side
rth
elig
htso
urce
asth
evi
ewer
.U
seon
lyth
e
� -buf
fer,
igno
reth
efr
ame
buffe
r.
2.A
pply
the
� -buf
fer
algo
rithm
toth
evi
ewer
with
the
follo
win
gm
odifi
catio
n:
But
befo
rea
proj
ectio
nis
ente
red
into
the
fram
ebu
ffer
���
for
the
view
er,a
nill
umin
atio
nte
stis
carr
ied
outt
och
eck
whe
ther
the
surf
ace
isill
umin
ated
byth
eco
nsid
ered
light
sour
ce.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
47/8
1
c
�
Two
-pas
s
� -bu
ffer
alg
ori
thm
Let
� �
and
� �
beth
etr
ansf
orm
atio
nstu
rnin
gth
epe
rspe
ctiv
epr
ojec
tion
with
the
view
eran
dth
elig
htso
urce
asth
ece
ntre
ofpr
ojec
tion
into
apa
ralle
lpr
ojec
tion
toth
e
��
� -pla
ne.
Coo
rdin
ates
ofa
poin
ton
the
surf
ace
tobe
proj
ecte
d:
�� ��
� � �� � .
�
��
��
��
�
� ��
� ��
�
��
� � � � � �
�
coor
dina
tes
ofth
esa
me
poin
tfro
mth
evi
ewpo
into
fth
elig
htso
urce
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
48/8
1
c
�
Two
-pas
s
� -bu
ffer
alg
ori
thm
Ifa
smal
ler
valu
eth
an
�� is
ente
red
inth
e� -b
uffe
r
��
at
��� �
��
,the
nth
ere
mus
tbe
anob
ject
betw
een
the
light
sour
cean
dth
eco
nsid
ered
surf
ace
soth
atth
issu
rfac
edo
esno
trec
eive
any
light
from
this
light
sour
ce(s
hado
w).
Oth
erw
ise,
the
cons
ider
edpo
into
nth
esu
rfac
eis
illum
inat
edby
the
light
sour
ce.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
49/8
1
c
�
Tran
spar
ency
Two
char
acte
ristic
sof
tran
spar
ents
urfa
ces:
�
How
muc
hlig
ht(o
fwhi
chco
lour
)ca
npa
ssth
roug
hth
etr
ansp
aren
tsur
face
?
�
How
stro
ngis
the
refr
actio
n?(R
efra
ctio
nw
illno
tbe
disc
usse
dhe
re.)
Con
tour
sof
obje
cts
behi
ndtr
ansp
aren
tsur
face
sar
evi
sibl
e.
Tran
slu
cen
tsu
rfac
eslik
em
ilkgl
ass
letl
ight
pass
thro
ugh
with
outs
how
ing
the
cont
ours
ofob
ject
sbe
hind
.C
ompu
ter
Gra
phic
s:Ill
umin
atio
nan
dsh
adin
g–
p.50
/81
c
�
Inte
rpo
late
dtr
ansp
aren
cy
Con
side
ra
surf
ace
� �
posi
tione
dbe
hind
atr
ansp
aren
tsu
rfac
e
� � .
Inte
rpo
late
d/fi
lter
edtr
ansp
aren
cy:
Inte
nsity
atpi
xel
� :
���
��
� tran
sp
�
� �
�� tr
ansp
�� �
�
� � :In
tens
ityof
the
poin
ton
if
� �
wou
ldbe
trea
ted
like
ano
rmal
nont
rans
pare
ntsu
rfac
e.
�
� � :In
tens
ityof
the
poin
t(on
� � )w
hen
� �
wou
ldbe
com
plet
ely
invi
sibl
e.
�
� tran
sp
�� � ��� :
Tran
smis
sio
nco
effi
cien
t.
� tran
sp
� :� �
isco
mpl
etel
ytr
ansp
aren
t(in
visi
ble)
.
� tran
sp
� :
� �
isno
ttra
nspa
rent
atal
l.C
ompu
ter
Gra
phic
s:Ill
umin
atio
nan
dsh
adin
g–
p.51
/81
c
�
Scr
een
-do
or
tran
spar
ency
Scr
een
-do
or
tran
spar
ency
:P
ixel
sob
tain
thei
rco
lour
alte
rnat
ingl
yfr
omth
etr
ansp
aren
tsur
face
and
the
surf
ace
behi
nd.
Dep
endi
ngon
the
tran
smis
sion
coef
ficie
nt,m
ore
orle
sspi
xels
are
assi
gned
toth
etr
ansp
aren
tsur
face
.
tran
spar
ent/b
ackg
roun
dsu
rfac
e:
50%
tran
spar
ency
25%
tran
spar
ency
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
52/8
1
c
�
Java
3D:
Tran
spar
ency
TransparencyAttributes
ta
=new
TransparencyAttributes();
ta.setTransparencyMode(
TransparencyAttributes.BLENDED);
ta.setTransparency(transpValue);
trApp.setTransparencyAttributes(ta);
transpValue
:float
-val
uebe
twee
n0
and
1de
finin
gth
etr
ansm
issi
onco
effic
ient
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
53/8
1
c
�
Java
3D:
Tran
spar
ency
Ava
ilabl
eTransparencyMode
s:
�
BLENDED
:int
erpo
late
d(fi
ltere
d)tr
ansp
aren
cy.
�
SCREENDOOR
:Scr
een-
door
tran
spar
ency
.
�
Als
o:NICEST,
FASTEST,
NONE
(see
TransparencyExample.java
) Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
54/8
1
c
�
Text
ure
s
Text
ure
:Im
age
map
ped
toa
surf
ace
for
mod
ellin
gsu
rfac
ede
tails
.
Imag
eso
nsu
rfac
es:
Exa
mpl
es:
�
Pai
nted
wal
l
�
Bac
kgro
und
land
scap
eor
sky
with
noex
plic
it3D
mod
ellin
g
�
Wol
rdm
appr
ojec
ted
onto
agl
obe
Pat
tern
s/st
ruct
ure
s:E
xam
ples
:
�
Woo
dgr
ain
�
Rou
ghca
st
�
Ingr
ain
wal
lpap
er
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
55/8
1
c
�
Text
ure
s
Text
ures
are
som
etim
esus
edfo
rm
odel
ling
smal
l(w
ood
grai
n)or
dist
ant(
back
grou
ndla
ndsc
ape)
thre
e-di
men
sion
alst
ruct
ures
.
Usi
ngex
plic
itan
3Dm
odel
base
don
extr
emel
ysm
all
poly
gons
for
such
effe
cts
wou
ldbe
too
inef
ficie
nt.
Pat
tern
sor
stru
ctur
esar
eus
ually
map
ped
repe
ated
lyon
toa
surf
ace.
Con
cret
eim
ages
orte
xtis
usua
llyon
lym
appe
don
ceto
asu
rfac
e.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
56/8
1
c
�
Text
ure
s
TT
PI
texture
mon
itor
surface
pixel
texel
Usi
nga
text
ure
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
57/8
1
c
�
Text
ure
s
Env
iro
nm
ent
orre
flec
tio
nm
app
ing:
Tech
niqu
eto
mod
elm
irror
sor
refle
ctin
gsu
rfac
eslik
eth
esu
rfac
eof
calm
wat
er.
�
Refl
ectt
hevi
ewer
atth
eco
rres
pond
ing
surf
ace.
�
Com
pute
the
imag
ew
hich
the
refle
cted
view
erw
ould
see.
�
Use
this
imag
eas
ate
xtur
efo
rth
ere
flect
ing
surf
ace.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
58/8
1
c
�
Env
iro
nm
ent
map
pin
g
mirror
view
er
reflected view
er
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
59/8
1
c
�
Bu
mp
map
pin
g
Asu
rfac
ere
mai
nsfla
twhe
na
text
ure
isat
tach
edto
it.
Bu
mp
map
pin
gle
aves
the
surf
ace
flat,
butm
odifi
esth
eno
rmal
vect
ors.
Abu
mp
map
assi
gns
toea
chte
xtur
epo
inta
pert
urba
tion
valu
e
��� ��
spec
ifyin
gho
wm
uch
the
poin
ton
the
surf
aces
shou
ldbe
mov
edal
ong
the
norm
alve
ctor
for
the
relie
f.
Ifth
esu
rfac
eis
give
nin
para
met
ricfo
rman
dth
epo
int
tobe
mod
ified
is
���
���� �
� �
���� �
� �
���� �
�
,the
nth
eno
nnor
mal
ised
mod
ified
norm
alve
ctor
at
� isob
tain
edfr
omth
ecr
oss
prod
ucto
fthe
part
ial
deriv
ativ
esw
ithre
spec
tto
�
and
� .
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
60/8
1
c
�
Bu
mp
map
pin
g
�
��
� �
��� � �
If
�����
��� ��
isth
eco
rres
pond
ing
bum
pva
lue,
one
obta
ins
��
��������
�
�
��
�
Goo
dap
prox
imat
ion
for
the
norm
alve
ctor
:
��
�
��
�
�
��
�
whe
re
�
� � ����
��
�� � � �
� � ���
��
�� � � �
�
��
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
61/8
1
c
�
Bu
mp
map
pin
g
Gen
erat
ing
a3D
impr
essi
onus
ing
abu
mp
map
ping
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
62/8
1
c
�
Java
3D:
Text
ure
s
Load
anim
age
toan
ImageComponent2D
.
The
heig
htan
dth
ew
idth
ofth
eImageComponent2D
mus
tbe
pow
ers
oftw
o.
TextureLoader
textureLoad
=new
TextureLoader("image.jpg",null);
ImageComponent2D
textureIm
=textureLoad.getScaledImage(128,128);
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
63/8
1
c
�
Java
3D:
Text
ure
s
Gen
erat
eaTextur2D
,whi
chca
nbe
assi
gned
toan
Appearance
.
Texture2D
myTexture
=new
Texture2D(
Texture2D.BASE_LEVEL,Texture2D.RGB,
textureIm.getWidth(),
textureIm.getHeight());
myTexture.setImage(0,textureIm);
Appearance
textureApp
=new
Appearance();
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
64/8
1
c
�
Java
3D:
Text
ure
s
textureApp.setTexture(myTexture);
TextureAttributes
textureAttr
=new
TextureAttributes();
textureAttr.setTextureMode(
TextureAttributes.REPLACE);
textureApp.setTextureAttributes(
textureAttr);
textureApp.setMaterial(
new
Material());
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
65/8
1
c
�
TextureExample.java
Inpr
inci
ple,
itca
nbe
spec
ified
inde
tail
how
tom
apth
ete
xtur
eto
the
surf
ace.
TexCoordGeneration
offe
ra
sim
ple
tom
apte
xtur
esau
tom
atic
aclly
tosu
rfac
es.
TexCoordGeneration
tcg
=new
TexCoordGeneration(
TexCoordGeneration.OBJECT_LINEAR,
TexCoordGeneration.TEXTURE_COORDINATE_2);
textureApp.setTexCoordGeneration(tcg);
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
66/8
1
c
�
Java
3D:
Text
ure
s
Text
ures
asba
ckgr
ound
inJa
va3D
:
TextureLoader
textureLoad
=new
TextureLoader("image.jpg",null);
Background
bg
=new
Background(textureLoad.getImage());
bg.setApplicationBounds(bounds);
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
67/8
1
c
�
Java
3D:
Text
ure
s
bounds
is,f
orin
stan
ce,a
BoundingSphere
spec
ifyin
gth
ere
gion
whe
reth
ete
xtur
esh
ould
beus
edas
back
grou
nd.
Add
the
back
grou
ndto
the
scen
e:theScene.addChild(bg);
Inst
ead
ofa
back
grou
ndim
age,
aco
lour
can
beas
sign
edto
the
back
grou
nd:
Background
bg
=new
Background(colour);
(see
BackgroundExample.java
)
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
68/8
1
c
�
Rad
iosi
tym
od
el
So
far:
Illum
inat
ion
ofob
ject
son
lyby
expl
icit
light
sour
ces
and
gene
rala
mbi
entl
ight
,no
refle
ctio
nof
light
betw
een
obje
cts.
Lead
sto
shar
ped
ges.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
69/8
1
c
�
Rad
iosi
tym
od
el
Rad
iosi
ty:
Rat
eof
ener
gyem
itted
bya
surf
ace
� �
inth
efo
rmof
light
.
Rad
iosi
tyis
the
supe
rpos
ition
ofth
ese
lf-em
itted
,re
flect
edan
d,in
case
oftr
ansp
aren
cy,l
ight
from
the
back
.
Rad
iosi
tym
od
el:
Eac
hsu
rfac
eis
cons
ider
edas
light
sour
ce.
Inte
ract
ion
ofth
elig
htbe
twee
nsu
rfac
esis
inde
pend
ento
fthe
posi
tion
ofth
evi
ewer
whe
non
lydi
ffuse
refle
ctio
nis
cons
ider
ed.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
70/8
1
c
�
Rad
iosi
tyeq
uat
ion
� �
� �����
�� ���
�
� ��
� ��
�
� � � �
�
� � :R
ate
ofen
ergy
com
ing
from
��
mea
sure
din
(ene
rgy/
time)
/are
a
�
� � :R
ate
atw
hich
light
isem
itted
from
surf
ace
� �
asan
activ
elig
htso
urce
(sel
f-em
ittin
g).
���
:R
eflec
tion
coef
ficie
ntof
the
surf
ace
� �
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
71/8
1
c
�
Rad
iosi
tyeq
uat
ion
�
� ��
:D
imen
sion
less
form
and
confi
gura
tion
fact
orta
king
the
shap
e,th
esi
zean
dth
ere
lativ
eor
ient
atio
nof
the
surf
aces
� �
and
��
into
acco
unt.
�
� � :A
rea
ofth
esu
rfac
e
�Tr
ansp
aren
cyis
notc
onsi
dere
dhe
re. C
ompu
ter
Gra
phic
s:Ill
umin
atio
nan
dsh
adin
g–
p.72
/81
c
�
Rad
iosi
tyeq
uat
ion
Whe
non
lydi
ffuse
refle
ctio
nis
take
nin
toac
coun
t:
� �� �
�
� �
� ��T
here
fore
,
� �
� �� ��
�� ���
�
� ��
� ��
i.e.
� �
��
�� ���
�
� ��
� ��
� � �
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
73/8
1
c
�
Rad
iosi
tyeq
uat
ion
� �������������������������� � ���
�� � ���
�� � ���
��� � �
��� � � �
��� � �
. . .. . .
. . .. . .
��� � �
��� � �
��� � � �
� ������������������������
� ������������������������ � � � . . . � �� �����������������������
�� ������������������������ � � � . . . � �� �����������������������
Thi
ssy
stem
oflin
ear
equa
tions
mus
tbe
solv
edfo
rth
epr
imar
yco
lour
sre
d,gr
een
and
blue
.
(��
and
� �
depe
ndon
the
colo
ur.)
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
74/8
1
c
�
Rad
iosi
tym
od
el
n
n
dA
dA
q
q
i
ii
j
jj
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
75/8
1
c
�
Rad
iosi
tym
od
el
For
mfa
ktor
from
the
patc
h(d
iffer
entia
lare
a)�� �
toth
epa
tch
�� � :
�� �
� ���
����� ������� �
��
��
�
� ���
�� �
� ��
�
if�� �
isvi
sibl
efr
om
�� �
�
othe
rwis
e Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
76/8
1
c
�
Rad
iosi
tym
od
el
For
mfa
ctor
from
the
patc
h(d
iffer
entia
lare
a)�� �
to
� � :
�� �
� ��
� ������ ������� �
��
��
�
� ��
�� �
For
mfa
ctor
from
the
surf
ace
� �to
the
surf
ace
� � :
� � ��
� � �
� �
� ������ ������� �
��
��
�
� ��
�� �
�� �
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
77/8
1
c
�
Rad
iosi
tym
od
el
Ai
App
roxi
mat
ion
ofth
efo
rmfa
ctor
:P
ropo
rtio
nof
the
circ
leth
atis
cove
red
byth
ispr
ojec
tion. C
ompu
ter
Gra
phic
s:Ill
umin
atio
nan
dsh
adin
g–
p.78
/81
c
�
Rad
iosi
tym
od
el
App
roxi
mat
eso
lutio
nof
the
syst
emof
linea
req
uatio
nsof
the
radi
osity
equa
tion:
Ste
pwis
ere
finem
ent.
Itera
tive
com
puta
tion
ofth
e
� � .
1.S
etea
ch
� �
� �
and
�� �
� � .
2.C
hoos
e
� ���
with
the
larg
est
�� ���
.
3.U
pdat
eea
ch
� �
and
�� ���
� (new
)
�
� (old
)�
� ��
�� ����
��� ���
�� (n
ew)
�
� � �
�� (o
ld)
�
� ��
�� ����
��� ���
if
�
� ���
�
if
�
���
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
79/8
1
c
�
Rad
iosi
tym
od
el
Rep
eats
teps
2an
d3
until
the
chan
ges
are
negl
ecta
ble
orth
em
axim
umnu
mbe
rof
itera
tion
step
sis
reac
hed.
Adv
anta
geof
the
step
wis
ere
finem
ent:
Can
bete
rmin
ated
any
time
and
impr
oves
shad
ing
step
wis
e.
Spe
cula
rre
flect
ion
has
tobe
adde
daf
terw
ards
.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
80/8
1
c
�
Ray
trac
ing
Rec
ursi
vera
ytr
acin
gfo
rre
alis
ticsp
ecul
arre
flect
ion.
Com
pute
rG
raph
ics:
Illum
inat
ion
and
shad
ing
–p.
81/8
1
Recommended