Menu - Top - Home - Donate to Me

H3DU.Material

Back to documentation index.

H3DU.Material([params], [diffuse], [specular], [shininess], [emission])

Specifies parameters for geometry materials, which describe the appearance of a 3D object. This includes how an object scatters or reflects light, as well as a texture image to apply on that object's surface.

NOTE: The default shader program assumes that all colors and the diffuse texture specified in this object are in companded sRGB.

Parameters

Members

Methods

H3DU.Material#ambient

Ambient color of this material.

Ambient color indicates how much an object's color is affected by ambient lights, those that color pixels the same way regardless of direction or distance. Because every part of an object will be shaded the same way by ambient colors, an object with just ambient color will not look much like a 3D object.

(Ambient color simulates the effect of light being scattered multiple times from the same surface.) This value is a 3-element array giving the red, green, and blue components of the ambient color; the final ambient color depends on the ambient color of the scene. (0,0,0) means no ambient color, and (1,1,1) means total ambient color.

Setting ambient color and diffusion color to the same value usually defines an object's color.

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

H3DU.Material#diffuse

Diffusion color of this material (also called "albedo"). This is the generally perceived color of the material when specular highlights are absent on the material's surface. See also H3DU.PbrMaterial#albedo; this property corresponds more closely to that in the metallic workflow rather than the specular workflow.

Type: Array.<number>

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

H3DU.Material#emission

Additive color emitted by objects with this material. See H3DU.PbrMaterial#emission.

Type: Array.<number>

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

H3DU.Material#emissionMap

Emission map texture. See H3DU.PbrMaterial#emissionMap.

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

Default Value: null

H3DU.Material#normalMap

Normal map (bump map) texture. See H3DU.PbrMaterial#normalMap.

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

Default Value: null

H3DU.Material#occlusionMap

Ambient occlusion map texture. See H3DU.PbrMaterial#occlusionMap.

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

Default Value: null

H3DU.Material#shader

Shader program to use when rendering objects with this material.

Default Value: null

H3DU.Material#shininess

Specular highlight exponent of this material. The greater the number, the more concentrated the specular highlights are (and the smoother the material behaves). The lower the number, the more extended the highlights are (and the rougher the material behaves). Ranges from 0 through 128.

Default Value: 32

H3DU.Material#specular

Specular highlight reflection of this material. This is usually a shade of gray (all three components are the same), but can be colored if the material represents an uncoated metal of some sort. See also H3DU.PbrMaterial#specular. NOTE: Before version 2.0, this value's default was (0,0,0).

Type: Array.<number>

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

H3DU.Material#specularMap

Specular map texture. See H3DU.PbrMaterial#specularMap. NOTE: If this property specifies a texture, this property will be used for the specular reflection rather than the "specular" property. This behavior is a change from versions earlier than 2.0, where this property, if present, multiplied the value of the "specular" property.

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

Default Value: null

H3DU.Material#texture

Texture for this material. Each color in the texture sets the diffusion (also called "albedo") of each part of the material.

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

Default Value: null

H3DU.Material#copy()

Clones this object's parameters to a new H3DU.Material 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.Material)

(static) H3DU.Material.fromBasic()

Creates a material with its emission color set to the given color. The effect will be that objects with that material will be drawn in that color without shading.

Return Value

A new material with the given emission color. (Type: H3DU.Material)

(static) H3DU.Material.fromBasicTexture()

Creates a material with its emission texture set to the given texture. The effect will be that objects with that material will be drawn in that texture without shading.

Return Value

A new material with the given emission texture. (Type: H3DU.Material)

(static) H3DU.Material.fromColor(r, g, b, [a])

Convenience method that returns an H3DU.Material object from an RGBA color.

Parameters

Return Value

The resulting material object. (Type: H3DU.Material)

(static) H3DU.Material.fromTexture(texture)

Convenience method that returns an H3DU.Material object from a texture to apply to a 3D object's surface.

Parameters

Return Value

The resulting material object. (Type: H3DU.Material)

H3DU.Material#setParams(params)

Sets parameters for this material object.

Parameters

Return Value

This object. (Type: H3DU.Material)

Back to documentation index.