DreamShaderLang
Language Core

Layout and Region

Use the Layout section and Graph

Layout is optional metadata for generated graph readability. It does not change shader math. Use it to pin important nodes, create comment boxes, and preserve decompiled layout hints.

Graph Region

Regions live inside Graph:

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

    Color = Tint * pulse;
}

Regions are useful for grouping generated nodes and producing comment boxes.

Layout Section

Add a Layout section next to Graph:

Layout = {
    Node("Tint", X=0, Y=0);
    Comment("Pulse", X=-160, Y=-120, W=520, H=260);
}

The compiler treats layout as metadata. Invalid layout entries should not be used to hide real graph issues.

Node(...)

Node(...) pins a generated node by logical name:

Node("Tint", X=0, Y=0);
Node("Color", X=420, Y=0);
FieldMeaning
first argumentNode or generated variable name.
XHorizontal position.
YVertical position.

Comment(...)

Comment(...) creates a graph comment:

Comment("Pulse", X=-160, Y=-120, W=520, H=260);
FieldMeaning
first argumentComment title.
X, YTop-left position.
W, HSize.

Full Example

Shader(Name="DreamMaterials/M_Layout")
{
    Properties = {
        vec3 Tint = vec3(0.2, 0.6, 1.0);
    }

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

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

        Color = Tint * pulse;
    }

    Layout = {
        Node("Tint", X=0, Y=0);
        Node("Color", X=520, Y=0);
        Comment("Pulse", X=160, Y=-140, W=320, H=260);
    }
}

Decompiled Layout

When a material or material function is exported to .dsm / .dsf, the exporter may emit Layout entries and regions so the text source preserves useful graph structure. Review these entries after export; generated names may need cleanup.

Diagnostics

ProblemFix
Layout references an unknown nodeCheck the variable or node name used in Node(...).
Comment has invalid sizeProvide positive W and H.
Region is not closedAdd matching #EndRegion.
Layout does not affect shader outputThis is expected; layout is metadata only.

On this page