Class: PBRMaterial

PBRMaterial

new PBRMaterial(params)

PBR材质

Name Type Description
params Object optional

初始化参数,所有params都会复制到实例上

Name Type Default Description
lightType string PBR optional

光照类型,只能为 PBR 或 NONE

baseColor Color new Color(1, 1, 1) optional

基础颜色

baseColorMap Texture optional

基础颜色贴图(sRGB空间)

metallic number 1 optional

金属度

metallicMap Texture optional

金属度贴图

roughness number 1 optional

粗糙度

roughnessMap Texture optional

粗糙度贴图

occlusionMap Texture optional

环境光遮蔽贴图

occlusionStrength number 1 optional

环境光遮蔽强度

emission Texture | Color optional

放射光贴图(sRGB 空间),或颜色

diffuseEnvMap Texture optional

漫反射辐照(Diffuse IBL)贴图

diffuseEnvSphereHarmonics3 SphericalHarmonics3 optional

漫反射 SphericalHarmonics3

diffuseEnvIntensity number 1 optional

漫反射强度

specularEnvMap Texture optional

环境反射(Specular IBL)贴图

brdfLUT Texture optional

BRDF贴图,跟环境反射贴图一起使用

specularEnvIntensity number 1 optional

环境反射(Specular IBL)贴图强度

[value:string] any optional

其它属性

Example
const material = new Hilo3d.PBRMaterial();

Extends

Members Show Inherited

Name Type Default Description
isPBRMaterial boolean true
className string PBRMaterial
lightType 'PBR' | 'NONE' PBR

光照类型,只能为 PBR 或 NONE

gammaCorrection Boolean true

gammaCorrection

usePhysicsLight Boolean true

是否使用物理灯光

baseColor Color null

基础颜色

baseColorMap Texture null

基础颜色贴图(sRGB空间)

metallic Number 1

金属度

metallicMap Texture null

金属度贴图

roughness Number 1

粗糙度

roughnessMap Texture null

粗糙度贴图

metallicRoughnessMap Texture null

金属度及粗糙度贴图,金属度为B通道,粗糙度为G通道,可以指定R通道作为环境光遮蔽

occlusionMap Texture null

环境光遮蔽贴图

occlusionStrength Number 1

环境光遮蔽强度

isOcclusionInMetallicRoughnessMap boolean false

环境光遮蔽贴图(occlusionMap)包含在 metallicRoughnessMap 的R通道中

diffuseEnvMap CubeTexture | Texture null

漫反射辐照(Diffuse IBL)贴图

diffuseEnvSphereHarmonics3 SphericalHarmonics3

漫反射 SphericalHarmonics3

diffuseEnvIntensity Number 1

漫反射环境强度

brdfLUT Texture null

BRDF贴图,跟环境反射贴图一起使用 示例

specularEnvIntensity Number 1

环境反射(Specular IBL)贴图强度

specularEnvMap CubeTexture | Texture null

环境反射(Specular IBL)贴图

isSpecularEnvMapIncludeMipmaps boolean false

环境反射是否包含 mipmaps

emission Texture null

放射光贴图(sRGB 空间)

emissionFactor Color new Color(0, 0, 0)

The emissive color of the material.

isSpecularGlossiness boolean false

是否基于反射光泽度的 PBR,具体见 KHR_materials_pbrSpecularGlossiness

specular Color Color(1, 1, 1)

镜面反射率,针对 isSpecularGlossiness 渲染

glossiness number 1

光泽度,针对 isSpecularGlossiness 渲染,默认PBR无效

specularGlossinessMap Texture null

镜面反射即光泽度贴图,RGB 通道为镜面反射率,A 通道为光泽度

clearcoatFactor number 0

The clearcoat layer intensity.

clearcoatMap Texture null

The clearcoat layer intensity texture.

clearcoatRoughnessFactor number 0

The clearcoat layer roughness.

clearcoatRoughnessMap Texture null

The clearcoat layer roughness texture.

clearcoatNormalMap Texture null

The clearcoat normal map texture.

isMaterial boolean true inherited
name string inherited

name

shaderCacheId string null inherited

shader cache id

shaderName string null inherited

shader name,会在 shader 中加个 SHADER_NAME 宏,不填用 className 代替。

wireframe boolean false inherited

是否开启网格模式

frontFace GLenum CCW inherited

front face winding orientation

depthTest boolean true inherited

是否开启深度测试

