Constants.
Returns the mode of the material's alpha channels, which are provided by baseColorFactor
and baseColorTexture
.
OPAQUE
: Alpha value is ignored and the rendered output is fully opaque.BLEND
: Alpha value is used to determine the transparency each pixel on a surface, and
the fraction of surface vs. background color in the final result. Alpha blending creates
significant edge cases in realtime renderers, and some care when structuring the model is
necessary for good results. In particular, transparent geometry should be kept in separate
meshes or primitives from opaque geometry. The depthWrite
or zWrite
settings in engines
should usually be disabled on transparent materials.MASK
: Alpha value is compared against alphaCutoff
threshold for each pixel on a
surface, and the pixel is either fully visible or fully discarded based on that cutoff.
This technique is useful for things like leafs/foliage, grass, fabric meshes, and other
surfaces where no semitransparency is needed. With a good choice of alphaCutoff
, surfaces
that don't require semitransparency can avoid the performance penalties and visual issues
involved with BLEND
transparency.Reference:
Returns the visibility threshold; applied only when .alphaMode='MASK'
.
Returns material alpha, equivalent to baseColorFactor[3].
Sets the mode of the material's alpha channels. See getAlphaMode for details.
Sets the visibility threshold; applied only when .alphaMode='MASK'
.
Sets material alpha, equivalent to baseColorFactor[3].
Settings affecting the material's use of its base color texture. If no texture is attached,
TextureInfo is null
.
Base color / albedo. The visible color of a non-metallic surface under constant ambient
light would be a linear combination (multiplication) of its vertex colors, base color
factor, and base color texture. Lighting, and reflections in metallic or smooth surfaces,
also effect the final color. The alpha (.a
) channel of base color factors and textures
will have varying effects, based on the setting of getAlphaMode.
Reference:
Base color / albedo; sRGB hexadecimal color. See getBaseColorTexture.
Base color / albedo factor; Linear-sRGB components. See getBaseColorTexture.
Sets base color / albedo texture. See getBaseColorTexture.
Base color / albedo; sRGB hexadecimal color. See getBaseColorTexture.
Base color / albedo factor; Linear-sRGB components. See getBaseColorTexture.
Makes a copy of this property, with the same resources (by reference) as the original.
Copies all data from another property to this one. Child properties are copied by reference, unless a 'resolve' function is given to override that.
Dispatches an event on the GraphNode, and on the associated
Graph. Event types on the graph are prefixed, "node:[type]"
.
Removes both inbound references to and outbound references from this object. At the end of the process the object holds no references, and nothing holds references to it. A disposed object is not reusable.
Returns true when both sides of triangles should be rendered. May impact performance.
Sets whether to render both sides of triangles. May impact performance.
Settings affecting the material's use of its emissive texture. If no texture is attached,
TextureInfo is null
.
Emissive texture. Emissive color is added to any base color of the material, after any lighting/shadowing are applied. An emissive color does not inherently "glow", or affect objects around it at all. To create that effect, most viewers must also enable a post-processing effect called "bloom".
Reference:
Emissive; sRGB hexadecimal color. See getBaseColorTexture.
Emissive color; Linear-sRGB components. See getEmissiveTexture.
Sets emissive texture. See getEmissiveTexture.
Emissive; sRGB hexadecimal color. See getEmissiveTexture.
Emissive color; Linear-sRGB components. See getEmissiveTexture.
Returns true if two properties are deeply equivalent, recursively comparing the attributes of the properties. Optionally, a 'skip' set may be included, specifying attributes whose values should not be considered in the comparison.
Example: Two Primitives are equivalent if they have accessors and materials with equivalent content — but not necessarily the same specific accessors and materials.
Returns an ExtensionProperty attached to this Property, if any.
Attaches the given ExtensionProperty to this Property. For a given extension, only one ExtensionProperty may be attached to any one Property at a time.
Lists all ExtensionProperty instances attached to this Property.
Returns a reference to the Extras object, containing application-specific data for this Property. Extras should be an Object, not a primitive value, for best portability.
Updates the Extras object, containing application-specific data for this Property. Extras should be an Object, not a primitive value, for best portability.
Returns true if the node has been permanently removed from the graph.
Settings affecting the material's use of its metallic/roughness texture. If no texture is
attached, TextureInfo is null
.
Metallic roughness texture. The metalness values are sampled from the B channel. The roughness values are sampled from the G channel. When a material is fully metallic, or nearly so, it may require image-based lighting (i.e. an environment map) or global illumination to appear well-lit.
Reference:
Metallic factor; linear multiplier. Affects roughness channel of
metallicRoughnessTexture
. See getMetallicRoughnessTexture.
Sets metallic/roughness texture. See getMetallicRoughnessTexture.
Sets metallic factor; linear multiplier. Affects roughness channel of
metallicRoughnessTexture
. See getMetallicRoughnessTexture.
Returns the name of this property. While names are not required to be unique, this is encouraged, and non-unique names will be overwritten in some tools. For custom data about a property, prefer to use Extras.
Sets the name of this property. While names are not required to be unique, this is encouraged, and non-unique names will be overwritten in some tools. For custom data about a property, prefer to use Extras.
Settings affecting the material's use of its normal texture. If no texture is attached,
TextureInfo is null
.
Normal (surface detail) texture.
A tangent space normal map. The texture contains RGB components. Each texel represents the XYZ components of a normal vector in tangent space. Red [0 to 255] maps to X [-1 to 1]. Green [0 to 255] maps to Y [-1 to 1]. Blue [128 to 255] maps to Z [1/255 to 1]. The normal vectors use OpenGL conventions where +X is right and +Y is up. +Z points toward the viewer.
Reference:
Normal (surface detail) factor; linear multiplier. Affects .normalTexture
.
Sets normal (surface detail) texture. See getNormalTexture.
Normal (surface detail) factor; linear multiplier. Affects .normalTexture
.
Settings affecting the material's use of its occlusion texture. If no texture is attached,
TextureInfo is null
.
(Ambient) Occlusion texture, generally used for subtle 'baked' shadowing effects that are independent of an object's position, such as shading in inset areas and corners. Direct lighting is not affected by occlusion, so at least one indirect light source must be present in the scene for occlusion effects to be visible.
The occlusion values are sampled from the R channel. Higher values indicate areas that should receive full indirect lighting and lower values indicate no indirect lighting.
Reference:
(Ambient) Occlusion factor; linear multiplier. Affects .occlusionTexture
.
Sets (ambient) occlusion texture. See getOcclusionTexture.
Sets (ambient) occlusion factor; linear multiplier. Affects .occlusionTexture
.
Returns a list of all properties that hold a reference to this property. For example, a material may hold references to various textures, but a texture does not hold references to the materials that use it.
It is often necessary to filter the results for a particular type: some resources, like Accessors, may be referenced by different types of properties. Most properties include the Root as a parent, which is usually not of interest.
Usage:
const materials = texture
.listParents()
.filter((p) => p instanceof Material)
Roughness factor; linear multiplier. Affects roughness channel of
metallicRoughnessTexture
. See getMetallicRoughnessTexture.
Sets roughness factor; linear multiplier. Affects roughness channel of
metallicRoughnessTexture
. See getMetallicRoughnessTexture.
Made by Don McCurdy. Documentation built with greendoc and published under Creative Commons Attribution 3.0.
Materials describe a surface's appearance and response to light.
Each Primitive within a Mesh may be assigned a single Material. The number of GPU draw calls typically increases with both the numbers of Primitives and of Materials in an asset; Materials should be reused wherever possible. Techniques like texture atlasing and vertex colors allow objects to have varied appearances while technically sharing a single Material.
Material properties are modified by both scalars (like
baseColorFactor
) and textures (likebaseColorTexture
). When both are available, factors are considered linear multipliers against textures of the same name. In the case of base color, vertex colors (COLOR_0
attributes) are also multiplied.Textures containing color data (
baseColorTexture
,emissiveTexture
) are sRGB. All other textures are linear. Like other resources, textures should be reused when possible.Usage:
const material = doc.createMaterial('myMaterial') .setBaseColorFactor([1, 0.5, 0.5, 1]) // RGBA .setOcclusionTexture(aoTexture) .setOcclusionStrength(0.5); mesh.listPrimitives() .forEach((prim) => prim.setMaterial(material));