Menu - Top - Home - Donate to Me

H3DU.PbrMaterial

Back to documentation index.

H3DU.PbrMaterial([params])

A material for physically-based rendering. Specifies parameters for geometry materials, which describe the appearance of a 3D object. This includes how an object scatters or reflects light.

NOTE: The default shader program assumes that all colors, as well as the albedo, specular, and emission maps, specified in this object are in nonlinearized sRGB.

Parameters

Members

Methods

H3DU.PbrMaterial.Metallic (constant)

Metallic workflow.

Default Value: 1

H3DU.PbrMaterial.Specular (constant)

Specular workflow.

Default Value: 0

H3DU.PbrMaterial#albedo

Albedo (or base color) of this material.

This value is a 3- or 4-element array giving the red, green, blue, and alpha components of the albedo (in nonlinearized sRGB). (0,0,0,1) means an albedo value of black, and (1,1,1,1) means an albedo value of white.

In the metallic workflow, this color specifies the amount of light that is reflected by this material's surface. For both metals and nonmetals, this color is the generally observed color of the surface.

In the specular workflow, this color specifies the amount of light that passes through the material and bounces off (diffuse color). For most nonmetals, this color is the generally observed color of the surface, though somewhat desaturated. Most metals do not reflect the light that passes through them, so for most metals, this color should generally be black or a very dark shade of gray. (In physically-based rendering, the sum of albedo and specular colors should not exceed 1.0 in each linearized sRGB channel.)

In both workflows in physically-based rendering, the albedo color should not have any added lighting.

This value can have an optional fourth element giving the alpha component (0-1). If this element is omitted, the default is 1.

In the default shader program, if a mesh defines its own colors, those colors are used rather than this property to set the color defined here.

Type: Array.<number>

Default Value: "[1,1,1,1]"

H3DU.PbrMaterial#albedoMap

A texture indicating the albedo (or base color) of each part of the texture, in the red, green, blue, and alpha channels. In physically-based rendering, the albedo texture should not have any added lighting or shadow detail.

Type: H3DU.Texture | H3DU.TextureInfo | H3DU.FrameBufferInfo

Default Value: null

H3DU.PbrMaterial#emission

Additive color emitted by objects with this material. Used for objects that glow on their own, among other things. This additive color is unaffected by lighting or shading.

This value is a 3-element array giving the red, green, and blue components. For each of the three color components, positive values add to that component, while negative values subtract from it. (0,0,0), the default, means no additive color.

Type: Array.<number>

Default Value: "[0,0,0]"

H3DU.PbrMaterial#emissionMap

A texture where each pixel identifies the emission of that part of the texture, as specified in the texture's red, green, and blue channel. If a texture is given, the emission found with this texture is multiplied by the value of the H3DU.PbrMaterial#emission property.

Type: H3DU.Texture | H3DU.TextureInfo | H3DU.FrameBufferInfo

Default Value: null

H3DU.PbrMaterial#invertRoughness

If true, the roughness property is treated as a "glossiness" property, or 1 minus roughness, and the roughness map is treated as a "glossiness" map, or an inverted roughness map.

Type: boolean

Default Value: false

H3DU.PbrMaterial#metalness

A value indicating whether objects described by this material are metals. This value ranges from 0 through 1. If 0, the surface is a nonmetal; if 1, the surface is a metal. Values in between 0 and 1 are rather rare and generally appear in transitions between metals and nonmetals. This value is only used in the metallic workflow.

Type: number

Default Value: 0

H3DU.PbrMaterial#metalnessMap

A texture indicating the metalness of each part of the texture, as specified in the texture's blue channel. Each pixel value in the blue channel (which ranges from 0-255 in most image formats) is scaled to the range [0, 1].

This value is only used in the metallic workflow. Any texture used for this map should not be in JPEG format or any other format that uses lossy compression, as compression artifacts can result in inaccurate metalness values in certain areas.

Type: H3DU.Texture | H3DU.TextureInfo | H3DU.FrameBufferInfo

Default Value: null

H3DU.PbrMaterial#normalMap

Normal map (bump map) texture. Normal maps are used either to add a sense of roughness to an otherwise flat surface or to give an object a highly-detailed appearance with fewer polygons.

