DreamShaderLang
HLSL / GLSL Background

Keyword Cheatsheet

Every word the DreamShaderLang grammar treats specially, plus the HLSL and GLSL vocabularies side by side for readers porting code.

A lookup page. The DreamShaderLang tables are exhaustive: block keywords, section names, qualifiers, contextual keywords and reserved names are the complete set the grammar recognises. The HLSL and GLSL tables are reference material for readers arriving from those languages.

No keyword is reserved against identifiers. A property, output variable, parameter or function may be named Shader, Graph, Layout or float; the parser never rejects an identifier because it collides with a keyword. Keywords are recognised only where the grammar expects them.

The exceptions are not keywords at all — they are the math builtin and constructor names, which win name resolution in a Graph block and silently shadow a user declaration.

Top-level block keywords

Matched case-sensitively, and only when the next character is not a letter, a digit or _ — that boundary rule is what keeps ShaderFunction from matching as Shader.

KeywordHeaderRequiredGenerates
ShaderShader(Name = "…"[, Root = "…"])NameUMaterial
ShaderFunctionShaderFunction(Name = "…"[, Root = "…"])NameUMaterialFunction
ShaderLayer since 1.3.0ShaderLayer(Name = "…"[, Root = "…"])NameUMaterialFunctionMaterialLayer
ShaderLayerBlend since 1.3.0ShaderLayerBlend(Name = "…"[, Root = "…"])NameUMaterialFunctionMaterialLayerBlend
MaterialLayer (deprecated in 1.3.0)MaterialLayer(Name = "…")Nameas ShaderLayer
MaterialLayerBlend (deprecated in 1.3.0)MaterialLayerBlend(Name = "…")Nameas ShaderLayerBlend
VirtualFunction since 1.2.0VirtualFunction(Name = "…"[, Asset = "…"])Name, plus an asset from Asset = or Options.Assetnothing — declares an existing asset
NamespaceNamespace(Name = "…")Namenothing — a scope for helpers
FunctionFunction [SelfContained | Inline] [<ret>] <Name>( … ) { <HLSL> }a name, at least one outputan HLSL helper
GraphFunction since 1.3.1GraphFunction [<ret>] <Name>( … ) { <HLSL> }a name, at least one outputan HLSL helper with node inputs

Shader is limited to one per translation unit, across the whole import closure. Every other block may be repeated. Function and GraphFunction may also appear nested inside a Namespace, where their names become <Namespace>::<Name>.

Deprecated since 1.3.0

Use ShaderLayer instead.

MaterialLayer and MaterialLayerBlend still parse and generate the same assets, but each emits MaterialLayer is deprecated; use ShaderLayer instead. / MaterialLayerBlend is deprecated; use ShaderLayerBlend instead. Later diagnostics 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.

NameAccepted inMeaning
PropertiesShader, ShaderFunction, ShaderLayer, ShaderLayerBlendparameter, const and UE.* node declarations
PropertiesVirtualFunctionalias for Inputs — typed parameters, not parameter nodes
InputsShaderFunction, ShaderLayer, ShaderLayerBlend, VirtualFunctiontyped input parameters
OutputsShaderFunction, ShaderLayer, ShaderLayerBlend, VirtualFunctiontyped output parameters
OutputsShaderoutput declarations and bindings — a different grammar
ResultsShaderFunction, ShaderLayer, ShaderLayerBlend, VirtualFunctionalias for Outputs
SettingsShadermaterial settings — special keys plus reflected UMaterial properties
SettingsShaderFunction, ShaderLayer, ShaderLayerBlendthe four material-function keys
SettingsVirtualFunctionalias for Options
OptionsVirtualFunctionthe declared asset and other stored keys
GraphShader, ShaderFunction, ShaderLayer, ShaderLayerBlendthe node-graph body, stored verbatim
Coderejected everywhere; use Graph
LayoutShader, ShaderFunction, ShaderLayer, ShaderLayerBlendNode / Comment placement; a second Layout replaces the first

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

Declaration qualifiers

QualifierPositionEffect
const since 1.2.6before the type in a Properties declarationemits a constant node instead of a parameter; rejected on parameter-node and UE.* declarations
opt since 1.2.3before the type in an Inputs declarationmarks the function input optional in Unreal; must be followed by a literal space
inbefore a Function / GraphFunction parameter typeinput parameter; the default when a parameter has only two tokens
outbefore a Function / GraphFunction parameter typeoutput parameter; at least one is required unless a return type is declared
SelfContainedafter Functionemits the body self-contained inside each caller's Custom node; not accepted on GraphFunction
Inlineafter Functionexact alias of SelfContained

in and out are the only accepted qualifiers on a function parameter. inout does not exist and is rejected.

Contextual keywords

Recognised only in the position listed, always case-insensitively.

