Skip to content

Documentation / scene / SpriteBlueprintMaterial

Class: SpriteBlueprintMaterial ​

Defined in: libs/scene/src/material/spriteblueprint.ts:21

Sprite material driven by a blueprint graph.

Remarks ​

This material extends SpriteMaterial and uses a MaterialBlueprintIR fragment graph to compute the final sprite color. All fragment shading logic is defined in the blueprint instead of being hard-coded in the material.

Extends ​

Constructors ​

Constructor ​

new SpriteBlueprintMaterial(irFrag?, uniformValues?, uniformTextures?): SpriteBlueprintMaterial

Defined in: libs/scene/src/material/spriteblueprint.ts:36

Creates a new SpriteBlueprintMaterial instance.

Parameters ​

irFrag? ​

MaterialBlueprintIR

Optional fragment blueprint IR. If omitted, a default IR containing a single SpriteBlockNode is created.

uniformValues? ​

BluePrintUniformValue[]

Optional initial list of uniform value descriptors.

uniformTextures? ​

BluePrintUniformTexture[]

Optional initial list of texture uniform descriptors.

Returns ​

SpriteBlueprintMaterial

Overrides ​

SpriteMaterial.constructor

Properties ​

UVINFO ​

static UVINFO: number

Defined in: libs/scene/src/material/sprite.ts:25

Inherited from ​

SpriteMaterial.UVINFO


ANCHOR_ROTATION ​

static ANCHOR_ROTATION: number

Defined in: libs/scene/src/material/sprite.ts:26

Inherited from ​

SpriteMaterial.ANCHOR_ROTATION

Accessors ​

disposed ​

Get Signature ​

get disposed(): boolean

Defined in: libs/base/dist/index.d.ts:6107

Returns ​

boolean

Inherited from ​

SpriteMaterial.disposed


changeTag ​

Get Signature ​

get changeTag(): number

Defined in: libs/scene/src/material/material.ts:173

Incremented when the material’s GPU-relevant state changes and render bundles may need to be rebuilt.

Returns ​

number

Inherited from ​

SpriteMaterial.changeTag


instanceId ​

Get Signature ​

get instanceId(): number

Defined in: libs/scene/src/material/material.ts:179

Runtime-unique numeric identifier for the material instance.

Returns ​

number

Inherited from ​

SpriteMaterial.instanceId


numPasses ​

Get Signature ​

get numPasses(): number

Defined in: libs/scene/src/material/material.ts:189

Number of rendering passes this material uses.

Increasing this will expand the per-pass hash cache; make sure to implement createHash(pass), _createProgram(pb, ctx, pass), and updateRenderStates(pass, ...) accordingly for each pass.

Returns ​

number

Set Signature ​

set numPasses(val): void

Defined in: libs/scene/src/material/material.ts:192

Parameters ​
val ​

number

Returns ​

void

Inherited from ​

SpriteMaterial.numPasses


coreMaterial ​

Get Signature ​

get coreMaterial(): this

Defined in: libs/scene/src/material/material.ts:283

Returns the core material that owns GPU state.

Instances may delegate to a shared core to reuse compiled programs and caches.

Returns ​

this

Inherited from ​

SpriteMaterial.coreMaterial


drawContext ​

Get Signature ​

get drawContext(): DrawContext

Defined in: libs/scene/src/material/meshmaterial.ts:514

Draw context captured during program creation, available inside shader hooks.

Returns ​

DrawContext

The last DrawContext used to build or apply this material.

Inherited from ​

SpriteMaterial.drawContext


pass ​

Get Signature ​

get pass(): number

Defined in: libs/scene/src/material/meshmaterial.ts:523

Current material pass index during program building. Typically used inside shader hooks to select per-pass logic.

Returns ​

number

The active pass index while building the program, or -1 when idle.

Inherited from ​

SpriteMaterial.pass


alphaCutoff ​

Get Signature ​

get alphaCutoff(): number

Defined in: libs/scene/src/material/meshmaterial.ts:532

Alpha test cutoff in [0, 1].

  • 0 disables alpha testing.
  • > 0 discards fragments with alpha < cutoff. Changing this marks uniforms dirty (no shader rebuild).
Returns ​

number

Set Signature ​

set alphaCutoff(val): void

Defined in: libs/scene/src/material/meshmaterial.ts:535

Parameters ​
val ​

number

Returns ​

void

Inherited from ​

SpriteMaterial.alphaCutoff


alphaDither ​

Get Signature ​

get alphaDither(): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:547

Whether alpha clipping uses frame-varying dither coverage.

  • Effective only when alpha cutoff is enabled.
  • Intended for masked materials (blendMode='none') to emulate soft transparency with TAA.
