A Standard material is the main, general purpose material that is most often used for rendering. It can approximate a wide variety of surface types and can simulate dynamic reflected light. Most maps can use 3 types of input values in any combination: constant (color or number), mesh vertex colors and a texture. All enabled inputs are multiplied together.

Hierarchy (view full)

Constructors

Properties

alphaFade alphaTest alphaToCoverage ambient ambientTint anisotropy aoDetailMap aoDetailMapChannel aoDetailMapOffset aoDetailMapRotation aoDetailMapTiling aoDetailMapUv aoDetailMode aoMap aoMapChannel aoMapOffset aoMapRotation aoMapTiling aoMapUv aoVertexColor aoVertexColorChannel attenuation attenuationDistance bumpiness clearCoat clearCoatBumpiness clearCoatGloss clearCoatGlossInvert clearCoatGlossMap clearCoatGlossMapChannel clearCoatGlossMapOffset clearCoatGlossMapRotation clearCoatGlossMapTiling clearCoatGlossMapUv clearCoatGlossVertexColor clearCoatGlossVertexColorChannel clearCoatMap clearCoatMapChannel clearCoatMapOffset clearCoatMapRotation clearCoatMapTiling clearCoatMapUv clearCoatNormalMap clearCoatNormalMapOffset clearCoatNormalMapRotation clearCoatNormalMapTiling clearCoatNormalMapUv clearCoatVertexColor clearCoatVertexColorChannel conserveEnergy cubeMap cubeMapProjection cubeMapProjectionBox cull diffuse diffuseDetailMap diffuseDetailMapChannel diffuseDetailMapOffset diffuseDetailMapRotation diffuseDetailMapTiling diffuseDetailMapUv diffuseDetailMode diffuseMap diffuseMapChannel diffuseMapOffset diffuseMapRotation diffuseMapTiling diffuseMapUv diffuseTint diffuseVertexColor diffuseVertexColorChannel dispersion emissive emissiveIntensity emissiveMap emissiveMapChannel emissiveMapOffset emissiveMapRotation emissiveMapTiling emissiveMapUv emissiveTint emissiveVertexColor emissiveVertexColorChannel enableGGXSpecular envAtlas fresnelModel gloss glossInvert glossMap glossMapChannel glossMapOffset glossMapRotation glossMapTiling glossMapUv glossVertexColor glossVertexColorChannel heightMap heightMapChannel heightMapFactor heightMapOffset heightMapRotation heightMapTiling heightMapUv iridescenceMap iridescenceMapChannel iridescenceMapOffset iridescenceMapRotation iridescenceMapTiling iridescenceMapUv iridescenceRefractionIndex iridescenceThicknessMap iridescenceThicknessMapChannel iridescenceThicknessMapOffset iridescenceThicknessMapRotation iridescenceThicknessMapTiling iridescenceThicknessMapUv iridescenceThicknessMax iridescenceThicknessMin lightMap lightMapChannel lightMapOffset lightMapRotation lightMapTiling lightMapUv lightVertexColor lightVertexColorChannel metalness metalnessMap metalnessMapChannel metalnessMapOffset metalnessMapRotation metalnessMapTiling metalnessMapUv metalnessVertexColor metalnessVertexColorChannel name normalDetailMap normalDetailMapBumpiness normalDetailMapOffset normalDetailMapRotation normalDetailMapTiling normalDetailMapUv normalMap normalMapOffset normalMapRotation normalMapTiling normalMapUv occludeDirect occludeSpecular occludeSpecularIntensity onUpdateShader opacity opacityDither opacityFadesSpecular opacityMap opacityMapChannel opacityMapOffset opacityMapRotation opacityMapTiling opacityMapUv opacityShadowDither opacityVertexColor opacityVertexColorChannel pixelSnap reflectivity refraction refractionIndex refractionMap refractionMapChannel refractionMapOffset refractionMapRotation refractionMapTiling refractionMapUv refractionVertexColor refractionVertexColorChannel shadingModel sheen sheenGloss sheenGlossInvert sheenGlossMap sheenGlossMapChannel sheenGlossMapOffset sheenGlossMapRotation sheenGlossMapTiling sheenGlossMapUv sheenGlossTint sheenGlossVertexColor sheenGlossVertexColorChannel sheenMap sheenMapChannel sheenMapOffset sheenMapRotation sheenMapTiling sheenMapUv sheenTint sheenVertexColor specular specularityFactor specularityFactorMap specularityFactorMapChannel specularityFactorMapOffset specularityFactorMapRotation specularityFactorMapTiling specularityFactorMapUv specularityFactorTint specularityFactorVertexColor specularityFactorVertexColorChannel specularMap specularMapChannel specularMapOffset specularMapRotation specularMapTiling specularMapUv specularTint specularVertexColor specularVertexColorChannel sphereMap stencilBack stencilFront thickness thicknessMap thicknessMapChannel thicknessMapOffset thicknessMapRotation thicknessMapTiling thicknessMapUv thicknessVertexColor twoSidedLighting useDynamicRefraction useFog useGammaTonemap useIridescence useLighting useMetalness useMetalnessSpecularColor userId useSheen useSkybox

