Skip to content

Documentation / scene / HairStrandMaterial

Class: HairStrandMaterial

Defined in: libs/scene/src/material/hairstrand.ts:44

Hair material that expands strand control points into ribbons on the GPU.

Remarks

Where HairMaterial shades ribbon geometry that something else built, this material builds the ribbon itself. The vertex shader derives which strand, which segment and which corner it is drawing from the vertex index alone, reads the control points from a storage buffer, and emits a camera-facing quad. No position, normal, tangent or texture coordinate attribute is read.

Two things fall out of that, and both are the reason to do it:

  • Memory. A CPU-built ribbon mesh for a full 69k-strand hair set costs around 266 MB of vertex data. The control points it is built from are about 20 MB, and that is all this material needs resident.
  • Orientation. A stored ribbon has a fixed plane, so there is a viewing angle at which it degenerates to an edge, and a whole coplanar group of strands can vanish at once. A quad expanded toward the camera never does.

Lighting is inherited unchanged from HairMaterial, so the two paths shade identically and can be compared against each other.

Control points are read in the drawing node's local space and put through its world matrix, so a groom follows the node it hangs off - a head bone, say - and several nodes can share one set of strands at different transforms.

Requires storage buffers in the vertex stage, which means WebGPU.

Extends

Implements

  • Clonable<HairStrandMaterial>

Constructors

Constructor

new HairStrandMaterial(): HairStrandMaterial

Defined in: libs/scene/src/material/hairstrand.ts:78

Creates a GPU strand material.

Returns

HairStrandMaterial

Overrides

HairMaterial.constructor

Properties

normalTexture

normalTexture: Texture2D<unknown>

Inherited from

HairMaterial.normalTexture


normalTextureSampler

normalTextureSampler: TextureSampler<unknown>

Inherited from

HairMaterial.normalTextureSampler


normalTexCoordIndex

normalTexCoordIndex: number

Inherited from

HairMaterial.normalTexCoordIndex


normalTexCoordMatrix

normalTexCoordMatrix: Matrix4x4

Inherited from

HairMaterial.normalTexCoordMatrix


hasNormalTexture

hasNormalTexture: () => boolean

Returns

boolean

Inherited from

HairMaterial.hasNormalTexture


getNormalTextureUniform

getNormalTextureUniform: (scope) => PBShaderExp

Parameters

scope

PBInsideFunctionScope

Returns

PBShaderExp

Inherited from

HairMaterial.getNormalTextureUniform


getNormalTexCoord

getNormalTexCoord: (scope) => PBShaderExp

Parameters

scope

PBInsideFunctionScope

Returns

PBShaderExp

Inherited from

HairMaterial.getNormalTexCoord


sampleNormalTexture

sampleNormalTexture: (scope, texCoord?) => PBShaderExp

Parameters

scope

PBInsideFunctionScope

texCoord?

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.sampleNormalTexture


albedoTexture

albedoTexture: Texture2D<unknown>

Inherited from

HairMaterial.albedoTexture


albedoTextureSampler

albedoTextureSampler: TextureSampler<unknown>

Inherited from

HairMaterial.albedoTextureSampler


albedoTexCoordIndex

albedoTexCoordIndex: number

Inherited from

HairMaterial.albedoTexCoordIndex


albedoTexCoordMatrix

albedoTexCoordMatrix: Matrix4x4

Inherited from

HairMaterial.albedoTexCoordMatrix


hasAlbedoTexture

hasAlbedoTexture: () => boolean

Returns

boolean

Inherited from

HairMaterial.hasAlbedoTexture


getAlbedoTextureUniform

getAlbedoTextureUniform: (scope) => PBShaderExp

Parameters

scope

PBInsideFunctionScope

Returns

PBShaderExp

Inherited from

HairMaterial.getAlbedoTextureUniform


getAlbedoTexCoord

getAlbedoTexCoord: (scope) => PBShaderExp

Parameters

scope

PBInsideFunctionScope

Returns

PBShaderExp

Inherited from

HairMaterial.getAlbedoTexCoord


sampleAlbedoTexture

sampleAlbedoTexture: (scope, texCoord?) => PBShaderExp

Parameters

scope

PBInsideFunctionScope

texCoord?

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.sampleAlbedoTexture


specularShiftTexture

specularShiftTexture: Texture2D<unknown>

Inherited from

HairMaterial.specularShiftTexture


specularShiftTextureSampler

specularShiftTextureSampler: TextureSampler<unknown>

Inherited from

HairMaterial.specularShiftTextureSampler


specularShiftTexCoordIndex

specularShiftTexCoordIndex: number

Inherited from

HairMaterial.specularShiftTexCoordIndex


specularShiftTexCoordMatrix

specularShiftTexCoordMatrix: Matrix4x4

Inherited from

HairMaterial.specularShiftTexCoordMatrix


hasSpecularShiftTexture

hasSpecularShiftTexture: () => boolean

Returns

