Skip to content

Sprite2DMaterial

Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:316

TSL-based material for 2D sprites.

UNIFIED API: This material reads from instance attributes, which works for:

  • Single sprites (Sprite2D sets attributes on its geometry)
  • Batched sprites (SpriteBatch sets instanced attributes)

Core instance attributes (always present):

  • instanceUV (vec4): frame UV (x, y, width, height) in atlas
  • instanceColor (vec4): tint color and alpha (r, g, b, a)
  • instanceFlip (vec2): flip flags (x, y) where 1 = normal, -1 = flipped

Effects are composed via registerEffect(), which packs effect data into fixed-size vec4 buffers with per-sprite enable flags.

new Sprite2DMaterial(options?): Sprite2DMaterial

Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:400

Sprite2DMaterialOptions = {}

Sprite2DMaterial

EffectMaterial.constructor

allowOverride: boolean

Defined in: three.js/materials/Material:allowOverride 

Whether it’s possible to override the material with Scene#overrideMaterial  or not.

true

EffectMaterial.allowOverride


alphaHash: boolean

Defined in: three.js/materials/Material:alphaHash 

Enables alpha hashed transparency, an alternative to Material#transparent or Material#alphaTest. The material will not be rendered if opacity is lower than a random threshold. Randomization introduces some grain or noise, but approximates alpha blending without the associated problems of sorting. Using TAA can reduce the resulting noise.

false

EffectMaterial.alphaHash


alphaMap: Texture <unknown, TextureEventMap > | null

Defined in: three.js/materials/MeshBasicMaterial:alphaMap 

The alpha map is a grayscale texture that controls the opacity across the surface (black: fully transparent; white: fully opaque).

Only the color of the texture is used, ignoring the alpha channel if one exists. For RGB and RGBA textures, the renderer will use the green channel when sampling this texture due to the extra bit of precision provided for green in DXT-compressed and uncompressed RGB 565 formats. Luminance-only and luminance/alpha textures will also still work as expected.

alphaMap represents non-color data. Any texture assigned must have texture.colorSpace = NoColorSpace (default).

null

EffectMaterial.alphaMap


alphaTestNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:alphaTestNode 

The alpha test of node materials is by default inferred from the alphaTest property. This node property allows to overwrite the default and define the alpha test with a node instead.

If you don’t want to overwrite the alpha test but modify the existing value instead, use materialAlphaTest.

null

EffectMaterial.alphaTestNode


alphaToCoverage: boolean

Defined in: three.js/materials/Material:alphaToCoverage 

Whether alpha to coverage should be enabled or not. Can only be used with MSAA-enabled contexts (meaning when the renderer was created with antialias parameter set to true). Enabling this will smooth aliasing on clip plane edges and alphaTest-clipped edges.

false

EffectMaterial.alphaToCoverage


aoMap: Texture <unknown, TextureEventMap > | null

Defined in: three.js/materials/MeshBasicMaterial:aoMap 

The red channel of this texture is used as the ambient occlusion map. Requires a second set of UVs.

aoMap represents non-color data. Any texture assigned must have texture.colorSpace = NoColorSpace (default).

null

EffectMaterial.aoMap


aoMapIntensity: number

Defined in: three.js/materials/MeshBasicMaterial:aoMapIntensity 

Intensity of the ambient occlusion effect. Range is [0,1], where 0 disables ambient occlusion. Where intensity is 1 and the AO map’s red channel is also 1, ambient light is fully occluded on a surface.

1

EffectMaterial.aoMapIntensity


aoNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:aoNode 

The lighting of node materials might be influenced by ambient occlusion. The default AO is inferred from an ambient occlusion map assigned to aoMap and the respective aoMapIntensity. This node property allows to overwrite the default and define the ambient occlusion with a custom node instead.

If you don’t want to overwrite the diffuse color but modify the existing values instead, use materialAO.

null

EffectMaterial.aoNode


backdropAlphaNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:backdropAlphaNode 

This node allows to modulate the influence of backdropNode to the outgoing light.

null

EffectMaterial.backdropAlphaNode


backdropNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:backdropNode 

This node can be used to implement a variety of filter-like effects. The idea is to store the current rendering into a texture e.g. via viewportSharedTexture(), use it to create an arbitrary effect and then assign the node composition to this property. Everything behind the object using this material will now be affected by a filter.

const material = new NodeMaterial()
material.transparent = true;
// everything behind the object will be monochromatic
material.backdropNode = saturation( viewportSharedTexture().rgb, 0 );

Backdrop computations are part of the lighting so only lit materials can use this property.

null

EffectMaterial.backdropNode


readonly batchId: number

Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:365

Unique batch ID for this material instance (used for batching).


blendAlpha: number

Defined in: three.js/materials/Material:blendAlpha 

Represents the alpha value of the constant blend color.

This property has only an effect when using custom blending with ConstantAlpha or OneMinusConstantAlpha.

0

EffectMaterial.blendAlpha


blendColor: Color 

Defined in: three.js/materials/Material:blendColor 

Represents the RGB values of the constant blend color.

This property has only an effect when using custom blending with ConstantColor or OneMinusConstantColor.

(0,0,0)

EffectMaterial.blendColor