Returns ​

boolean

Set Signature ​

set alphaDither(val): void

Defined in: libs/scene/src/material/meshmaterial.ts:550

Parameters ​
val ​

boolean

Returns ​

void

Inherited from ​

SpriteMaterial.alphaDither


TAADisabled ​

Get Signature ​

get TAADisabled(): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:561

Whether TAA is disabled for this material.

  • When true, motion vectors encode a large sentinel to skip TAA accumulation.
  • Managed via an internal feature toggle.
Returns ​

boolean

Set Signature ​

set TAADisabled(val): void

Defined in: libs/scene/src/material/meshmaterial.ts:564

Parameters ​
val ​

boolean

Returns ​

void

Inherited from ​

SpriteMaterial.TAADisabled


transparentMotionVector ​

Get Signature ​

get transparentMotionVector(): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:581

Whether a blended material contributes motion vectors.

Remarks ​

Off by default, and only meaningful with blendMode !== 'none': blended geometry is normally absent from the prepass, so it writes no velocity and a temporal filter reprojects it with whatever is behind it. Turning this on adds it to a motion-vector-only pass over the transparent queue.

Right for geometry that is dense enough to own its pixels - hair, foliage cards - where one velocity per pixel is a fair summary. Wrong for genuinely see-through surfaces such as glass, where the background's own velocity is the one that should survive, which is why this is opt-in.

Returns ​

boolean

Set Signature ​

set transparentMotionVector(val): void

Defined in: libs/scene/src/material/meshmaterial.ts:584

Parameters ​
val ​

boolean

Returns ​

void

Inherited from ​

SpriteMaterial.transparentMotionVector


TAAStrength ​

Get Signature ​

get TAAStrength(): number

Defined in: libs/scene/src/material/meshmaterial.ts:592

TAA strength in [0, 1].

  • Higher values generally imply stronger accumulation.
  • The value is mapped when writing motion-vector outputs during depth pass.
Returns ​

number

Set Signature ​

set TAAStrength(val): void

Defined in: libs/scene/src/material/meshmaterial.ts:595

Parameters ​
val ​

number

Returns ​

void

Inherited from ​

SpriteMaterial.TAAStrength


alphaToCoverage ​

Get Signature ​

get alphaToCoverage(): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:607

Alpha-to-coverage toggle.

  • Useful to approximate transparency for MSAA targets.
  • Managed as a shader feature; toggling rebuilds variants.
Returns ​

boolean

Set Signature ​

set alphaToCoverage(val): void

Defined in: libs/scene/src/material/meshmaterial.ts:610

Parameters ​
val ​

boolean

Returns ​

void

Inherited from ​

SpriteMaterial.alphaToCoverage


blendMode ​

Get Signature ​

get blendMode(): BlendMode

Defined in: libs/scene/src/material/meshmaterial.ts:618

Blending mode of this material.

  • 'none' for opaque, 'blend' for standard alpha, 'additive' for emissive FX.
  • Changing the mode toggles an internal feature and rebuilds variants.
Returns ​

BlendMode

Set Signature ​

set blendMode(val): void

Defined in: libs/scene/src/material/meshmaterial.ts:621

Parameters ​
val ​

BlendMode

Returns ​

void

Inherited from ​

SpriteMaterial.blendMode


transparentShadowCaster ​

Get Signature ​

get transparentShadowCaster(): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:632

Whether transparent visible materials cast shadow through a masked shadow-only path.

  • Visible rendering stays blended.
  • Shadow-map rendering is treated like a cutout material using shadowAlphaCutoff.
Returns ​

boolean

Set Signature ​

set transparentShadowCaster(val): void

Defined in: libs/scene/src/material/meshmaterial.ts:635

Parameters ​
val ​

boolean

Returns ​

void

Inherited from ​

SpriteMaterial.transparentShadowCaster


shadowAlphaCutoff ​

Get Signature ​

get shadowAlphaCutoff(): number

Defined in: libs/scene/src/material/meshmaterial.ts:644

Alpha cutoff used by the shadow-only masked caster path.

Returns ​

number

Set Signature ​

set shadowAlphaCutoff(val): void

Defined in: libs/scene/src/material/meshmaterial.ts:647

Parameters ​
val ​

number

Returns ​

void

Inherited from ​

SpriteMaterial.shadowAlphaCutoff


cullMode ​

Get Signature ​

get cullMode(): FaceMode

Defined in: libs/scene/src/material/meshmaterial.ts:658

Face culling mode: 'none' | 'front' | 'back'.

  • Does not force shader rebuild; affects rasterizer state.