boolean

Inherited from

HairMaterial.hasSpecularShiftTexture


getSpecularShiftTextureUniform

getSpecularShiftTextureUniform: (scope) => PBShaderExp

Parameters

scope

PBInsideFunctionScope

Returns

PBShaderExp

Inherited from

HairMaterial.getSpecularShiftTextureUniform


getSpecularShiftTexCoord

getSpecularShiftTexCoord: (scope) => PBShaderExp

Parameters

scope

PBInsideFunctionScope

Returns

PBShaderExp

Inherited from

HairMaterial.getSpecularShiftTexCoord


sampleSpecularShiftTexture

sampleSpecularShiftTexture: (scope, texCoord?) => PBShaderExp

Parameters

scope

PBInsideFunctionScope

texCoord?

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.sampleSpecularShiftTexture


occlusionTexture

occlusionTexture: Texture2D<unknown>

Inherited from

HairMaterial.occlusionTexture


occlusionTextureSampler

occlusionTextureSampler: TextureSampler<unknown>

Inherited from

HairMaterial.occlusionTextureSampler


occlusionTexCoordIndex

occlusionTexCoordIndex: number

Inherited from

HairMaterial.occlusionTexCoordIndex


occlusionTexCoordMatrix

occlusionTexCoordMatrix: Matrix4x4

Inherited from

HairMaterial.occlusionTexCoordMatrix


hasOcclusionTexture

hasOcclusionTexture: () => boolean

Returns

boolean

Inherited from

HairMaterial.hasOcclusionTexture


getOcclusionTextureUniform

getOcclusionTextureUniform: (scope) => PBShaderExp

Parameters

scope

PBInsideFunctionScope

Returns

PBShaderExp

Inherited from

HairMaterial.getOcclusionTextureUniform


getOcclusionTexCoord

getOcclusionTexCoord: (scope) => PBShaderExp

Parameters

scope

PBInsideFunctionScope

Returns

PBShaderExp

Inherited from

HairMaterial.getOcclusionTexCoord


sampleOcclusionTexture

sampleOcclusionTexture: (scope, texCoord?) => PBShaderExp

Parameters

scope

PBInsideFunctionScope

texCoord?

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.sampleOcclusionTexture


albedoColor

albedoColor: Vector4

Defined in: libs/scene/src/material/mixins/albedocolor.ts:16

Inherited from

HairMaterial.albedoColor


normalScale

normalScale: number

Defined in: libs/scene/src/material/mixins/lit.ts:23

Inherited from

HairMaterial.normalScale


normalFlipY

normalFlipY: boolean

Defined in: libs/scene/src/material/mixins/lit.ts:24

Inherited from

HairMaterial.normalFlipY


normalMapMode

normalMapMode: "tangent-space" | "object-space"

Defined in: libs/scene/src/material/mixins/lit.ts:25

Inherited from

HairMaterial.normalMapMode


doubleSidedLighting

doubleSidedLighting: boolean

Defined in: libs/scene/src/material/mixins/lit.ts:26

Inherited from

HairMaterial.doubleSidedLighting


vertexColor

vertexColor: boolean

Defined in: libs/scene/src/material/mixins/vertexcolor.ts:10

Inherited from

HairMaterial.vertexColor

Accessors

disposed

Get Signature

get disposed(): boolean

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

Returns

boolean

Inherited from

HairMaterial.disposed


vertexNormal

Get Signature

get vertexNormal(): boolean

Defined in: libs/scene/src/material/hair.ts:188

true if vertex normal attribute presents

Returns

boolean

Set Signature

set vertexNormal(val): void

Defined in: libs/scene/src/material/hair.ts:191

Parameters
val

boolean

Returns

void

Inherited from

HairMaterial.vertexNormal


vertexTangent

Get Signature

get vertexTangent(): boolean

Defined in: libs/scene/src/material/hair.ts:195

true if vertex tangent attribute presents

Returns

boolean

Set Signature

set vertexTangent(val): void

Defined in: libs/scene/src/material/hair.ts:198

Parameters
val

boolean

Returns

void

Inherited from

HairMaterial.vertexTangent


strandDirection

Get Signature

get strandDirection(): HairStrandDirection

Defined in: libs/scene/src/material/hair.ts:202

Which TBN axis runs along the strands

Returns

HairStrandDirection

Set Signature

set strandDirection(val): void

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

Parameters
val

HairStrandDirection

Returns

void

Inherited from

HairMaterial.strandDirection


specular1Color

Get Signature

get specular1Color(): Immutable<Vector3>

Defined in: libs/scene/src/material/hair.ts:209

Primary specular lobe color

Returns

Immutable<Vector3>

Set Signature

set specular1Color(val): void

Defined in: libs/scene/src/material/hair.ts:212

Parameters
val

Immutable<Vector3>

Returns

void

Inherited from

HairMaterial.specular1Color


specular1Power

Get Signature

get specular1Power(): number

