l
i
g
h
t
V
e
c
t
o
r
=
l
i
g
h
t
P
o
s
i
t
i
o
n
W
S
?
p
o
s
i
t
i
o
n
W
S
lightVector = lightPositionWS - positionWS
lightVector=lightPositionWS?positionWS
向量归一化:
l
i
g
h
t
D
i
r
e
c
t
i
o
n
=
l
i
g
h
t
V
e
c
t
o
r
∣
l
i
g
h
t
V
e
c
t
o
r
∣
=
l
i
g
h
t
V
e
c
t
o
r
1
l
i
g
h
t
V
e
c
t
o
r
?
l
i
g
h
t
V
e
c
t
o
r
lightDirection = \frac{lightVector}{\lvert lightVector\rvert}=lightVector\frac{1}{\sqrt{lightVector·lightVector}}
lightDirection=∣lightVector∣lightVector?=lightVectorlightVector?lightVector?1?
最后,带入公式:
l
i
g
h
t
D
i
r
e
c
t
i
o
n
=
l
i
g
h
t
V
e
c
t
o
r
∣
l
i
g
h
t
V
e
c
t
o
r
∣
lightDirection = \frac{lightVector}{\lvert lightVector\rvert}
lightDirection=∣lightVector∣lightVector?,得到额外灯方向单位向量