Accessors

Methods

Constructors

  • Create a new StandardMaterial instance.

    Returns StandardMaterial

    // Create a new Standard material
    const material = new pc.StandardMaterial();

    // Update the material's diffuse and specular properties
    material.diffuse.set(1, 0, 0);
    material.specular.set(1, 1, 1);

    // Notify the material that it has been modified
    material.update();
    // Create a new Standard material
    const material = new pc.StandardMaterial();

    // Assign a texture to the diffuse slot
    material.diffuseMap = texture;

    // Use the alpha channel of the texture for alpha testing with a reference value of 0.5
    material.opacityMap = texture;
    material.alphaTest = 0.5;

    // Notify the material that it has been modified
    material.update();

Properties

alphaFade: number

Used to fade out materials when StandardMaterial#opacityFadesSpecular is set to false.

alphaTest: number = 0

The alpha test reference value to control which fragments are written to the currently active render target based on alpha value. All fragments with an alpha value of less than the alphaTest reference value will be discarded. alphaTest defaults to 0 (all fragments pass).

alphaToCoverage: boolean = false

Enables or disables alpha to coverage (WebGL2 only). When enabled, and if hardware anti-aliasing is on, limited order-independent transparency can be achieved. Quality depends on the number of MSAA samples of the current render target. It can nicely soften edges of otherwise sharp alpha cutouts, but isn't recommended for large area semi-transparent surfaces. Note, that you don't need to enable blending to make alpha to coverage work. It will work without it, just like alphaTest.

ambient: Color

The ambient color of the material. This color value is 3-component (RGB), where each component is between 0 and 1.

ambientTint: boolean

Enables scene ambient multiplication by material ambient color.

anisotropy: number

Defines amount of anisotropy. Requires StandardMaterial#enableGGXSpecular is set to true.

  • When anisotropy == 0, specular is isotropic.
  • When anisotropy < 0, anisotropy direction aligns with the tangent, and specular anisotropy increases as the anisotropy value decreases to minimum of -1.
  • When anisotropy > 0, anisotropy direction aligns with the bi-normal, and specular anisotropy increases as anisotropy value increases to maximum of 1.
aoDetailMap: Texture | null

The detail (secondary) baked ambient occlusion (AO) map of the material (default is null). Will only be used if main (primary) ao map is non-null.

aoDetailMapChannel: string

Color channels of the detail (secondary) AO map to use. Can be "r", "g", "b" or "a" (default is "g").

aoDetailMapOffset: Vec2

Controls the 2D offset of the detail (secondary) AO map. Each component is between 0 and 1.

aoDetailMapRotation: number

Controls the 2D rotation (in degrees) of the detail (secondary) AO map.

aoDetailMapTiling: Vec2

Controls the 2D tiling of the detail (secondary) AO map.

aoDetailMapUv: number

Detail (secondary) AO map UV channel.

aoDetailMode: string

Determines how the main (primary) and detail (secondary) AO maps are blended together. Can be:

  • DETAILMODE_MUL: Multiply together the primary and secondary colors.
  • DETAILMODE_ADD: Add together the primary and secondary colors.
  • DETAILMODE_SCREEN: Softer version of DETAILMODE_ADD.
  • DETAILMODE_OVERLAY: Multiplies or screens the colors, depending on the primary color.
  • DETAILMODE_MIN: Select whichever of the primary and secondary colors is darker, component-wise.
  • DETAILMODE_MAX: Select whichever of the primary and secondary colors is lighter, component-wise.

Defaults to DETAILMODE_MUL.

aoMap: Texture | null

The main (primary) baked ambient occlusion (AO) map (default is null). Modulates ambient color.

aoMapChannel: string

Color channel of the main (primary) AO map to use. Can be "r", "g", "b" or "a".

aoMapOffset: Vec2

Controls the 2D offset of the main (primary) AO map. Each component is between 0 and 1.

aoMapRotation: number

Controls the 2D rotation (in degrees) of the main (primary) AO map.

aoMapTiling: Vec2

Controls the 2D tiling of the main (primary) AO map.

aoMapUv: number

Main (primary) AO map UV channel

aoVertexColor: boolean

Use mesh vertex colors for AO. If aoMap is set, it'll be multiplied by vertex colors.

aoVertexColorChannel: string

Vertex color channels to use for AO. Can be "r", "g", "b" or "a".

attenuation: Color

The attenuation color for refractive materials, only used when useDynamicRefraction is enabled.

attenuationDistance: number

The distance defining the absorption rate of light within the medium. Only used when useDynamicRefraction is enabled.

bumpiness: number

The bumpiness of the material. This value scales the assigned main (primary) normal map. It should be normally between 0 (no bump mapping) and 1 (full bump mapping), but can be set to e.g. 2 to give even more pronounced bump effect.

