API Reference

Class List

pc.StandardMaterial

Extends: pc.Material

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.

// Create a new Standard material
var 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();

Summary

Properties

ambientThe ambient color of the material.
ambientTintEnables scene ambient multiplication by material ambient color.
aoMapBaked ambient occlusion (AO) map.
aoMapChannelColor channel of the AO map to use.
aoMapOffsetControls the 2D offset of the AO map.
aoMapTilingControls the 2D tiling of the AO map.
aoMapUvAO map UV channel
aoVertexColorUse mesh vertex colors for AO.
aoVertexColorChannelVertex color channels to use for AO.
bumpinessThe bumpiness of the material.
conserveEnergyDefines how diffuse and specular components are combined when Fresnel is on.
cubeMapThe cubic environment map of the material.
cubeMapProjectionThe type of projection applied to the cubeMap property:
  • pc.CUBEPROJ_NONE: The cube map is treated as if it is infinitely far away.
cubeMapProjectionBoxThe world space axis-aligned bounding box defining the box-projection used for the cubeMap property.
diffuseThe diffuse color of the material.
diffuseMapThe diffuse map of the material.
diffuseMapChannelColor channels of the diffuse map to use.
diffuseMapOffsetControls the 2D offset of the diffuse map.
diffuseMapTilingControls the 2D tiling of the diffuse map.
diffuseMapUvDiffuse map UV channel
diffuseTintMultiply diffuse map and/or diffuse vertex color by the constant diffuse value.
diffuseVertexColorUse mesh vertex colors for diffuse.
diffuseVertexColorChannelVertex color channels to use for diffuse.
emissiveThe emissive color of the material.
emissiveIntensityEmissive color multiplier.
emissiveMapThe emissive map of the material.
emissiveMapChannelColor channels of the emissive map to use.
emissiveMapOffsetControls the 2D offset of the emissive map.
emissiveMapTilingControls the 2D tiling of the emissive map.
emissiveMapUvEmissive map UV channel.
emissiveTintMultiply emissive map and/or emissive vertex color by the constant emissive value.
emissiveVertexColorUse mesh vertex colors for emission.
emissiveVertexColorChannelVertex color channels to use for emission.
fresnelModelDefines the formula used for Fresnel effect.
glossMapGlossiness map.
glossMapChannelColor channel of the gloss map to use.
glossMapOffsetControls the 2D offset of the gloss map.
glossMapTilingControls the 2D tiling of the gloss map.
glossMapUvGloss map UV channel
glossVertexColorUse mesh vertex colors for glossiness.
glossVertexColorChannelVertex color channel to use for glossiness.
heightMapThe height map of the material.
heightMapChannelColor channel of the height map to use.
heightMapFactorHeight map multiplier.
heightMapOffsetControls the 2D offset of the height map.
heightMapTilingControls the 2D tiling of the height map.
heightMapUvHeight map UV channel
lightMapA custom lightmap of the material.
lightMapChannelColor channels of the lightmap to use.
lightMapOffsetControls the 2D offset of the lightmap.
lightMapTilingControls the 2D tiling of the lightmap.
lightMapUvLightmap UV channel
lightVertexColorUse baked vertex lighting.
lightVertexColorChannelVertex color channels to use for baked lighting.
metalnessDefines how much the surface is metallic.
metalnessMapMonochrome metalness map.
metalnessMapChannelColor channel of the metalness map to use.
metalnessMapOffsetControls the 2D offset of the metalness map.
metalnessMapTilingControls the 2D tiling of the metalness map.
metalnessMapUvMetalness map UV channel
metalnessVertexColorUse mesh vertex colors for metalness.
metalnessVertexColorChannelVertex color channel to use for metalness.
normalMapThe normal map of the material.
normalMapOffsetControls the 2D offset of the normal map.
normalMapTilingControls the 2D tiling of the normal map.
normalMapUvNormal map UV channel
occludeDirectTells if AO should darken directional lighting.
occludeSpecularUses ambient occlusion to darken specular/reflection.
occludeSpecularIntensityControls visibility of specular occlusion.
onUpdateShaderA custom function that will be called after all shader generator properties are collected and before shader code is generated.
opacityThe opacity of the material.
opacityMapThe opacity map of the material.
opacityMapChannelColor channel of the opacity map to use.
opacityMapOffsetControls the 2D offset of the opacity map.
opacityMapTilingControls the 2D tiling of the opacity map.
opacityMapUvOpacity map UV channel
opacityVertexColorUse mesh vertex colors for opacity.
opacityVertexColorChannelVertex color channels to use for opacity.
pixelSnapAlign vertices to pixel co-ordinates when rendering.
reflectivityEnvironment map intensity.
refractionDefines the visibility of refraction.
refractionIndexDefines the index of refraction, i.
shadingModelDefines the shading model.
shininessDefines glossiness of the material from 0 (rough) to 100 (shiny mirror).
specularThe specular color of the material.
specularAntialiasEnables Toksvig AA for mipmapped normal maps with specular.
specularMapThe specular map of the material.
specularMapChannelColor channels of the specular map to use.
specularMapOffsetControls the 2D offset of the specular map.
specularMapTilingControls the 2D tiling of the specular map.
specularMapUvSpecular map UV channel
specularTintMultiply specular map and/or specular vertex color by the constant specular value.
specularVertexColorUse mesh vertex colors for specular.
specularVertexColorChannelVertex color channels to use for specular.
sphereMapThe spherical environment map of the material.
twoSidedLightingCalculate proper normals (and therefore lighting) on backfaces
useFogApply fogging (as configured in scene settings)
useGammaTonemapApply gamma correction and tonemapping (as configured in scene settings)
useLightingApply lighting
useMetalnessUse metalness properties instead of specular.
useSkyboxApply scene skybox as prefiltered environment map

