DreamShaderLang
Language Core

Top-level Declarations

Structure of Shader, ShaderFunction, ShaderLayer, VirtualFunction, Function, GraphFunction, and Namespace.

Top-level declarations define generated assets and shared helpers. Asset declarations use sections such as Properties, Inputs, Outputs, Settings, Graph, and Layout.

Shader

Shader generates a UMaterial.

Shader(Name="DreamMaterials/M_UI")
{
    Properties = {
        vec3 Tint = vec3(1, 1, 1);
    }

    Settings = {
        Domain = "UI";
        ShadingModel = "Unlit";
    }

    Outputs = {
        vec3 Color;
        Base.EmissiveColor = Color;
    }

    Graph = {
        Color = Tint;
    }
}
AttributeMeaning
NameGenerated package path relative to Root.
RootOptional root such as Game or Plugin.MyPlugin.

ShaderFunction

ShaderFunction generates a UMaterialFunction.

ShaderFunction(Name="DreamFunctions/F_Tint")
{
    Inputs = {
        vec3 Color;
        float Strength = 1.0;
    }

    Outputs = {
        vec3 Result;
    }

    Graph = {
        Result = Color * Strength;
    }
}

Use .dsf files for project-owned ShaderFunction sources.

ShaderLayer and ShaderLayerBlend

ShaderLayer and ShaderLayerBlend generate native Unreal Material Layer assets:

ShaderLayer(Name="DreamLayers/ML_Tint")
{
    Inputs = {
        MaterialAttributes BaseMaterial;
        vec3 Tint = vec3(1, 0.5, 0.2);
    }

    Outputs = {
        MaterialAttributes Result;
        return = Result;
    }

    Graph = {
        Result = BaseMaterial;
    }
}

Use these blocks instead of hand-building layer function assets when the output should be a native Material Layer or Layer Blend.

VirtualFunction

VirtualFunction declares an existing Unreal material function so it can be called from Graph. It does not generate or overwrite an asset.

VirtualFunction(Name="Engine/Functions/Engine_MaterialFunctions02/Utility/BreakOutFloat3Components")
{
    Inputs = {
        vec3 InColor;
    }

    Outputs = {
        float R;
        float G;
        float B;
    }
}

Function

Function is an HLSL-style helper. It can be placed in .dsh, .dsm, or .dsf.

Function float Luma(vec3 color)
{
    return dot(color, vec3(0.2126, 0.7152, 0.0722));
}

Single-output calls can be used as Graph value expressions:

float y = Luma(Tint);

GraphFunction

GraphFunction is a reusable Custom-node helper that can call UE.* graph nodes inside its body. The generator creates the required graph nodes and wires them as Custom inputs.

GraphFunction float Pulse(float speed)
{
    float t = UE.Time();
    return sin(t * speed) * 0.5 + 0.5;
}

SelfContained and Inline

SelfContained helpers are emitted with their own helper body so they are less dependent on surrounding generated code. Inline is used when the helper is intended to be expanded or treated as a lightweight expression by the generator.

Use these modifiers when a helper needs predictable Custom-node output or when you want to avoid scattering helper dependencies across multiple generated snippets.

Namespace

Namespace groups helper functions:

Namespace ColorTools
{
    Function float Luma(vec3 color)
    {
        return dot(color, vec3(0.2126, 0.7152, 0.0722));
    }
}

Call namespaced helpers as:

float y = ColorTools::Luma(Tint);

On this page