Defined in: libs/scene/src/material/hair.ts:219

Primary specular lobe exponent

Returns

number

Set Signature

set specular1Power(val): void

Defined in: libs/scene/src/material/hair.ts:222

Parameters
val

number

Returns

void

Inherited from

HairMaterial.specular1Power


specular1Shift

Get Signature

get specular1Shift(): number

Defined in: libs/scene/src/material/hair.ts:229

Primary specular lobe shift along the normal

Returns

number

Set Signature

set specular1Shift(val): void

Defined in: libs/scene/src/material/hair.ts:232

Parameters
val

number

Returns

void

Inherited from

HairMaterial.specular1Shift


specular2Color

Get Signature

get specular2Color(): Immutable<Vector3>

Defined in: libs/scene/src/material/hair.ts:239

Secondary specular lobe color (multiplied by albedo)

Returns

Immutable<Vector3>

Set Signature

set specular2Color(val): void

Defined in: libs/scene/src/material/hair.ts:242

Parameters
val

Immutable<Vector3>

Returns

void

Inherited from

HairMaterial.specular2Color


specular2Power

Get Signature

get specular2Power(): number

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

Secondary specular lobe exponent

Returns

number

Set Signature

set specular2Power(val): void

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

Parameters
val

number

Returns

void

Inherited from

HairMaterial.specular2Power


specular2Shift

Get Signature

get specular2Shift(): number

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

Secondary specular lobe shift along the normal

Returns

number

Set Signature

set specular2Shift(val): void

Defined in: libs/scene/src/material/hair.ts:262

Parameters
val

number

Returns

void

Inherited from

HairMaterial.specular2Shift


shiftMapScale

Get Signature

get shiftMapScale(): number

Defined in: libs/scene/src/material/hair.ts:269

Scale applied to the shift texture

Returns

number

Set Signature

set shiftMapScale(val): void

Defined in: libs/scene/src/material/hair.ts:272

Parameters
val

number

Returns

void

Inherited from

HairMaterial.shiftMapScale


diffuseWrap

Get Signature

get diffuseWrap(): number

Defined in: libs/scene/src/material/hair.ts:279

Wrap diffuse amount in [0, 1]

Returns

number

Set Signature

set diffuseWrap(val): void

Defined in: libs/scene/src/material/hair.ts:282

Parameters
val

number

Returns

void

Inherited from

HairMaterial.diffuseWrap


transmissionColor

Get Signature

get transmissionColor(): Immutable<Vector3>

Defined in: libs/scene/src/material/hair.ts:290

Transmission tint color

Returns

Immutable<Vector3>

Set Signature

set transmissionColor(val): void

Defined in: libs/scene/src/material/hair.ts:293

Parameters
val

Immutable<Vector3>

Returns

void

Inherited from

HairMaterial.transmissionColor


transmissionIntensity

Get Signature

get transmissionIntensity(): number

Defined in: libs/scene/src/material/hair.ts:300

Transmission intensity, 0 disables the transmission term

Returns

number

Set Signature

set transmissionIntensity(val): void

Defined in: libs/scene/src/material/hair.ts:303

Parameters
val

number

Returns

void

Inherited from

HairMaterial.transmissionIntensity


transmissionPower

Get Signature

get transmissionPower(): number

Defined in: libs/scene/src/material/hair.ts:312

Transmission view-alignment exponent

Returns

number

Set Signature

set transmissionPower(val): void

Defined in: libs/scene/src/material/hair.ts:315

Parameters
val

number

Returns

void

Inherited from

HairMaterial.transmissionPower


scatterColor

Get Signature

get scatterColor(): Immutable<Vector3>

Defined in: libs/scene/src/material/hair.ts:330

Tint of multiply-scattered light.

Remarks

Multiple scattering is strongly wavelength dependent - it is why blonde hair glows and black hair does not - and the tint is applied on top of the hair's own colour, which the term is already modulated by. Warm by default, since the light that survives several bounces through keratin has lost its blue.

Returns

Immutable<Vector3>

Set Signature

set scatterColor(val): void

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

Parameters
val

Immutable<Vector3>

Returns

void

Inherited from

HairMaterial.scatterColor


scatterIntensity

Get Signature

get scatterIntensity(): number

Defined in: libs/scene/src/material/hair.ts:364

Multiple scattering intensity. Zero disables the term, which is the default.

Remarks

Absorption alone makes the inside of a groom black, because that is what absorption does: past a few fibres essentially nothing of the direct beam survives. Real hair is not black there, and the difference is light that reached the point after bouncing off neighbouring fibres rather than travelling straight through.

This adds an approximation of it in two parts, following the decomposition dual scattering makes: a global term, the light that came through the hair in front and arrives spread over a wide angle, and a local term, the light that did not come through but re-emerges after scattering nearby. The first fades with depth into the groom, the second does not, and it is the second that stops the interior going black.

