Skip to main content

Class: ForgeShaderSource

Defined in: rendering/shaders/dependency-resolution/forge-shader-source.ts:4

Represents a shader source file with metadata.

Constructors

Constructor

new ForgeShaderSource(rawSource): ForgeShaderSource

Defined in: rendering/shaders/dependency-resolution/forge-shader-source.ts:19

Constructs a new instance of the ForgeShaderSource class. Parses the provided shader source code and extracts metadata.

Parameters

rawSource

string

The raw source code of the shader.

Returns

ForgeShaderSource

Throws

If the shader source does not contain a valid #property name directive.

Throws

If any #include or #property directive has invalid syntax.

Accessors

includes

Get Signature

get includes(): Set<string>

Defined in: rendering/shaders/dependency-resolution/forge-shader-source.ts:40

Gets the set of include dependencies declared in the shader. These are extracted from #include directives in the source.

Returns

Set<string>

A Set containing the names of all included shaders.


name

Get Signature

get name(): string

Defined in: rendering/shaders/dependency-resolution/forge-shader-source.ts:50

Gets the name of the shader. The name is extracted from the required #property name directive.

Returns

string

The shader name.


rawSource

Get Signature

get rawSource(): string

Defined in: rendering/shaders/dependency-resolution/forge-shader-source.ts:30

Gets the raw, unprocessed source code of the shader.

Returns

string

The raw shader source code as provided to the constructor.

Methods

getPropertyValue()

getPropertyValue(name): null | string

Defined in: rendering/shaders/dependency-resolution/forge-shader-source.ts:70

Gets the value of a custom property by its name. Properties are defined using #property directives in the shader source. Property names are case-insensitive.

Parameters

name

string

The name of the property to retrieve.

Returns

null | string

The value of the property, or null if the property does not exist.

Example

// Shader source contains: #property version: 1.0
shader.getPropertyValue('version'); // "1.0"
shader.getPropertyValue('VERSION'); // "1.0" (case-insensitive)
shader.getPropertyValue('missing'); // null