clearCoat: number

Defines intensity of clearcoat layer from 0 to 1. Clearcoat layer is disabled when clearCoat == 0. Default value is 0 (disabled).

clearCoatBumpiness: number

The bumpiness of the clearcoat layer. This value scales the assigned main clearcoat normal map. It should be normally between 0 (no bump mapping) and 1 (full bump mapping), but can be set to e.g. 2 to give even more pronounced bump effect.

clearCoatGloss: number

Defines the clearcoat glossiness of the clearcoat layer from 0 (rough) to 1 (mirror).

clearCoatGlossInvert: boolean

Invert the clearcoat gloss component (default is false). Enabling this flag results in material treating the clear coat gloss members as roughness.

clearCoatGlossMap: Texture | null

Monochrome clearcoat glossiness map (default is null). If specified, will be multiplied by normalized 'clearCoatGloss' value and/or vertex colors.

clearCoatGlossMapChannel: string

Color channel of the clearcoat gloss map to use. Can be "r", "g", "b" or "a".

clearCoatGlossMapOffset: Vec2

Controls the 2D offset of the clearcoat gloss map. Each component is between 0 and 1.

clearCoatGlossMapRotation: number

Controls the 2D rotation (in degrees) of the clear coat gloss map.

clearCoatGlossMapTiling: Vec2

Controls the 2D tiling of the clearcoat gloss map.

clearCoatGlossMapUv: number

Clearcoat gloss map UV channel.

clearCoatGlossVertexColor: boolean

Use mesh vertex colors for clearcoat glossiness. If clearCoatGlossMap is set, it'll be multiplied by vertex colors.

clearCoatGlossVertexColorChannel: string

Vertex color channel to use for clearcoat glossiness. Can be "r", "g", "b" or "a".

clearCoatMap: Texture | null

Monochrome clearcoat intensity map (default is null). If specified, will be multiplied by normalized 'clearCoat' value and/or vertex colors.

clearCoatMapChannel: string

Color channel of the clearcoat intensity map to use. Can be "r", "g", "b" or "a".

clearCoatMapOffset: Vec2

Controls the 2D offset of the clearcoat intensity map. Each component is between 0 and 1.

clearCoatMapRotation: number

Controls the 2D rotation (in degrees) of the clearcoat intensity map.

clearCoatMapTiling: Vec2

Controls the 2D tiling of the clearcoat intensity map.

clearCoatMapUv: number

Clearcoat intensity map UV channel.

clearCoatNormalMap: Texture | null

The clearcoat normal map of the material (default is null). The texture must contains normalized, tangent space normals.

clearCoatNormalMapOffset: Vec2

Controls the 2D offset of the main clearcoat normal map. Each component is between 0 and 1.

clearCoatNormalMapRotation: number

Controls the 2D rotation (in degrees) of the main clearcoat map.

clearCoatNormalMapTiling: Vec2

Controls the 2D tiling of the main clearcoat normal map.

clearCoatNormalMapUv: number

Clearcoat normal map UV channel.

clearCoatVertexColor: boolean

Use mesh vertex colors for clearcoat intensity. If clearCoatMap is set, it'll be multiplied by vertex colors.

clearCoatVertexColorChannel: string

Vertex color channel to use for clearcoat intensity. Can be "r", "g", "b" or "a".

conserveEnergy: boolean

Defines how diffuse and specular components are combined when Fresnel is on. It is recommended that you leave this option enabled, although you may want to disable it in case when all reflection comes only from a few light sources, and you don't use an environment map, therefore having mostly black reflection.

cubeMap: Texture | null

The cubic environment map of the material (default is null). This setting overrides sphereMap and will replace the scene lighting environment.

cubeMapProjection: number

The type of projection applied to the cubeMap property:

  • CUBEPROJ_NONE: The cube map is treated as if it is infinitely far away.
  • CUBEPROJ_BOX: Box-projection based on a world space axis-aligned bounding box. Defaults to CUBEPROJ_NONE.
cubeMapProjectionBox: BoundingBox

The world space axis-aligned bounding box defining the box-projection used for the cubeMap property. Only used when cubeMapProjection is set to CUBEPROJ_BOX.

cull: number = CULLFACE_BACK

Controls how triangles are culled based on their face direction with respect to the viewpoint. Can be:

  • CULLFACE_NONE: Do not cull triangles based on face direction.
  • CULLFACE_BACK: Cull the back faces of triangles (do not render triangles facing away from the view point).
  • CULLFACE_FRONT: Cull the front faces of triangles (do not render triangles facing towards the view point).

Defaults to CULLFACE_BACK.

diffuse: Color

The diffuse color of the material. This color value is 3-component (RGB), where each component is between 0 and 1. Defines basic surface color (aka albedo).

diffuseDetailMap: Texture | null

The detail (secondary) diffuse map of the material (default is null). Will only be used if main (primary) diffuse map is non-null.

diffuseDetailMapChannel: string

Color channels of the detail (secondary) diffuse map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.

