DreamShaderLang
Plugin referenceDreamShaderLang

Keyword index

Keyword index

Keyword index

DreamShader » DreamShaderLang » Keyword index

Every word the declaration grammar treats specially: top-level block keywords, section names and their aliases, declaration qualifiers, contextual keywords, reserved names, and the identifiers that are rewritten before HLSL is emitted.

Declared in.dsm, .dsf, .dsh
Kindindex
Case ruletop-level block keywords and the reserved words are case-sensitive; everything else on this page is case-insensitive unless its row says otherwise

Synopsis

<top-level-keyword> ( <attribute-key> = <value> [, …] )
{
    <section-name> [=] { <qualifier>… <type> <name> [= <default>] [[ <metadata> ]] ; … } [;]
}

[!NOTE] Block words, section names and type names are not reserved against identifiers. A property, output variable, parameter or function may be named Shader, Graph or Layout; they are recognized only where the grammar expects them. The reserved words are the exception (since 2.0.0).

Top-level block keywords

Matched case-sensitively, as a whole word: ShaderFunction is its own word, never Shader followed by something. A mis-cased one (shader(…)) is not a block: DSH2240.

KeywordHeaderRequired attributesGeneratesReference
ShaderShader(Name = "…"[, Root = "…"])NameUMaterialShader
ShaderFunctionShaderFunction(Name = "…"[, Root = "…"])NameUMaterialFunctionShaderFunction
ShaderLayer (since 1.3.0)ShaderLayer(Name = "…"[, Root = "…"])NameUMaterialFunctionMaterialLayerShaderLayer
ShaderLayerBlend (since 1.3.0)ShaderLayerBlend(Name = "…"[, Root = "…"])NameUMaterialFunctionMaterialLayerBlendShaderLayer
MaterialLayer (deprecated in 1.3.0)MaterialLayer(Name = "…"[, Root = "…"])Nameas ShaderLayerShaderLayer
MaterialLayerBlend (deprecated in 1.3.0)MaterialLayerBlend(Name = "…"[, Root = "…"])Nameas ShaderLayerBlendShaderLayer
VirtualFunction (since 1.2.0)VirtualFunction(Name = "…"[, Asset = "…"])Name, and an asset from Asset = or Options.Assetnothing — declares an existing assetVirtualFunction
NamespaceNamespace(Name = "…")Namenothing — a scope for helpersNamespace
FunctionFunction [SelfContained | Inline] [<ret>] <Name>( … ) { <HLSL> }a name, at least one outputHLSL helperFunction
GraphFunction (since 1.3.1)GraphFunction [<ret>] <Name>( … ) { <HLSL> }a name, at least one outputHLSL helper with node inputsGraphFunction

Shader is limited to one per file (DSH2250), and a .dsh header holds no asset block at all (DSH2249), so an import cannot add a second one. Every other block may be repeated. Function and GraphFunction may also appear nested inside Namespace, where their names become <Namespace>::<Name>.

[!WARNING] MaterialLayer and MaterialLayerBlend are deprecated since 1.3.0 in favour of ShaderLayer and ShaderLayerBlend. They still read the same, with the warning DSH2251. Later diagnostics and generated metadata always report the modern spelling.

Section names

Matched case-insensitively. The = before the block is optional (since 1.5.0), as is the ; after it. Sections may appear in any order and may repeat: Properties, Inputs and Outputs append, Settings merges key by key, and a second Graph or Layout replaces the first, with the warning DSH2258 (since 2.0.0). A name a block does not take is DSH2245.