The forward transmittance both terms are built from is the shadow value, so this is at its most meaningful under a shadow mode that grades it - a deep opacity map. Under a binary filter the global term simply follows the shadow and the local term fills its complement.

Off by default: it adds light the material did not previously emit, so it changes the look of any groom it is enabled on rather than refining it.

Returns

number

Set Signature

set scatterIntensity(val): void

Defined in: libs/scene/src/material/hair.ts:367

Parameters
val

number

Returns

void

Inherited from

HairMaterial.scatterIntensity


scatterLocal

Get Signature

get scatterLocal(): number

Defined in: libs/scene/src/material/hair.ts:384

Balance between the two scattering terms, in [0, 1].

Remarks

Zero keeps only the global term, so the scattering follows the light and vanishes deep in the groom. One keeps only the local term, which is brightest exactly where the direct light is blocked. The default splits them evenly; denser and lighter hair wants more local.

Returns

number

Set Signature

set scatterLocal(val): void

Defined in: libs/scene/src/material/hair.ts:387

Parameters
val

number

Returns

void

Inherited from

HairMaterial.scatterLocal


scatterWrap

Get Signature

get scatterWrap(): number

Defined in: libs/scene/src/material/hair.ts:404

Angular width of the forward-scattered lobe.

Remarks

Scattering spreads light as it crosses fibres, so the global term is not a cosine lobe but a much broader one; this is how far past the terminator it reaches. Larger than HairMaterial.diffuseWrap on purpose - that one softens a terminator, this one models a beam that has genuinely lost its direction.

Returns

number

Set Signature

set scatterWrap(val): void

Defined in: libs/scene/src/material/hair.ts:407

Parameters
val

number

Returns

void

Inherited from

HairMaterial.scatterWrap


shadingModel

Get Signature

get shadingModel(): HairShadingModel

Defined in: libs/scene/src/material/hair.ts:429

Which scattering model shades the hair. Defaults to kajiya-kay.

Remarks

Switching to marschner changes the look of any hair it is enabled on rather than refining it, so it is opted into. See HairShadingModel for what the two models are; the marschner* properties are inert under kajiya-kay and the specular lobe properties are inert under marschner.

Two existing properties overlap with it and should be left alone when it is on: HairMaterial.transmissionIntensity, whose whole job is faking the backlit glow that Marschner's TT path produces for real, and - on HairStrandMaterial - strandRoundness, whose bent normal no longer reaches the highlight, because Marschner already integrates across the fibre.

Returns

HairShadingModel

Set Signature

set shadingModel(val): void

Defined in: libs/scene/src/material/hair.ts:432

Parameters
val

HairShadingModel

Returns

void

Inherited from

HairMaterial.shadingModel


marschnerShift

Get Signature

get marschnerShift(): number

Defined in: libs/scene/src/material/hair.ts:448

Longitudinal shift of the Marschner lobes, in sine units.

Remarks

Hair is not a smooth cylinder: overlapping cuticle scales tilt its surface by a few degrees toward the tip. That tilt is the only reason the three lobes sit at different angles instead of on top of one another, so this is what makes them read as separate highlights at all. The three shifts are derived from it in the ratio the measurements give, R getting -2x and TRT 4x, so one dial moves the whole set consistently.

Defaults to 0.035, roughly the measured 2 degrees.

Returns

number

Set Signature

set marschnerShift(val): void

Defined in: libs/scene/src/material/hair.ts:451

Parameters
val

number

Returns

void

Inherited from

HairMaterial.marschnerShift


marschnerRoughness

Get Signature

get marschnerRoughness(): number

Defined in: libs/scene/src/material/hair.ts:465

Longitudinal roughness of the Marschner lobes, in (0, 1].

Remarks

The angular width of the highlight bands. Per-lobe widths are derived from it - TT half, TRT double - which is the ordering real fibres show: light that only passes through stays tight, light that has bounced inside spreads.

Returns

number

Set Signature

set marschnerRoughness(val): void

Defined in: libs/scene/src/material/hair.ts:468

Parameters
val

number

Returns

void

Inherited from

HairMaterial.marschnerRoughness


marschnerIOR

Get Signature

get marschnerIOR(): number

Defined in: libs/scene/src/material/hair.ts:484

Refractive index of the fibre. Defaults to the measured 1.55 for keratin.

Remarks

Sets how much light reflects at the surface rather than entering, and how sharply it bends once inside - so it moves the balance between the white R highlight and the two coloured paths. Rarely worth changing from the measured value, but exposed because it is a real physical quantity.

Returns

number

Set Signature

set marschnerIOR(val): void

Defined in: libs/scene/src/material/hair.ts:487

Parameters
val

number

Returns

void

Inherited from

HairMaterial.marschnerIOR


marschnerAbsorption

Get Signature

get marschnerAbsorption(): number

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

Multiplier on how far light travels through the fibre before leaving.

Remarks