diffuseDetailMapOffset: Vec2

Controls the 2D offset of the detail (secondary) diffuse map. Each component is between 0 and 1.

diffuseDetailMapRotation: number

Controls the 2D rotation (in degrees) of the main (secondary) diffuse map.

diffuseDetailMapTiling: Vec2

Controls the 2D tiling of the detail (secondary) diffuse map.

diffuseDetailMapUv: number

Detail (secondary) diffuse map UV channel.

diffuseDetailMode: string

Determines how the main (primary) and detail (secondary) diffuse maps are blended together. Can be:

  • DETAILMODE_MUL: Multiply together the primary and secondary colors.
  • DETAILMODE_ADD: Add together the primary and secondary colors.
  • DETAILMODE_SCREEN: Softer version of DETAILMODE_ADD.
  • DETAILMODE_OVERLAY: Multiplies or screens the colors, depending on the primary color.
  • DETAILMODE_MIN: Select whichever of the primary and secondary colors is darker, component-wise.
  • DETAILMODE_MAX: Select whichever of the primary and secondary colors is lighter, component-wise.

Defaults to DETAILMODE_MUL.

diffuseMap: Texture | null

The main (primary) diffuse map of the material (default is null).

diffuseMapChannel: string

Color channels of the main (primary) diffuse map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.

diffuseMapOffset: Vec2

Controls the 2D offset of the main (primary) diffuse map. Each component is between 0 and 1.

diffuseMapRotation: number

Controls the 2D rotation (in degrees) of the main (primary) diffuse map.

diffuseMapTiling: Vec2

Controls the 2D tiling of the main (primary) diffuse map.

diffuseMapUv: number

Main (primary) diffuse map UV channel.

diffuseTint: boolean

Multiply main (primary) diffuse map and/or diffuse vertex color by the constant diffuse value.

diffuseVertexColor: boolean

Use mesh vertex colors for diffuse. If diffuseMap or are diffuseTint are set, they'll be multiplied by vertex colors.

diffuseVertexColorChannel: string

Vertex color channels to use for diffuse. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.

dispersion: number

The strength of the angular separation of colors (chromatic aberration) transmitting through a volume. Defaults to 0, which is equivalent to no dispersion.

emissive: Color

The emissive color of the material. This color value is 3-component (RGB), where each component is between 0 and 1.

emissiveIntensity: number

Emissive color multiplier.

emissiveMap: Texture | null

The emissive map of the material (default is null). Can be HDR.

emissiveMapChannel: string

Color channels of the emissive map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.

emissiveMapOffset: Vec2

Controls the 2D offset of the emissive map. Each component is between 0 and 1.

emissiveMapRotation: number

Controls the 2D rotation (in degrees) of the emissive map.

emissiveMapTiling: Vec2

Controls the 2D tiling of the emissive map.

emissiveMapUv: number

Emissive map UV channel.

emissiveTint: boolean

Multiply emissive map and/or emissive vertex color by the constant emissive value.

emissiveVertexColor: boolean

Use mesh vertex colors for emission. If emissiveMap or emissiveTint are set, they'll be multiplied by vertex colors.

emissiveVertexColorChannel: string

Vertex color channels to use for emission. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.

enableGGXSpecular: boolean

Enables GGX specular. Also enables StandardMaterial#anisotropy parameter to set material anisotropy.

envAtlas: Texture | null

The prefiltered environment lighting atlas (default is null). This setting overrides cubeMap and sphereMap and will replace the scene lighting environment.

fresnelModel: number

Defines the formula used for Fresnel effect. As a side-effect, enabling any Fresnel model changes the way diffuse and reflection components are combined. When Fresnel is off, legacy non energy-conserving combining is used. When it is on, combining behavior is defined by conserveEnergy parameter.

  • FRESNEL_NONE: No Fresnel.
  • FRESNEL_SCHLICK: Schlick's approximation of Fresnel (recommended). Parameterized by specular color.
gloss: number

Defines the glossiness of the material from 0 (rough) to 1 (shiny).

glossInvert: boolean

Invert the gloss component (default is false). Enabling this flag results in material treating the gloss members as roughness.

glossMap: Texture | null

Gloss map (default is null). If specified, will be multiplied by normalized gloss value and/or vertex colors.

glossMapChannel: string

Color channel of the gloss map to use. Can be "r", "g", "b" or "a".

glossMapOffset: Vec2

Controls the 2D offset of the gloss map. Each component is between 0 and 1.

glossMapRotation: number

Controls the 2D rotation (in degrees) of the gloss map.

glossMapTiling: Vec2

Controls the 2D tiling of the gloss map.

glossMapUv: number

Gloss map UV channel.

glossVertexColor: boolean

Use mesh vertex colors for glossiness. If glossMap is set, it'll be multiplied by vertex colors.

glossVertexColorChannel: string

Vertex color channel to use for glossiness. Can be "r", "g", "b" or "a".

heightMap: Texture | null

