light sources
- directed/parallel light source
position is point at infinity (x,y,z,0)^T - point light source
finite position (x,y,z,1)^T - spot
position, direction, opening angle - ambient light
type of reflection
- specular(mirror-like)
- diffuse
- mixed
reflection distribution
specular + glossy光滑 + diffuse = distribution
ideal diffuse reflection
reflected radiance is independent of reflection direction
Lambert s cosine law
d
I
=
L
d
A
1
c
o
s
θ
1
dI = LdA_1cos\theta_1
dI=LdA1cosθ1
computation:
I
d
i
f
f
u
s
e
=
k
d
I
l
i
g
h
t
c
o
s
θ
I_{diffuse} = k_d I_light cos\theta
Idiffuse=kdIlightcosθ
I
d
i
f
f
u
s
e
=
k
d
I
l
i
g
h
t
(
n
⋅
l
)
I_{diffuse} = k_d I_light (\textbf{n} \cdot \textbf{l})
Idiffuse=kdIlight(n⋅l)
n, l is normalized.
ideal specular reflection
refraction
n
1
s
i
n
θ
1
=
n
2
s
i
n
θ
2
n_1sin\theta_1 = n_2sin\theta_2
n1sinθ1=n2sinθ2
specular-diffuse reflection
- phong model
I p h o n g = k a I a + k d I d m a x ( n ⋅ l , 0 ) + k s I s m a x ( r ⋅ v , 0 ) α I_{phong} = k_aI_a + k_dI_dmax(n \cdot l,0)+k_sI_smax(r \cdot v,0)^\alpha Iphong=kaIa+kdIdmax(n⋅l,0)+ksIsmax(r⋅v,0)α
I p h o n g I_{phong} Iphong 最终光强
k a k_a ka 环境材质属性,反射系数,越大反射光越强
I a I_a Ia 环境光分量
k d k_d kd 漫反射材质
I d I_d Id 漫射光分量
n n n 表面法线的单位矢量
l l l 光线的单位矢量,方向指向光源
k s k_s ks 镜面反射材质属性
I s I_s Is 镜面光分量
r r r 反射光单位矢量
v v v 视线单位矢量,指向观察者
α \alpha α 材质的光泽度 - blinn-phong-model
shading variants(intepolation 插补)
- flat shading
one color per face - gouraud shading
one color per vertex, color on primitives get interpolated
color get calculated in the vertex shader - phong shading
one color per pixel
color get calculated in the fragment shader
Shading\Illumination | Toon | Lambert(+ambient) | Phong(+lambert+ambient) | Blinn-phong(+lambert+ambient) |
---|---|---|---|---|
Flat | No | No | No | No |
Gouraud | No | Ok | Ok | No |
Phong | Ok | Ok | Ok | Ok |
Resources
- <<Web高级编程:开发Web3D图形>>