blendDst: BlendingDstFactor 

Defined in: three.js/materials/Material:blendDst 

Defines the blending destination factor.

OneMinusSrcAlphaFactor

EffectMaterial.blendDst


blendDstAlpha: BlendingDstFactor  | null

Defined in: three.js/materials/Material:blendDstAlpha 

Defines the blending destination alpha factor.

null

EffectMaterial.blendDstAlpha


blendEquation: BlendingEquation 

Defined in: three.js/materials/Material:blendEquation 

Defines the blending equation.

AddEquation

EffectMaterial.blendEquation


blendEquationAlpha: BlendingEquation  | null

Defined in: three.js/materials/Material:blendEquationAlpha 

Defines the blending equation of the alpha channel.

null

EffectMaterial.blendEquationAlpha


blending: Blending 

Defined in: three.js/materials/Material:blending 

Defines the blending type of the material.

It must be set to CustomBlending if custom blending properties like Material#blendSrc, Material#blendDst or Material#blendEquation should have any effect.

NormalBlending

EffectMaterial.blending


blendSrc: BlendingSrcFactor 

Defined in: three.js/materials/Material:blendSrc 

Defines the blending source factor.

SrcAlphaFactor

EffectMaterial.blendSrc


blendSrcAlpha: BlendingSrcFactor  | null

Defined in: three.js/materials/Material:blendSrcAlpha 

Defines the blending source alpha factor.

null

EffectMaterial.blendSrcAlpha


castShadowNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:castShadowNode 

This node can be used to influence how an object using this node material casts shadows. To apply a color to shadows, you can simply do:

material.castShadowNode = vec4( 1, 0, 0, 1 );

Which can be nice to fake colored shadows of semi-transparent objects. It is also common to use the property with Fn function so checks are performed per fragment.

materialCustomShadow.castShadowNode = Fn( () => {
hash( vertexIndex ).greaterThan( 0.5 ).discard();
return materialColor;
} )();
null

EffectMaterial.castShadowNode


castShadowPositionNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:castShadowPositionNode 

Allows to overwrite the geometry position used for shadow map projection which is by default positionLocal, the vertex position in local space.

null

EffectMaterial.castShadowPositionNode


clipIntersection: boolean

Defined in: three.js/materials/Material:clipIntersection 

Changes the behavior of clipping planes so that only their intersection is clipped, rather than their union.

false

EffectMaterial.clipIntersection


clippingPlanes: Plane [] | null

Defined in: three.js/materials/Material:clippingPlanes 

User-defined clipping planes specified as THREE.Plane objects in world space. These planes apply to the objects this material is attached to. Points in space whose signed distance to the plane is negative are clipped (not rendered). This requires WebGLRenderer#localClippingEnabled  to be true.

null

EffectMaterial.clippingPlanes


clipShadows: boolean

Defined in: three.js/materials/Material:clipShadows 

Defines whether to clip shadows according to the clipping planes specified on this material.

false

EffectMaterial.clipShadows


color: Color 

Defined in: three.js/materials/MeshBasicMaterial:color 

Color of the material.

(1,1,1)

EffectMaterial.color


colorNode: Node <"vec3"> | Node <"float"> | Node <"vec4"> | Node <"vec2"> | Node <"color"> | null

Defined in: three.js/materials/nodes/NodeMaterial:colorNode 

The diffuse color of node materials is by default inferred from the color and map properties. This node property allows to overwrite the default and define the diffuse color with a node instead.

material.colorNode = color( 0xff0000 ); // define red color

If you don’t want to overwrite the diffuse color but modify the existing values instead, use materialColor.

material.colorNode = materialColor.mul( color( 0xff0000 ) ); // give diffuse colors a red tint
null

EffectMaterial.colorNode


colorWrite: boolean

Defined in: three.js/materials/Material:colorWrite 

Whether to render the material’s color.

This can be used in conjunction with Object3D#renderOder to create invisible objects that occlude other objects.

true

EffectMaterial.colorWrite


combine: Combine 

Defined in: three.js/materials/MeshBasicMaterial:combine 

How to combine the result of the surface’s color with the environment map, if any.

When set to MixOperation, the MeshBasicMaterial#reflectivity is used to blend between the two colors.

MultiplyOperation

EffectMaterial.combine


contextNode: ContextNode <unknown> | null

Defined in: three.js/materials/nodes/NodeMaterial:contextNode 

This node can be used as a global context management component for this material.

null

EffectMaterial.contextNode


optional defines?: Record<string, unknown>

Defined in: three.js/materials/Material:defines 

EffectMaterial.defines


depthFunc: DepthModes 

Defined in: three.js/materials/Material:depthFunc 

Defines the depth function.

LessEqualDepth

EffectMaterial.depthFunc


depthNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:depthNode 

Allows to overwrite depth values in the fragment shader.

null

EffectMaterial.depthNode


depthTest: boolean

Defined in: three.js/materials/Material:depthTest 

Whether to have depth test enabled when rendering this material. When the depth test is disabled, the depth write will also be implicitly disabled.

true

EffectMaterial.depthTest


depthWrite: boolean

Defined in: three.js/materials/Material:depthWrite 

Whether rendering this material has any effect on the depth buffer.

