Create a new StandardMaterial instance.
// 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();
Used to fade out materials when StandardMaterial#opacityFadesSpecular is set to false.
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).
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.
The ambient color of the material. This color value is 3-component (RGB), where each component is between 0 and 1.
Enables scene ambient multiplication by material ambient color.
Defines amount of anisotropy. Requires StandardMaterial#enableGGXSpecular is set to true.
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.
Color channels of the detail (secondary) AO map to use. Can be "r", "g", "b" or "a" (default is "g").
Controls the 2D offset of the detail (secondary) AO map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the detail (secondary) AO map.
Controls the 2D tiling of the detail (secondary) AO map.
Detail (secondary) AO map UV channel.
Determines how the main (primary) and detail (secondary) AO maps are blended together. Can be:
Defaults to DETAILMODE_MUL.
The main (primary) baked ambient occlusion (AO) map (default is null). Modulates ambient color.
Color channel of the main (primary) AO map to use. Can be "r", "g", "b" or "a".
Controls the 2D offset of the main (primary) AO map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the main (primary) AO map.
Controls the 2D tiling of the main (primary) AO map.
Main (primary) AO map UV channel
Use mesh vertex colors for AO. If aoMap is set, it'll be multiplied by vertex colors.
Vertex color channels to use for AO. Can be "r", "g", "b" or "a".
The attenuation color for refractive materials, only used when useDynamicRefraction is enabled.
The distance defining the absorption rate of light within the medium. Only used when useDynamicRefraction is enabled.
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.
Defines intensity of clearcoat layer from 0 to 1. Clearcoat layer is disabled when clearCoat == 0. Default value is 0 (disabled).
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.
Defines the clearcoat glossiness of the clearcoat layer from 0 (rough) to 1 (mirror).
Invert the clearcoat gloss component (default is false). Enabling this flag results in material treating the clear coat gloss members as roughness.
Monochrome clearcoat glossiness map (default is null). If specified, will be multiplied by normalized 'clearCoatGloss' value and/or vertex colors.
Color channel of the clearcoat gloss map to use. Can be "r", "g", "b" or "a".
Controls the 2D offset of the clearcoat gloss map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the clear coat gloss map.
Controls the 2D tiling of the clearcoat gloss map.
Clearcoat gloss map UV channel.
Use mesh vertex colors for clearcoat glossiness. If clearCoatGlossMap is set, it'll be multiplied by vertex colors.
Vertex color channel to use for clearcoat glossiness. Can be "r", "g", "b" or "a".
Monochrome clearcoat intensity map (default is null). If specified, will be multiplied by normalized 'clearCoat' value and/or vertex colors.
Color channel of the clearcoat intensity map to use. Can be "r", "g", "b" or "a".
Controls the 2D offset of the clearcoat intensity map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the clearcoat intensity map.
Controls the 2D tiling of the clearcoat intensity map.
Clearcoat intensity map UV channel.
The clearcoat normal map of the material (default is null). The texture must contains normalized, tangent space normals.
Controls the 2D offset of the main clearcoat normal map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the main clearcoat map.
Controls the 2D tiling of the main clearcoat normal map.
Clearcoat normal map UV channel.
Use mesh vertex colors for clearcoat intensity. If clearCoatMap is set, it'll be multiplied by vertex colors.
Vertex color channel to use for clearcoat intensity. Can be "r", "g", "b" or "a".
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.
The cubic environment map of the material (default is null). This setting overrides sphereMap and will replace the scene lighting environment.
The type of projection applied to the cubeMap property:
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.
Controls how triangles are culled based on their face direction with respect to the viewpoint. Can be:
Defaults to CULLFACE_BACK.
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).
The detail (secondary) diffuse map of the material (default is null). Will only be used if main (primary) diffuse map is non-null.
Color channels of the detail (secondary) diffuse map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.
Controls the 2D offset of the detail (secondary) diffuse map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the main (secondary) diffuse map.
Controls the 2D tiling of the detail (secondary) diffuse map.
Detail (secondary) diffuse map UV channel.
Determines how the main (primary) and detail (secondary) diffuse maps are blended together. Can be:
Defaults to DETAILMODE_MUL.
The main (primary) diffuse map of the material (default is null).
Color channels of the main (primary) diffuse map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.
Controls the 2D offset of the main (primary) diffuse map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the main (primary) diffuse map.
Controls the 2D tiling of the main (primary) diffuse map.
Main (primary) diffuse map UV channel.
Multiply main (primary) diffuse map and/or diffuse vertex color by the constant diffuse value.
Use mesh vertex colors for diffuse. If diffuseMap or are diffuseTint are set, they'll be multiplied by vertex colors.
Vertex color channels to use for diffuse. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.
The strength of the angular separation of colors (chromatic aberration) transmitting through a volume. Defaults to 0, which is equivalent to no dispersion.
The emissive color of the material. This color value is 3-component (RGB), where each component is between 0 and 1.
Emissive color multiplier.
The emissive map of the material (default is null). Can be HDR.
Color channels of the emissive map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.
Controls the 2D offset of the emissive map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the emissive map.
Controls the 2D tiling of the emissive map.
Emissive map UV channel.
Multiply emissive map and/or emissive vertex color by the constant emissive value.
Use mesh vertex colors for emission. If emissiveMap or emissiveTint are set, they'll be multiplied by vertex colors.
Vertex color channels to use for emission. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.
Enables GGX specular. Also enables StandardMaterial#anisotropy parameter to set material anisotropy.
The prefiltered environment lighting atlas (default is null). This setting overrides cubeMap and sphereMap and will replace the scene lighting environment.
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.
Defines the glossiness of the material from 0 (rough) to 1 (shiny).
Invert the gloss component (default is false). Enabling this flag results in material treating the gloss members as roughness.
Gloss map (default is null). If specified, will be multiplied by normalized gloss value and/or vertex colors.
Color channel of the gloss map to use. Can be "r", "g", "b" or "a".
Controls the 2D offset of the gloss map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the gloss map.
Controls the 2D tiling of the gloss map.
Gloss map UV channel.
Use mesh vertex colors for glossiness. If glossMap is set, it'll be multiplied by vertex colors.
Vertex color channel to use for glossiness. Can be "r", "g", "b" or "a".
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.
Color channel of the height map to use. Can be "r", "g", "b" or "a".
Height map multiplier. Affects the strength of the parallax effect.
Controls the 2D offset of the height map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the height map.
Controls the 2D tiling of the height map.
Height map UV channel.
The per-pixel iridescence intensity. Only used when useIridescence is enabled.
Color channels of the iridescence map to use. Can be "r", "g", "b" or "a".
Controls the 2D offset of the iridescence map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the iridescence map.
Controls the 2D tiling of the iridescence map.
Iridescence map UV channel.
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
The per-pixel iridescence thickness. Defines a gradient weight between iridescenceThicknessMin and iridescenceThicknessMax. Only used when useIridescence is enabled.
Color channels of the iridescence thickness map to use. Can be "r", "g", "b" or "a".
Controls the 2D offset of the iridescence thickness map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the iridescence map.
Controls the 2D tiling of the iridescence thickness map.
Iridescence thickness map UV channel.
The maximum thickness for the iridescence layer. Used as the 'base' thickness when no iridescence thickness map is defined. The unit is in nm.
The minimum thickness for the iridescence layer. Only used when an iridescence thickness map is used. The unit is in nm.
A custom lightmap of the material (default is null). Lightmaps are textures that contain pre-rendered lighting. Can be HDR.
Color channels of the lightmap to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.
Controls the 2D offset of the lightmap. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the lightmap.
Controls the 2D tiling of the lightmap.
Lightmap UV channel
Use baked vertex lighting. If lightMap is set, it'll be multiplied by vertex colors.
Vertex color channels to use for baked lighting. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.
Defines how much the surface is metallic. From 0 (dielectric) to 1 (metal).
Monochrome metalness map (default is null).
Color channel of the metalness map to use. Can be "r", "g", "b" or "a".
Controls the 2D offset of the metalness map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the metalness map.
Controls the 2D tiling of the metalness map.
Metalness map UV channel.
Use mesh vertex colors for metalness. If metalnessMap is set, it'll be multiplied by vertex colors.
Vertex color channel to use for metalness. Can be "r", "g", "b" or "a".
The name of the material.
The detail (secondary) normal map of the material (default is null). Will only be used if main (primary) normal map is non-null.
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.
Controls the 2D offset of the detail (secondary) normal map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the detail (secondary) normal map.
Controls the 2D tiling of the detail (secondary) normal map.
Detail (secondary) normal map UV channel.
The main (primary) normal map of the material (default is null). The texture must contains normalized, tangent space normals.
Controls the 2D offset of the main (primary) normal map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the main (primary) normal map.
Controls the 2D tiling of the main (primary) normal map.
Main (primary) normal map UV channel.
Tells if AO should darken directional lighting. Defaults to false.
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.
Controls visibility of specular occlusion.
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.
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.
Used to specify whether opacity is dithered, which allows transparency without alpha blending. Can be:
Defaults to DITHER_NONE.
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.
The opacity map of the material (default is null).
Color channel of the opacity map to use. Can be "r", "g", "b" or "a".
Controls the 2D offset of the opacity map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the opacity map.
Controls the 2D tiling of the opacity map.
Opacity map UV channel.
Used to specify whether shadow opacity is dithered, which allows shadow transparency without alpha blending. Can be:
Defaults to DITHER_NONE.
Use mesh vertex colors for opacity. If opacityMap is set, it'll be multiplied by vertex colors.
Vertex color channels to use for opacity. Can be "r", "g", "b" or "a".
Align vertices to pixel coordinates when rendering. Useful for pixel perfect 2D graphics.
Environment map intensity.
Defines the visibility of refraction. Material can refract the same cube map as used for reflections.
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).
The map of the refraction visibility.
Color channels of the refraction map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.
Controls the 2D offset of the refraction map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the emissive map.
Controls the 2D tiling of the refraction map.
Refraction map UV channel.
Use mesh vertex colors for refraction. If refraction map is set, it will be be multiplied by vertex colors.
Vertex color channel to use for refraction. Can be "r", "g", "b" or "a".
Defines the shading model.
The specular color of the sheen (fabric) microfiber structure. This color value is 3-component (RGB), where each component is between 0 and 1.
The glossiness of the sheen (fabric) microfiber structure. This color value is a single value between 0 and 1.
Invert the sheen gloss component (default is false). Enabling this flag results in material treating the sheen gloss members as roughness.
The sheen glossiness microstructure color map of the material (default is null).
Color channels of the sheen glossiness map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.
Controls the 2D offset of the sheen glossiness map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the sheen glossiness map.
Controls the 2D tiling of the sheen glossiness map.
Sheen map UV channel.
Multiply sheen glossiness map and/or sheen glossiness vertex value by the scalar sheen glossiness value.
Use mesh vertex colors for sheen glossiness. If sheen glossiness map or sheen glossiness tint are set, they'll be multiplied by vertex colors.
Vertex color channels to use for sheen glossiness. Can be "r", "g", "b" or "a".
The sheen microstructure color map of the material (default is null).
Color channels of the sheen map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.
Controls the 2D offset of the sheen map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the sheen map.
Controls the 2D tiling of the sheen map.
Sheen map UV channel.
Multiply sheen map and/or sheen vertex color by the constant sheen value.
Use mesh vertex colors for sheen. If sheen map or sheen tint are set, they'll be multiplied by vertex colors.
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.
The factor of specular intensity, used to weight the fresnel and specularity. Default is 1.0.
The factor of specularity as a texture (default is null).
The channel used by the specularity factor texture to sample from (default is 'a').
Controls the 2D offset of the specularity factor map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the specularity factor map.
Controls the 2D tiling of the specularity factor map.
Specularity factor map UV channel.
Multiply specularity factor map and/or specular vertex color by the constant specular value. "r", "g", "b", "a", "rgb" or any swizzled combination.
Use mesh vertex colors for specularity factor. If specularityFactorMap or are specularityFactorTint are set, they'll be multiplied by vertex colors.
Vertex color channels to use for specularity factor. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.
The specular map of the material (default is null).
Color channels of the specular map to use. Can be "r", "g", "b", "a", "rgb" or any swizzled combination.
Controls the 2D offset of the specular map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the specular map.
Controls the 2D tiling of the specular map.
Specular map UV channel.
Multiply specular map and/or specular vertex color by the constant specular value.
Use mesh vertex colors for specular. If specularMap or are specularTint are set, they'll be multiplied by vertex colors.
Vertex color channels to use for specular. Can be
The spherical environment map of the material (default is null). This will replace the scene lighting environment.
Stencil parameters for back faces (default is null).
Stencil parameters for front faces (default is null).
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.
The per-pixel thickness of the medium, only used when useDynamicRefraction is enabled.
Color channels of the thickness map to use. Can be "r", "g", "b" or "a".
Controls the 2D offset of the thickness map. Each component is between 0 and 1.
Controls the 2D rotation (in degrees) of the thickness map.
Controls the 2D tiling of the thickness map.
Thickness map UV channel.
Use mesh vertex colors for thickness. If thickness map is set, it will be be multiplied by vertex colors.
Calculate proper normals (and therefore lighting) on backfaces.
Enables higher quality refractions using the grab pass instead of pre-computed cube maps for refractions.
Apply fogging (as configured in scene settings)
Apply gamma correction and tonemapping (as configured in scene settings).
Enable thin-film iridescence.
Apply lighting
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.
When metalness is enabled, use the specular map to apply color tint to specular reflections. at direct angles.
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.
Toggle sheen specular effect on/off.
Apply scene skybox as prefiltered environment map
Gets whether the alpha channel is written to the color buffer.
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.
Gets the blend state for this material.
Sets the blend state for this material. Controls how fragment shader outputs are blended when being written to the currently active render target. This overwrites blending type set using Material#blendType, and offers more control over blending.
Gets the blend mode for this material.
Sets the blend mode for this material. Controls how fragment shader outputs are blended when being written to the currently active render target. Can be:
Defaults to BLEND_NONE.
Gets whether the blue channel is written to the color buffer.
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.
Object containing custom shader chunks that will replace default ones.
Gets the offset for the output depth buffer value.
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.
Gets the depth test function.
Sets the depth test function. Controls how the depth of new fragments is compared against the current depth contained in the depth buffer. Can be:
Defaults to FUNC_LESSEQUAL.
Gets the depth state.
Sets the depth state. Note that this can also be done by using Material#depthTest, Material#depthFunc and Material#depthWrite.
Gets whether depth testing is enabled.
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.
Gets whether depth writing is enabled.
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.
Gets whether the green channel is written to the color buffer.
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.
Gets whether the red channel is written to the color buffer.
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.
Sets the shader used by this material to render mesh instances. Defaults to null
.
Sets the shader used by this material to render mesh instances. Defaults to null
.
Gets the offset for the output depth buffer value based on the slope of the triangle relative to the camera.
Sets the offset for the output depth buffer value based on the slope of the triangle relative to the camera.
Clone a material.
A newly cloned material.
Copy a StandardMaterial
.
The material to copy from.
The destination material.
Sets a shader parameter on a material.
The name of the parameter to set.
The value for the specified parameter.
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.