The transmitted paths are tinted by absorbing the hair's own colour over the distance they cross, so raising this deepens the colour of TT and TRT without touching the white surface reflection. It is the dial for "how strongly pigmented", separate from which colour the pigment is.

Returns

number

Set Signature

set marschnerAbsorption(val): void

Defined in: libs/scene/src/material/hair.ts:506

Parameters
val

number

Returns

void

Inherited from

HairMaterial.marschnerAbsorption


marschnerLobes

Get Signature

get marschnerLobes(): Immutable<Vector3>

Defined in: libs/scene/src/material/hair.ts:521

Per-path intensities as (R, TT, TRT), all 1 by default.

Remarks

Art override on top of the physics, and the fastest way to see what each path contributes: zero two of them and the third is on its own. R is the white surface highlight, TT the backlit glow, TRT the coloured secondary.

Returns

Immutable<Vector3>

Set Signature

set marschnerLobes(val): void

Defined in: libs/scene/src/material/hair.ts:524

Parameters
val

Immutable<Vector3>

Returns

void

Inherited from

HairMaterial.marschnerLobes


occlusionStrength

Get Signature

get occlusionStrength(): number

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

Occlusion map strength in [0, 1]

Returns

number

Set Signature

set occlusionStrength(val): void

Defined in: libs/scene/src/material/hair.ts:534

Parameters
val

number

Returns

void

Inherited from

HairMaterial.occlusionStrength


strands

Get Signature

get strands(): HairStrandData

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

GPU-resident strand geometry.

Returns

HairStrandData

Set Signature

set strands(val): void

Defined in: libs/scene/src/material/hairstrand.ts:139

Parameters
val

HairStrandData

Returns

void


segmentsPerStrand

Get Signature

get segmentsPerStrand(): number

Defined in: libs/scene/src/material/hairstrand.ts:153

Ribbon segments generated per strand.

Remarks

The primary quality/cost dial, and independent of the control point count: the shader resamples the curve, so the same 30-point strand can be drawn with 12 segments up close and 3 far away.

Returns

number

Set Signature

set segmentsPerStrand(val): void

Defined in: libs/scene/src/material/hairstrand.ts:156

Parameters
val

number

Returns

void


strandWidthScale

Get Signature

get strandWidthScale(): number

Defined in: libs/scene/src/material/hairstrand.ts:164

Multiplier applied to the width stored in the strand data.

Returns

number

Set Signature

set strandWidthScale(val): void

Defined in: libs/scene/src/material/hairstrand.ts:167

Parameters
val

number

Returns

void


minStrandWidth

Get Signature

get minStrandWidth(): number

Defined in: libs/scene/src/material/hairstrand.ts:174

Lower bound on ribbon width in world units.

Returns

number

Set Signature

set minStrandWidth(val): void

Defined in: libs/scene/src/material/hairstrand.ts:177

Parameters
val

number

Returns

void


minPixelWidth

Get Signature

get minPixelWidth(): number

Defined in: libs/scene/src/material/hairstrand.ts:194

Lower bound on ribbon width in pixels.

Remarks

A strand narrower than a pixel rasterises to a flickering dotted line, because whether a given segment covers a sample point changes with subpixel position. Clamping the quad to about a pixel and scaling alpha by how much it was widened keeps total energy roughly constant, so the strand reads as fainter rather than as broken. Set to 0 to disable.

Returns

number

Set Signature

set minPixelWidth(val): void

Defined in: libs/scene/src/material/hairstrand.ts:197

Parameters
val

number

Returns

void


strandLOD

Get Signature

get strandLOD(): boolean

Defined in: libs/scene/src/material/hairstrand.ts:227

Trades strand count for strand opacity with distance.

Remarks

Past the point where a strand is thinner than a pixel, minPixelWidth widens it and pays the widening back as alpha, so a distant groom is drawn as tens of thousands of ribbons each contributing a few percent of a pixel. That is correct on average and unstable in practice: any per-fragment stochastic alpha - alphaDither, alpha-to-coverage - is sampling a five percent event once per pixel per frame, and the variance reads as pixel-level crawl that a temporal filter's short history cannot average away.

This moves the randomness from the fragment to the strand. Each strand is kept with a probability equal to the coverage it would have been drawn at and the survivors are drawn at full coverage, which puts the same quantity of hair on screen: N strands at alpha a and N*a strands at alpha 1 integrate to the same image. The difference is that the draw is decided once per strand from a fixed seed rather than once per fragment per frame, so the result is stable across frames, and the culled strands cost no fragments at all.

Off by default: it changes which strands are drawn, so it is opted into rather than applied to existing grooms silently.

Returns

boolean

Set Signature

set strandLOD(val): void

Defined in: libs/scene/src/material/hairstrand.ts:230

Parameters
val

boolean

Returns

void


prevPoints

Get Signature

get prevPoints(): GPUDataBuffer<unknown>

Defined in: libs/scene/src/material/hairstrand.ts:245

Control points as of the previously rendered frame, or null.

Remarks