The height map of the material (default is null). Used for a view-dependent parallax effect. The texture must represent the height of the surface where darker pixels are lower and lighter pixels are higher. It is recommended to use it together with a normal map.

heightMapChannel: string

Color channel of the height map to use. Can be "r", "g", "b" or "a".

heightMapFactor: number

Height map multiplier. Affects the strength of the parallax effect.

heightMapOffset: Vec2

Controls the 2D offset of the height map. Each component is between 0 and 1.

heightMapRotation: number

Controls the 2D rotation (in degrees) of the height map.

heightMapTiling: Vec2

Controls the 2D tiling of the height map.

heightMapUv: number

Height map UV channel.

iridescenceMap: Texture | null

The per-pixel iridescence intensity. Only used when useIridescence is enabled.

iridescenceMapChannel: string

Color channels of the iridescence map to use. Can be "r", "g", "b" or "a".

iridescenceMapOffset: Vec2

Controls the 2D offset of the iridescence map. Each component is between 0 and 1.

iridescenceMapRotation: number

Controls the 2D rotation (in degrees) of the iridescence map.

iridescenceMapTiling: Vec2

Controls the 2D tiling of the iridescence map.

iridescenceMapUv: number

Iridescence map UV channel.

iridescenceRefractionIndex: number

The index of refraction of the iridescent thin-film. Affects the color phase shift as described here: https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_iridescence

iridescenceThicknessMap: Texture | null

The per-pixel iridescence thickness. Defines a gradient weight between iridescenceThicknessMin and iridescenceThicknessMax. Only used when useIridescence is enabled.

iridescenceThicknessMapChannel: string

Color channels of the iridescence thickness map to use. Can be "r", "g", "b" or "a".

iridescenceThicknessMapOffset: Vec2

Controls the 2D offset of the iridescence thickness map. Each component is between 0 and 1.

iridescenceThicknessMapRotation: number

Controls the 2D rotation (in degrees) of the iridescence map.

iridescenceThicknessMapTiling: Vec2

Controls the 2D tiling of the iridescence thickness map.

iridescenceThicknessMapUv: number

Iridescence thickness map UV channel.

iridescenceThicknessMax: number

The maximum thickness for the iridescence layer. Used as the 'base' thickness when no iridescence thickness map is defined. The unit is in nm.

iridescenceThicknessMin: number

The minimum thickness for the iridescence layer. Only used when an iridescence thickness map is used. The unit is in nm.

lightMap: Texture | null

A custom lightmap of the material (default is null). Lightmaps are textures that contain pre-rendered lighting. Can be HDR.

lightMapChannel: string

Color channels of the lightmap to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.

lightMapOffset: Vec2

Controls the 2D offset of the lightmap. Each component is between 0 and 1.

lightMapRotation: number

Controls the 2D rotation (in degrees) of the lightmap.

lightMapTiling: Vec2

Controls the 2D tiling of the lightmap.

lightMapUv: number

Lightmap UV channel

lightVertexColor: boolean

Use baked vertex lighting. If lightMap is set, it'll be multiplied by vertex colors.

lightVertexColorChannel: string

Vertex color channels to use for baked lighting. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.

metalness: number

Defines how much the surface is metallic. From 0 (dielectric) to 1 (metal).

metalnessMap: Texture | null

Monochrome metalness map (default is null).

metalnessMapChannel: string

Color channel of the metalness map to use. Can be "r", "g", "b" or "a".

metalnessMapOffset: Vec2

Controls the 2D offset of the metalness map. Each component is between 0 and 1.

metalnessMapRotation: number

Controls the 2D rotation (in degrees) of the metalness map.

metalnessMapTiling: Vec2

Controls the 2D tiling of the metalness map.

metalnessMapUv: number

Metalness map UV channel.

metalnessVertexColor: boolean

Use mesh vertex colors for metalness. If metalnessMap is set, it'll be multiplied by vertex colors.

metalnessVertexColorChannel: string

Vertex color channel to use for metalness. Can be "r", "g", "b" or "a".

name: string = 'Untitled'

The name of the material.

normalDetailMap: Texture | null

The detail (secondary) normal map of the material (default is null). Will only be used if main (primary) normal map is non-null.

normalDetailMapBumpiness: number

The bumpiness of the material. This value scales the assigned detail (secondary) normal map. It should be normally between 0 (no bump mapping) and 1 (full bump mapping), but can be set to e.g. 2 to give even more pronounced bump effect.

normalDetailMapOffset: Vec2

Controls the 2D offset of the detail (secondary) normal map. Each component is between 0 and 1.

normalDetailMapRotation: number

Controls the 2D rotation (in degrees) of the detail (secondary) normal map.

normalDetailMapTiling: Vec2

Controls the 2D tiling of the detail (secondary) normal map.

normalDetailMapUv: number

Detail (secondary) normal map UV channel.

normalMap: Texture | null

The main (primary) normal map of the material (default is null). The texture must contains normalized, tangent space normals.

normalMapOffset: Vec2

