Skip to content

Documentation / scene / TextureSampleNode

Class: TextureSampleNode

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:995

Texture sampling node

Remarks

Samples a texture at the specified coordinates and returns the color value. This is the primary way to read texture data in material shaders.

Supports multiple texture types:

  • tex2D: Requires vec2 coordinates (u, v)
  • tex2DArray: Requires vec3 coordinates (u, v, layer)
  • texCube: Requires vec3 direction vector

Sampler types:

  • Color: Standard color sampling (returns RGBA as-is)
  • Normal: Normal map sampling (may apply special transformations)

The sampling uses the texture's configured filtering and addressing modes. Mipmap level is automatically selected based on screen-space derivatives.

Inputs:

  • Input 1: Texture sampler (tex2D, tex2DArray, or texCube)
  • Input 2: Texture coordinates (vec2 for 2D, vec3 for array/cube)

Output:

  • Output 1: Sampled color (vec4 RGBA)

Examples

typescript
// Basic 2D texture sampling
const albedoTex = new ConstantTexture2DNode();
const uv = new VertexUVNode();

const sample = new TextureSampleNode();
sample.samplerType = 'Color';
sample.connectInput(1, albedoTex, 1);
sample.connectInput(2, uv, 1);

output.connectInput(1, sample, 1); // Use as base color
typescript
// Normal map sampling
const normalMap = new ConstantTexture2DNode();
const uv = new VertexUVNode();

const sample = new TextureSampleNode();
sample.samplerType = 'Normal';
sample.connectInput(1, normalMap, 1);
sample.connectInput(2, uv, 1);

output.connectInput(6, sample, 1); // Use as normal
typescript
// Cubemap environment sampling
const envMap = new ConstantTextureCubeNode();
const normal = new VertexNormalNode();
const viewDir = new ViewDirectionNode();

const reflectDir = new ReflectNode();
reflectDir.connectInput(1, viewDir, 1);
reflectDir.connectInput(2, normal, 1);

const sample = new TextureSampleNode();
sample.connectInput(1, envMap, 1);
sample.connectInput(2, reflectDir, 1);

Extends

Constructors

Constructor

new TextureSampleNode(): TextureSampleNode

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1025

Creates a new texture sample node

Returns

TextureSampleNode

Remarks

Initializes with:

  • Two required inputs (texture and coordinates)
  • One output (sampled color)
  • Color sampler type by default

Overrides

BaseGraphNode.constructor

Properties

samplerType

samplerType: "Color" | "Normal"

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:997

The type of sampling (Color or Normal)


textureId

textureId: string

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1003

Asset ID for fallback texture (used when texture input is not connected)


sRGB

sRGB: boolean

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1005

Whether fallback texture should be loaded in sRGB color space


addressU

addressU: TextureAddressMode

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1007

Horizontal texture coordinate wrapping mode for fallback texture


addressV

addressV: TextureAddressMode

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1009

Vertical texture coordinate wrapping mode for fallback texture


filterMin

filterMin: TextureFilterMode

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1011

Minification filter mode for fallback texture


filterMag

filterMag: TextureFilterMode

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1013

Magnification filter mode for fallback texture


filterMip

filterMip: TextureFilterMode

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1015

Mipmap filter mode for fallback texture


_inputs

protected _inputs: GraphNodeInput[]

Defined in: libs/scene/src/utility/blueprint/node.ts:336

Internal storage for input slot definitions

Inherited from

BaseGraphNode._inputs


_outputs

protected _outputs: GraphNodeOutput[]

Defined in: libs/scene/src/utility/blueprint/node.ts:338

Internal storage for output slot definitions

Inherited from

BaseGraphNode._outputs


_error

protected _error: string

Defined in: libs/scene/src/utility/blueprint/node.ts:340

Internal storage for error message

Inherited from

BaseGraphNode._error

Accessors

isUniform

Get Signature

get isUniform(): boolean

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1086

Indicates this node can provide a texture uniform when texture input is not connected.

Returns

boolean

Whether this node has uniform value

Overrides

BaseGraphNode.isUniform


paramName

Get Signature

get paramName(): string

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1092

Gets fallback texture uniform parameter name.

Returns

string

Set Signature

set paramName(val): void

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1095

Uniform parameter name

Parameters
val

string

Returns

void

Uniform parameter name

Overrides

BaseGraphNode.paramName


expose

Get Signature

get expose(): boolean

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1107

Whether fallback texture parameter should be exposed to material instances.

Remarks

Only meaningful when the texture input is not connected.