Set by HairNode while a simulation is running. Without it the previous position is the current control point put through the previous world matrix, which carries the node's motion but none of the strand's own - so a groom swinging under a still head reports no motion at all, and a temporal filter blends a history that has nothing to do with the pixel. Costs four extra point fetches per vertex, hence a feature rather than an always-on path: a static groom does not need it.

Returns

GPUDataBuffer<unknown>

Set Signature

set prevPoints(buffer): void

Defined in: libs/scene/src/material/hairstrand.ts:248

Parameters
buffer

GPUDataBuffer<unknown>

Returns

void


minStrandLODRatio

Get Signature

get minStrandLODRatio(): number

Defined in: libs/scene/src/material/hairstrand.ts:265

Floor on the fraction of strands strandLOD keeps.

Remarks

Decimation follows coverage, and coverage falls without bound as the groom recedes, so an unclamped ratio eventually culls every strand and the hair disappears. This is the point past which thinning stops and the remaining strands simply fade instead. Defaults to 0.05.

Returns

number

Set Signature

set minStrandLODRatio(val): void

Defined in: libs/scene/src/material/hairstrand.ts:268

Parameters
val

number

Returns

void


strandRoundness

Get Signature

get strandRoundness(): number

Defined in: libs/scene/src/material/hairstrand.ts:295

How far the shading normal bends across the ribbon, in [0, 1].

Remarks

The quad is a stand-in for a cylinder, and this is how much it is shaded like one. At 1 the normal sweeps a full half turn about the curve tangent between the two edges, as the visible surface of a fibre does; at 0 it stays the quad's own normal and every fragment across the width shades identically, which is the flat ribbon this material drew before.

It matters more than its size suggests. A flat ribbon has one normal, so the specular lobes either fire across the strand's whole width or not at all, and a groom becomes a field of uniformly bright or uniformly dull tape. Bending the normal puts a narrow highlight down the length of each strand and lets the edges fall off, which is most of what separates strands from one another when they are all the same colour.

Values below 1 keep the highlight but widen it, which reads as a softer, thicker fibre; artists after a stylised look sometimes want that.

Returns

number

Set Signature

set strandRoundness(val): void

Defined in: libs/scene/src/material/hairstrand.ts:298

Parameters
val

number

Returns

void


rootOcclusion

Get Signature

get rootOcclusion(): number

Defined in: libs/scene/src/material/hairstrand.ts:328

Strength of the root-depth ambient occlusion, in [0, 1].

Remarks

Environment irradiance is not attenuated by anything - a shadow map answers for one light, not for the sky - so without this every strand of a groom receives the full sky, and a dense hairstyle lights up as brightly in its interior as on its surface. That reads as a flat silhouette with no volume, and it is most obvious on pale hair, where there is little pigment to darken the interior instead.

Real occlusion would need to know how much hair sits between a fibre and the sky. This approximates that by where along the strand the fragment is: roots grow from the scalp, buried under everything above them, while tips are on the outside. It is only an approximation - a tip tucked under a fringe is treated as exposed - but it is free, it needs no texture coordinates, which this material has none of, and it captures the dominant effect. Set to 0 to disable.

Applied to ambient light and the scatter term only. Direct light keeps its own answer - the shadow map, or DOM's graded transmittance - and multiplying this on top would count the same blockage twice.

Returns

number

Set Signature

set rootOcclusion(val): void

Defined in: libs/scene/src/material/hairstrand.ts:331

Parameters
val

number

Returns

void


rootOcclusionRange

Get Signature

get rootOcclusionRange(): number

Defined in: libs/scene/src/material/hairstrand.ts:346

How far along a strand the root occlusion reaches, in (0, 1].

Remarks

The fraction of the strand's length over which occlusion fades from full at the root to none. Short for a groom whose strands leave the scalp quickly, longer for one where they lie against each other most of their length.

Returns

number

Set Signature

set rootOcclusionRange(val): void

Defined in: libs/scene/src/material/hairstrand.ts:349

Parameters
val

number

Returns

void


vertexCount

Get Signature

get vertexCount(): number

Defined in: libs/scene/src/material/hairstrand.ts:363

Vertex count needed to draw the current strand set.

Remarks

Assign this to the primitive's indexCount. Drawing is non-indexed, with six vertices per ribbon segment forming two triangles.

Returns

number


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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.objectColor

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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.dispatchEvent


dispose()

dispose(): void

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

Returns

void

Inherited from

HairMaterial.dispose


vertexShader()

vertexShader(scope): void

Defined in: libs/scene/src/material/hair.ts:541

Vertex shader hook. Prepares common inputs (skin/morph/instancing), varyings, and pass-dependent outputs. Override to implement per-vertex logic; use ShaderHelper as needed.

Parameters

scope

PBFunctionScope

Vertex shader function scope.

Returns

void

void

Inherited from

HairMaterial.vertexShader


fragmentShader()

fragmentShader(scope): void

