Keyword Cheatsheet
Every word DreamShaderLang's grammar treats specially — the 1.x blocks, sections, qualifiers and contextual keywords, the .dss declarations,
A lookup page. The DreamShaderLang tables are exhaustive: the 1.x block keywords, section names, qualifiers and
contextual keywords, the .dss declaration forms, #pragmas and /// tags, and the reserved words are the complete
sets the grammar recognises. The HLSL and GLSL tables are for reference when arriving from those languages.
Block keywords, 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 recognised only where the grammar expects
them. The exception is a small set of reserved words since 2.0.0. The names of math
builtins and constructors cannot name a function either — that is DSH6206 at the declaration (through 1.9.x it
silently shadowed).
.dss declaration forms
since 2.0.0 A .dss is HLSL with declarations: these are the only forms at file scope. The full grammar is on
DreamShaderLang 2.0.
| Form | Meaning |
|---|---|
uniform <Type> Name = <init>; | a material parameter. uniform bool is a dynamic scalar by default; /// @static makes it a static switch |
static const <Type> Name = <init>; | a compile-time constant |
<Type> Name(params) { … } | a file-local helper; no linkage keyword |
export <Type> Name(params) { … } | produces an asset: void (inout material) is a material, anything else a material function |
extern <Type> Name(params); | a prototype bound to an existing asset through /// @asset; no body |
struct Name { … }; | fields may carry their own /// block and array dimensions; no methods, no nesting |
#include "path" · import "path"; | the same thing; the path must be double-quoted |
#pragma material(Key = Value, …) | file-level material settings; a key set twice is DSH7200 |
#pragma layout(Node|Comment, Key = Value, …) | node coordinates and comment boxes, written by the decompiler |
#pragma region Name · #pragma endregion | the 2.0 spelling of the 1.x #Region comment box |
The other #pragma names are instance (.dsi) and pipeline (.dsp). Types particular to a .dss: material (a
material attribute set; the entry's parameter is inout material m), void, and user structs.
/// tags
The /// lines above a declaration are its doc block: @key value @key value … per line, keys case-insensitive.
| Tag | On | Meaning |
|---|---|---|
@group, @sort, @desc | a uniform | group, sort order and description on the parameter panel |
@slider min max | a scalar uniform | slider range; on a vector or a switch it is the warning DSH7233 |
@default /Game/… | a texture uniform | the default asset |
@sampler | a texture uniform | the sampler type |
@static | a uniform bool | a static switch |
@name | an export function, a @custom function | the asset name (or object path); the node title |
@asset | an extern prototype | the existing asset it binds to |
@library, @param | an exported material function | the library category; the description of an input |
@layer, @layerblend | an exported function | produces a material layer / layer blend function |
@custom | a function | the body is captured verbatim, one Custom node per call |
1.x top-level block keywords
Case-sensitive, matched as a whole word — ShaderFunction is its own word, never Shader followed by something. A
mis-cased one (shader(…)) is no block: DSH2240.
| Keyword | Header | Required | Generates |
|---|---|---|---|
Shader | Shader(Name = "…"[, Root = "…"]) | Name | UMaterial |
ShaderFunction | ShaderFunction(Name = "…"[, Root = "…"]) | Name | UMaterialFunction |
ShaderLayer since 1.3.0 | ShaderLayer(Name = "…"[, Root = "…"]) | Name | UMaterialFunctionMaterialLayer |
ShaderLayerBlend since 1.3.0 | ShaderLayerBlend(Name = "…"[, Root = "…"]) | Name | UMaterialFunctionMaterialLayerBlend |
MaterialLayer (deprecated in 1.3.0) | MaterialLayer(Name = "…"[, Root = "…"]) | Name | as ShaderLayer |
MaterialLayerBlend (deprecated in 1.3.0) | MaterialLayerBlend(Name = "…"[, Root = "…"]) | Name | as ShaderLayerBlend |
VirtualFunction since 1.2.0 | VirtualFunction(Name = "…"[, Asset = "…"]) | Name, and an asset from Asset = or Options.Asset | nothing — declares an existing asset |
Namespace | Namespace(Name = "…") | Name | nothing — a scope for helpers |
Function | Function [SelfContained | Inline] [<ret>] <Name>( … ) { <HLSL> } | a name, at least one output | an HLSL helper — one Custom node per call |
GraphFunction since 1.3.1 | GraphFunction [<ret>] <Name>( … ) { <HLSL> } | a name, at least one output | an HLSL helper with node inputs |
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 repeat. Function and GraphFunction may also appear nested
inside Namespace, where their names become <Namespace>::<Name>.
Deprecated since 1.3.0
Use ShaderLayer instead.
MaterialLayer and MaterialLayerBlend still parse and generate identical assets, with the warning DSH2251. Later
diagnostics and generated metadata report the modern spelling.
1.x section names
Case-insensitive. The = before the block is optional since 1.5.0, as is the ; after it. Sections may appear
in any order and repeat: Properties, Inputs and Outputs append, Settings merges key by key, and a second Graph
or Layout replaces the first with the warning DSH2258. A name the block does not take is DSH2245.
| Name | Accepted in | Meaning |
|---|---|---|
Properties | Shader, ShaderFunction, ShaderLayer, ShaderLayerBlend | parameter, const and UE.* node declarations |
Properties | VirtualFunction | alias for Inputs — typed parameters, not parameter nodes |
Inputs | ShaderFunction, ShaderLayer, ShaderLayerBlend, VirtualFunction | typed input parameters |
Outputs | ShaderFunction, ShaderLayer, ShaderLayerBlend, VirtualFunction | typed output parameters |
Outputs | Shader | output declarations and bindings — a different grammar |
Results | ShaderFunction, ShaderLayer, ShaderLayerBlend, VirtualFunction | alias for Outputs |
Settings | Shader | material settings — special keys plus reflected UMaterial properties |
Settings | ShaderFunction, ShaderLayer, ShaderLayerBlend | the material-function keys |
Settings | VirtualFunction | alias for Options |
Options | VirtualFunction | the declared asset and other stored keys |
Graph | Shader, ShaderFunction, ShaderLayer, ShaderLayerBlend | the node-graph body |
Code | — | rejected everywhere (DSH2246; in a VirtualFunction both Graph and Code are DSH2247); use Graph |
Layout | Shader, ShaderFunction, ShaderLayer, ShaderLayerBlend | Node / Comment placement |
Function and GraphFunction have no sections at all — their { … } is raw HLSL.
1.x declaration qualifiers
| Qualifier | Position | Effect |
|---|---|---|
const since 1.2.6 | before the type in a Properties declaration | emits a constant node instead of a parameter; refused on most parameter-node tokens (DSH3253) |
opt since 1.2.3 | before the type in an Inputs declaration | marks the function input optional in Unreal; recognised when a type and a name follow it |
in | before a Function / GraphFunction parameter type | input parameter; the default when a parameter has only two words |
out | before a Function / GraphFunction parameter type | output parameter; at least one is required unless a return type is declared, and none may stand beside one (DSH6305, DSH6304) |
SelfContained | after Function | read and ignored: every Function node already embeds what its body calls since 2.0.0; not accepted on GraphFunction (DSH6307) |
Inline | after Function | the old spelling of SelfContained, with the warning DSH6306 |
in and out are the only qualifiers accepted on a function parameter, in any case; anything else, inout included,
is DSH6302.
1.x contextual keywords
Recognised only in the position listed, and case-insensitively unless the row says otherwise.
| Keyword | Position | Meaning |
|---|---|---|
import | top level, between blocks | declares 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 DSH2253 |
Group("…") { … } since 1.5.0 | statement position inside Properties | scopes a parameter group onto every declaration inside; nests, composing with | |
Slider(min, max) since 1.5.0 | entry inside a [ … ] metadata block | sets a scalar parameter's UI range |
Path( … ) | default value of a texture or asset-valued declaration | asset reference with a root spelling |
Base. | start of an Outputs binding target | binds to a material property |
Expression( … ) | start of an Outputs binding target | binds to a pin on a reflected node; Class="…" is mandatory |
.Pin[<index>] | after an Expression( … ) target | selects the pin to bind |
Node( … ) | statement inside Layout | pins a variable's node position |
Comment( … ) | statement inside Layout | places a comment box |
#Region / #EndRegion | own line inside a Graph body | names a region of the graph; nests |
#if / #elif / #else / #endif since 1.9.0 | own line, anywhere except a Function / GraphFunction HLSL body | cuts the untaken branch out of the text before parsing; lowercase only |
#ifdef / #ifndef since 1.9.0 | own line, same positions | sugar for #if defined(NAME) and #if !defined(NAME) |
#define / #undef since 1.9.0 | own line, same positions | defines or removes a name, for that file only |
defined since 1.9.0 | inside a #if / #elif expression | 1 when the name is defined, 0 otherwise |
UE. | type position in Properties, call position in Graph | builtin material-node namespace; in a Graph call written exactly UE since 2.0.0 |
Substrate. | call position in Graph | the Substrate node namespace, since UE 5.4 |
true / false | default values, Graph expressions | boolean literal; converts to 1.0 / 0.0 where a scalar is expected |
default since 1.2.3 | call argument in Graph | leaves that input unconnected, so the function's own default applies; lower case only since 2.0.0 |
The preprocessor works in a .dss too; see Lexical rules ▸ Preprocessor.
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. See Lexical rules ▸ Reserved words.
Reserved names
| Name | Where | Rule |
|---|---|---|
__return | Function / GraphFunction parameter names | reserved in any case; a parameter of that name is DSH6303 |
return | everywhere | a reserved word: it cannot name an output variable, and is no binding source since 2.0.0 |
DS_… since 1.9.0 | preprocessor define names | the whole DS_ prefix is DreamShader's: #define or #undef of such a name is DSH1039, and the other define tiers drop it with a warning |
return inside a Function body is HLSL, kept as written since 2.0.0; a bare return; in a function that
declares a return type is DSH6308.
Type tokens
The complete set is 52 tokens. Per-context validity is on Types and Values.
| Family | Tokens | Count |
|---|---|---|
| Scalar (1 component) | float half double int uint bool, and each with a 1 suffix (float1 …) | 12 |
| Vector (2 / 3 / 4 components) | float2..4 half2..4 double2..4 int2..4 uint2..4 bool2..4 vec2..4 ivec2..4 uvec2..4 bvec2..4 | 30 |
| Texture | Texture2D TextureCube Texture2DArray Texture3D VolumeTexture | 5 |
| Opaque / other | SamplerState MaterialAttributes Substrate StaticBool StaticBoolParameter | 5 |
vec* / ivec* / uvec* / bvec* are types in a 1.x source only; a .dss writes the HLSL spelling, and adds
material, void and user structs. A graph has no matrix values: mat2 / mat3 / mat4 and float2x2 /
float3x3 / float4x4 are DSH3252 in Properties and DSH4361 where they would become a node or a pin. Three tokens
have been removed:
| Removed token | Replacement |
|---|---|
Scalar | float |
Color | float4 / vec4 |
Vector | float2 … float4 / vec2 … vec4 |
1.x Properties declarations can also use the explicit *Parameter node tokens (ScalarParameter,
TextureSampleParameter2D, ChannelMaskParameter, …), catalogued on Property types.
Identifier rewrites
Applied only inside 1.x Function and GraphFunction declarations, before HLSL is emitted. Matching is case-insensitive
and whole-identifier; strings and comments are skipped, and a ::-qualified name bypasses the table — it is flattened
to <Namespace>_<Name>. A .dss /// @custom body is not rewritten.
| Written | Rewritten to | Applies to |
|---|---|---|
vec2 vec3 vec4 | float2 float3 float4 | parameter and return types, body text |
ivec2 ivec3 ivec4 | int2 int3 int4 | parameter and return types, body text |
uvec2 uvec3 uvec4 | uint2 uint3 uint4 | parameter and return types, body text |
bvec2 bvec3 bvec4 | bool2 bool3 bool4 | parameter and return types, body text |
mat2 mat3 mat4 | float2x2 float3x3 float4x4 | parameter and return types, body text |
mix | lerp | body text only |
fract | frac | body text only |
mod | fmod | body text only |
HLSL keywords
For reference — HLSL's own vocabulary, valid inside a /// @custom or Function body; .dss graph code understands
most of it, see HLSL Overview.
| Category | Keywords |
|---|---|
| Types | void, bool, int, uint, half, float, double |
| Control flow | if, else, for, while, do, switch, case, default |
| Jumps | return, break, continue, discard |
| Parameters | in, out, inout |
| Modifiers | const, static, uniform, groupshared |
| Textures | Texture2D, TextureCube, SamplerState, SamplerComparisonState |
| Aggregates | struct |
GLSL keywords
For reference — nothing here is part of the DreamShaderLang grammar except the vec* / ivec* / uvec* / bvec* type
aliases of a 1.x source, which are first-class tokens.
| Category | Keywords |
|---|---|
| Types | void, bool, int, uint, float, double, vec2, vec3, vec4, mat2, mat3, mat4 |
| Control flow | if, else, for, while, do, switch, case, default |
| Jumps | return, break, continue, discard |
| Parameters | in, out, inout |
| Modifiers | const, uniform, layout, centroid, flat, smooth, attribute, varying |
| Precision | lowp, mediump, highp |
Migration reminders
| Habit | In DreamShaderLang |
|---|---|
vec3 | write float3 in a .dss; in 1.x vec3 is a real token, read as float3 |
mix(a, b, t), fract(x), mod(a, b) | write lerp, frac, fmod. In a 1.x Graph the GLSL spellings still compile, with the warning DSH5277; in a .dss they are the error DSH4250; in a 1.x Function body they are rewritten |
length(v), distance, exp, log | all builtins — spelled the same in both languages |
main() | a .dss entry, export void M(inout material m); in 1.x a Shader block with Outputs bindings |
uniform | in a .dss it is uniform, with /// tags; in 1.x a Properties declaration |
sampler2D + texture(s, uv) | .dss: Tex.Sample(uv); 1.x: SampleTexture2D(tex, uv) for a texture object, Tex(Coordinates = uv) for a TextureSampleParameter* |
HLSL Custom node bodies | a /// @custom function in a .dss; in 1.x a Function, or a GraphFunction when the body needs UE.* values |
| Visual material nodes | the specific UE.* builtin, or UE.Expression(Class = "…") |
| Shared include files | a .dsh header with #include (.dss) or import (1.x) |
Where to next
HLSL Overview
Where HLSL runs, and the shipped helper header.
GLSL Overview
Aliases, rewrites, and what has no equivalent.
DreamShaderLang 2.0
The .dss declarations, parameters and /// tags.
Top-level Blocks
Every 1.x block keyword in full.
Sections
The section grammar these names belong to.
Lexical Rules
Case sensitivity, reserved words and the preprocessor.
GLSL Overview
GLSL for DreamShaderLang authors — which GLSL spellings are first-class tokens in a 1.x source, which are rewritten inside Function bodies, which carry a warning, why a .dss takes HLSL only, and what has no equivalent at all.
ChangeLog
Where to track changes across the DreamShaderLang ecosystem — the Unreal plugin, the VSCode extension and this site.