Controls the 2D offset of the main (primary) normal map. Each component is between 0 and 1.

normalMapRotation: number

Controls the 2D rotation (in degrees) of the main (primary) normal map.

normalMapTiling: Vec2

Controls the 2D tiling of the main (primary) normal map.

normalMapUv: number

Main (primary) normal map UV channel.

occludeDirect: boolean

Tells if AO should darken directional lighting. Defaults to false.

occludeSpecular: number

Uses ambient occlusion to darken specular/reflection. It's a hack, because real specular occlusion is view-dependent. However, it can be better than nothing.

  • SPECOCC_NONE: No specular occlusion
  • SPECOCC_AO: Use AO directly to occlude specular.
  • SPECOCC_GLOSSDEPENDENT: Modify AO based on material glossiness/view angle to occlude specular.
occludeSpecularIntensity: number

Controls visibility of specular occlusion.

onUpdateShader: any

A custom function that will be called after all shader generator properties are collected and before shader code is generated. This function will receive an object with shader generator settings (based on current material and scene properties), that you can change and then return. Returned value will be used instead. This is mostly useful when rendering the same set of objects, but with different shader variations based on the same material. For example, you may wish to render a depth or normal pass using textures assigned to the material, a reflection pass with simpler shaders and so on. These properties are split into two sections, generic standard material options and lit options. Properties of the standard material options are StandardMaterialOptions and the options for the lit options are LitShaderOptions.

opacity: number

The opacity of the material. This value can be between 0 and 1, where 0 is fully transparent and 1 is fully opaque. If you want the material to be semi-transparent you also need to set the Material#blendType to BLEND_NORMAL, BLEND_ADDITIVE or any other mode. Also note that for most semi-transparent objects you want Material#depthWrite to be false, otherwise they can fully occlude objects behind them.

opacityDither: string

Used to specify whether opacity is dithered, which allows transparency without alpha blending. Can be:

  • DITHER_NONE: Opacity dithering is disabled.
  • DITHER_BAYER8: Opacity is dithered using a Bayer 8 matrix.
  • DITHER_BLUENOISE: Opacity is dithered using a blue noise.
  • DITHER_IGNNOISE: Opacity is dithered using an interleaved gradient noise.

Defaults to DITHER_NONE.

opacityFadesSpecular: boolean

Used to specify whether specular and reflections are faded out using StandardMaterial#opacity. Default is true. When set to false use Material#alphaFade to fade out materials.

opacityMap: Texture | null

The opacity map of the material (default is null).

opacityMapChannel: string

Color channel of the opacity map to use. Can be "r", "g", "b" or "a".

opacityMapOffset: Vec2

Controls the 2D offset of the opacity map. Each component is between 0 and 1.

opacityMapRotation: number

Controls the 2D rotation (in degrees) of the opacity map.

opacityMapTiling: Vec2

Controls the 2D tiling of the opacity map.

opacityMapUv: number

Opacity map UV channel.

opacityShadowDither: boolean

Used to specify whether shadow opacity is dithered, which allows shadow transparency without alpha blending. Can be:

  • DITHER_NONE: Opacity dithering is disabled.
  • DITHER_BAYER8: Opacity is dithered using a Bayer 8 matrix.
  • DITHER_BLUENOISE: Opacity is dithered using a blue noise.
  • DITHER_IGNNOISE: Opacity is dithered using an interleaved gradient noise.

Defaults to DITHER_NONE.

opacityVertexColor: boolean

Use mesh vertex colors for opacity. If opacityMap is set, it'll be multiplied by vertex colors.

opacityVertexColorChannel: string

Vertex color channels to use for opacity. Can be "r", "g", "b" or "a".

pixelSnap: boolean

Align vertices to pixel coordinates when rendering. Useful for pixel perfect 2D graphics.

reflectivity: number

Environment map intensity.

refraction: number

Defines the visibility of refraction. Material can refract the same cube map as used for reflections.

refractionIndex: number

Defines the index of refraction, i.e. The amount of distortion. The value is calculated as (outerIor / surfaceIor), where inputs are measured indices of refraction, the one around the object and the one of its own surface. In most situations outer medium is air, so outerIor will be approximately 1. Then you only need to do (1.0 / surfaceIor).

refractionMap: Texture | null

The map of the refraction visibility.

refractionMapChannel: string

Color channels of the refraction map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.

refractionMapOffset: Vec2

Controls the 2D offset of the refraction map. Each component is between 0 and 1.

refractionMapRotation: number

Controls the 2D rotation (in degrees) of the emissive map.

refractionMapTiling: Vec2

Controls the 2D tiling of the refraction map.

refractionMapUv: number

Refraction map UV channel.

refractionVertexColor: boolean

Use mesh vertex colors for refraction. If refraction map is set, it will be be multiplied by vertex colors.

refractionVertexColorChannel: boolean

Vertex color channel to use for refraction. Can be "r", "g", "b" or "a".

shadingModel: number