Methods

cloneDuplicates a Standard material.

Inherited

Properties

alphaTestThe alpha test reference value to control which fragments are written to the currently active render target based on alpha value.
alphaToCoverageEnables or disables alpha to coverage (WebGL2 only).
alphaWriteIf true, the alpha component of fragments generated by the shader of this material is written to the color buffer of the currently active render target.
blendTypeControls how primitives are blended when being written to the currently active render target.
blueWriteIf true, the blue component of fragments generated by the shader of this material is written to the color buffer of the currently active render target.
cullControls how triangles are culled based on their face direction with respect to the viewpoint.
depthBiasOffsets the output depth buffer value.
depthTestIf true, fragments generated by the shader of this material are only written to the current render target if they pass the depth test.
depthWriteIf true, fragments generated by the shader of this material write a depth value to the depth buffer of the currently active render target.
greenWriteIf true, the green component of fragments generated by the shader of this material is written to the color buffer of the currently active render target.
nameThe name of the material.
redWriteIf 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.
shaderThe shader used by this material to render mesh instances.
slopeDepthBiasSame as pc.Material#depthBias, but also depends on the slope of the triangle relative to the camera.
stencilBackStencil parameters for back faces (default is null).
stencilFrontStencil parameters for front faces (default is null).

Methods

deleteParameterDeletes a shader parameter on a material.
destroyRemoves this material from the scene and possibly frees up memory from its shaders (if there are no other materials using it).
getParameterRetrieves the specified shader parameter from a material.
setParameterSets a shader parameter on a material.
setParametersPushes all material parameters into scope.
updateApplies any changes made to the material's properties.

Details

Constructor

StandardMaterial()

// Create a new Standard material
var 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();

Properties

pc.Colorambient

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

BooleanambientTint

Enables scene ambient multiplication by material ambient color.

pc.TextureaoMap

Baked ambient occlusion (AO) map. Modulates ambient color.

StringaoMapChannel

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

pc.Vec2aoMapOffset

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

pc.Vec2aoMapTiling

Controls the 2D tiling of the AO map.

NumberaoMapUv

AO map UV channel

BooleanaoVertexColor

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

StringaoVertexColorChannel

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

Numberbumpiness

The bumpiness of the material. This value scales the assigned 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.

BooleanconserveEnergy

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.

pc.TexturecubeMap

The cubic environment map of the material. Overrides sphereMap. Affects reflections. If cubemap is prefiltered, will also affect ambient color.

NumbercubeMapProjection

The type of projection applied to the cubeMap property:

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

pc.BoundingBoxcubeMapProjectionBox

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

pc.Colordiffuse

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).

pc.TexturediffuseMap

The diffuse map of the material.

StringdiffuseMapChannel

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

pc.Vec2diffuseMapOffset

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

pc.Vec2diffuseMapTiling

Controls the 2D tiling of the diffuse map.

NumberdiffuseMapUv

Diffuse map UV channel