In a normal map texture, each pixel is a vector in which each component (which usually ranges from 0-255 in most image formats) is scaled to the range [-1, 1], where:

Each pixel indicates a tilt from the vector (0, 0, 1), or positive Z axis, to the vector given in that pixel. This tilt adjusts the normals used for the purpose of calculating lighting effects at that part of the surface. A strong tilt indicates strong relief detail at that point.

Any texture used for normal maps should not be in JPEG format or any other format that uses lossy compression, as compression artifacts can result in inaccurate normals in certain areas.

For normal mapping to work, an object's mesh must include normals and texture coordinates.

Type: H3DU.Texture | H3DU.TextureInfo | H3DU.FrameBufferInfo

Default Value: null

H3DU.PbrMaterial#occlusionMap

A texture where each pixel identifies the ambient occlusion of that part of the texture, as specified in the texture's red channel.

Type: H3DU.Texture | H3DU.TextureInfo | H3DU.FrameBufferInfo

Default Value: null

H3DU.PbrMaterial#roughness

Describes the roughness of the surface described by this material. The inverse of roughness is glossiness or smoothness, which equals 1 minus roughness. To make this property equivalent to glossiness or smoothness, set the invertRoughness property to true.

Type: number

Default Value: 0.35

H3DU.PbrMaterial#roughnessMap

A texture indicating the roughness of each part of the texture, as specified in the texture's green channel. Each pixel value in the green channel (which ranges from 0-255 in most image formats) is scaled to the range [0, 1].

The inverse of roughness is glossiness or smoothness; to treat the texture as a glossiness or smoothness map, set the invertRoughness property to true. Any texture used for this map should not be in JPEG format or any other format that uses lossy compression, as compression artifacts can result in inaccurate roughness values in certain areas.

Type: H3DU.Texture | H3DU.TextureInfo | H3DU.FrameBufferInfo

Default Value: null

H3DU.PbrMaterial#shader

Shader program to use when rendering objects with this material.

Default Value: null

H3DU.PbrMaterial#specular

Specular reflectivity of this material. Specular reflection is a bounced-back reflection from the direction the light reaches the material in, similar to a mirror. As a result, depending on the viewing angle, specular reflection can give off shiny highlights on the material.

This value is a 3-element array giving the red, green, and blue components of the surface's base reflectivity when looking directly at the surface (base reflectivity at 0 degree incidence, or F0). For most nonmetals, this is a shade of gray ranging from (0.15, 0.15, 0.15) to (0.32, 0.32, 0.32) in sRGB. For most metals, this is a very light version of the surface's color.

This value is only used in the specular workflow.

Type: Array.<number>

Default Value: "[0.2,0.2,0.2]"

H3DU.PbrMaterial#specularMap

A texture where each pixel identifies the "specular" property of that part of the texture, as specified in the texture's red, green, and blue channels (in nonlinearized sRGB).

This value is only used in the specular workflow.

Any texture used for this map should not be in JPEG format or any other format that uses lossy compression, as compression artifacts can result in inaccurate specular factors in certain areas.

Type: H3DU.Texture | H3DU.TextureInfo | H3DU.FrameBufferInfo

Default Value: null

H3DU.PbrMaterial#workflow

Specifies which workflow to use when interpreting values for this material.

The metallic workflow (H3DU.PbrMaterial.Metallic, the default) is usually easier to understand and uses albedo to set the surface's color and metalness to set whether the surface is a metal or not.

The specular workflow (H3DU.PbrMaterial.Specular) uses albedo to set the surface's color for nonmetals and specular to set the surface's specular reflectivity.

Type: number

H3DU.PbrMaterial#copy()

Clones this object's parameters to a new H3DU.PbrMaterial object and returns that object. The material's texture maps and shader info, if any, won't be cloned, but rather, a reference to the same object will be used.

Return Value

A copy of this object. (Type: H3DU.PbrMaterial)

H3DU.PbrMaterial#setParams(params)

Sets parameters for this material object.

Parameters

Return Value

This object. (Type: H3DU.PbrMaterial)

Back to documentation index.