pub struct MeshBasicNodeMaterial {Show 122 fields
pub id: MaterialId,
pub version: u32,
pub kind: MaterialKind,
pub color: Color,
pub opacity: f64,
pub reflectivity: f64,
pub refraction_ratio: f64,
pub env_map: Option<CubeTexture>,
pub pmrem_env: Option<PmremHandle>,
pub color_node: Option<NodeRef>,
pub opacity_node: Option<NodeRef>,
pub alpha_test_node: Option<NodeRef>,
pub alpha_test: f64,
pub alpha_hash: bool,
pub alpha_map: Option<Texture>,
pub emissive_node: Option<NodeRef>,
pub specular: Color,
pub shininess: f64,
pub emissive: Color,
pub emissive_intensity: f64,
pub flat_shading: bool,
pub lights: bool,
pub lights_node: Option<Vec<usize>>,
pub lighting_model: Option<Rc<dyn LightingModel>>,
pub environment_specular: bool,
pub mask_node: Option<NodeRef>,
pub cast_shadow_node: Option<NodeRef>,
pub received_shadow_position_node: Option<NodeRef>,
pub fog: bool,
pub metalness: f64,
pub roughness: f64,
pub map: Option<Texture>,
pub vertex_colors: bool,
pub roughness_map: Option<Texture>,
pub metalness_map: Option<Texture>,
pub emissive_map: Option<Texture>,
pub gradient_map: Option<Texture>,
pub ao_map: Option<Texture>,
pub ao_map_intensity: f64,
pub light_map: Option<Texture>,
pub light_map_intensity: f64,
pub specular_map: Option<Texture>,
pub bump_map: Option<Texture>,
pub bump_scale: f64,
pub clearcoat: f64,
pub clearcoat_roughness: f64,
pub clearcoat_map: Option<Texture>,
pub clearcoat_roughness_map: Option<Texture>,
pub sheen: f64,
pub sheen_color: Color,
pub sheen_roughness: f64,
pub diffuse_roughness: f64,
pub ior: f64,
pub specular_intensity: f64,
pub specular_color: Color,
pub specular_node: Option<NodeRef>,
pub normal_map: Option<Texture>,
pub normal_scale: Vector2,
pub specular_color_map: Option<Texture>,
pub anisotropy: f64,
pub anisotropy_rotation: f64,
pub anisotropy_map: Option<Texture>,
pub iridescence: f64,
pub iridescence_ior: f64,
pub iridescence_thickness_range: [f64; 2],
pub iridescence_thickness_map: Option<Texture>,
pub clearcoat_normal_map: Option<Texture>,
pub clearcoat_normal_scale: Vector2,
pub transmission: f64,
pub transmission_map: Option<Texture>,
pub thickness: f64,
pub thickness_map: Option<Texture>,
pub attenuation_distance: f64,
pub attenuation_color: Color,
pub normal_node: Option<NodeRef>,
pub position_node: Option<NodeRef>,
pub scale_node: Option<NodeRef>,
pub rotation_node: Option<NodeRef>,
pub size_node: Option<NodeRef>,
pub size: f64,
pub rotation: f64,
pub linewidth: f64,
pub size_attenuation: bool,
pub vertex_node: Option<NodeRef>,
pub fragment_node: Option<NodeRef>,
pub output_node: Option<NodeRef>,
pub backdrop_node: Option<NodeRef>,
pub backdrop_alpha_node: Option<NodeRef>,
pub mrt_node: Option<MrtNode>,
pub metalness_node: Option<NodeRef>,
pub roughness_node: Option<NodeRef>,
pub depth_node: Option<NodeRef>,
pub context_overrides: Option<OverrideNodes>,
pub context_node: Option<ContextValue>,
pub side: Side,
pub visible: bool,
pub transparent: bool,
pub force_single_pass: bool,
pub wireframe: bool,
pub blending: Blending,
pub premultiplied_alpha: bool,
pub alpha_to_coverage: bool,
pub world_units: bool,
pub blend_src: BlendFactor,
pub blend_dst: BlendFactor,
pub blend_equation: BlendEquation,
pub blend_src_alpha: Option<BlendFactor>,
pub blend_dst_alpha: Option<BlendFactor>,
pub blend_equation_alpha: Option<BlendEquation>,
pub depth_test: bool,
pub depth_write: bool,
pub depth_func: DepthFunc,
pub color_write: bool,
pub stencil_write: bool,
pub stencil_write_mask: u32,
pub stencil_func: StencilFunc,
pub stencil_ref: u32,
pub stencil_func_mask: u32,
pub stencil_fail: StencilOp,
pub stencil_z_fail: StencilOp,
pub stencil_z_pass: StencilOp,
pub name: &'static str,
}Expand description
Port of MeshBasicNodeMaterial.js + the NodeMaterial.js / Material.js
fields the ladder uses. Defaults mirror three.js: white, opaque,
FrontSide, depth test on with LessEqualDepth, depth write on,
reflectivity = 1.
§Changing a material after its first frame
The renderer builds a material’s shader program once and looks it up by
id and version from then on (docs/scene-graph.md, “Program cache”),
exactly as WebGPURenderer does. So the rule is three.js’:
- a field the program depends on — any node (
color_node,position_node,fragment_node, …), any map orenv_map,kind,lights,lights_node,lighting_model,environment_specular,flat_shading,fog,transparent,blending,alpha_to_coverage,world_units,size_attenuation,mask_node,cast_shadow_node— needsset_needs_updateafter it changes, which ismaterial.needsUpdate = true. Without it the old program keeps drawing. - a field the program reads as a uniform —
color,opacity,specular,shininess,emissive,emissive_intensity,metalness,roughness,bump_scale,rotation,reflectivity,refraction_ratio— is uploaded every frame and needs nothing, as in three.js. side,depth_test,depth_write,color_write, thestencil_*fields and the blend factors are pipeline state, keyed per draw, and need nothing either.- a map’s (or
env_map’s) filters and wrap modes need nothing: they are part of the program’s cache key, read off the textures at every draw, as three’s WebGPU backend reads them ingetMaterialCacheKey().
Fields§
§id: MaterialIdMaterial.id. Read-only in spirit; see MaterialId for why a clone
gets a new one.
version: u32Material.version — “starts at 0 and counts how many times
needsUpdate is set to true”. Part of the program cache key.
kind: MaterialKindWhich NodeMaterial subclass this stands in for — see MaterialKind.
color: ColorMaterial.color — MeshBasicMaterial’s diffuse colour.
opacity: f64Material.opacity.
reflectivity: f64MeshBasicMaterial.reflectivity — the mix factor BasicEnvironmentNode
blends the reflected environment colour in by.
refraction_ratio: f64MeshBasicMaterial.refractionRatio — the index ratio
refract_view bends the view ray by
(materialRefractionRatio).
0.98 for the kinds whose three.js material has the property — Basic
(new), lambert and
phong — and 0 from every other constructor, whose
material has none. Three’s materialRefractionRatio is one shared
uniform( 0 ) that onObjectUpdate leaves alone when
material.refractionRatio is undefined, so such a material reads 0
until a Basic, Lambert or Phong draw writes it, and the last value
written after that; the port writes this field every draw instead.
env_map: Option<CubeTexture>MeshBasicMaterial.envMap — setupEnvironment() turns it into
BasicEnvironmentNode( cubeTexture( envMap ) ).
pmrem_env: Option<PmremHandle>MeshStandardMaterial.envMap on a PBR material, which
NodeMaterial.setupEnvironment() turns into EnvironmentNode( pmremTexture( envMap ) ) rather than a plain cube read. The handle
comes from a
PmremEnvironment, which
owns the generated atlas; scene.environment reaches the same place by
being copied onto every material that has none of its own.
color_node: Option<NodeRef>NodeMaterial.colorNode — replaces the materialColor uniform in
setupDiffuseColor().
opacity_node: Option<NodeRef>NodeMaterial.opacityNode — replaces the materialOpacity uniform in
setupDiffuseColor(), so DiffuseColor.a is multiplied by a node’s
value instead. float( opacityNode ) narrows a wider node to its first
component, which is how opacityNode = texture( map ) becomes
DiffuseColor.w * texel.x.
alpha_test_node: Option<NodeRef>NodeMaterial.alphaTestNode — diffuseColor.a.lessThanEqual( node ).discard() at the end of setupDiffuseColor().
Takes precedence over alpha_test, as in three.
alpha_test: f64Material.alphaTest — when positive, setupDiffuseColor() discards
against the materialAlphaTest object uniform
(webgpu_shadowmap_pointlight’s spheres use 0.5). The shadow pass
copies it onto its override material, so cut-away texels cast no
shadow either.
alpha_hash: boolMaterial.alphaHash — when set, setupDiffuseColor() discards the
fragments whose alpha is below getAlphaHashThreshold( positionLocal )
(see crate::nodes::alpha_hash), the stochastic stand-in for
blending that webgpu_materials_alphahash renders.
alpha_map: Option<Texture>Material.alphaMap — materialOpacity becomes opacity * texture( alphaMap ) (MaterialNode.OPACITY), a vec4 product that the alpha
assign narrows back to its .x. Copied onto the shadow pass’s
override material like alpha_test.
emissive_node: Option<NodeRef>NodeMaterial.emissiveNode — setupLighting()’s EMISSIVE tail:
EmissiveColor = vec3( emissiveNode ) and outgoingLight += EmissiveColor. On a Phong or Standard material the materialEmissive
uniform already takes that path; on an unlit MeshBasicNodeMaterial
this node is the only way in, which is what webgpu_instance_uniform
uses it for.
specular: ColorMeshPhongMaterial.specular / .shininess / .emissive /
.emissiveIntensity. The dumps show all four reaching the shader as
object-group uniforms on every Phong material, even the ones the example
never sets.
MeshPhongMaterial.specular — the Blinn-Phong specular tint. Read by
Phong only; Lambert
forces the specular lobe off.
shininess: f64MeshPhongMaterial.shininess — the Blinn-Phong specular exponent.
emissive: ColorMaterial.emissive — the uniform tail NodeMaterial.setupLighting()
adds to outgoingLight on a lit material.
emissive_intensity: f64Material.emissiveIntensity — multiplies emissive.
flat_shading: boolMaterial.flatShading — NodeMaterial.setupNormal() picks normalFlat
(the screen-space derivative frame) over the interpolated vertex normal,
so there is no normal attribute and no normal varying at all.
lights: boolNodeMaterial.lights. false is the light spheres’ material: no
lighting flow at all, outgoingLight = DiffuseColor.rgb.
lights_node: Option<Vec<usize>>material.lightsNode = lights( [ light1 ] ) — the selective-lights
form. Indices into Scene.lights, since a PointLight is owned by the
scene here rather than shared through an Rc. None means “every light
in the scene”, which is what LightsNode defaults to.
lighting_model: Option<Rc<dyn LightingModel>>The lightingModel of material.lightsNode = lights( [ … ] ).context( { lightingModel } ) — a user-defined
LightingModel that the LightsNode
drives in place of a built-in one.
LightingContextNode.setup() reads this.lightingModel || builder.context.lightingModel, so the material’s own
setupLightingModel() wins: this is read only by the kinds that have
none of their own — Points, Sprite, and Basic standing in for a
bare NodeMaterial — and ignored, as in three, by Phong, Lambert,
Standard and Physical. A program input, like lights_node.
environment_specular: boolWhether PhysicalLightingModel.indirectSpecular() reads the
environment’s specular radiance. true is three’s model.
false is the patch webgpu_postprocessing_ssr_denoise applies to
PhysicalLightingModel.prototype.indirectSpecular, where screen-space
reflections supply all the specular: builder.context.radiance = vec3( 0 ) and, on a clearcoat model, clearcoatRadiance.assign( vec3( 0 ) ), before the original method runs. The environment’s
diffuse term (iblIrradiance) is untouched, and EnvironmentNode
still samples radiance, as three’s dump does; only the read in
indirectSpecular becomes the zero vector. Three patches the
prototype for the whole page; the port scopes it to the material,
which the page applies to every material in the scene. Read by
Standard and Physical only, and a program input, like lights
(docs/nodes.md §89).
mask_node: Option<NodeRef>material.maskNode — NodeMaterial.setupDiscard() turns it into
If( mask.not(), () => Discard() ) at the top of the fragment.
cast_shadow_node: Option<NodeRef>material.castShadowNode — the colour this material casts into the
shadow map’s colour target, which receivers tint their shadow by when
renderer.shadowMap.transmitted is on (docs/nodes.md §43).
Renderer._getShadowNodes() reads its .rgb and .a.
received_shadow_position_node: Option<NodeRef>material.receivedShadowPositionNode —
ShadowBaseNode.setupShadowPosition() assigns it to
shadowPositionWorld instead of positionWorld.
fog: boolMaterial.fog — false on the shadow-pass material, which is why the
shadow programs carry no fog mix even though scene.fog is set.
metalness: f64MeshStandardMaterial.metalness / .roughness and the three maps the
example uses. map multiplies the diffuse colour; roughnessMap takes
its green channel and metalnessMap its blue, which is the glTF
packing three.js follows.
roughness: f64MeshStandardMaterial.roughness.
map: Option<Texture>Material.map — the base colour texture; multiplies
color.
vertex_colors: boolMaterial.vertexColors — setupDiffuseColor() multiplies the diffuse
colour by vertexColor(), so one LineSegments (or one mesh) can carry
a colour per vertex instead of one per draw call. The geometry needs a
three-component color attribute; see
vertex_color for the one divergence
from three’s node.
roughness_map: Option<Texture>MeshStandardMaterial.roughnessMap — its green channel multiplies
roughness.
metalness_map: Option<Texture>MeshStandardMaterial.metalnessMap — its blue channel multiplies
metalness.
emissive_map: Option<Texture>MeshStandardMaterial.emissiveMap — MaterialNode.EMISSIVE’s
emissiveNode.mul( texture ), where emissiveNode is already
emissive * emissiveIntensity. The multiply is a vec4 one in three
(vec4( emissive, 1 ) * tex) and the .xyz is taken afterwards, which
is why the port builds it the same way rather than multiplying vec3s.
gradient_map: Option<Texture>MeshToonMaterial.gradientMap — the ramp ToonLightingModel reads
the direct light’s dotNL * 0.5 + 0.5 through. Read by the Toon
kind only.
ao_map: Option<Texture>MeshStandardMaterial.aoMap / .aoMapIntensity — materialAO,
tex.r.sub( 1 ).mul( aoMapIntensity ).add( 1 ), assigned to the
AmbientOcclusion property by NodeMaterial.setupAmbientOcclusion().
Read by every lit mesh kind (Basic, Lambert, Phong, Toon, Standard,
Physical), as three’s aoMap is.
ao_map_intensity: f64MeshStandardMaterial.aoMapIntensity — multiplies
ao_map’s contribution.
light_map: Option<Texture>material.lightMap (MeshBasicMaterial, MeshLambertMaterial,
MeshPhongMaterial, MeshStandardMaterial, MeshToonMaterial) —
read by material_light_map
only: three’s setupLightMap() (an IrradianceNode in the lights
list) is not ported, so the material’s own flow does not apply it.
light_map_intensity: f64material.lightMapIntensity, on the same materials as
light_map — the materialLightMap scale.
specular_map: Option<Texture>material.specularMap (MeshBasicMaterial, MeshLambertMaterial,
MeshPhongMaterial) — read by
material_specular_strength
only; the Phong flow does not apply it.
bump_map: Option<Texture>MeshStandardMaterial.bumpMap / .bumpScale — BumpMapNode.
bump_scale: f64MeshStandardMaterial.bumpScale — scales bump_map’s
derivative before it perturbs the normal.
clearcoat: f64MeshPhysicalMaterial’s own fields. Nothing on this rung sets them, but
rung 10’s glTF materials will: KHR_materials_specular is
specularIntensity + specularColor, and ior drives the dielectric
F0. They are carried here so the material API does not have to change
shape when MaterialKind::Physical arrives.
clearcoat_roughness: f64MeshPhysicalMaterial.clearcoatRoughness.
clearcoat_map: Option<Texture>MeshPhysicalMaterial.clearcoatMap — MaterialNode.CLEARCOAT
multiplies clearcoat by the texel’s red channel.
clearcoat_roughness_map: Option<Texture>MeshPhysicalMaterial.clearcoatRoughnessMap —
MaterialNode.CLEARCOAT_ROUGHNESS multiplies clearcoatRoughness by
the texel’s green channel.
sheen: f64MeshPhysicalMaterial.sheen / .sheenColor / .sheenRoughness —
KHR_materials_sheen. sheen is the intensity and sheen_color the
tint; MaterialNode.SHEEN is sheenColor.mul( sheen ) and the shader
carries both as separate uniforms, which is why the multiply is in the
WGSL and not here.
sheen > 0 is MeshPhysicalNodeMaterial.useSheen: it is what turns the
whole sheen half of PhysicalLightingModel on, so a sheen colour with a
zero intensity generates exactly the shader it did before.
sheen_color: ColorMeshPhysicalMaterial.sheenColor — the sheen lobe’s tint.
sheen_roughness: f64MeshPhysicalMaterial.sheenRoughness.
diffuse_roughness: f64MeshPhysicalMaterial.diffuseRoughness — KHR_materials_diffuse_roughness.
diffuse_roughness > 0 is MeshPhysicalNodeMaterial.useDiffuseRoughness,
which swaps the Lambert diffuse lobe of PhysicalLightingModel for
the energy-preserving Oren–Nayar one (EON). diffuseRoughnessMap is
not ported: no graded page carries one.
ior: f64MeshPhysicalMaterial.ior — drives the dielectric F0 that
setupSpecular() derives before specular_color modulates it.
specular_intensity: f64MeshPhysicalMaterial.specularIntensity — KHR_materials_specular.
specular_color: ColorMeshPhysicalMaterial.specularColor — KHR_materials_specular.
specular_node: Option<NodeRef>material.specularNode.
normal_map: Option<Texture>MeshStandardMaterial.normalMap and .normalScale. GLTFLoader
flips normalScale.y on a geometry that has a normal map but no
tangent attribute (useDerivativeTangents), which is where Michelle’s
( 1, -1 ) comes from — it is not in the asset.
normal_scale: Vector2Material.normalScale — scales normal_map’s x
and y before it perturbs the surface normal.
specular_color_map: Option<Texture>MeshPhysicalMaterial.specularColorMap — multiplies specularColor.
anisotropy: f64MeshPhysicalMaterial.anisotropy / .anisotropyRotation /
.anisotropyMap — KHR_materials_anisotropy. The pair reaches the
shader as one materialAnisotropyVector uniform,
vec2( anisotropy * cos( rotation ), anisotropy * sin( rotation ) ),
exactly as three’s MeshPhysicalNodeMaterial builds it.
anisotropy_rotation: f64MeshPhysicalMaterial.anisotropyRotation, in radians.
anisotropy_map: Option<Texture>MeshPhysicalMaterial.anisotropyMap — its red and green channels give
the per-texel anisotropy strength and rotation.
iridescence: f64MeshPhysicalMaterial.iridescence — KHR_materials_iridescence’s
strength. iridescence > 0 is MeshPhysicalNodeMaterial.useIridescence,
the flag that turns on evalIridescence and the iridescent F0 in
computeMultiscattering, so every material with the default 0
generates exactly the shader it did before. iridescenceMap is not
ported: MaterialNode.IRIDESCENCE has no map branch in three
(docs/nodes.md §95).
iridescence_ior: f64MeshPhysicalMaterial.iridescenceIOR — the thin film’s index of
refraction.
iridescence_thickness_range: [f64; 2]MeshPhysicalMaterial.iridescenceThicknessRange — [ minimum, maximum ]
in nanometres. With no
iridescence_thickness_map only the
maximum is read, which is three’s own behaviour, not a typo.
iridescence_thickness_map: Option<Texture>MeshPhysicalMaterial.iridescenceThicknessMap — its green channel
interpolates the film thickness between the two ends of
iridescence_thickness_range.
clearcoat_normal_map: Option<Texture>MeshPhysicalMaterial.clearcoatNormalMap / .clearcoatNormalScale.
The clearcoat lobe’s own normal, through the same TBN sub-build the
base normal map uses.
clearcoat_normal_scale: Vector2MeshPhysicalMaterial.clearcoatNormalScale — scales
clearcoat_normal_map’s x and y.
transmission: f64MeshPhysicalMaterial.transmission / .thickness /
.attenuationDistance / .attenuationColor —
KHR_materials_transmission and KHR_materials_volume. A non-zero
transmission moves the object into the renderer’s transmission pass.
transmission_map: Option<Texture>MeshPhysicalMaterial.transmissionMap — MaterialNode.TRANSMISSION
multiplies transmission by the texel’s red channel.
thickness: f64MeshPhysicalMaterial.thickness — KHR_materials_volume; the modelled
thickness of the transmissive medium.
thickness_map: Option<Texture>MeshPhysicalMaterial.thicknessMap — MaterialNode.THICKNESS
multiplies thickness by the texel’s green channel.
attenuation_distance: f64MeshPhysicalMaterial.attenuationDistance — KHR_materials_volume;
the distance light travels through the medium before it is tinted by
attenuation_color.
attenuation_color: ColorMeshPhysicalMaterial.attenuationColor — KHR_materials_volume.
normal_node: Option<NodeRef>material.normalNode — e.g. normalMap( texture( map ) ).
position_node: Option<NodeRef>NodeMaterial.positionNode — replaces positionLocal.
Deviation from r186, deliberate (plan §5.2, docs/nodes.md §10):
three’s setupPosition() assigns the instance transform first and
positionNode after, so positionNode discards the instance matrix.
The port assigns positionNode first and then the instance transform.
SpriteNodeMaterial reads it a second time in setupPositionView().
scale_node: Option<NodeRef>SpriteNodeMaterial.scaleNode / .rotationNode.
rotation_node: Option<NodeRef>SpriteNodeMaterial.rotationNode — replaces the materialRotation
uniform.
size_node: Option<NodeRef>PointsNodeMaterial.sizeNode — the point size in pixels when the
material draws a Sprite (instanced quads)
rather than Points. Read by setupVertexSprite() only.
size: f64PointsMaterial.size — the materialPointSize uniform. Read by
material_point_size only;
the points flow sizes a sprite by size_node.
rotation: f64SpriteMaterial.rotation — the materialRotation uniform.
linewidth: f64LineBasicMaterial.linewidth — the materialLineWidth uniform.
A hairline Line ignores it, as three.js says: “WebGL and WebGPU ignore
this setting and always render line primitives with a width of one
pixel”. It is read by the fat-line material, which turns each segment
into a screen-space quad and so can honour a width.
size_attenuation: boolSpriteNodeMaterial.sizeAttenuation. true (the default) is the branch
that omits the mvPosition.z.negate() scale factor.
vertex_node: Option<NodeRef>NodeMaterial.vertexNode — replaces the whole clip-position flow.
fragment_node: Option<NodeRef>NodeMaterial.fragmentNode — replaces the whole fragment flow.
output_node: Option<NodeRef>NodeMaterial.outputNode — replaces only what output.color is written
from. The standard flow still runs and still writes the Output
property, so the custom node can read DiffuseColor, Output and the
normal accessors.
backdrop_node: Option<NodeRef>NodeMaterial.backdropNode — what the diffuse light is replaced
with: LightsNode.setup() assigns it to totalDiffuse on a lit
material, setupLighting() makes it the outgoing light on an unlit
one. Usually a viewport_shared_texture tap — the scene behind the
object, read back. A material with one goes in the transparent list
whatever transparent says, so that it draws
after what it reads.
backdrop_alpha_node: Option<NodeRef>NodeMaterial.backdropAlphaNode — blend backdrop_node
over the lit diffuse by this much instead of replacing it.
mrt_node: Option<MrtNode>NodeMaterial.mrtNode — the material’s own MRT overrides, merged over
the renderer’s (the pass’s) by NodeMaterial.setup(). Read only when a
render target with more than one colour attachment is bound, which is
what makes it inert for every material that is not drawn into one.
webgpu_postprocessing_bloom_selective gives each of its fifty spheres
a material whose mrtNode is mrt( { bloomIntensity: uniform( 0 or 1 ) } ), over the pass’s mrt( { output, bloomIntensity: float( 0 ) } ).
metalness_node: Option<NodeRef>MeshStandardNodeMaterial.metalnessNode / .roughnessNode — the two
setupVariants() inputs, replacing the materialMetalness /
materialRoughness uniforms (and their maps). webgpu_deferred’s
resolve material reads both out of the G-buffer.
roughness_node: Option<NodeRef>MeshStandardNodeMaterial.roughnessNode — see
metalness_node.
depth_node: Option<NodeRef>NodeMaterial.depthNode — setupDepth()’s value, written to the
fragment stage’s @builtin( frag_depth ) output. Set only when the
material is drawn with a depth buffer (three checks
depthWrite || depthTest and the target’s depthBuffer).
context_overrides: Option<OverrideNodes>NodeMaterial.contextNode = overrideNodes( [ … ] ) — the three
accessors webgpu_deferred’s resolve material reads out of the
G-buffer instead of out of the geometry. See docs/nodes.md §27.
context_node: Option<ContextValue>NodeMaterial.contextNode = context( { … } ) — builder-context keys
installed for the whole of the material’s setup, the way
context installs them for one subgraph.
The keys the port reads are the ones RetroPassNode sets: getUV,
which every texture tap of a material
map takes in place of its default uv(), and getTextureLevel, which
turns its textureSample into a textureSampleLevel. See
docs/nodes.md §79.
side: SideMaterial.side — which face(s) are drawn.
visible: boolMaterial.visible — _projectObject() skips an object whose material is
not visible.
transparent: boolMaterial.transparent — which of the render list’s two arrays the object
goes into, and so whether it is sorted front-to-back or back-to-front.
force_single_pass: boolMaterial.forceSinglePass — a transparent DoubleSide material is
drawn once, both faces together, instead of as three’s back-then-front
pair.
wireframe: boolMaterial.wireframe — only MeshBasicMaterial and its kin expose it.
It reaches no shader: WebGPUUtils.getPrimitiveTopology() turns a
wireframe Mesh into a line-list, and Geometries.getIndex()
swaps the geometry’s index for getWireframeIndex()’s — each
triangle’s three edges as six indices (see Renderer’s
wireframe_index).
blending: BlendingMaterial.blending — NormalBlending by default, which together with
transparent: false is what keeps a pipeline blend-state-free.
premultiplied_alpha: boolMaterial.premultipliedAlpha — selects the other half of the
_getBlending() table.
alpha_to_coverage: boolMaterial.alphaToCoverage — read by builder.isOpaque(), by
Line2NodeMaterial’s alphaLine, and by the pipeline’s
alphaToCoverageEnabled (with more than one sample).
world_units: boolLine2NodeMaterial.worldUnits (_useWorldUnits) — the fat line’s
linewidth is in world units rather than screen pixels. Read by
setup() and by LineSegments2.raycast(); ignored by every other
material. A program input: set it before the first frame, or call
set_needs_update.
blend_src: BlendFactorMaterial.blendSrc / .blendDst / .blendEquation and the three
*Alpha overrides (None is Three’s null), read only under
CustomBlending.
blend_dst: BlendFactorMaterial.blendDst.
blend_equation: BlendEquationMaterial.blendEquation.
blend_src_alpha: Option<BlendFactor>Material.blendSrcAlpha.
blend_dst_alpha: Option<BlendFactor>Material.blendDstAlpha.
blend_equation_alpha: Option<BlendEquation>Material.blendEquationAlpha.
depth_test: boolMaterial.depthTest.
depth_write: boolMaterial.depthWrite.
depth_func: DepthFuncMaterial.depthFunc — the depth compare while depth_test is on.
color_write: boolMaterial.colorWrite — false masks every colour channel
(GPUColorWrite.NONE), as the stencil-writing caps in
webgpu_clipping_stencil do. Pipeline state.
stencil_write: boolMaterial.stencilWrite — turns the stencil test and the stencil_*
operations on. Without it the pipeline keeps WebGPU’s default stencil
face state, as _getStencilState() does. Takes effect only on a
renderer created with
RendererParameters::stencil,
whose depth buffer has a stencil aspect. Pipeline state.
stencil_write_mask: u32Material.stencilWriteMask — the pipeline’s stencilWriteMask.
stencil_func: StencilFuncMaterial.stencilFunc — the stencil compare.
stencil_ref: u32Material.stencilRef — setStencilReference() for each draw.
stencil_func_mask: u32Material.stencilFuncMask — the pipeline’s stencilReadMask.
stencil_fail: StencilOpMaterial.stencilFail — the op when the stencil test fails.
stencil_z_fail: StencilOpMaterial.stencilZFail — the op when the stencil test passes and the
depth test fails.
stencil_z_pass: StencilOpMaterial.stencilZPass — the op when both tests pass.
name: &'static strBackground’s material samples the cube map through the background
uniforms rather than an env map.
Implementations§
Source§impl MeshBasicNodeMaterial
impl MeshBasicNodeMaterial
Sourcepub fn dispose(self)
pub fn dispose(self)
material.dispose() — drops this material, and nothing more. A
material is a value here and the renderer only sees per-frame clones,
so there is no count to read: what the renderer built for it ages out
once no render has drawn it for a few renders (docs/scene-graph.md,
“Identity and eviction”). Dropping the material does the same; this
exists so three.js code ports line for line.
Sourcepub fn new() -> Self
pub fn new() -> Self
new MeshBasicMaterial() — a white, opaque Basic
material. Equivalent to Default::default.
Sourcepub fn unsupported_fields(&self) -> Vec<&'static str>
pub fn unsupported_fields(&self) -> Vec<&'static str>
The fields set on this material that nothing in the port reads for its
kind, by their three.js names — the audit in
docs/api.md (“Material fields the port does not read”). The renderer
logs each one once per material when it builds the program; call
check_supported to fail on them instead.
The list is the kind’s declared loud fields (the per-kind table in
src/materials/fields.rs, which the flow dispatch in [setup] reads
too) that this material sets, in the table’s order. A field three’s
own class for that kind lacks (a clearcoat on a Standard material,
say) is not listed: three ignores it too.
Sourcepub fn check_supported(&self) -> Result<(), Error>
pub fn check_supported(&self) -> Result<(), Error>
Err(Error::Unsupported) for the first of
unsupported_fields, so an application
that would rather fail than draw a material differently from three can
ask before its first frame.
Sourcepub fn set_needs_update(&mut self)
pub fn set_needs_update(&mut self)
material.needsUpdate = true: Material.js’ setter, which bumps
version so the next frame builds the program afresh. Call it after
changing anything the program depends on — the struct docs list what
does and does not.
Sourcepub fn sprite() -> Self
pub fn sprite() -> Self
new SpriteNodeMaterial(). SpriteNodeMaterial’s constructor sets
transparent = true explicitly — “In Sprites, the transparent property
is enabled by default” — which also takes it out of isOpaque(), so the
fragment flow keeps its per-fragment alpha.
Sourcepub fn points() -> Self
pub fn points() -> Self
new PointsNodeMaterial().
PointsNodeMaterial extends SpriteNodeMaterial
(src/materials/nodes/PointsNodeMaterial.js), so it inherits
transparent = true — which puts a Points object in the transparent
render list, gives its pipeline a NormalBlending blend state, and
takes it out of is_opaque so the fragment flow
keeps its per-fragment alpha. alphaToCoverage stays off: three.js’
own dump of this pipeline has alphaToCoverageEnabled: false.
Sourcepub fn line(color: Color) -> Self
pub fn line(color: Color) -> Self
new LineBasicNodeMaterial( { color } ).
No MaterialKind of its own, and that is a finding, not a shortcut.
LineBasicNodeMaterial is a bare NodeMaterial that only calls
setDefaultValues( new LineBasicMaterial() ), and every default it
brings that this port models — color white, opacity 1, fog true,
lights false (NodeMaterial’s own default), transparent false — is
already MeshBasicNodeMaterial’s. linewidth / linecap / linejoin
are SVGRenderer-only (“WebGL and WebGPU ignore this setting and always
render line primitives with a width of one pixel”). vertexColors is on
the shared material, since setupDiffuseColor() is where three reads
it — see MeshBasicNodeMaterial::vertex_colors. Three’s own dump of this
material from the d33 page (docs/lines/LineBasicNodeMaterial_27.*) is
the Basic program statement for statement, so a second kind would
generate identical WGSL.
What makes a line a line is the object, not the material:
WebGPUUtils.getPrimitiveTopology( object, material ) reads
object.isLine / object.isLineSegments.
Sourcepub fn line2(color: Color) -> Self
pub fn line2(color: Color) -> Self
new Line2NodeMaterial( { color, linewidth, vertexColors } ) — the
fat line.
Line2NodeMaterial.setDefaultValues( new LineBasicMaterial() ) and then
this.blending = NoBlending — three sets it in the constructor because
the material writes its own coverage through the discard and must not
have the result blended a second time. That default has teeth here: it
makes is_opaque false, so the fragment flow does
not emit DiffuseColor.w = 1.0 (docs/nodes.md §8).
this._useAlphaToCoverage = true is the constructor’s other default,
so alpha_to_coverage starts true; webgpu_lines_fat turns it off.
Sourcepub fn normal() -> Self
pub fn normal() -> Self
new MeshNormalNodeMaterial() — MeshNormalMaterial under
WebGPURenderer.
The whole subclass is one overridden setupDiffuseColor():
diffuseColor = colorSpaceToWorking( vec4( packNormalToRGB( normalView ), opacity ), SRGBColorSpace ). Nothing else about it differs from a
MeshBasicNodeMaterial, so it is a MaterialKind rather than a type.
Sourcepub fn phong(color: Color) -> Self
pub fn phong(color: Color) -> Self
new MeshPhongNodeMaterial( { color } ). NodeMaterial.lights is true
for every lit material, which is what puts the LightsNode flow in the
fragment stage.
Sourcepub fn lambert(color: Color) -> Self
pub fn lambert(color: Color) -> Self
new MeshLambertNodeMaterial( { color } ).
MeshLambertMaterial’s own defaults over Material’s are all shared
with the Phong ones the struct already carries, so the constructor is
the Phong one under a different MaterialKind.
Source§impl MeshBasicNodeMaterial
impl MeshBasicNodeMaterial
Sourcepub fn toon(color: Color, gradient_map: Option<Texture>) -> Self
pub fn toon(color: Color, gradient_map: Option<Texture>) -> Self
new MeshToonNodeMaterial( { color, gradientMap } ).
MeshToonMaterial’s defaults over Material’s — white, emissive
black at intensity 1, no maps — are all ones the struct already
carries, and lights = true is the constructor’s own.