BooleandiffuseTint

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

BooleandiffuseVertexColor

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

StringdiffuseVertexColorChannel

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

pc.Coloremissive

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

NumberemissiveIntensity

Emissive color multiplier.

pc.TextureemissiveMap

The emissive map of the material. Can be HDR.

StringemissiveMapChannel

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

pc.Vec2emissiveMapOffset

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

pc.Vec2emissiveMapTiling

Controls the 2D tiling of the emissive map.

NumberemissiveMapUv

Emissive map UV channel.

BooleanemissiveTint

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

BooleanemissiveVertexColor

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

StringemissiveVertexColorChannel

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

NumberfresnelModel

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 behaviour is defined by conserveEnergy parameter.

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

pc.TextureglossMap

Glossiness map. If set, will be multiplied by normalized 'shininess' value and/or vertex colors.

StringglossMapChannel

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

pc.Vec2glossMapOffset

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

pc.Vec2glossMapTiling

Controls the 2D tiling of the gloss map.

NumberglossMapUv

Gloss map UV channel

BooleanglossVertexColor

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

StringglossVertexColorChannel

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

pc.TextureheightMap

The height map of the material. 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.

StringheightMapChannel

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

NumberheightMapFactor

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

pc.Vec2heightMapOffset

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

pc.Vec2heightMapTiling

Controls the 2D tiling of the height map.

NumberheightMapUv

Height map UV channel

pc.TexturelightMap

A custom lightmap of the material. Lightmaps are textures that contain pre-rendered lighting. Can be HDR.

StringlightMapChannel

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

pc.Vec2lightMapOffset

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

pc.Vec2lightMapTiling

Controls the 2D tiling of the lightmap.

NumberlightMapUv

Lightmap UV channel

BooleanlightVertexColor

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

StringlightVertexColorChannel

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

Numbermetalness

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

pc.TexturemetalnessMap

Monochrome metalness map.

StringmetalnessMapChannel

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

pc.Vec2metalnessMapOffset

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

pc.Vec2metalnessMapTiling

Controls the 2D tiling of the metalness map.

NumbermetalnessMapUv

Metalness map UV channel

BooleanmetalnessVertexColor

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

StringmetalnessVertexColorChannel

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

pc.TexturenormalMap

The normal map of the material. The texture must contains normalized, tangent space normals.

pc.Vec2normalMapOffset

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

pc.Vec2normalMapTiling

Controls the 2D tiling of the normal map.

NumbernormalMapUv

Normal map UV channel

NumberoccludeDirect

Tells if AO should darken directional lighting.

NumberoccludeSpecular

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.

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

NumberoccludeSpecularIntensity

Controls visibility of specular occlusion.

