材质
材质(Material)定义了物体在场景中的外观。
基本材质
MeshBasicMaterial
:不发光。MeshLambertMaterial
:会计算顶点的光照。MeshPhongMaterial
:会计算每一个像素的光照,并且支持镜面高亮。
shininess
可以设置MeshPhongMaterial
的镜面高亮程度。
信息
下图中设置三者不同的属性,最后达到的效果是一样的:
效果一样,为什么还要用三个不同的材质?
这是因为更复杂的材质会消耗更多的 GPU 算力,比如在手机上,可以使用简单材质节省 GPU 算力。
卡通材质
MeshToonMaterial
和 MeshPhongMaterial
类似,但是会使用渐变图(Gradient Map)来模拟卡通效果。
PBR 材质
2 种基于物理渲染(Physically Based Rendering, PBR)的材质,PBR 材质的特点是更加真实:
MeshStandardMaterial
:和MeshPhongMaterial
类似,但MeshPhongMaterial
使用shininess
属性,而MeshStandardMaterial
使用roughness
(粗糙性)和metalness
(金属性)属性。roughness
属性和shininess
属性刚好相反,值越大,材质越粗糙。metalness
属性表示材质的金属程度,值越大,材质越像金属。
MeshPhysicalMaterial
:和MeshStandardMaterial
类似,但MeshPhysicalMaterial
多了clearcoat
(清漆)和clearcoatRoughness
(清漆粗糙性)属性。
清漆是透明或者半透明的材质,覆盖在物体表面,可以提高物体表面的光泽度。 见视频:什么是清漆?清漆的基本概念
渲染速度从快到慢排序:
MeshBasicMaterial
MeshLambertMaterial
MeshPhongMaterial
MeshStandardMaterial
MeshPhysicalMaterial
渲染速度越慢,效果越真实,需要做好平衡。
其他材质
ShadowMaterial
:阴影材质。MeshDepthMaterial
:深度材质。MeshNormalMaterial
:法线材质。ShaderMaterial
:着色器材质。RawShaderMaterial
:原始着色器材质。