When drawing 2D overlays it can be useful to disable the depth writing in order to layer several things together without creating z-index artifacts.

true

EffectMaterial.depthWrite


dithering: boolean

Defined in: three.js/materials/Material:dithering 

Whether to apply dithering to the color to remove the appearance of banding.

false

EffectMaterial.dithering


envMap: Texture <unknown, TextureEventMap > | null

Defined in: three.js/materials/MeshBasicMaterial:envMap 

The environment map.

envMap represents luminance data, and the texture must be assigned a Texture#colorSpace . Most envMap textures set texture.colorSpace = LinearSRGBColorSpace and use float-type formats such as .exr or .hdr.

null

EffectMaterial.envMap


envMapRotation: Euler 

Defined in: three.js/materials/MeshBasicMaterial:envMapRotation 

The rotation of the environment map in radians.

(0,0,0)

EffectMaterial.envMapRotation


envNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:envNode 

The environment of node materials can be defined by an environment map assigned to the envMap property or by Scene.environment if the node material is a PBR material. This node property allows to overwrite the default behavior and define the environment with a custom node.

material.envNode = pmremTexture( renderTarget.texture );
null

EffectMaterial.envNode


fog: boolean

Defined in: three.js/materials/nodes/NodeMaterial:fog 

Whether this material is affected by fog or not.

true

EffectMaterial.fog


forceSinglePass: boolean

Defined in: three.js/materials/Material:forceSinglePass 

Whether double-sided, transparent objects should be rendered with a single pass or not.

The engine renders double-sided, transparent objects with two draw calls (back faces first, then front faces) to mitigate transparency artifacts. There are scenarios however where this approach produces no quality gains but still doubles draw calls e.g. when rendering flat vegetation like grass sprites. In these cases, set the forceSinglePass flag to true to disable the two pass rendering to avoid performance issues.

false

EffectMaterial.forceSinglePass


fragmentNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:fragmentNode 

This node property can be used if you need complete freedom in implementing the fragment shader. Assigning a node will replace the built-in material logic used in the fragment stage.

null

EffectMaterial.fragmentNode


geometryNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:geometryNode 

This node property is intended for logic which modifies geometry data once or per animation step. Apps usually place such logic randomly in initialization routines or in the animation loop. geometryNode is intended as a dedicated API so there is an intended spot where geometry modifications can be implemented.

The idea is to assign a Fn definition that holds the geometry modification logic. A typical example would be a GPU based particle system that provides a node material for usage on app level. The particle simulation would be implemented as compute shaders and managed inside a Fn function. This function is eventually assigned to geometryNode.

null

EffectMaterial.geometryNode


readonly isMaterial: boolean

Defined in: three.js/materials/Material:isMaterial 

This flag can be used for type testing.

true

EffectMaterial.isMaterial


readonly isMeshBasicNodeMaterial: boolean

Defined in: three.js/materials/nodes/MeshBasicNodeMaterial:isMeshBasicNodeMaterial 

This flag can be used for type testing.

true

EffectMaterial.isMeshBasicNodeMaterial


readonly isNodeMaterial: boolean

Defined in: three.js/materials/nodes/NodeMaterial:isNodeMaterial 

This flag can be used for type testing.

true

EffectMaterial.isNodeMaterial


lightMap: Texture <unknown, TextureEventMap > | null

Defined in: three.js/materials/MeshBasicMaterial:lightMap 

The light map. Requires a second set of UVs.

lightMap represents pre-baked illuminance data, and the texture must be assigned a Texture#colorSpace . Most lightMap textures set texture.colorSpace = LinearSRGBColorSpace and use float-type formats such as .exr or .hdr.

null

EffectMaterial.lightMap


lightMapIntensity: number

Defined in: three.js/materials/MeshBasicMaterial:lightMapIntensity 

Intensity of the baked light.

1

EffectMaterial.lightMapIntensity


lights: boolean

Defined in: three.js/materials/nodes/NodeMaterial:lights 

Whether this material is affected by lights or not.

false

EffectMaterial.lights


lightsNode: LightsNode  | null

Defined in: three.js/materials/nodes/NodeMaterial:lightsNode 

Node materials which set their lights property to true are affected by all lights of the scene. Sometimes selective lighting is wanted which means only some lights in the scene affect a material. This can be achieved by creating an instance of LightsNode  with a list of selective lights and assign the node to this property.

const customLightsNode = lights( [ light1, light2 ] );
material.lightsNode = customLightsNode;
null

EffectMaterial.lightsNode


map: Texture <unknown, TextureEventMap > | null

Defined in: three.js/materials/MeshBasicMaterial:map 

The color map. May optionally include an alpha channel, typically combined with Material#transparent or Material#alphaTest. The texture map color is modulated by the diffuse color.

map represents color data, and the texture must be assigned a Texture#colorSpace . Most map textures set texture.colorSpace = SRGBColorSpace.

null

EffectMaterial.map


maskNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:maskNode 

Discards the fragment if the mask value is false.

null

EffectMaterial.maskNode


maskShadowNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:maskShadowNode 

This node can be used to implement a shadow mask for the material.

null

EffectMaterial.maskShadowNode


mrtNode: MRTNode  | null