Returns ​

FaceMode

Set Signature ​

set cullMode(val): void

Defined in: libs/scene/src/material/meshmaterial.ts:661

Parameters ​
val ​

FaceMode

Returns ​

void

Inherited from ​

SpriteMaterial.cullMode


opacity ​

Get Signature ​

get opacity(): number

Defined in: libs/scene/src/material/meshmaterial.ts:671

Material opacity in [0, 1].

  • Used in transparent passes. Changing marks uniforms dirty only.
Returns ​

number

Set Signature ​

set opacity(val): void

Defined in: libs/scene/src/material/meshmaterial.ts:674

Parameters ​
val ​

number

Returns ​

void

Inherited from ​

SpriteMaterial.opacity


objectColor ​

Get Signature ​

get objectColor(): Immutable<Vector4>

Defined in: libs/scene/src/material/meshmaterial.ts:685

Per-object color used for GPU picking/object-ID pass.

  • Changing marks uniforms dirty only.
Returns ​

Immutable<Vector4>

Set Signature ​

set objectColor(val): void

Defined in: libs/scene/src/material/meshmaterial.ts:688

Parameters ​
val ​

Immutable<Vector4>

Returns ​

void

Inherited from ​

SpriteMaterial.objectColor


uvinfo ​

Get Signature ​

get uvinfo(): Immutable<Vector4>

Defined in: libs/scene/src/material/sprite.ts:49

Gets the UV rectangle of the sprite in the texture.

Returns ​

Immutable<Vector4>

A Vector4 storing ([u0, v0, u1, v1]).

Set Signature ​

set uvinfo(value): void

Defined in: libs/scene/src/material/sprite.ts:52

Parameters ​
value ​

Immutable<Vector4>

Returns ​

void

Inherited from ​

SpriteMaterial.uvinfo


anchorRotation ​

Get Signature ​

get anchorRotation(): Immutable<Vector4>

Defined in: libs/scene/src/material/sprite.ts:74

Gets the sprite anchor-rotation.

Returns ​

Immutable<Vector4>

The current anchor-rotation.

Set Signature ​

set anchorRotation(value): void

Defined in: libs/scene/src/material/sprite.ts:77

Parameters ​
value ​

Immutable<Vector4>

Returns ​

void

Inherited from ​

SpriteMaterial.anchorRotation


anchor ​

Get Signature ​

get anchor(): Immutable<Vector2>

Defined in: libs/scene/src/material/sprite.ts:88

Gets the sprite anchor point in normalized quad space.

Returns ​

Immutable<Vector2>

The current anchor as a Vector2.

Set Signature ​

set anchor(value): void

Defined in: libs/scene/src/material/sprite.ts:91

Parameters ​
value ​

Immutable<Vector2>

Returns ​

void

Inherited from ​

SpriteMaterial.anchor


rotation ​

Get Signature ​

get rotation(): number

Defined in: libs/scene/src/material/sprite.ts:101

Gets the sprite rotation around the Z axis.

Returns ​

number

The sprite rotation.

Set Signature ​

set rotation(value): void

Defined in: libs/scene/src/material/sprite.ts:104

Parameters ​
value ​

number

Returns ​

void

Inherited from ​

SpriteMaterial.rotation


anchorX ​

Get Signature ​

get anchorX(): number

Defined in: libs/scene/src/material/sprite.ts:117

Gets the X component of the sprite anchor.

Returns ​

number

Set Signature ​

set anchorX(value): void

Defined in: libs/scene/src/material/sprite.ts:120

Parameters ​
value ​

number

Returns ​

void

Inherited from ​

SpriteMaterial.anchorX


anchorY ​

Get Signature ​

get anchorY(): number

Defined in: libs/scene/src/material/sprite.ts:133

Gets the Y component of the sprite anchor.

Returns ​

number

Set Signature ​

set anchorY(value): void

Defined in: libs/scene/src/material/sprite.ts:136

Parameters ​
value ​

number

Returns ​

void

Inherited from ​

SpriteMaterial.anchorY


fragmentIR ​

Get Signature ​

get fragmentIR(): MaterialBlueprintIR

Defined in: libs/scene/src/material/spriteblueprint.ts:63

Gets the fragment blueprint IR used to generate the fragment shader.

Returns ​

MaterialBlueprintIR

Set Signature ​

set fragmentIR(ir): void

Defined in: libs/scene/src/material/spriteblueprint.ts:66

Parameters ​
ir ​

MaterialBlueprintIR

Returns ​

void


uniformValues ​

Get Signature ​

get uniformValues(): BluePrintUniformValue[]