functiononUpdateShader

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. Properties of the object passed into this function are:

  • pass: value of pc.Layer#shaderPass of the Layer being rendered.
  • chunks: Object containing custom shader chunks that will replace default ones.
  • customFragmentShader: Completely replace fragment shader with this code.
  • forceUv1: if UV1 (second set of texture coordinates) is required in the shader. Will be declared as "vUv1" and passed to the fragment shader.
  • fog: the type of fog being applied in the shader. See pc.Scene#fog for the list of possible values.
  • gamma: the type of gamma correction being applied in the shader. See pc.Scene#gammaCorrection for the list of possible values.
  • toneMap: the type of tone mapping being applied in the shader. See pc.Scene#toneMapping for the list of possible values.
  • ambientTint: the value of pc.StandardMaterial#ambientTint.
  • specularAntialias: the value of pc.StandardMaterial#specularAntialias.
  • conserveEnergy: the value of pc.StandardMaterial#conserveEnergy.
  • occludeSpecular: the value of pc.StandardMaterial#occludeSpecular.
  • occludeDirect: the value of pc.StandardMaterial#occludeDirect.
  • shadingModel: the value of pc.StandardMaterial#shadingModel.
  • fresnelModel: the value of pc.StandardMaterial#fresnelModel.
  • cubeMapProjection: the value of pc.StandardMaterial#cubeMapProjection.
  • useMetalness: the value of pc.StandardMaterial#useMetalness.
  • blendType: the value of pc.Material#blendType.
  • twoSidedLighting: the value of pc.Material#twoSidedLighting.
  • diffuseTint: defines if pc.StandardMaterial#diffuse constant should affect diffuse color.
  • specularTint: defines if pc.StandardMaterial#specular constant should affect specular color.
  • metalnessTint: defines if pc.StandardMaterial#metalness constant should affect metalness value.
  • glossTint: defines if pc.StandardMaterial#shininess constant should affect glossiness value.
  • emissiveTint: defines if pc.StandardMaterial#emissive constant should affect emission value.
  • opacityTint: defines if pc.StandardMaterial#opacity constant should affect opacity value.
  • occludeSpecularFloat: defines if pc.StandardMaterial#occludeSpecularIntensity constant should affect specular occlusion.
  • alphaTest: enable alpha testing. See pc.Material#alphaTest.
  • alphaToCoverage: enable alpha to coverage. See pc.Material#alphaToCoverage.
  • sphereMap: if pc.StandardMaterial#sphereMap is used.
  • cubeMap: if pc.StandardMaterial#cubeMap is used.
  • dpAtlas: if dual-paraboloid reflection is used. Dual paraboloid reflections replace prefiltered cubemaps on certain platform (mostly Android) for performance reasons.
  • ambientSH: if ambient spherical harmonics are used. Ambient SH replace prefiltered cubemap ambient on certain platform (mostly Android) for performance reasons.
  • useSpecular: if any specular or reflections are needed at all.
  • rgbmAmbient: if ambient cubemap or spherical harmonics are RGBM-encoded.
  • hdrAmbient: if ambient cubemap or spherical harmonics are plain float HDR data.
  • rgbmReflection: if reflection cubemap or dual paraboloid are RGBM-encoded.
  • hdrReflection: if reflection cubemap or dual paraboloid are plain float HDR data.
  • fixSeams: if cubemaps require seam fixing (see pc.Texture#options.fixCubemapSeams).
  • prefilteredCubemap: if prefiltered cubemaps are used.
  • emissiveFormat: how emissiveMap must be sampled. This value is based on pc.Texture#options.rgbm and pc.Texture#options.format. Possible values are:
    • 0: sRGB texture
    • 1: RGBM-encoded HDR texture
    • 2: Simple read (no conversion from sRGB)
  • lightMapFormat: how lightMap must be sampled. This value is based on pc.Texture#options.rgbm and pc.Texture#options.format. Possible values are:
    • 0: sRGB texture
    • 1: RGBM-encoded HDR texture
    • 2: Simple read (no conversion from sRGB)
  • useRgbm: if decodeRGBM() function is needed in the shader at all.
  • packedNormal: if normal map contains X in RGB, Y in Alpha, and Z must be reconstructed.
  • forceFragmentPrecision: Override fragment shader numeric precision. Can be "lowp", "mediump", "highp" or null to use default.
  • fastTbn: Use slightly cheaper normal mapping code (skip tangent space normalization). Can look buggy sometimes.
  • refraction: if refraction is used.
  • skyboxIntensity: if reflected skybox intensity should be modulated.
  • useTexCubeLod: if textureCubeLodEXT function should be used to read prefiltered cubemaps. Usually true of iOS, false on other devices due to quality/performance balance.

Numberopacity

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 pc.Material#blendType to pc.BLEND_NORMAL, pc.BLEND_ADDITIVE or any other mode. Also note that for most semi-transparent objects you want pc.Material#depthWrite to be false, otherwise they can fully occlude objects behind them.

pc.TextureopacityMap

The opacity map of the material.

StringopacityMapChannel

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

pc.Vec2opacityMapOffset

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

pc.Vec2opacityMapTiling

Controls the 2D tiling of the opacity map.

NumberopacityMapUv

Opacity map UV channel

BooleanopacityVertexColor

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

StringopacityVertexColorChannel

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

BooleanpixelSnap

Align vertices to pixel co-ordinates when rendering. Useful for pixel perfect 2D graphics

Numberreflectivity

Environment map intensity.

Numberrefraction

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

NumberrefractionIndex

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 it's own surface. In most situations outer medium is air, so outerIor will be approximately 1. Then you only need to do (1.0 / surfaceIor).

NumbershadingModel

Defines the shading model.

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

Numbershininess

Defines glossiness of the material from 0 (rough) to 100 (shiny mirror). A higher shininess value results in a more focused specular highlight. Glossiness map/vertex colors are always multiplied by this value (normalized to 0 - 1 range), or it is used directly as constant output.

pc.Colorspecular

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.

BooleanspecularAntialias

Enables Toksvig AA for mipmapped normal maps with specular.

pc.TexturespecularMap

The specular map of the material.

StringspecularMapChannel

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

pc.Vec2specularMapOffset

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

pc.Vec2specularMapTiling

Controls the 2D tiling of the specular map.

NumberspecularMapUv

Specular map UV channel

BooleanspecularTint

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

BooleanspecularVertexColor

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

StringspecularVertexColorChannel

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

pc.TexturesphereMap

The spherical environment map of the material. Affects reflections.

BooleantwoSidedLighting

Calculate proper normals (and therefore lighting) on backfaces

BooleanuseFog

Apply fogging (as configured in scene settings)

BooleanuseGammaTonemap

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

BooleanuseLighting

Apply lighting

BooleanuseMetalness

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 metaless == 0, the pixel is assumed to be dielectric, and diffuse color is used as normal. With metaless == 1, the pixel is fully metallic, and diffuse color is used as specular color instead.

BooleanuseSkybox

Apply scene skybox as prefiltered environment map

Methods

clone()

Duplicates a Standard material. All properties are duplicated except textures where only the references are copied.

Returns

pc.StandardMaterial A cloned Standard material.

Inherited

Properties

NumberalphaTest

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).