Defines the shading model.

  • SPECULAR_PHONG: Phong without energy conservation. You should only use it as a backwards compatibility with older projects.
  • SPECULAR_BLINN: Energy-conserving Blinn-Phong.
sheen: Color

The specular color of the sheen (fabric) microfiber structure. This color value is 3-component (RGB), where each component is between 0 and 1.

sheenGloss: number

The glossiness of the sheen (fabric) microfiber structure. This color value is a single value between 0 and 1.

sheenGlossInvert: boolean

Invert the sheen gloss component (default is false). Enabling this flag results in material treating the sheen gloss members as roughness.

sheenGlossMap: Texture | null

The sheen glossiness microstructure color map of the material (default is null).

sheenGlossMapChannel: string

Color channels of the sheen glossiness map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.

sheenGlossMapOffset: Vec2

Controls the 2D offset of the sheen glossiness map. Each component is between 0 and 1.

sheenGlossMapRotation: number

Controls the 2D rotation (in degrees) of the sheen glossiness map.

sheenGlossMapTiling: Vec2

Controls the 2D tiling of the sheen glossiness map.

sheenGlossMapUv: number

Sheen map UV channel.

sheenGlossTint: boolean

Multiply sheen glossiness map and/or sheen glossiness vertex value by the scalar sheen glossiness value.

sheenGlossVertexColor: boolean

Use mesh vertex colors for sheen glossiness. If sheen glossiness map or sheen glossiness tint are set, they'll be multiplied by vertex colors.

sheenGlossVertexColorChannel: string

Vertex color channels to use for sheen glossiness. Can be "r", "g", "b" or "a".

sheenMap: Texture | null

The sheen microstructure color map of the material (default is null).

sheenMapChannel: string

Color channels of the sheen map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.

sheenMapOffset: Vec2

Controls the 2D offset of the sheen map. Each component is between 0 and 1.

sheenMapRotation: number

Controls the 2D rotation (in degrees) of the sheen map.

sheenMapTiling: Vec2

Controls the 2D tiling of the sheen map.

sheenMapUv: number

Sheen map UV channel.

sheenTint: boolean

Multiply sheen map and/or sheen vertex color by the constant sheen value.

sheenVertexColor: boolean

Use mesh vertex colors for sheen. If sheen map or sheen tint are set, they'll be multiplied by vertex colors.

specular: Color

The specular color of the material. This color value is 3-component (RGB), where each component is between 0 and 1. Defines surface reflection/specular color. Affects specular intensity and tint.

specularityFactor: number

The factor of specular intensity, used to weight the fresnel and specularity. Default is 1.0.

specularityFactorMap: Texture | null

The factor of specularity as a texture (default is null).

specularityFactorMapChannel: string

The channel used by the specularity factor texture to sample from (default is 'a').

specularityFactorMapOffset: Vec2

Controls the 2D offset of the specularity factor map. Each component is between 0 and 1.

specularityFactorMapRotation: number

Controls the 2D rotation (in degrees) of the specularity factor map.

specularityFactorMapTiling: Vec2

Controls the 2D tiling of the specularity factor map.

specularityFactorMapUv: number

Specularity factor map UV channel.

specularityFactorTint: boolean

Multiply specularity factor map and/or specular vertex color by the constant specular value. "r", "g", "b", "a", "rgb" or any swizzled combination.

specularityFactorVertexColor: boolean

Use mesh vertex colors for specularity factor. If specularityFactorMap or are specularityFactorTint are set, they'll be multiplied by vertex colors.

specularityFactorVertexColorChannel: string

Vertex color channels to use for specularity factor. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.

specularMap: Texture | null

The specular map of the material (default is null).

specularMapChannel: string

Color channels of the specular map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.

specularMapOffset: Vec2

Controls the 2D offset of the specular map. Each component is between 0 and 1.

specularMapRotation: number

Controls the 2D rotation (in degrees) of the specular map.

specularMapTiling: Vec2

Controls the 2D tiling of the specular map.

specularMapUv: number

Specular map UV channel.

specularTint: boolean

Multiply specular map and/or specular vertex color by the constant specular value.

specularVertexColor: boolean

Use mesh vertex colors for specular. If specularMap or are specularTint are set, they'll be multiplied by vertex colors.

specularVertexColorChannel: string

Vertex color channels to use for specular. Can be

sphereMap: Texture | null

The spherical environment map of the material (default is null). This will replace the scene lighting environment.

stencilBack: StencilParameters = null

Stencil parameters for back faces (default is null).

stencilFront: StencilParameters = null

Stencil parameters for front faces (default is null).

thickness: number

The thickness of the medium, only used when useDynamicRefraction is enabled. The unit is in base units, and scales with the size of the object.

thicknessMap: Texture | null

The per-pixel thickness of the medium, only used when useDynamicRefraction is enabled.

thicknessMapChannel: string

Color channels of the thickness map to use. Can be "r", "g", "b" or "a".

thicknessMapOffset: Vec2

Controls the 2D offset of the thickness map. Each component is between 0 and 1.