Defined in: libs/scene/src/material/spriteblueprint.ts:76

Gets the list of uniform value descriptors used by the blueprint.

Returns ​

BluePrintUniformValue[]

Set Signature ​

set uniformValues(val): void

Defined in: libs/scene/src/material/spriteblueprint.ts:79

Parameters ​
val ​

BluePrintUniformValue[]

Returns ​

void


uniformTextures ​

Get Signature ​

get uniformTextures(): BluePrintUniformTexture[]

Defined in: libs/scene/src/material/spriteblueprint.ts:86

Gets the list of texture uniform descriptors used by the blueprint.

Returns ​

BluePrintUniformTexture[]

Set Signature ​

set uniformTextures(val): void

Defined in: libs/scene/src/material/spriteblueprint.ts:89

Parameters ​
val ​

BluePrintUniformTexture[]

Returns ​

void

Methods ​

on() ​

on<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:630

IEventTarget.on

Type Parameters ​

K ​

K extends "dispose"

Parameters ​

type ​

K

listener ​

EventListener<{ dispose: []; }, K>

context? ​

unknown

Returns ​

void

Inherited from ​

SpriteMaterial.on


once() ​

once<K>(type, listener, context?): void

Defined in: libs/base/dist/index.d.ts:634

IEventTarget.once

Type Parameters ​

K ​

K extends "dispose"

Parameters ​

type ​

K

listener ​

EventListener<{ dispose: []; }, K>

context? ​

unknown

Returns ​

void

Inherited from ​

SpriteMaterial.once


off() ​

off<K>(type, listener?, context?): void

Defined in: libs/base/dist/index.d.ts:638

IEventTarget.off

Type Parameters ​

K ​

K extends "dispose"

Parameters ​

type ​

K

listener? ​

EventListener<{ dispose: []; }>

context? ​

unknown

Returns ​

void

Inherited from ​

SpriteMaterial.off


dispatchEvent() ​

dispatchEvent<K>(type, ...args): void

Defined in: libs/base/dist/index.d.ts:642

IEventTarget.dispatchEvent

Type Parameters ​

K ​

K extends "dispose"

Parameters ​

type ​

K

args ​

...object[K]

Returns ​

void

Inherited from ​

SpriteMaterial.dispatchEvent


dispose() ​

dispose(): void

Defined in: libs/base/dist/index.d.ts:6108

Returns ​

void

Inherited from ​

SpriteMaterial.dispose


getNumPassesForRender() ​

protected getNumPassesForRender(_ctx): number

Defined in: libs/scene/src/material/material.ts:205

Get the number of passes this material will render for the given draw context.

Default returns numPasses. Subclasses may override to skip passes based on context flags.

Parameters ​

_ctx ​

DrawContext

Draw context (device, flags, pass hash, instance data, etc.).

Returns ​

number

Number of passes to render for this context.

Inherited from ​

SpriteMaterial.getNumPassesForRender


supportInstancing() ​

supportInstancing(): boolean

Defined in: libs/scene/src/material/material.ts:249

Whether this material supports hardware instancing.

Override and return false if per-instance data is not supported in the shader.

Returns ​

boolean

Inherited from ​

SpriteMaterial.supportInstancing


isBatchable() ​

isBatchable(): boolean

Defined in: libs/scene/src/material/material.ts:253

Returns true if this is a instance of material

Returns ​

boolean

Inherited from ​

SpriteMaterial.isBatchable


needSceneColor() ​

needSceneColor(): boolean

Defined in: libs/scene/src/material/material.ts:260

Whether this material requires the scene color texture (e.g., for refraction).

Returns ​

boolean

Inherited from ​

SpriteMaterial.needSceneColor


needSceneDepth() ​

needSceneDepth(): boolean

Defined in: libs/scene/src/material/material.ts:266

Whether this material requires the linear scene depth texture (e.g., for depth-aware effects).

Returns ​

boolean

Inherited from ​

SpriteMaterial.needSceneDepth


applyUniforms() ​

applyUniforms(bindGroup, ctx, needUpdate, pass): void

Defined in: libs/scene/src/material/material.ts:450

Conditionally update uniforms/resources into the material bind group.

Delegates to _applyUniforms() when needUpdate is true (based on _optionTag check).

Parameters ​

bindGroup ​

BindGroup

Material bind group at index 2 (may be null if program has no layout).

ctx ​

DrawContext

Draw context.

needUpdate ​

boolean

Whether uniforms need to be refreshed.

pass ​

number

Pass index.

Returns ​

void

Inherited from ​

SpriteMaterial.applyUniforms


clearCache() ​

clearCache(): void