BooleanalphaToCoverage

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.

BooleanalphaWrite

If true, the alpha 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.

NumberblendType

Controls how primitives are blended when being written to the currently active render target. Can be one of the following values:

  • pc.BLEND_SUBTRACTIVE: Subtract the color of the source fragment from the destination fragment and write the result to the frame buffer.
  • pc.BLEND_ADDITIVE: Add the color of the source fragment to the destination fragment and write the result to the frame buffer.
  • pc.BLEND_NORMAL: Enable simple translucency for materials such as glass. This is equivalent to enabling a source blend mode of pc.BLENDMODE_SRC_ALPHA and a destination blend mode of pc.BLENDMODE_ONE_MINUS_SRC_ALPHA.
  • pc.BLEND_NONE: Disable blending.
  • pc.BLEND_PREMULTIPLIED: Similar to pc.BLEND_NORMAL expect the source fragment is assumed to have already been multiplied by the source alpha value.
  • pc.BLEND_MULTIPLICATIVE: Multiply the color of the source fragment by the color of the destination fragment and write the result to the frame buffer.
  • pc.BLEND_ADDITIVEALPHA: Same as pc.BLEND_ADDITIVE except the source RGB is multiplied by the source alpha.
Defaults to pc.BLEND_NONE.

BooleanblueWrite

If true, the blue 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.

Numbercull

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

  • pc.CULLFACE_NONE: Do not cull triangles based on face direction.
  • pc.CULLFACE_BACK: Cull the back faces of triangles (do not render triangles facing away from the view point).
  • pc.CULLFACE_FRONT: Cull the front faces of triangles (do not render triangles facing towards the view point).
  • pc.CULLFACE_FRONTANDBACK: Cull both front and back faces (triangles will not be rendered).
Defaults to pc.CULLFACE_BACK.

NumberdepthBias

Offsets the output depth buffer value. Useful for decals to prevent z-fighting.

BooleandepthTest

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.

BooleandepthWrite

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.

BooleangreenWrite

If true, the green 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.

Stringname

The name of the material.

BooleanredWrite

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.

pc.Shadershader

The shader used by this material to render mesh instances.

NumberslopeDepthBias

Same as pc.Material#depthBias, but also depends on the slope of the triangle relative to the camera.

pc.StencilParametersstencilBack

Stencil parameters for back faces (default is null).

pc.StencilParametersstencilFront

Stencil parameters for front faces (default is null).

Methods

deleteParameter(name)

Deletes a shader parameter on a material.

Parameters

nameStringThe name of the parameter to delete.

destroy()

Removes this material from the scene and possibly frees up memory from its shaders (if there are no other materials using it).

getParameter(name)

Retrieves the specified shader parameter from a material.

Parameters

nameStringThe name of the parameter to query.

Returns

Object The named parameter.

setParameter(name, data, [passFlags])

Sets a shader parameter on a material.

Parameters

nameStringThe name of the parameter to set.
dataNumber, Array, pc.TextureThe value for the specified parameter.
passFlagsNumberMask describing which passes the material should be included in.

setParameters()

Pushes all material parameters into scope.

update()

Applies any changes made to the material's properties.