Skip to content

Documentation / scene / TextureSampleGrad

Class: TextureSampleGrad ​

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

Texture sampling with explicit gradients node

Remarks ​

Samples a texture using explicitly provided screen-space gradients (derivatives) instead of automatically computed ones. This allows precise control over mipmap level selection and can be used for advanced effects.

Use cases:

  • Manual mipmap level control
  • Sampling in non-fragment shaders (where automatic derivatives aren't available)
  • Custom anisotropic filtering
  • Texture sampling in control flow that breaks derivatives
  • Advanced procedural effects

Note: The current implementation appears identical to TextureSampleNode. Full gradient support would require additional inputs for dPdx and dPdy.

Inputs:

  • Input 1: Texture sampler (tex2D, tex2DArray, or texCube)
  • Input 2: Texture coordinates (vec2 or vec3)

Output:

  • Output 1: Sampled color (vec4 RGBA)

Extends ​

Constructors ​

Constructor ​

new TextureSampleGrad(): TextureSampleGrad

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

Creates a new texture sample with gradients node

Returns ​

TextureSampleGrad

Remarks ​

Initializes with:

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

TODO: Add gradient inputs (dPdx, dPdy) for full explicit gradient support

Overrides ​

BaseGraphNode.constructor

Properties ​

samplerType ​

samplerType: "Color" | "Normal"

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

The type of sampling (Color or Normal)


_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/node.ts:357

Whether this node contains uniform value/texture

Returns ​

boolean

Whether this node has uniform value

Inherited from ​

BaseGraphNode.isUniform


paramName ​

Get Signature ​

get paramName(): string

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

Uniform parameter name

Returns ​

string

Uniform parameter name

Inherited from ​

BaseGraphNode.paramName


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:2091

Gets the serialization descriptor for this node type

Returns ​

SerializableClass

Serialization class descriptor

Remarks ​

Currently returns TextureSampleNode serialization (likely needs separate class).


toString() ​

toString(): string

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

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:2136

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

Overrides ​

BaseGraphNode.validate


getType() ​

protected getType(): string

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

Gets the output type

Returns ​

string

'vec4' (RGBA color)

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.