Defined in: three.js/materials/nodes/NodeMaterial:mrtNode 

MRT configuration is done on renderer or pass level. This node allows to overwrite what values are written into MRT targets on material level. This can be useful for implementing selective FX features that should only affect specific objects.

null

EffectMaterial.mrtNode


name: string

Defined in: three.js/materials/Material:name 

The name of the material.

EffectMaterial.name


normalNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:normalNode 

The normals of node materials are by default inferred from the normalMap/normalScale or bumpMap/bumpScale properties. This node property allows to overwrite the default and define the normals with a node instead.

If you don’t want to overwrite the normals but modify the existing values instead, use materialNormal.

null

EffectMaterial.normalNode


opacity: number

Defined in: three.js/materials/Material:opacity 

Defines how transparent the material is. A value of 0.0 indicates fully transparent, 1.0 is fully opaque.

If the Material#transparent is not set to true, the material will remain fully opaque and this value will only affect its color.

1

EffectMaterial.opacity


opacityNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:opacityNode 

The opacity of node materials is by default inferred from the opacity and alphaMap properties. This node property allows to overwrite the default and define the opacity with a node instead.

If you don’t want to overwrite the opacity but modify the existing value instead, use materialOpacity.

null

EffectMaterial.opacityNode


outputNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:outputNode 

This node can be used to define the final output of the material.

TODO: Explain the differences to fragmentNode.

null

EffectMaterial.outputNode


polygonOffset: boolean

Defined in: three.js/materials/Material:polygonOffset 

Whether to use polygon offset or not. When enabled, each fragment’s depth value will be offset after it is interpolated from the depth values of the appropriate vertices. The offset is added before the depth test is performed and before the value is written into the depth buffer.

Can be useful for rendering hidden-line images, for applying decals to surfaces, and for rendering solids with highlighted edges.

false

EffectMaterial.polygonOffset


polygonOffsetFactor: number

Defined in: three.js/materials/Material:polygonOffsetFactor 

Specifies a scale factor that is used to create a variable depth offset for each polygon.

0

EffectMaterial.polygonOffsetFactor


polygonOffsetUnits: number

Defined in: three.js/materials/Material:polygonOffsetUnits 

Is multiplied by an implementation-specific value to create a constant depth offset.

0

EffectMaterial.polygonOffsetUnits


positionNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:positionNode 

The local vertex positions are computed based on multiple factors like the attribute data, morphing or skinning. This node property allows to overwrite the default and define local vertex positions with nodes instead.

If you don’t want to overwrite the vertex positions but modify the existing values instead, use positionLocal.

material.positionNode = positionLocal.add( displace );
null

EffectMaterial.positionNode


precision: "highp" | "mediump" | "lowp" | null

Defined in: three.js/materials/Material:precision 

Override the renderer’s default precision for this material.

null

EffectMaterial.precision


premultipliedAlpha: boolean

Defined in: three.js/materials/Material:premultipliedAlpha 

Whether to premultiply the alpha (transparency) value.

false

EffectMaterial.premultipliedAlpha


receivedShadowNode: (() => Node ) | null

Defined in: three.js/materials/nodes/NodeMaterial:receivedShadowNode 

This node can be used to influence how an object using this node material receive shadows.