Defined in: libs/scene/src/material/material.ts:475

Returns ​

void

Inherited from ​

SpriteMaterial.clearCache


passToHash() ​

passToHash(pass): string

Defined in: libs/scene/src/material/material.ts:503

Convert a pass index to a hash seed string.

Subclasses may override to encode per-pass role (e.g., "depth", "forward", "shadow").

Parameters ​

pass ​

number

Pass number.

Returns ​

string

String used when building full hash.

Inherited from ​

SpriteMaterial.passToHash


drawPrimitive() ​

drawPrimitive(pass, primitive, ctx, numInstances): void

Defined in: libs/scene/src/material/material.ts:531

Issue the actual draw call for a pass.

Override for custom per-pass draw behavior if necessary. The default implementation:

  • Draws instanced if numInstances > 0.
  • Else uses ctx.instanceData.numInstances if available.
  • Else issues a non-instanced draw.

Parameters ​

pass ​

number

Pass number.

primitive ​

Primitive

Primitive to draw.

ctx ​

DrawContext

Draw context.

numInstances ​

number

Explicit instance count (0 = auto).

Returns ​

void

Inherited from ​

SpriteMaterial.drawPrimitive


apply() ​

apply(ctx): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:243

Capture the active draw context for both cached and freshly-built program paths.

The shader-building hooks access this.drawContext, but uniform application may also consult it on subsequent frames when the GPU program is reused from cache. Updating it here keeps material mixins in sync even when createProgram() is skipped.

Parameters ​

ctx ​

DrawContext

Current draw context.

Returns ​

boolean

Whether material preparation succeeded.

Inherited from ​

SpriteMaterial.apply


uniformChanged() ​

uniformChanged(): void

Defined in: libs/scene/src/material/meshmaterial.ts:252

Mark uniform-only changes so uniforms are re-uploaded on next apply, without rebuilding shader programs.

Returns ​

void

Inherited from ​

SpriteMaterial.uniformChanged


defineFeature() ​

static defineFeature(): number

Defined in: libs/scene/src/material/meshmaterial.ts:259

Define a new feature bit/index for shader variants. Subclasses may use this to add their own switches.

Returns ​

number

Inherited from ​

SpriteMaterial.defineFeature


defineInstanceUniform() ​

static defineInstanceUniform(prop, type, name?): number

Defined in: libs/scene/src/material/meshmaterial.ts:292

Define a per-instance uniform for this class.

Returns a compact index encoding the vector index and component offset, which can be used in shader code via getInstancedUniform(...).

Parameters ​

prop ​

string

Property name exposed on instances.

type ​

InstanceUniformType

Uniform data type.

name? ​

string = ''

Returns ​

number

Encoded index for use in getInstancedUniform.

Throws ​

If the property is already defined or type is invalid.

Inherited from ​

SpriteMaterial.defineInstanceUniform


getInstancedUniform() ​

getInstancedUniform(scope, uniformIndex): PBShaderExp

Defined in: libs/scene/src/material/meshmaterial.ts:333

Read an encoded per-instance uniform in shader code.

Encoded index packs: vector index, component offset, and component count.

Parameters ​

scope ​

PBInsideFunctionScope

Inside-function shader scope.

uniformIndex ​

number

Encoded index from defineInstanceUniform.

Returns ​

PBShaderExp

The shader expression reading the selected components.

Inherited from ​

SpriteMaterial.getInstancedUniform


getInstancedUniforms() ​

getInstancedUniforms(): object[]

Defined in: libs/scene/src/material/meshmaterial.ts:355

Get the list of per-instance uniforms for this material class.

Returns ​

object[]

Inherited from ​

SpriteMaterial.getInstancedUniforms


createInstance() ​

createInstance(): this

Defined in: libs/scene/src/material/meshmaterial.ts:370

Create a material instance (preferred for GPU instancing).

  • On WebGL1 (or when instancing unsupported), falls back to cloning.
  • Otherwise, returns a proxy instance that shares GPU programs and stores per-instance uniforms in a compact Float32Array.

The returned instance:

  • Exposes properties defined by defineInstanceUniform with getter/setter that read/write the packed buffer and notify RenderBundleWrapper.
  • Delegates methods to the core material via prototype chain.

Returns ​

this

Inherited from ​

SpriteMaterial.createInstance


supportLighting() ​

supportLighting(): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:700

Whether this material responds to scene lighting. Override to return false for unlit materials.

Returns ​

boolean

True if lighting affects this material; otherwise false.

Inherited from ​

SpriteMaterial.supportLighting


getEffectiveBlendMode() ​

protected getEffectiveBlendMode(pass, ctx?): BlendMode

