DreamShaderLang
Language Core

Graph Language

The graph DSL used by DreamShaderLang to generate Unreal material nodes.

Graph is the part of DreamShaderLang that becomes Unreal material nodes. It looks like a small shader language, but its statements are interpreted by the generator.

Statements

Common statements include:

float t = UE.Time();
float pulse = sin(t) * 0.5 + 0.5;
Color = Tint * pulse;
StatementRole
DeclarationCreates a named intermediate value.
AssignmentConnects a value to another variable or output.
Function callCalls Function, GraphFunction, ShaderFunction, VirtualFunction, or UE.*.
if / elseGenerates conditional graph logic for supported cases.
#RegionGroups nodes and can produce layout comment boxes.

Declarations

float Strength = 1.0;
vec3 Color = Tint * Strength;

The declared name can be referenced later in the same Graph.

Expressions

Arithmetic

Color = Tint * Strength + vec3(0.1, 0.1, 0.1);

Constructors

vec3 Blue = vec3(0.2, 0.6, 1.0);
float4 Packed = float4(Blue, 1.0);

Swizzle

float r = Color.r;
vec2 rg = Color.rg;

MaterialAttributes

MaterialAttributes values are used by Material Layer and Layer Blend graphs.

MaterialAttributes Result = BaseMaterial;

Function Calls

Single-output calls can be used as value expressions:

float y = ColorTools::Luma(Tint);

Multi-output calls use explicit output variables.

Function Calls

Function calls become Custom-node helper calls or generated HLSL depending on the helper mode and compiler behavior.

float y = Luma(Tint);

GraphFunction Calls

GraphFunction calls can contain UE.* calls inside the helper body:

float pulse = Pulse(2.0);

ShaderFunction Calls

Generated .dsf functions can be called from other Graphs once imported:

vec3 result = F_Tint(Color, Strength);

The exact callable name follows the declaration/import symbol exposed by the source.

VirtualFunction Calls

VirtualFunction calls reference existing Unreal Material Function assets without generating them.

Use this when a project already owns the material function in Unreal.

Parameter Node Calls

Parameters are usually declared in Properties or Inputs, then referenced by name:

Color = Tint * Strength;

Explicit parameter node types can carry Unreal metadata such as group and sort priority.

if / else

Simple conditionals are supported for graph-friendly expressions:

if (UseTint)
{
    Color = BaseColor * Tint;
}
else
{
    Color = BaseColor;
}

For complex control flow, put the logic in a Function or GraphFunction.

Graph Region

Use #Region and #EndRegion to group a portion of a graph:

Graph = {
    #Region "Pulse"
    float t = UE.Time();
    float pulse = sin(t) * 0.5 + 0.5;
    #EndRegion

    Color = Tint * pulse;
}

Regions can work with generated layout comments and make decompiled graphs easier to review.

Not Currently Supported

FeatureAlternative
Arbitrary complex loops in GraphPut loop logic in Function.
Unsupported Unreal node shorthandUse generic UE.Expression(...).
Deep shader-language constructs inside GraphUse Function / GraphFunction.
Ambiguous multi-output value expressionsUse explicit output variables.

On this page