thicknessMapRotation: number

Controls the 2D rotation (in degrees) of the thickness map.

thicknessMapTiling: Vec2

Controls the 2D tiling of the thickness map.

thicknessMapUv: number

Thickness map UV channel.

thicknessVertexColor: boolean

Use mesh vertex colors for thickness. If thickness map is set, it will be be multiplied by vertex colors.

twoSidedLighting: boolean

Calculate proper normals (and therefore lighting) on backfaces.

useDynamicRefraction: boolean

Enables higher quality refractions using the grab pass instead of pre-computed cube maps for refractions.

useFog: boolean

Apply fogging (as configured in scene settings)

useGammaTonemap: boolean

Apply gamma correction and tonemapping (as configured in scene settings).

useIridescence: boolean

Enable thin-film iridescence.

useLighting: boolean

Apply lighting

useMetalness: boolean

Use metalness properties instead of specular. When enabled, diffuse colors also affect specular instead of the dedicated specular map. This can be used as alternative to specular color to save space. With metalness == 0, the pixel is assumed to be dielectric, and diffuse color is used as normal. With metalness == 1, the pixel is fully metallic, and diffuse color is used as specular color instead.

useMetalnessSpecularColor: boolean

When metalness is enabled, use the specular map to apply color tint to specular reflections. at direct angles.

userId: string = ''

A unique id the user can assign to the material. The engine internally does not use this for anything, and the user can assign a value to this id for any purpose they like. Defaults to an empty string.

useSheen: boolean

Toggle sheen specular effect on/off.

useSkybox: boolean

Apply scene skybox as prefiltered environment map

Accessors

  • get alphaWrite(): boolean
  • Gets whether the alpha channel is written to the color buffer.

    Returns boolean

  • set alphaWrite(value): void
  • Sets whether the alpha channel is written to the color buffer. If true, the red component of fragments generated by the shader of this material is written to the color buffer of the currently active render target. If false, the alpha component will not be written. Defaults to true.

    Parameters

    • value: boolean

    Returns void

  • get blueWrite(): boolean
  • Gets whether the blue channel is written to the color buffer.

    Returns boolean

  • set blueWrite(value): void
  • Sets whether the blue channel is written to the color buffer. If true, the red component of fragments generated by the shader of this material is written to the color buffer of the currently active render target. If false, the blue component will not be written. Defaults to true.

    Parameters

    • value: boolean

    Returns void

  • get depthBias(): number
  • Gets the offset for the output depth buffer value.

    Returns number

  • set depthBias(value): void
  • Sets the offset for the output depth buffer value. Useful for decals to prevent z-fighting. Typically a small negative value (-0.1) is used to render the mesh slightly closer to the camera.

    Parameters

    • value: number

    Returns void

  • get depthTest(): boolean
  • Gets whether depth testing is enabled.

    Returns boolean

  • set depthTest(value): void
  • Sets whether depth testing is enabled. If true, fragments generated by the shader of this material are only written to the current render target if they pass the depth test. If false, fragments generated by the shader of this material are written to the current render target regardless of what is in the depth buffer. Defaults to true.

    Parameters

    • value: boolean

    Returns void

  • get depthWrite(): boolean
  • Gets whether depth writing is enabled.

    Returns boolean

  • set depthWrite(value): void
  • Sets whether depth writing is enabled. If true, fragments generated by the shader of this material write a depth value to the depth buffer of the currently active render target. If false, no depth value is written. Defaults to true.

    Parameters

    • value: boolean

    Returns void

  • get greenWrite(): boolean
  • Gets whether the green channel is written to the color buffer.

    Returns boolean

  • set greenWrite(value): void
  • Sets whether the green channel is written to the color buffer. If true, the red component of fragments generated by the shader of this material is written to the color buffer of the currently active render target. If false, the green component will not be written. Defaults to true.

    Parameters

    • value: boolean

    Returns void

  • get redWrite(): boolean
  • Gets whether the red channel is written to the color buffer.

    Returns boolean

  • set redWrite(value): void
  • Sets whether the red channel is written to the color buffer. If true, the red component of fragments generated by the shader of this material is written to the color buffer of the currently active render target. If false, the red component will not be written. Defaults to true.

    Parameters

    • value: boolean

    Returns void

  • get slopeDepthBias(): number
  • Gets the offset for the output depth buffer value based on the slope of the triangle relative to the camera.

    Returns number

  • set slopeDepthBias(value): void
  • Sets the offset for the output depth buffer value based on the slope of the triangle relative to the camera.

    Parameters

    • value: number

    Returns void

Methods

  • Sets a vertex shader attribute on a material.

    Parameters

    • name: string

      The name of the parameter to set.

    • semantic: string

      Semantic to map the vertex data. Must match with the semantic set on vertex stream of the mesh.

    Returns void

    mesh.setVertexStream(pc.SEMANTIC_ATTR15, offset, 3);
    material.setAttribute('offset', pc.SEMANTIC_ATTR15);