Defined in: libs/scene/src/material/meshmaterial.ts:707

Returns the effective blend mode for the current pass. Transparent-shadow-caster materials stay blended in visible passes, but become masked in shadow passes.

Parameters ​

pass ​

number

ctx? ​

DrawContext

Returns ​

BlendMode

Inherited from ​

SpriteMaterial.getEffectiveBlendMode


getActiveAlphaCutoff() ​

protected getActiveAlphaCutoff(ctx?, pass?): number

Defined in: libs/scene/src/material/meshmaterial.ts:736

Returns the alpha cutoff that should be used for the current pass.

Parameters ​

ctx? ​

DrawContext

pass? ​

number = ...

Returns ​

number

Inherited from ​

SpriteMaterial.getActiveAlphaCutoff


useTransparentShadowCaster() ​

useTransparentShadowCaster(ctx?, _pass?): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:742

Whether the current pass should use the shadow-only masked caster path.

Parameters ​

ctx? ​

DrawContext

_pass? ​

number = ...

Returns ​

boolean

Inherited from ​

SpriteMaterial.useTransparentShadowCaster


useTransparentShadowCasterForPass() ​

useTransparentShadowCasterForPass(renderPassType?): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:748

Whether the specified render pass type should reinterpret this transparent material as a masked shadow caster.

Parameters ​

renderPassType? ​

number

Returns ​

boolean

Inherited from ​

SpriteMaterial.useTransparentShadowCasterForPass


usesAlphaCutoff() ​

protected usesAlphaCutoff(ctx, pass): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:758

Whether this pass needs an alpha-cutoff uniform bound.

Parameters ​

ctx ​

DrawContext

pass ​

number

Returns ​

boolean

Inherited from ​

SpriteMaterial.usesAlphaCutoff


needFragmentColorInput() ​

needFragmentColorInput(ctx?): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:766

Whether this pass needs fragment color inputs. This stays aligned with the historical meaning of needFragmentColor, but also allows shadow-only transparent casters to fetch alpha sources.

Parameters ​

ctx? ​

DrawContext

Returns ​

boolean

Inherited from ​

SpriteMaterial.needFragmentColorInput


updateRenderStates() ​

protected updateRenderStates(pass, stateSet, ctx): void

Defined in: libs/scene/src/material/meshmaterial.ts:779

Update render states per pass and draw context. Sets blending, alpha-to-coverage, depth test/write, cull mode, color mask, and cooperates with OIT.

Parameters ​

pass ​

number

Current material pass index.

stateSet ​

RenderStateSet

Render state set to update.

ctx ​

DrawContext

Current draw context.

Returns ​

void

void

Inherited from ​

SpriteMaterial.updateRenderStates


getQueueType() ​

getQueueType(): number

Defined in: libs/scene/src/material/meshmaterial.ts:893

Determine the render queue for this material. Transparent materials are queued as QUEUE_TRANSPARENT, otherwise QUEUE_OPAQUE.

Returns ​

number

The queue type constant.

Inherited from ​

SpriteMaterial.getQueueType


isTransparentPass() ​

isTransparentPass(pass, ctx?): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:903

Whether the given pass is transparent. Default returns true when blendMode !== 'none'.

Parameters ​

pass ​

number

Material pass index.

ctx? ​

DrawContext

Returns ​

boolean

True if the pass is transparent; otherwise false.

Inherited from ​

SpriteMaterial.isTransparentPass


featureUsed() ​

featureUsed<T>(feature): T

Defined in: libs/scene/src/material/meshmaterial.ts:930

Query a feature flag’s current value.

Type Parameters ​

T ​

T = unknown

Expected value type.

Parameters ​

feature ​

number

The feature index.

Returns ​

T

The current value for the feature, typed as T.

Inherited from ​

SpriteMaterial.featureUsed


useFeature() ​

useFeature(feature, use): void

Defined in: libs/scene/src/material/meshmaterial.ts:941

Enable or disable a feature and trigger variant rebuild when changed. Calls optionChanged(true) internally on change.

Parameters ​

feature ​

number

The feature index to set.

use ​

unknown

The new feature value (typed by convention).

Returns ​

void

void

Inherited from ​

SpriteMaterial.useFeature


isMaterialTextureEnabled() ​

protected isMaterialTextureEnabled(_name): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:972

Parameters ​

_name ​

string

Returns ​

boolean

Inherited from ​

SpriteMaterial.isMaterialTextureEnabled


needFragmentColor() ​

needFragmentColor(ctx?): boolean

Defined in: libs/scene/src/material/meshmaterial.ts:983

