#[non_exhaustive]pub enum BufferSource {
Show 19 variants
InstanceMatrix,
InstanceColor,
Range {
min: [f64; 4],
max: [f64; 4],
},
MorphInfluences,
UniformArray(Rc<Vec<f32>>),
CameraViewMatrices,
CameraProjectionMatrices,
ClippingIntersection,
ClippingUnion,
PreviousBoneMatrices,
BoneMatrices,
Attribute(Rc<Vec<f32>>),
Storage,
AtomicStorage,
Struct {
layout: Rc<StructLayout>,
init: Rc<Vec<u32>>,
},
StorageData {
init: Rc<Vec<u32>>,
read_only: bool,
},
SkeletonBoneMatrices(SkeletonRef),
LightProbe(usize),
Live(LiveValue),
}Expand description
Where an array-typed uniform buffer’s contents come from — BufferNode.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InstanceMatrix
InstancedMesh.instanceMatrix.
InstanceColor
InstancedMesh.instanceColor — setColorAt()’s three floats per
instance, always a stepMode: 'instance' vertex buffer (three.js wraps
it in a fresh InstancedBufferAttribute( colors.array, 3 ) and never
takes the uniform branch for it).
Range
RangeNode resolved per instance:
lerp( min[c], max[c], Math.random() ). min/max are the Vector4s
RangeNode.setup() builds out of the min/max values: a scalar splats
into all four components, a Color fills xyz and leaves w at 1, and
any other vector takes x, y, z || 0, w || 0 — so a vec3 range
has w 0 at both ends, not 1.
Fields
MorphInfluences
Morph.js’ uniformArray( mesh.morphTargetInfluences, 'float' ) — one
vec4 per morph target with the influence in .x.
UniformArray(Rc<Vec<f32>>)
uniformArray( values ) — a constant array the application supplies,
already padded to one vec4 per element the way
UniformArrayNode.updateBuffer() pads it. BloomNode.bloomTintColors
is the ladder’s first; GodraysNode, SSAONode, GTAONode and
SSRNode want the same node.
The values travel in an Rc so the buffer can be cached on the node’s
identity and uploaded once, like BufferSource::Attribute.
CameraViewMatrices
Camera.js’ uniformArray( matrices ).setGroup( renderGroup ) .setName( 'cameraViewMatrices' ) — every ArrayCamera sub-camera’s
matrixWorldInverse, rewritten per render. A render-group buffer, the
only one.
CameraProjectionMatrices
The same for cameraProjectionMatrices — the sub-cameras’
projectionMatrix.
ClippingIntersection
ClippingNode’s uniformArray( intersectionPlanes ).setGroup( renderGroup ) — the clipping context’s intersection planes in view
space, one vec4 each, written per draw from the draw’s context.
ClippingUnion
The same for the context’s unionPlanes.
PreviousBoneMatrices
buffer( previousBoneMatrices, 'mat4', bones ) — Skinning.js’
getPreviousSkinnedPosition(): the skeleton’s bone matrices as they
were before this frame’s skeleton.update(), for the
positionPrevious of a draw into a velocity MRT.
BoneMatrices
referenceBuffer( 'skeleton.boneMatrices', 'mat4', bones ) — the
skeleton’s bone matrices as one array< mat4x4<f32>, N >. Three falls
back to a bone texture when bones * 64 passes the uniform buffer
limit; the ladder’s skeletons fit (Michelle is 65 bones, 4160 bytes).
Attribute(Rc<Vec<f32>>)
A per-instance attribute the caller fills itself — three.js’
new InstancedBufferAttribute( array, itemSize ) on the geometry, e.g.
BatchedText’s aGlyphUV / aGlyphBounds / aColor / aOpacity.
Only ever a vertex buffer: the uniform path has no equivalent.
Storage
instancedArray( count, type ) — a GPU-only storage buffer
(StorageBufferNode, StorageInstancedBufferAttribute with no array
behind it). Zero-filled once by the renderer and never re-uploaded: the
only thing that ever writes it is a compute pass.
Declared array< T > with no element count, because
WGSLNodeBuilder.getStorageAccess() emits a runtime-sized array; the
count on the BufferNode is only what the renderer allocates.
AtomicStorage
instancedArray( count, 'uint' ).toAtomic() — BufferSource::Storage
whose elements are declared atomic< T >
(WGSLNodeBuilder.getUniforms()’s bufferNode.isAtomic arm), so the
only way to touch one is an atomic function.
Struct
storage( indirectAttribute, struct( … ), count ) — an
IndirectStorageBufferAttribute read and written through a named WGSL
struct (StructTypeNode). Declared as the struct itself rather than
wrapped in { value : array< … > }, which is
WGSLNodeBuilder.isCustomStruct()’s single-struct case. init is the
attribute’s Uint32Array, uploaded once when the GPU buffer is made;
see crate::core::IndirectStorageBufferAttribute.
Fields
layout: Rc<StructLayout>The struct’s name and member list.
StorageData
storage( attribute, type, count ) over an attribute that has a CPU
array — computeSkinning()’s storage( new InstancedBufferAttribute( position.array, 3 ), 'vec3' ), or a StorageInstancedBufferAttribute( array, itemSize ). Uploaded once, when the GPU buffer is made, then
left to the kernels. init is the array’s bits already laid out at the
storage stride (a vec3 padded to 16 bytes, as
WebGPUAttributeUtils.createAttribute() pads it).
read_only is .toReadOnly(): var<storage, read> in a kernel too.
Fields
SkeletonBoneMatrices(SkeletonRef)
buffer( skeleton.boneMatrices, 'mat4', bones ) — computeSkinning()’s
bone matrices: a plain uniform BufferNode over the skeleton’s own
array rather than SkinningNode’s referenceBuffer, so it is resolved
from the skeleton it names and not from a render object. The
skeleton’s OnObjectUpdate (skeleton.update(), once per frame) runs
when the buffer is written.
LightProbe(usize)
LightProbeNode.lightProbe — uniformArray( 9 × Vector3 ) holding the
probe at this index of the renderer’s light list, each coefficient
already multiplied by light.intensity (LightProbeNode.update()).
One vec4 per coefficient, rewritten per draw like
BufferSource::MorphInfluences, because the probe can change between
frames while the program does not.
Live(LiveValue)
uniformArray( values ) over an array the application keeps changing
— LightProbeHelper’s uniformArray( lightProbe.sh.coefficients ),
which shares the probe’s own Vector3s. The reader returns the
elements already padded to four floats each; the buffer is rewritten
per draw. Compares by identity, as UniformSource::Live does.
Trait Implementations§
Source§impl Clone for BufferSource
impl Clone for BufferSource
Source§impl Debug for BufferSource
Derived but for Attribute, whose Rc<Vec<f32>> is the caller’s whole
per-instance array — BatchedText hands it four floats per glyph.
impl Debug for BufferSource
Derived but for Attribute, whose Rc<Vec<f32>> is the caller’s whole
per-instance array — BatchedText hands it four floats per glyph.