Returns

boolean

Set Signature

set expose(val): void

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1110

Parameters
val

boolean

Returns

void


inputs

Get Signature

get inputs(): GraphNodeInput[]

Defined in: libs/scene/src/utility/blueprint/node.ts:380

Gets the input slot definitions array

Returns

GraphNodeInput[]

Array of input slot definitions

Inherited from

BaseGraphNode.inputs


outputs

Get Signature

get outputs(): GraphNodeOutput[]

Defined in: libs/scene/src/utility/blueprint/node.ts:384

Gets the output slot definitions array

Returns

GraphNodeOutput[]

Array of output slot definitions

Inherited from

BaseGraphNode.outputs


error

Get Signature

get error(): string

Defined in: libs/scene/src/utility/blueprint/node.ts:388

Gets the current error message

Returns

string

Set Signature

set error(str): void

Defined in: libs/scene/src/utility/blueprint/node.ts:391

Current error message, empty string if no error

Parameters
str

string

Returns

void

Current error message, empty string if no error

Inherited from

BaseGraphNode.error

Methods

on()

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

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

IEventTarget.on

Type Parameters

K

K extends "changed"

Parameters

type

K

listener

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

context?

unknown

Returns

void

Inherited from

BaseGraphNode.on


once()

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

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

IEventTarget.once

Type Parameters

K

K extends "changed"

Parameters

type

K

listener

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

context?

unknown

Returns

void

Inherited from

BaseGraphNode.once


off()

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

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

IEventTarget.off

Type Parameters

K

K extends "changed"

Parameters

type

K

listener?

EventListener<{ changed: []; }>

context?

unknown

Returns

void

Inherited from

BaseGraphNode.off


dispatchEvent()

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

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

IEventTarget.dispatchEvent

Type Parameters

K

K extends "changed"

Parameters

type

K

args

...object[K]

Returns

void

Inherited from

BaseGraphNode.dispatchEvent


getSerializationCls()

static getSerializationCls(): SerializableClass

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1124

Gets the serialization descriptor for this node type

Returns

SerializableClass

Serialization class descriptor

Remarks

Serializes the sampler type (Color or Normal).


toString()

toString(): string

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1181

Generates a string representation of this node

Returns

string

'textureSample'

Overrides

BaseGraphNode.toString


validate()

protected validate(): string

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1198

Validates the node state and input type compatibility

Returns

string

Error message if invalid, empty string if valid

Remarks

Validation ensures:

  • Both inputs are connected
  • Texture input is a valid texture type
  • Coordinate input matches texture dimensionality:
    • tex2D requires vec2
    • tex2DArray requires vec3 (u, v, layer)
    • texCube requires vec3 (direction)

Overrides

BaseGraphNode.validate


getType()

protected getType(id): "" | "vec3" | "vec4" | "float"

Defined in: libs/scene/src/utility/blueprint/material/texture.ts:1231

Gets the output type

Parameters

id

number

Returns

"" | "vec3" | "vec4" | "float"

Overrides

BaseGraphNode.getType


getOutputType()

getOutputType(id): string

Defined in: libs/scene/src/utility/blueprint/node.ts:376

Gets the output type for a specific output slot

Parameters

id

number

The output slot ID

Returns

string

The type name of the output

Remarks

Default implementation delegates to the abstract getType() method. Can be overridden for more complex type logic.

Inherited from

BaseGraphNode.getOutputType


check()

check(): void

Defined in: libs/scene/src/utility/blueprint/node.ts:413

Validates the node and updates error state

Returns

void

Remarks

Calls the validate() method and stores the result in _error. Emits a 'changed' event if the error state changes.

Inherited from

BaseGraphNode.check


reset()

reset(): void

Defined in: libs/scene/src/utility/blueprint/node.ts:422

Clears the error state

Returns

void

Remarks

Sets _error to an empty string.

Inherited from

BaseGraphNode.reset


setInput()

setInput(id, node, inputId): void

Defined in: libs/scene/src/utility/blueprint/node.ts:443

Connects an input slot to another node's output

Parameters

id

number

The input slot ID to connect

node

BaseGraphNode

The source node to connect from

inputId

number

The output slot ID of the source node

Returns

void

Throws

Error if the input slot with the given ID doesn't exist

Example

typescript
const addNode = new AddNode();
const constantNode = new ConstantNode(5.0);

// Connect constantNode's output 0 to addNode's input 0
addNode.setInput(0, constantNode, 0);

Inherited from

BaseGraphNode.setInput

Released under the MIT License.