sampleAlphaToCoverage Boolean false inherited

SAMPLE_ALPHA_TO_COVERAGE

depthMask boolean true inherited

是否开启depthMask

depthRange Array [0, 1] inherited

深度测试Range

depthFunc GLenum LESS inherited

深度测试方法

normalMap Texture null inherited

法线贴图

parallaxMap Texture null inherited

视差贴图

normalMapScale Number 1 inherited

法线贴图scale

ignoreTranparent Boolean false inherited

是否忽略透明度

isDiffuesEnvAndAmbientLightWorkTogether Boolean false inherited

是否环境贴图和环境光同时生效

userData any null inherited

用户数据

renderOrder Number 0 inherited

渲染顺序数字小的先渲染(透明物体和不透明在不同的队列)

premultiplyAlpha Boolean true inherited

是否预乘 alpha

gammaOutput Boolean false inherited

gammaOutput

gammaFactor Number 2.2 inherited

gamma值

castShadows Boolean true inherited

是否投射阴影

receiveShadows Boolean true inherited

是否接受阴影

uvMatrix Matrix3 inherited

uv transform eg:new Matrix3().fromRotationTranslationScale(Math.PI/2, 0, 0, 2, 2)

uvMatrix1 Matrix3 inherited

uv1 transform eg:new Matrix3().fromRotationTranslationScale(Math.PI/2, 0, 0, 2, 2)

cullFace boolean true inherited

是否开启 CullFace

cullFaceType GLenum BACK inherited

CullFace 类型

side GLenum FRONT inherited

显示面,可选值 FRONT, BACK, FRONT_AND_BACK

blend boolean false inherited

是否开启颜色混合

blendEquation GLenum FUNC_ADD inherited

颜色混合方式

blendEquationAlpha GLenum FUNC_ADD inherited

透明度混合方式

blendSrc GLenum ONE inherited

颜色混合来源比例

blendDst GLenum ZERO inherited

颜色混合目标比例

blendSrcAlpha GLenum ONE inherited

透明度混合来源比例

blendDstAlpha GLenum ONE inherited

透明度混合目标比例

stencilTest boolean 1 inherited

stencilTest

stencilMask number 0xff inherited

stencilMask

stencilFunc GLenum ALWAYS inherited

stencilFunc func

stencilFuncRef number 1 inherited

stencilFunc ref

stencilFuncMask number 0xff inherited

stencilFunc mask

stencilOpFail GLenum KEEP inherited

stencilOp fail

stencilOpZFail GLenum KEEP inherited

stencilOp zfail

stencilOpZPass GLenum KEEP inherited

stencilOp zpass

isDirty boolean false inherited

当前是否需要强制更新

transparency number 1 inherited

透明度 0~1

transparent boolean false inherited

是否需要透明

alphaCutoff number 0 inherited

透明度剪裁,如果渲染的颜色透明度大于等于这个值的话渲染为完全不透明,否则渲染为完全透明

useHDR Boolean false inherited

是否使用HDR

exposure Number 1 inherited

曝光度,仅在 useHDR 为 true 时生效

enableTextureLod Boolean false inherited

是否开启 texture lod

enableDrawBuffers Boolean false inherited

是否开启 drawBuffers

needBasicUnifroms Boolean true inherited

是否需要加基础 uniforms

needBasicAttributes Boolean true inherited

是否需要加基础 attributes

id string inherited
uniforms object {} inherited

可以通过指定,semantic来指定值的获取方式,或者自定义get方法

attributes object {} inherited

可以通过指定,semantic来指定值的获取方式,或者自定义get方法

Methods Show Inherited

inherited addBasicAttributes()

增加基础 attributes

增加基础 uniforms

inherited addTextureUniforms(textureUniforms)

增加贴图 uniforms

Name Type Description
textureUniforms Object

textureName:semanticName 键值对

inherited getRenderOption(option){Object}

获取渲染选项值

Name Type Default Description
option Object {} optional

渲染选项值

Returns:
Type Description
Object 渲染选项值

clone 当前Material

Returns:
Type Description
Material 返回clone的Material

销毁贴图

Returns:
Type Description
Material this

获取材质全部贴图

Returns:
Type Description
Array.<Texture>

inherited getShadowMaterial(shadowMaterial){Material}

获取阴影材质,子类可重写

Name Type Description
shadowMaterial Material

通用阴影材质

Returns:
Type Description
Material