Whether the fragment shader needs to compute color. Returns true for LIGHT pass, or when alpha test or alpha-to-coverage is enabled. Override if the material writes color in other passes.

Parameters ​

ctx? ​

DrawContext

Optional draw context; defaults to the last captured drawContext.

Returns ​

boolean

True if fragment color computation is needed; otherwise false.

Inherited from ​

SpriteMaterial.needFragmentColor


outputFragmentColor() ​

outputFragmentColor(scope, worldPos, color, ssrRoughness?, ssrNormal?, sssProfile?, sssParams?, sssDiffuse?, sssTransmission?, sssProfileEnabled?, skinSSS?): void

Defined in: libs/scene/src/material/meshmaterial.ts:1139

Centralized final color write and per-pass output composition.

Behavior by pass:

  • LIGHT: clipping, alpha handling, optional OIT integration, fog application, color output encoding.
  • DEPTH: encoded depth; optional motion vectors (TAA enabled/disabled handling).
  • OBJECT_COLOR: object color and distance output (linear depth or world-pos + distance).
  • SHADOWMAP: writes shadow depth via light’s shadow implementation.

Also writes SSR roughness/normal buffers when requested via material flags.

Parameters ​

scope ​

PBInsideFunctionScope

Inside-function shader scope.

worldPos ​

PBShaderExp

Fragment world-space position expression.

color ​

PBShaderExp

Lit fragment color expression; may be undefined for depth-only paths.

ssrRoughness? ​

PBShaderExp

Optional SSR roughness output expression.

ssrNormal? ​

PBShaderExp

Optional SSR normal output expression.

sssProfile? ​

PBShaderExp

Optional SSS profile output expression.

sssParams? ​

PBShaderExp

Optional SSS packed params output expression.

sssDiffuse? ​

PBShaderExp

Optional diffuse-only lighting color for SSS composition.

sssTransmission? ​

PBShaderExp

Optional thin-shell transmission lighting color for SSS composition.

sssProfileEnabled? ​

boolean = false

True only when this material should write SSS profile data.

skinSSS? ​

PBShaderExp

Returns ​

void

void

Inherited from ​

SpriteMaterial.outputFragmentColor


setUVInfo() ​

setUVInfo(uvx0, uvy0, uvx1, uvy1): void

Defined in: libs/scene/src/material/sprite.ts:66

Convenience method to set the UV rectangle via individual components.

Parameters ​

uvx0 ​

number

Left (U) coordinate.

uvy0 ​

number

Bottom (V) coordinate.

uvx1 ​

number

Right (U) coordinate.

uvy1 ​

number

Top (V) coordinate.

Returns ​

void

Inherited from ​

SpriteMaterial.setUVInfo


setAnchor() ​

setAnchor(anchorX, anchorY): void

Defined in: libs/scene/src/material/sprite.ts:152

Convenience method to set both anchor components at once.

Parameters ​

anchorX ​

number

X coordinate of the anchor.

anchorY ​

number

Y coordinate of the anchor.

Returns ​

void

Inherited from ​

SpriteMaterial.setAnchor


copyFrom() ​

copyFrom(other): void

Defined in: libs/scene/src/material/sprite.ts:172

Copies all relevant state from another SpriteMaterial.

Parameters ​

other ​

this

The source material to copy from.

Returns ​

void

Inherited from ​

SpriteMaterial.copyFrom


vertexShader() ​

vertexShader(scope): void

Defined in: libs/scene/src/material/sprite.ts:192

Builds the vertex shader for this material.

Parameters ​

scope ​

PBFunctionScope

The current programmable builder function scope.

Returns ​

void

Remarks ​

This method:

  • Calls the base implementation.
  • Computes per-vertex positions for a camera-facing quad (billboard) based on the sprite's world transform, size, and anchor.
  • Selects the correct UV coordinates for each quad corner using the vertexId attribute.
  • Outputs world-space position (zWorldPos) and UVs (zVertexUV) for use in the fragment shader.

Inherited from ​

SpriteMaterial.vertexShader


fragmentShader() ​

fragmentShader(scope): void

Defined in: libs/scene/src/material/sprite.ts:271

Builds the fragment shader for this material.

Parameters ​

scope ​

PBFunctionScope

The current programmable builder function scope.

Returns ​

void

Remarks ​

This method:

  • Calls the base implementation.
  • Invokes internalSetupUniforms() for fragment-stage specific uniform declarations.
  • Computes fragment color by calling calcFragmentColor() if fragment color is needed.
  • Outputs the final fragment color via MeshMaterial.outputFragmentColor.

Inherited from ​

SpriteMaterial.fragmentShader