KeywordPositionMeaning
importfirst token of its own line, anywhere in a source fileinlines another source file
Group("…") { … } since 1.5.0statement position inside Propertiesscopes a parameter group onto every declaration it contains; nests, composing with |
Slider(min, max) since 1.5.0entry inside a [ … ] metadata blocksets a scalar parameter's UI range
Path( … )default value of a texture or asset-valued declarationasset reference with a root spelling
Base.start of an Outputs binding targetbinds to a material property
Expression( … )start of an Outputs binding targetbinds to a pin on a reflected node; Class="…" is mandatory
.Pin[<index>]after an Expression( … ) targetselects the pin to bind
Node( … )statement inside Layoutpins a variable's node position
Comment( … )statement inside Layoutplaces a comment box
#Region / #EndRegionown line inside a Graph bodynames a region of the graph; nests
UE.type position in Properties, call position in Graphbuiltin material-node namespace
Substrate.call position in GraphSubstrate BSDF namespace, since UE 5.4
true / falsedefault valuesboolean literal; converts to 1.0 / 0.0 where a scalar is expected
default since 1.2.3call argument in Graphuse the parameter's declared default

Reserved names

NameWhereRule
__returnFunction / GraphFunction parameter namesreserved for return-type lowering; a declared return type becomes an out parameter with this name
returnShader Outputs declarationsmay not be used as an output-variable name, and as a binding source it may only feed Base.* targets

return inside a Function body is a statement, not a reserved name: a top-level return <expr>; is rewritten to an assignment to __return.

Type tokens

The complete set is 44 tokens, matched case-insensitively in every context. Per-context validity is on Types and Values.

FamilyTokensCount
Scalar (1 component)float float1 half half1 int uint bool7
Vector (2 / 3 / 4 components)float2..4 half2..4 vec2..4 int2..4 uint2..4 bool2..4 ivec2..4 uvec2..4 bvec2..427
TextureTexture2D TextureCube Texture2DArray Texture3D VolumeTexture5
Opaque and otherSamplerState MaterialAttributes Substrate StaticBool StaticBoolParameter5

There are no matrix types: mat2 / mat3 / mat4 and float2x2 / float3x3 / float4x4 are rejected by every declaration position. Three tokens were removed and now fall through to the generic "unsupported type" diagnostic:

Removed tokenReplacement
Scalarfloat
Colorfloat4 / vec4
Vectorfloat2float4 / vec2vec4

A Properties declaration may additionally use one of 22 explicit *Parameter node tokens (ScalarParameter, TextureSampleParameter2D, ChannelMaskParameter, …). Those are catalogued on Property Types.

Identifier rewrites

Applied inside Function and GraphFunction declarations only, before HLSL is emitted. Matching is case-insensitive and whole-identifier; strings and comments are skipped, and a ::-qualified name bypasses the table.

WrittenRewritten toApplies to
vec2 vec3 vec4float2 float3 float4parameter and return types, body text
ivec2 ivec3 ivec4int2 int3 int4parameter and return types, body text
uvec2 uvec3 uvec4uint2 uint3 uint4parameter and return types, body text
bvec2 bvec3 bvec4bool2 bool3 bool4parameter and return types, body text
mat2 mat3 mat4float2x2 float3x3 float4x4parameter and return types, body text
mixlerpbody text only
fractfracbody text only
modfmodbody text only

HLSL keywords

Reference — HLSL's own vocabulary, valid inside a Function body.

CategoryKeywords
Typesvoid, bool, int, uint, half, float, double
Control flowif, else, for, while, do, switch, case, default
Jumpsreturn, break, continue, discard
Parametersin, out, inout
Modifiersconst, static, uniform, groupshared
TexturesTexture2D, TextureCube, SamplerState, SamplerComparisonState
Aggregatesstruct

GLSL keywords

Reference — nothing here is DreamShaderLang grammar, except the vec* / ivec* / uvec* / bvec* type aliases, which are first-class tokens.

CategoryKeywords
Typesvoid, bool, int, uint, float, double, vec2, vec3, vec4, mat2, mat3, mat4
Control flowif, else, for, while, do, switch, case, default
Jumpsreturn, break, continue, discard
Parametersin, out, inout
Modifiersconst, uniform, layout, centroid, flat, smooth, attribute, varying
Precisionlowp, mediump, highp

Migration reminders

Source habitIn DreamShaderLang
vec3keep it — vec3 is a real token; it becomes float3 only in generated HLSL
mix(a, b, t)works in both places: a real builtin in Graph, rewritten to lerp in a Function body
fract(x), mod(a, b)the same — real builtins since 1.5.0 in Graph, rewritten in a body
length(v)not a builtin — sqrt(dot(v, v)), UE.Expression(Class = …), or a Function body
main()not needed; a Shader block with Outputs bindings describes the material
uniforma Properties declaration
sampler2D + texture(s, uv)SampleTexture2D(tex, uv) for a texture object, or Tex(Coordinates = uv) for a TextureSampleParameter*
An HLSL Custom node bodya Function, or a GraphFunction when the body needs UE.* values
A visual material nodea specific UE.* builtin, or UE.Expression(Class = "…")
A shared include filea .dsh header plus import

Where to next

On this page