const totalShadows = float( 1 ).toVar();
material.receivedShadowNode = Fn( ( [ shadow ] ) => {
totalShadows.mulAssign( shadow );
//return float( 1 ); // bypass received shadows
return shadow.mix( color( 0xff0000 ), 1 ); // modify shadow color
} );
@default null
#### Inherited from
[`EffectMaterial`](/three-flatland/api/three-flatland/src/classes/effectmaterial/).[`receivedShadowNode`](/three-flatland/api/three-flatland/src/classes/effectmaterial/#receivedshadownode)
***
### receivedShadowPositionNode
> **receivedShadowPositionNode**: [`Node`](https://threejs.org/docs/) \| `null`
Defined in: [three.js/materials/nodes/NodeMaterial:receivedShadowPositionNode](https://threejs.org/docs/#api/en/materials/nodes/NodeMaterial.receivedShadowPositionNode)
Allows to overwrite the position used for shadow map rendering which
is by default positionWorld, the vertex position
in world space.
#### Default
```ts
null

EffectMaterial.receivedShadowPositionNode


reflectivity: number

Defined in: three.js/materials/MeshBasicMaterial:reflectivity 

How much the environment map affects the surface. The valid range is between 0 (no reflections) and 1 (full reflections).

1

EffectMaterial.reflectivity


refractionRatio: number

Defined in: three.js/materials/MeshBasicMaterial:refractionRatio 

The index of refraction (IOR) of air (approximately 1) divided by the index of refraction of the material. It is used with environment mapping modes CubeRefractionMapping and EquirectangularRefractionMapping. The refraction ratio should not exceed 1.

0.98

EffectMaterial.refractionRatio


shadowSide: Side  | null

Defined in: three.js/materials/Material:shadowSide 

Defines which side of faces cast shadows. If null, the side casting shadows is determined as follows:

  • When Material#side is set to FrontSide, the back side cast shadows.
  • When Material#side is set to BackSide, the front side cast shadows.
  • When Material#side is set to DoubleSide, both sides cast shadows.
null

EffectMaterial.shadowSide


side: Side 

Defined in: three.js/materials/Material:side 

Defines which side of faces will be rendered - front, back or both.

FrontSide

EffectMaterial.side


specularMap: Texture <unknown, TextureEventMap > | null

Defined in: three.js/materials/MeshBasicMaterial:specularMap 

Specular map used by the material.

specularMap represents color data, and the texture must be assigned a Texture#colorSpace . Most specularMap textures set texture.colorSpace = SRGBColorSpace.

null

EffectMaterial.specularMap


stencilFail: StencilOp 

Defined in: three.js/materials/Material:stencilFail 

Which stencil operation to perform when the comparison function returns false.

KeepStencilOp

EffectMaterial.stencilFail


stencilFunc: StencilFunc 

Defined in: three.js/materials/Material:stencilFunc 

The stencil comparison function to use.

AlwaysStencilFunc

EffectMaterial.stencilFunc


stencilFuncMask: number

Defined in: three.js/materials/Material:stencilFuncMask 

The bit mask to use when comparing against the stencil buffer.

0xff

EffectMaterial.stencilFuncMask


stencilRef: number

Defined in: three.js/materials/Material:stencilRef 

The value to use when performing stencil comparisons or stencil operations.

0

EffectMaterial.stencilRef


stencilWrite: boolean

Defined in: three.js/materials/Material:stencilWrite 

Whether stencil operations are performed against the stencil buffer. In order to perform writes or comparisons against the stencil buffer this value must be true.

false

EffectMaterial.stencilWrite


stencilWriteMask: number

Defined in: three.js/materials/Material:stencilWriteMask 

The bit mask to use when writing to the stencil buffer.

0xff

EffectMaterial.stencilWriteMask


stencilZFail: StencilOp 

Defined in: three.js/materials/Material:stencilZFail 

Which stencil operation to perform when the comparison function returns true but the depth test fails.

KeepStencilOp

EffectMaterial.stencilZFail


stencilZPass: StencilOp 

Defined in: three.js/materials/Material:stencilZPass 

Which stencil operation to perform when the comparison function returns true and the depth test passes.

KeepStencilOp

EffectMaterial.stencilZPass


toneMapped: boolean

Defined in: three.js/materials/Material:toneMapped 

Defines whether this material is tone mapped according to the renderer’s tone mapping setting.

It is ignored when rendering to a render target or using post processing or when using WebGPURenderer. In all these cases, all materials are honored by tone mapping.

true

EffectMaterial.toneMapped


transparent: boolean

Defined in: three.js/materials/Material:transparent 

Defines whether this material is transparent. This has an effect on rendering as transparent objects need special treatment and are rendered after non-transparent objects.

When set to true, the extent to which the material is transparent is controlled by Material#opacity.

false

EffectMaterial.transparent


type: string = 'Sprite2DMaterial'

Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:337

Canonical three.js class identifier — every built-in material overrides this (MeshBasicMaterial’s type is 'MeshBasicMaterial', etc.). Devtools / inspectors that walk the scene graph read .type to categorise materials without instanceof checks. Subclasses (e.g. future TileMapMaterial) should override again.

EffectMaterial.type


userData: Record<string, any>

Defined in: three.js/materials/Material:userData 

An object that can be used to store custom data about the Material. It should not hold references to functions as these will not be cloned.

EffectMaterial.userData


readonly uuid: string

Defined in: three.js/materials/Material:uuid 

The UUID of the material.

EffectMaterial.uuid


readonly version: number

Defined in: three.js/materials/Material:version 

This starts at 0 and counts how many times Material#needsUpdate  is set to true.

0

EffectMaterial.version


vertexColors: boolean

Defined in: three.js/materials/Material:vertexColors 

If set to true, vertex colors should be used.

The engine supports RGB and RGBA vertex colors depending on whether a three (RGB) or four (RGBA) component color buffer attribute is used.

false

EffectMaterial.vertexColors


vertexNode: Node  | null

Defined in: three.js/materials/nodes/NodeMaterial:vertexNode 

This node property can be used if you need complete freedom in implementing the vertex shader. Assigning a node will replace the built-in material logic used in the vertex stage.

null

EffectMaterial.vertexNode


visible: boolean

Defined in: three.js/materials/Material:visible 

Defines whether 3D objects using this material are visible.

true

EffectMaterial.visible


wireframe: boolean

Defined in: three.js/materials/MeshBasicMaterial:wireframe 

Renders the geometry as a wireframe.

false

EffectMaterial.wireframe


wireframeLinecap: "round" | "bevel" | "miter"

Defined in: three.js/materials/MeshBasicMaterial:wireframeLinecap 

Defines appearance of wireframe ends.

Can only be used with SVGRenderer.

'round'

EffectMaterial.wireframeLinecap


wireframeLinejoin: "round" | "bevel" | "miter"

Defined in: three.js/materials/MeshBasicMaterial:wireframeLinejoin 

Defines appearance of wireframe joints.

Can only be used with SVGRenderer.

'round'

EffectMaterial.wireframeLinejoin


wireframeLinewidth: number

Defined in: three.js/materials/MeshBasicMaterial:wireframeLinewidth 

Controls the thickness of the wireframe.

Can only be used with SVGRenderer.

1

EffectMaterial.wireframeLinewidth


readonly static MAX_EFFECT_FLOATS: 24 = 24

Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:154

Maximum total effect-data floats allowed across all registered effects on this material. WebGPU allows 8 vertex-buffer bindings per pipeline; SpriteBatch uses 2 fixed bindings (instanceMatrix + interleaved core — the synth-quad geometry’s position/uv attributes exist for user TSL but cost a binding only when a material’s nodes actually read them), leaving 6 for effectBuf0..5 × 4 floats = 24 floats. Exceeding this would force a 7th effectBuf binding which WebGPU rejects at pipeline creation with a cryptic “vertex buffer count exceeds maximum” error. registerEffect throws clearly when the cap would be exceeded.

A material whose custom TSL nodes call uv()/positionGeometry() consumes one or two additional vertex-buffer bindings beyond the 2 above, reducing headroom below 24 floats for that material.

EffectMaterial.MAX_EFFECT_FLOATS

get alphaTest(): number

Defined in: three.js/materials/Material:alphaTest 

Sets the alpha value to be used when running an alpha test. The material will not be rendered if the opacity is lower than this value.

0

number

set alphaTest(value): void

Defined in: three.js/materials/Material:alphaTest 

number

void

EffectMaterial.alphaTest


get colorTransform(): ColorTransformFn | null

Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:251

Get the color transform function.

ColorTransformFn | null

set colorTransform(value): void

Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:259

Set the color transform function. Triggers shader rebuild.

ColorTransformFn | null

void

EffectMaterial.colorTransform


get globalUniforms(): GlobalUniforms | null

Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:553

Get the global uniforms reference.

GlobalUniforms | null

set globalUniforms(value): void

Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:561

Set the global uniforms reference. Triggers shader rebuild to include global tint.

GlobalUniforms | null

void


set needsUpdate(value): void

Defined in: three.js/materials/Material:needsUpdate 

Setting this property to true indicates the engine the material needs to be recompiled.

false

boolean

void

EffectMaterial.needsUpdate


get requiredChannels(): ReadonlySet<string>

Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:271

Get the required channels set.

ReadonlySet<string>

set requiredChannels(value): void

Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:279

Set the required channels. Triggers shader rebuild when channels change.

ReadonlySet<string>

void

EffectMaterial.requiredChannels


get static type(): string

Defined in: three.js/materials/nodes/NodeMaterial:type 

string

EffectMaterial.type

addEventListener<T>(type, listener): void

Defined in: three.js/core/EventDispatcher:addEventListener 

Adds a listener to an event type.

T extends "dispose"

T

The type of event to listen to.

EventListener <MaterialEventMap [T], T, Sprite2DMaterial>

The function that gets called when the event is fired.

void

EffectMaterial.addEventListener


build(builder): void

Defined in: three.js/materials/nodes/NodeMaterial:build 

Builds this material with the given node builder.

NodeBuilder 

The current node builder.

void

EffectMaterial.build


clone(): this

Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:823

Clone this material.

this

EffectMaterial.clone


copy(source): this

Defined in: three.js/materials/nodes/NodeMaterial:copy 

Copies the common properties of the given material to this instance.

Material 

The material to copy.

this

A reference to this node material.

EffectMaterial.copy


customProgramCacheKey(): string

Defined in: three.js/materials/Material:customProgramCacheKey 

In case Material#onBeforeCompile  is used, this callback can be used to identify values of settings used in onBeforeCompile(), so three.js can reuse a cached shader or recompile the shader for this material as needed.

This method can only be used when rendering with WebGLRenderer .

string

The custom program cache key.

EffectMaterial.customProgramCacheKey


dispatchEvent<T>(event): void

Defined in: three.js/core/EventDispatcher:dispatchEvent 

Fire an event type.

T extends "dispose"

BaseEvent <T> & MaterialEventMap [T]

The event that gets fired.

void

EffectMaterial.dispatchEvent


dispose(): void

Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:845

Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.

void

Material#dispose

EffectMaterial.dispose


fromJSON(json, textures): this

Defined in: three.js/materials/Material:fromJSON 

Deserializes the material from the given JSON.

MaterialJSON 

The JSON holding the serialized material.

Record<string, Texture >

A dictionary holding textures referenced by the material.

this

A reference to this material.

EffectMaterial.fromJSON


getEffectFieldLocation(effectName, fieldName): { bufferName: string; componentIndex: number; size: number; } | undefined

Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:785

Locate an effect’s schema field within the packed instance buffers. Returns the effectBufN attribute that contains this field, the float offset within a single instance’s 4-float slice of that buffer (0-3), and the field’s float width. Returns undefined if no registered effect declares the given field.

Used by instance-writing code (e.g. TileLayer, SpriteBatch) that needs to poke per-instance effect values directly without going through a MaterialEffect instance’s property setter.

string

string

{ bufferName: string; componentIndex: number; size: number; } | undefined

EffectMaterial.getEffectFieldLocation


getEffects(): readonly typeof MaterialEffect[]

Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:511

Get the list of registered effect classes.

readonly typeof MaterialEffect[]

EffectMaterial.getEffects


getTexture(): Texture <unknown, TextureEventMap > | null

Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:670

Get the sprite texture.

Texture <unknown, TextureEventMap > | null


getUsedEffectFloats(): number

Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:213

Current per-instance effect-float usage (sum across all registered effects). Complements getMaxEffectFloats.

number

EffectMaterial.getUsedEffectFloats


hasEffect(effectClass): boolean

Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:504

Check if an effect class is registered on this material.

typeof MaterialEffect

boolean

EffectMaterial.hasEffect


hasEventListener<T>(type, listener): boolean

Defined in: three.js/core/EventDispatcher:hasEventListener 

Checks if listener is added to an event type.

T extends "dispose"

T

The type of event to listen to.

EventListener <MaterialEventMap [T], T, Sprite2DMaterial>

The function that gets called when the event is fired.

boolean

EffectMaterial.hasEventListener


onBeforeCompile(parameters, renderer): void

Defined in: three.js/materials/Material:onBeforeCompile 

An optional callback that is executed immediately before the shader program is compiled. This function is called with the shader source code as a parameter. Useful for the modification of built-in materials.

This method can only be used when rendering with WebGLRenderer . The recommended approach when customizing materials is to use WebGPURenderer with the new Node Material system and TSL .

WebGLProgramParametersWithUniforms 

WebGLRenderer 

A reference to the renderer.

void

EffectMaterial.onBeforeCompile


onBeforeRender(renderer, scene, camera, geometry, object, group): void

Defined in: three.js/materials/Material:onBeforeRender 

An optional callback that is executed immediately before the material is used to render a 3D object.

This method can only be used when rendering with WebGLRenderer .

WebGLRenderer 

The renderer.

Scene 

The scene.

Camera 

The camera that is used to render the scene.

BufferGeometry 

The 3D object’s geometry.

Object3D 

The 3D object.

Group 

The geometry group data.

void

EffectMaterial.onBeforeRender


registerEffect(effectClass, constants?): boolean

Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:325

Register an effect class on this material. Assigns a bit index and packed buffer slots, then rebuilds the shader. If the effect is already registered, this is a no-op.

typeof MaterialEffect

The MaterialEffect subclass to register

Record<string, unknown>

Optional constants from the effect instance (for provider effects)

boolean

Whether the buffer tier changed (requiring batch rebuild).

EffectMaterial.registerEffect


removeEventListener<T>(type, listener): void

Defined in: three.js/core/EventDispatcher:removeEventListener 

Removes a listener from an event type.

T extends "dispose"

T

The type of the listener that gets removed.

EventListener <MaterialEventMap [T], T, Sprite2DMaterial>

The listener function that gets removed.

void

EffectMaterial.removeEventListener


setDefaultValues(material): void

Defined in: three.js/materials/nodes/NodeMaterial:setDefaultValues 

Most classic material types have a node pendant e.g. for MeshBasicMaterial there is MeshBasicNodeMaterial. This utility method is intended for defining all material properties of the classic type in the node type.

Material 

The material to copy properties with their values to this node material.

void

EffectMaterial.setDefaultValues


setTexture(value): void

Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:681

Set the sprite texture. Re-resolves the geometry strategy: an alpha-blend material whose atlas registered polygon meshes flips to the tight-mesh path (geometry position/uv instead of vertexIndex synthesis). A flip bumps the schema version so existing batches rebuild with matching geometry.

Texture <unknown, TextureEventMap > | null

void


setup(builder): void

Defined in: three.js/materials/nodes/NodeMaterial:setup 

Setups the vertex and fragment stage of this node material.

NodeBuilder 

The current node builder.

void

EffectMaterial.setup


setupAmbientOcclusion(builder): Node 

Defined in: three.js/materials/nodes/NodeMaterial:setupAmbientOcclusion 

Setups the ambient occlusion node from the material.

NodeBuilder 

The current node builder.

Node 

The ambient occlusion node.

EffectMaterial.setupAmbientOcclusion


setupClipping(builder): ClippingNode 

Defined in: three.js/materials/nodes/NodeMaterial:setupClipping 

Setups the clipping node.

NodeBuilder 

The current node builder.

ClippingNode 

The clipping node.

EffectMaterial.setupClipping


setupDepth(builder): void

Defined in: three.js/materials/nodes/NodeMaterial:setupDepth 

Setups the depth of this material.

NodeBuilder 

The current node builder.

void

EffectMaterial.setupDepth


setupDiffuseColor(builder): void

Defined in: three.js/materials/nodes/NodeMaterial:setupDiffuseColor 

Setups the computation of the material’s diffuse color.

NodeBuilder 

The current node builder.

void

EffectMaterial.setupDiffuseColor


setupEnvironment(builder): BasicEnvironmentNode  | null

Defined in: three.js/materials/nodes/MeshBasicNodeMaterial:setupEnvironment 

Overwritten since this type of material uses BasicEnvironmentNode  to implement the default environment mapping.

NodeBuilder 

The current node builder.

BasicEnvironmentNode  | null

The environment node.

EffectMaterial.setupEnvironment


setupFog(builder, outputNode): Node 

Defined in: three.js/materials/nodes/NodeMaterial:setupFog 

Setup the fog.

NodeBuilder 

The current node builder.

Node 

The existing output node.

Node 

The output node.

EffectMaterial.setupFog


setupLighting(builder): Node 

Defined in: three.js/materials/nodes/NodeMaterial:setupLighting 

Setups the outgoing light node.

NodeBuilder 

The current node builder.

Node 

The outgoing light node.

EffectMaterial.setupLighting


setupLightingModel(): BasicLightingModel 

Defined in: three.js/materials/nodes/MeshBasicNodeMaterial:setupLightingModel 

Setups the lighting model.

BasicLightingModel 

The lighting model.

EffectMaterial.setupLightingModel


setupLightMap(builder): Node 

Defined in: three.js/materials/nodes/NodeMaterial:setupLightMap 

Setups the light map node from the material.

NodeBuilder 

The current node builder.

Node 

The light map node.

EffectMaterial.setupLightMap


setupMaterialLightings(builder): LightingNode []

Defined in: three.js/materials/nodes/NodeMaterial:setupMaterialLightings 

Setups the lights node based on the scene, environment and material.

NodeBuilder 

The current node builder.

LightingNode []

The lights node.

EffectMaterial.setupMaterialLightings


setupNormal(): Node 

Defined in: three.js/materials/nodes/NodeMaterial:setupNormal 

Setups the normal node from the material.

Node 

The normal node.

EffectMaterial.setupNormal


setupObserver(builder): NodeMaterialObserver 

Defined in: three.js/materials/nodes/NodeMaterial:setupObserver 

Setups a node material observer with the given builder.

NodeBuilder 

The current node builder.

NodeMaterialObserver 

The node material observer.

EffectMaterial.setupObserver


setupOutgoingLight(): Node 

Defined in: three.js/materials/nodes/NodeMaterial:setupOutgoingLight 

Setups the outgoing light node variable

Node 

The outgoing light node.

EffectMaterial.setupOutgoingLight


setupOutput(builder, outputNode): Node 

Defined in: three.js/materials/nodes/NodeMaterial:setupOutput 

Setups the output node.

This method can be implemented by derived materials to extend the functionality of the material’s output or replace it altogether.

class ColoredShadowMaterial extends MeshPhongNodeMaterial {
constructor( parameters ) {
super( parameters );
this._shadeColor = uniform( new Color( parameters.shadeColor ?? 0xff0000 ) );
}
setupOutput( builder, outputNode ) {
// Modify the native output of the MeshPhongNodeMaterial fragment shader
const brightness = min( outputNode.r, 1.0 );
const mixedColor = mix( this._shadeColor, diffuseColor.rgb, brightness );
// Return new output back into NodeMaterial flow
return super.setupOutput( builder, vec4( mixedColor, outputNode.a ) );
}
}

NodeBuilder 

The current node builder.

Node 

The existing output node.

Node 

The output node.

EffectMaterial.setupOutput


setupPositionView(builder): Node 

Defined in: three.js/materials/nodes/NodeMaterial:setupPositionView 

Setups the position node in view space. This method exists so derived node materials can modify the implementation e.g. sprite materials.

NodeBuilder 

The current node builder.

Node 

The position in view space.

EffectMaterial.setupPositionView


setupPremultipliedAlpha(builder, outputNode): Node 

Defined in: three.js/materials/nodes/NodeMaterial:setupPremultipliedAlpha 

Setups premultiplied alpha.

NodeBuilder 

The current node builder.

Node 

The existing output node.

Node 

The output node.

EffectMaterial.setupPremultipliedAlpha


abstract setupVariants(builder): void

Defined in: three.js/materials/nodes/NodeMaterial:setupVariants 

Abstract interface method that can be implemented by derived materials to setup material-specific node variables.

NodeBuilder 

The current node builder.

void

EffectMaterial.setupVariants


setupVertex(builder): Node 

Defined in: three.js/materials/nodes/NodeMaterial:setupVertex 

Setups the logic for the vertex stage.

NodeBuilder 

The current node builder.

Node 

The position in clip space.

EffectMaterial.setupVertex


setValues(values?): void

Defined in: three.js/materials/nodes/MeshBasicNodeMaterial:setValues 

MeshBasicNodeMaterialParameters 

void

EffectMaterial.setValues


toJSON(meta?): MaterialJSON 

Defined in: three.js/materials/Material:toJSON 

Serializes the material into JSON.

JSONMeta 

An optional value holding meta information about the serialization.

MaterialJSON 

A JSON object representing the serialized material.

ObjectLoader#parse

EffectMaterial.toJSON


static getMaxEffectFloats(): number

Defined in: packages/three-flatland/src/materials/EffectMaterial.ts:196

Return the maximum number of per-instance effect floats this material type supports. See MAX_EFFECT_FLOATS.

number

EffectMaterial.getMaxEffectFloats


static getShared(options?): Sprite2DMaterial

Defined in: packages/three-flatland/src/materials/Sprite2DMaterial.ts:350

Get a shared material instance for the given options. Materials with identical configuration (texture, transparent, lit, colorTransform) return the same instance, enabling automatic batching.

Sprite2DMaterialOptions = {}

Sprite2DMaterial