NameAccepted inMeaningReference
PropertiesShader, ShaderFunction, ShaderLayer, ShaderLayerBlendparameter, const and UE.* node declarationsProperties
PropertiesVirtualFunctionalias for Inputs — typed parameters, not parameter nodesVirtualFunction
InputsShaderFunction, ShaderLayer, ShaderLayerBlend, VirtualFunctiontyped input parametersInputs / Outputs
OutputsShaderFunction, ShaderLayer, ShaderLayerBlend, VirtualFunctiontyped output parametersInputs / Outputs
OutputsShaderoutput declarations and bindings — a different grammarOutput bindings
ResultsShaderFunction, ShaderLayer, ShaderLayerBlend, VirtualFunctionalias for OutputsInputs / Outputs
SettingsShadermaterial settings — special keys plus reflected UMaterial propertiesMaterial settings
SettingsShaderFunction, ShaderLayer, ShaderLayerBlendthe material-function keysFunction settings
SettingsVirtualFunctionalias for OptionsOptions
OptionsVirtualFunctionthe declared asset and other stored keysOptions
GraphShader, ShaderFunction, ShaderLayer, ShaderLayerBlendthe node-graph bodyGraph
Code—rejected everywhere; use GraphGraph
LayoutShader, ShaderFunction, ShaderLayer, ShaderLayerBlendNode / Comment placementLayout

Function and GraphFunction have no sections at all — their { … } is raw HLSL.

[!WARNING] Code = { … } is an error in every block that accepts sections: DSH2246, and in a VirtualFunction, together with Graph, DSH2247. Use Graph.

Declaration qualifiers

QualifierPositionEffectReference
const (since 1.2.6)before the type in a Properties declarationemits a constant node instead of a parameter; refused on most parameter-node tokens (DSH3253)Properties
opt (since 1.2.3)before the type in an Inputs declarationmarks the function input optional in Unreal; recognized when a type and a name follow itInputs / Outputs
inbefore a Function / GraphFunction parameter typeinput parameter; the default when a parameter has only two wordsFunction
outbefore a Function / GraphFunction parameter typeoutput parameter; at least one is required unless a return type is declared, and none may stand beside one (DSH6305, DSH6304)Function
SelfContainedafter Functionread and ignored: every Function node already embeds what its body calls, which is what it asked 1.x for; not accepted on GraphFunction (DSH6307)Function
Inlineafter Functionexact alias of SelfContained, with the warning DSH6306 (since 2.0.0)Function

in and out are the only accepted qualifiers on a function parameter, in any case; anything else is DSH6302.

Contextual keywords

Recognized only in the position listed, and case-insensitively except where the row says otherwise.

KeywordPositionMeaningReference
importtop level, between blocksdeclares the names of a .dsh header into this file (since 2.0.0; 1.x pasted the file in); lower case — another case reads the same, with the warning DSH2253import
Group("…") { … } (since 1.5.0)statement position inside Propertiesscopes a parameter group onto every declaration it contains; nests, composing with |Properties
Slider(min, max) (since 1.5.0)entry inside a [ … ] metadata blocksets a scalar parameter's UI rangeMetadata block
Path( … )default value of a texture or asset-valued declarationasset reference with a root spellingPath(...)
Base.start of an Outputs binding targetbinds to a material propertyOutput bindings
Expression( … )start of an Outputs binding targetbinds to a pin on a reflected node; Class="…" is mandatoryOutput bindings
.Pin[<index>]after an Expression( … ) targetselects the pin to bindOutput bindings
Node( … )statement inside Layoutpins a variable's node positionLayout
Comment( … )statement inside Layoutplaces a comment boxLayout
#Region / #EndRegionown line inside a Graph bodynames a region of the graph; nestsLayout
#if / #elif / #else / #endif (since 1.9.0)own line, anywhere except a Function / GraphFunction HLSL bodycuts the untaken branch out of the text before parsing; lowercase onlyPreprocessor
#ifdef / #ifndef (since 1.9.0)own line, same positionssugar for #if defined(NAME) and #if !defined(NAME)Preprocessor
#define / #undef (since 1.9.0)own line, same positionsdefines or removes a name, for that file only; a #define value runs to end of line and is plain textPreprocessor
defined (since 1.9.0)inside a #if / #elif expression1 when the name is defined, 0 otherwise; defined(X) and defined X both workPreprocessor
UE.type position in Properties, call position in Graphbuiltin material-node namespace; in a Graph call written exactly UE (since 2.0.0)UE.* catalogue
true / falsedefault values, Graph expressionsboolean literal; converts to 1.0 / 0.0 where a scalar is expectedTypes
default (since 1.2.3)call argument in Graphleaves that input unconnected, so the function's own default applies; lower case only (since 2.0.0)Calls