internalSetupUniforms() ​

protected internalSetupUniforms(_scope): void

Defined in: libs/scene/src/material/sprite.ts:319

Hook for derived classes to declare additional uniforms.

Parameters ​

_scope ​

PBInsideFunctionScope

The current shader function scope.

Returns ​

void

Remarks ​

This is invoked in both the vertex and fragment shader construction phases, allowing subclasses to register extra uniforms or resources needed by their custom shading logic.

The base implementation does nothing.

Inherited from ​

SpriteMaterial.internalSetupUniforms


internalApplyUniforms() ​

protected internalApplyUniforms(_bindGroup, _ctx, _pass): void

Defined in: libs/scene/src/material/sprite.ts:334

Hook for derived classes to bind additional uniform values or resources.

Parameters ​

_bindGroup ​

BindGroup

The bind group used for binding uniforms and resources.

_ctx ​

DrawContext

The current draw context.

_pass ​

number

Index of the active render pass.

Returns ​

void

Remarks ​

This is called from SpriteMaterial.applyUniformValues and is intended for subclasses to bind their own textures, samplers, or other GPU resources.

The base implementation does nothing.

Inherited from ​

SpriteMaterial.internalApplyUniforms


clone() ​

clone(): SpriteBlueprintMaterial

Defined in: libs/scene/src/material/spriteblueprint.ts:126

Creates a deep copy of this blueprint material.

Returns ​

SpriteBlueprintMaterial

A new SpriteBlueprintMaterial instance.

Remarks ​

The clone shares the same fragment IR reference and copies the current uniform descriptors, then calls SpriteMaterial.copyFrom to copy base-class state.

Overrides ​

SpriteMaterial.clone


applyUniformValues() ​

applyUniformValues(bindGroup, ctx, pass): void

Defined in: libs/scene/src/material/spriteblueprint.ts:145

Applies runtime uniform values and textures to the given bind group.

Parameters ​

bindGroup ​

BindGroup

The bind group to bind material resources to.

ctx ​

DrawContext

The current draw context.

pass ​

number

Index of the active render pass.

Returns ​

void

Remarks ​

  • Calls the base implementation to bind sprite-related uniforms first.
  • If fragment color is needed for the current context, all blueprint uniform values and textures are then bound by name:
    • uniformValues via bindGroup.setValue.
    • uniformTextures via bindGroup.setTexture.

Overrides ​

SpriteMaterial.applyUniformValues


calcFragmentColor() ​

protected calcFragmentColor(scope): PBShaderExp

Defined in: libs/scene/src/material/spriteblueprint.ts:171

Computes the fragment color by invoking the blueprint-generated function.

Parameters ​

scope ​

PBInsideFunctionScope

The current fragment shader function scope.

Returns ​

PBShaderExp

A shader expression representing the final fragment color.

Remarks ​

  • A helper function zCalcSpriteColor(zWorldPos, zVertexUV) is declared on the shader builder using the current fragment IR.
  • The blueprint IR is asked to create its node network via MaterialBlueprintIR.create, and the output named "Color" is used as the return value.
  • The resulting function is invoked with the current world position and UV coordinates for each fragment.

Overrides ​

SpriteMaterial.calcFragmentColor


_createHash() ​

protected _createHash(): string

Defined in: libs/scene/src/material/spriteblueprint.ts:203

Creates a unique hash string used for program caching.

Returns ​

string

A hash string that identifies this material configuration.

Remarks ​

The hash includes the base SpriteMaterial hash and the fragment IR hash, so that different blueprints will produce different shader programs.

Overrides ​

SpriteMaterial._createHash


createProgram() ​

protected createProgram(ctx, pass): GPUProgram<unknown>

Defined in: libs/scene/src/material/spriteblueprint.ts:218

Creates the GPU program for this material.

Parameters ​

ctx ​

DrawContext

The current draw context.

pass ​

number

Index of the active material pass.

Returns ​

GPUProgram<unknown>

The created GPU program.

Remarks ​

This simply delegates to the base implementation and returns its result. Commented-out logging lines are available for debugging the generated vertex and fragment shader sources.

Overrides ​

SpriteMaterial.createProgram


onDispose() ​

protected onDispose(): void

Defined in: libs/scene/src/material/spriteblueprint.ts:235

Disposes resources associated with this material.

Returns ​

void

Remarks ​

  • Calls the base onDispose to clean up inherited resources.
  • Disposes all finalTexture references from the blueprint texture uniform descriptors.

This method is intended to be called by the engine's resource management system rather than directly from user code.

Overrides ​

SpriteMaterial.onDispose

Released under the MIT License.