Defined in: libs/scene/src/material/hair.ts:545

Fragment shader hook. Declares pass-dependent uniforms (e.g., opacity, objectColor, alphaCutoff). Override to implement per-fragment logic, and call outputFragmentColor to finalize writes.

Parameters

scope

PBFunctionScope

Fragment shader function scope.

Returns

void

void

Inherited from

HairMaterial.fragmentShader


hairLight()

hairLight(scope, worldPos, normal, strandT, viewVec, albedo, shiftVal, ao, aoDirect, geometricNormal?): PBShaderExp

Defined in: libs/scene/src/material/hair.ts:1098

Parameters

scope

PBInsideFunctionScope

worldPos

PBShaderExp

normal

PBShaderExp

strandT

PBShaderExp

viewVec

PBShaderExp

albedo

PBShaderExp

shiftVal

PBShaderExp

ao

PBShaderExp

Ambient occlusion, applied to environment irradiance and the scatter term - the light no shadow query answers for.

aoDirect

PBShaderExp

Occlusion applied to per-light shading, whose direct blockage the shadow map already accounts for. See HairMaterial.calculateHairDirectOcclusion.

geometricNormal?

PBShaderExp

Interpolated vertex normal, used for shadow normal offset bias. Defaults to normal.

Returns

PBShaderExp

Inherited from

HairMaterial.hairLight


clone()

clone(): HairStrandMaterial

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

Create a shallow clone of this material. Subclasses should override to copy custom fields.

Returns

HairStrandMaterial

Implementation of

Clonable.clone

Overrides

HairMaterial.clone


copyFrom()

copyFrom(other): void

Defined in: libs/scene/src/material/hairstrand.ts:122

Copy common MeshMaterial properties from another material. Call super.copyFrom(other) first when overriding in subclasses.

Parameters

other

this

Source material.

Returns

void

Overrides

HairMaterial.copyFrom


calculateAlbedoColor()

calculateAlbedoColor(scope, uv?): PBShaderExp

Defined in: libs/scene/src/material/hairstrand.ts:376

Albedo, with alpha scaled by how much the ribbon was widened to meet the pixel floor.

Parameters

scope

PBInsideFunctionScope

uv?

PBShaderExp

Returns

PBShaderExp

Remarks

Widening a sub-pixel strand to a pixel adds coverage that is not physically there. Scaling alpha by the inverse keeps the strand's contribution roughly constant, so distant hair thins out in opacity instead of breaking into a flickering dotted line.

Overrides

HairMaterial.calculateAlbedoColor


vertexShaderImpl()

protected vertexShaderImpl(scope): void

Defined in: libs/scene/src/material/hairstrand.ts:385

Parameters

scope

PBFunctionScope

Returns

void

Overrides

HairMaterial.vertexShaderImpl


applyUniformValues()

applyUniformValues(bindGroup, ctx, pass): void

Defined in: libs/scene/src/material/hairstrand.ts:499

Submit material uniforms/resources to the material bind group (set 2). Handles alpha cutoff, opacity (non-instanced transparent), OIT, object color, and TAA strength.

Parameters

bindGroup

BindGroup

The material bind group to write into.

ctx

DrawContext

Current draw context.

pass

number

Current material pass index.

Returns

void

void

Overrides

HairMaterial.applyUniformValues


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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.applyUniforms


clearCache()

clearCache(): void

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

Returns

void

Inherited from

HairMaterial.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

HairMaterial.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

HairMaterial.drawPrimitive


onDispose()

protected onDispose(): void

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

Dispose the material and release GPU-side resource references.

  • Unregisters from the global registry.
  • Disposes the per-material bind groups kept in _states.

Returns

void

Inherited from

HairMaterial.onDispose


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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.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

HairMaterial.useFeature


isMaterialTextureEnabled()

protected isMaterialTextureEnabled(_name): boolean

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

Parameters

_name

string

Returns

boolean

Inherited from

HairMaterial.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

HairMaterial.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

HairMaterial.outputFragmentColor


receivesWaterCaustics()

receivesWaterCaustics(): boolean

Defined in: libs/scene/src/material/mixins/lit.ts:27

Returns

boolean

Inherited from

HairMaterial.receivesWaterCaustics


needCalculateEnvLight()

needCalculateEnvLight(): boolean

Defined in: libs/scene/src/material/mixins/lit.ts:28

Returns

boolean

Inherited from

HairMaterial.needCalculateEnvLight


getUniformNormalScale()

getUniformNormalScale(scope): PBShaderExp

Defined in: libs/scene/src/material/mixins/lit.ts:29

Parameters

scope

PBInsideFunctionScope

Returns

PBShaderExp

Inherited from

HairMaterial.getUniformNormalScale


getEnvLightIrradiance()

getEnvLightIrradiance(scope, normal): PBShaderExp

Defined in: libs/scene/src/material/mixins/lit.ts:30

Parameters

scope

PBInsideFunctionScope