Reserved words

(since 2.0.0) One lexer reads every file, and its keywords are reserved in a 1.x file too, in lower case: uniform static const extern export in out inout struct if else for while do return break continue discard true false import. None of them can name a property, an output, an input or a Graph variable. Another case is an ordinary word: Const and IN are read as const and in where the 1.x grammar expects those, and True as true.

Reserved names

NameWhereRule
__returnFunction / GraphFunction parameter namesreserved, in any case; a parameter of that name is DSH6303
returneverywherea reserved word: it cannot name an output variable, and is no binding source (since 2.0.0)
DS_… (since 1.9.0)preprocessor define namesthe whole DS_ prefix is DreamShader's. #define or #undef of such a name fails with DSH1039; the other define tiers drop it with a warning. See Preprocessor

return inside a Function body is HLSL. A bare return; in a function that declares a return type is DSH6308.

Identifier rewrites

Identifiers rewritten inside Function and GraphFunction declarations before HLSL is emitted. Matching is case-insensitive and whole-identifier only; text inside strings and comments is left alone, and a ::-qualified name bypasses the table — it is flattened to <Namespace>_<Name>.

WrittenRewritten toApplies to
vec2float2parameter and return types, body text
vec3float3parameter and return types, body text
vec4float4parameter and return types, body text
ivec2int2parameter and return types, body text
ivec3int3parameter and return types, body text
ivec4int4parameter and return types, body text
uvec2uint2parameter and return types, body text
uvec3uint3parameter and return types, body text
uvec4uint4parameter and return types, body text
bvec2bool2parameter and return types, body text
bvec3bool3parameter and return types, body text
bvec4bool4parameter and return types, body text
mat2float2x2parameter and return types, body text
mat3float3x3parameter and return types, body text
mat4float4x4parameter and return types, body text
mixlerpbody text only
fractfracbody text only
modfmodbody text only

A token that matches nothing in this table is emitted unchanged. Type tokens in every section are read through the one type table on Types, which holds the same GLSL spellings.

Diagnostics

CodeRaised when
DSH2240text at top level that is not a block keyword or import — including a correctly spelled keyword in the wrong case
DSH22482.0 syntax at the top level of a .dsm / .dsf
DSH2242an asset block header with no Name attribute
DSH6309, DSH6311a Namespace / VirtualFunction with no name, or one that is not an identifier
DSH2250a second Shader in the file
DSH2245a section name the block does not accept
DSH2246, DSH2247a Code section; a Graph or Code section in a VirtualFunction
DSH6310anything but Function or GraphFunction inside a Namespace, including a nested Namespace
DSH2251warning: MaterialLayer / MaterialLayerBlend
DSH2253warning: import in another case
DSH2258warning: a second Graph or Layout section
DSH6302, DSH6303, DSH6304, DSH6305, DSH6306, DSH6307, DSH6308the Function / GraphFunction signature rules above

The complete list is in the diagnostics index.

Example

Every keyword class in one file.

Namespace(Name="Common")
{
    Function float Luma(in vec3 color) {
        return dot(color, vec3(0.2126, 0.7152, 0.0722));   // vec3 -> float3 on emission
    }
}

Shader(Name="Materials/M_Keywords")
{
    Properties {
        Group("Look") {
            const vec3      Ambient = vec3(0.02, 0.02, 0.03);
            ScalarParameter Rough   = 0.5 [Group="Surface"; Slider(0, 1)];
        }
        TextureSampleParameter2D BaseTex = Path(Game, "Textures/T_Noise");
    }

    Settings {
        Domain       = "Surface";
        ShadingModel = "Unlit";
        BlendMode    = "Opaque";
    }

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

    Graph {
        #Region "Sampling"
        vec2 UV  = UE.TexCoord(Index = 0);
        vec4 Tex = BaseTex(Coordinates = UV);
        #EndRegion

        Color = Tex.rgb * Common::Luma(Tex.rgb) + Ambient * Rough;
    }

    Layout {
        Comment(Name="Sampling", X=-1200, Y=-200, W=900, H=400);
        Node(Var="UV", X=-1100, Y=-120);
    }
}

See also

On this page