A custom node-based material.
This material used to describe custom material setups exported from Blender, 3ds Max, or Maya. It can be physically based or non-physical depending on the specified node graph.
Change material color specified in the "RGB.001" node:
const object = app.scene.getObjectByName("MyObj");
const mat = object.material;
const index = mat.nodeRGBMap['RGB.001']; // 'RGB.001' is the name of an RGB node
mat.nodeRGB[index] = new v3d.Vector4(1, 0, 0, 1); // new color in RGBA format
mat.needsUpdate = true;
Change value specified in the "Value.001" node:
const object = app.scene.getObjectByName("Circle");
const mat = object.material;
const index = mat.nodeValueMap['Value.001'];
mat.nodeValue[index] = 0.5; // new value
mat.needsUpdate = true;
parameters — (optional) an object with one or more properties defining the material's appearance. Any property of the material (including any property inherited from Material) can be passed in here.
The exception is the property color which is 0xffffff
(white) by default. In case if no nodeGraph parameter passed to the constructor, this value will be used to generate a fallback node graph which in turn will render that color.
// no nodeGraph passed, this material will render solid red color
const mat = new MeshNodeMaterial({color: 'red'});
Designing node-based materials with JavaScript can be a cumbersome task. It is more efficient to use the modelling suite for that, which conveniently provides real-time preview in viewport.
See the base Material class for common properties.
Additional graphs representing node groups of the main node graph.
The environment map. To ensure a physically correct rendering, you should only add environment maps which were preprocessed by PMREMGenerator. Assigned automatically from a corresponding CubeReflectionProbe object if Material.envMapAutoAssign is true. Default is null.
Scales the effect of the environment map by multiplying its color. Default is 1.
A Matrix4 used for applying the parallax effect to the material's .envMap. This matrix carries the transformation from the world space to the space of a particular reflection probe, which environment map this material uses for rendering. Calculated automatically if Material.envMapAutoAssign is true. Default is the identity matrix.
A Matrix4 inverse to .envMapParallaxMatrix. Used for applying the parallax effect to the material's .envMap. Calculated automatically if Material.envMapAutoAssign is true. Default is the identity matrix.
Defines the type of the parallax volume. The same as CubeReflectionProbe.parallaxType. Assigned automatically from the corresponding CubeReflectionProbe if Material.envMapAutoAssign is true. Default is ReflectionProbeTypeInfinite.
Define whether the material is rendered with flat shading. Default is false
.
Whether the material is affected by fog. Default is true
.
Used to check whether this class represent node material. You should not change this, as it is used internally for optimization.
Material index. Used to define the corresponding output in the Blender's object info node.
Directed graph which contains material nodes.
Array of Vector4 values which contains color values of a material's "RGB" nodes. Please note that these colors are represented by 4-dimentional vector, not the Color class.
Maps "RGB" node name to index in .nodeRGB array. Used to define which color value is to be updated, see the example listing above.
Object with material textures. It maps texture names to textures. You can use it to dynamically assign new textures to a material.
Array of float values which contain values of the material's "Value" nodes.
Maps "Value" node name to index in .nodeValue array. Used to define which value is to be updated, see the example listing above.
Node material profile, one of "blender"
, "max"
, or "maya"
.
See the base Material class for common methods.
Check if the node material uses nodes that render GTAO effect.
Connect texture to the node input. Both the node and its input specified by their names.
Check if this material is unlit (based on emissive nodes).
Find and return a node which has the given name.
Resolve color value passed to given node input.
Find texture connected to given node input.
Resolve float value passed to given node input.
Analyze material and return main shader node.
Analyze material node structure and return a value of the "standard" property. If the property could not be resolved, return default value for that property.
Allowed properties:
0xffffff
(white).null
(no texture).1.0
(opaque).0.5
(semi-metallic).null
(no texture)0.5
.null
(no texture)null
(no texture)1.0
.null
(no texture)(1.0, 1.0)
.0x000000
(black).null
(no texture)0.0
.
Check if the node material has a node of the specified type (nodeType
).
Check if the node material includes Light Path, Ray Switch, or OSL nodes.
Traverse the node material and execute the given callback function per each node in the graph.
Generate shaders and update other material parameters based on the specified .nodeGraph.
Check if the node material uses additive transparency.
Check if the world material can be simplified to a solid color and return that color.
Generate texture uniform name from the given type and arbitrary index (e.g texture index inside glTF asset).
Convert glTF node graph to the format used by the material's .nodeGraph property.
Traverse the graph and execute the given callback function per each node in the graph.
There are numerous material puzzles to manage your materials with no coding.
For more info on how to obtain the source code of this module see this page.