normal

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.getEnvLightIrradiance


getEnvLightRadiance()

getEnvLightRadiance(scope, reflectVec, roughness): PBShaderExp

Defined in: libs/scene/src/material/mixins/lit.ts:31

Parameters

scope

PBInsideFunctionScope

reflectVec

PBShaderExp

roughness

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.getEnvLightRadiance


calculateViewVector()

calculateViewVector(scope, worldPos): PBShaderExp

Defined in: libs/scene/src/material/mixins/lit.ts:36

Parameters

scope

PBInsideFunctionScope

worldPos

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.calculateViewVector


calculateReflectionVector()

calculateReflectionVector(scope, normal, viewVec): PBShaderExp

Defined in: libs/scene/src/material/mixins/lit.ts:37

Parameters

scope

PBInsideFunctionScope

normal

PBShaderExp

viewVec

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.calculateReflectionVector


calculateTBN()

calculateTBN(scope, worldPos, worldNormal?, worldTangent?, worldBinormal?): PBShaderExp

Defined in: libs/scene/src/material/mixins/lit.ts:42

Parameters

scope

PBInsideFunctionScope

worldPos

PBShaderExp

worldNormal?

PBShaderExp

worldTangent?

PBShaderExp

worldBinormal?

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.calculateTBN


calculateNormal()

calculateNormal(scope, worldPos, worldNormal?, worldTangent?, worldBinormal?): PBShaderExp

Defined in: libs/scene/src/material/mixins/lit.ts:49

Parameters

scope

PBInsideFunctionScope

worldPos

PBShaderExp

worldNormal?

PBShaderExp

worldTangent?

PBShaderExp

worldBinormal?

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.calculateNormal


calculateNormalAndTBN()

calculateNormalAndTBN(scope, worldPos, worldNormal?, worldTangent?, worldBinormal?): PBShaderExp

Defined in: libs/scene/src/material/mixins/lit.ts:56

Parameters

scope

PBInsideFunctionScope

worldPos

PBShaderExp

worldNormal?

PBShaderExp

worldTangent?

PBShaderExp

worldBinormal?

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.calculateNormalAndTBN


calculateLightAttenuation()

calculateLightAttenuation(scope, type, worldPos, posRange, dirCutoff, extra?): PBShaderExp

Defined in: libs/scene/src/material/mixins/lit.ts:63

Parameters

scope

PBInsideFunctionScope

type

PBShaderExp

worldPos

PBShaderExp

posRange

PBShaderExp

dirCutoff

PBShaderExp

extra?

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.calculateLightAttenuation


calculateLightDirection()

calculateLightDirection(scope, type, worldPos, posRange, dirCutoff): PBShaderExp

Defined in: libs/scene/src/material/mixins/lit.ts:71

Parameters

scope

PBInsideFunctionScope

type

PBShaderExp

worldPos

PBShaderExp

posRange

PBShaderExp

dirCutoff

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.calculateLightDirection


calculateShadow()

calculateShadow(scope, worldPos, worldNormal, NoL): PBShaderExp

Defined in: libs/scene/src/material/mixins/lit.ts:78

Parameters

scope

PBInsideFunctionScope

worldPos

PBShaderExp

worldNormal

PBShaderExp

NoL

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.calculateShadow


forEachLight()

forEachLight(scope, callback): void

Defined in: libs/scene/src/material/mixins/lit.ts:84

Parameters

scope

PBInsideFunctionScope

callback

(this, type, posRange, dirCutoff, colorIntensity, extra, shadow) => void

Returns

void

Inherited from

HairMaterial.forEachLight


fresnelSchlick()

fresnelSchlick(scope, cosTheta, F0, F90): PBShaderExp

Defined in: libs/scene/src/material/mixins/pbr/brdf.ts:14

Parameters

scope

PBInsideFunctionScope

cosTheta

PBShaderExp

F0

PBShaderExp

F90

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.fresnelSchlick


distributionGGX()

distributionGGX(scope, NdotH, alphaRoughness): PBShaderExp

Defined in: libs/scene/src/material/mixins/pbr/brdf.ts:20

Parameters

scope

PBInsideFunctionScope

NdotH

PBShaderExp

alphaRoughness

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.distributionGGX


visGGX()

visGGX(scope, NdotV, NdotL, alphaRoughness): PBShaderExp

Defined in: libs/scene/src/material/mixins/pbr/brdf.ts:21

Parameters

scope

PBInsideFunctionScope

NdotV

PBShaderExp

NdotL

PBShaderExp

alphaRoughness

PBShaderExp

Returns

PBShaderExp

Inherited from

HairMaterial.visGGX


getVertexColor()

getVertexColor(scope): PBShaderExp

Defined in: libs/scene/src/material/mixins/vertexcolor.ts:11

Parameters

scope

PBInsideFunctionScope

Returns

PBShaderExp

Inherited from

HairMaterial.getVertexColor

Released under the MIT License.