DreamShaderLang
Plugin referenceC++ API

DreamShaderTypes.h

DreamShaderTypes.h

DreamShaderTypes.h

DreamShader » C++ API » DreamShaderTypes.h

The 1.x source data model. Through 1.9.x, FTextShaderParser::Parse filled these structs and the generator built assets from them. Since 2.0 nothing parses into them: a 1.x source is read by the legacy front end into the language module's AST (see the retired parser page). The header stays because the compiler's asset layer still speaks it — BuildDefinitionForIRProduct fills an FTextShaderDefinition (name, root, settings) from an IR product to resolve where an asset goes and how its material is configured — and because the VirtualFunction tools and dump-graph in the editor module still use a few of its structs and enums.

Defined in header DreamShaderTypes.h.

ModuleDreamShader (Runtime)
Include#include "DreamShaderTypes.h"
NamespaceUE::DreamShader
Contents13 structs, 5 enums, 1 inline function, 1 free function, 2 member functions
Reflectionnone — no USTRUCT, no UENUM, no UPROPERTY
Pulls inCoreMinimal.h only

[!NOTE] None of the structs carries DREAMSHADER_API. They are header-only aggregates with implicit special member functions, so no exported symbol is needed to construct, copy or destroy them across a module boundary. Only three things in this header are exported: FTextShaderDefinition::TryGetSetting, FTextShaderDefinition::GetSetting and NormalizeSettingKey.

Declaration index

namespace UE::DreamShader
{
    enum class ETextShaderPropertyType : uint8;
    enum class ETextShaderTextureType : uint8;
    enum class ETextShaderPropertySource : uint8;
    enum class ETextShaderMaterialFunctionKind : uint8;

    struct FTextShaderMetadata;
    struct FTextShaderPropertyDefinition;
    struct FTextShaderOutputBinding;             // nests enum class ETargetKind : uint8
    struct FTextShaderVariableDeclaration;
    struct FTextShaderGraphRegion;
    struct FTextShaderLayoutNode;
    struct FTextShaderLayoutComment;
    struct FTextShaderLayout;
    struct FTextShaderFunctionParameter;
    struct FTextShaderFunctionDefinition;
    struct FTextShaderMaterialFunctionDefinition;
    struct FTextShaderVirtualFunctionDefinition;
    struct FTextShaderDefinition;

    inline const TCHAR* LexToString(ETextShaderMaterialFunctionKind Kind);

    DREAMSHADER_API FString NormalizeSettingKey(const FString& InKey);
}

Enumerations

ETextShaderPropertyType

enum class ETextShaderPropertyType : uint8
{
    Scalar,
    Vector,
    Texture2D,
};
EnumeratorValueMeaning
Scalar0Scalar-valued property — the float / int / bool families
Vector1Vector-valued property — the float2 / float3 / float4 family
Texture2D2Texture-valued property of any dimension; the dimension is carried separately in ETextShaderTextureType

The Texture2D enumerator name is a historical spelling. A TextureCube or VolumeTexture property also has Type == Texture2D.

ETextShaderTextureType

enum class ETextShaderTextureType : uint8
{
    Texture2D,
    TextureCube,
    Texture2DArray,
    VolumeTexture,
};
EnumeratorValue
Texture2D0
TextureCube1
Texture2DArray2
VolumeTexture3

ETextShaderPropertySource

enum class ETextShaderPropertySource : uint8
{
    Parameter,
    UEBuiltin,
};
EnumeratorValueMeaning
Parameter0The property becomes a material parameter node
UEBuiltin1The property is a UE.* builtin call bound to a name

FTextShaderOutputBinding::ETargetKind

enum class ETargetKind : uint8
{
    MaterialProperty,
    ExpressionInput,
};
EnumeratorValueMeaning
MaterialProperty0The binding target is a material property, e.g. Base.BaseColor
ExpressionInput1The binding target is an input pin on a named expression, e.g. Expression(Class="…").Pin[0]

ETextShaderMaterialFunctionKind

enum class ETextShaderMaterialFunctionKind : uint8
{
    ShaderFunction,
    MaterialLayer,
    MaterialLayerBlend,
};

inline const TCHAR* LexToString(const ETextShaderMaterialFunctionKind Kind);
EnumeratorValueLexToString resultGenerates
ShaderFunction0"ShaderFunction"UMaterialFunction
MaterialLayer1"ShaderLayer"UMaterialFunctionMaterialLayer
MaterialLayerBlend2"ShaderLayerBlend"UMaterialFunctionMaterialLayerBlend

[!NOTE] The enumerator names still use the pre-1.3.0 MaterialLayer* spelling, but LexToString prints the current ShaderLayer* spelling. Generated messages therefore say ShaderLayer, never MaterialLayer, even for a source file that used the deprecated keyword. The default: label shares the ShaderFunction case, so an out-of-range value also prints "ShaderFunction".

Structures

[!NOTE] The Meaning columns below say what the 1.x parser stored in each member and how the 1.x generator read it. Since 2.0.0 no parse fills these structs; the few users left are named in the introduction and under Notes. The parse-time checks, warnings and source mapping mentioned here belonged to the retired parser: a 1.x source is now diagnosed by the legacy front end, with DSHnnnn codes that carry the line and column of the construct.

FTextShaderMetadata

Declaration metadata attached to a property or a function parameter.

struct FTextShaderMetadata
{
    FString Group;
    bool bHasSortPriority = false;
    int32 SortPriority = 32;
    FString Description;
    TMap<FString, FString> ReflectedProperties;
};
MemberTypeDefaultMeaning
GroupFString""Parameter group. Inherited from an enclosing Properties Group("…") scope when the declaration does not set it explicitly.
bHasSortPriorityboolfalseWhether SortPriority is meaningful. Set to true by an explicit SortPriority / Sort key, and also by the auto-numbering applied to declarations inside a Group("…") scope. A top-level (ungrouped) declaration that omits the key keeps false.
SortPriorityint3232Sort order within the group.
DescriptionFString""Tooltip / description text.
ReflectedPropertiesTMap<FString, FString>emptyArbitrary reflected UPROPERTY name → literal-text pairs from the [ … ] block. Keys are normalized with NormalizeSettingKey, i.e. trimmed and lower-cased.

Keys the 1.x parser consumed itself, rather than putting them in ReflectedProperties: Group / Category, Description, SortPriority / Sort, and the SliderMin / SliderMax pair produced by Slider(min, max). See Metadata block.

FTextShaderPropertyDefinition

One entry of a Properties section.

struct FTextShaderPropertyDefinition
{
    FString Name;
    ETextShaderPropertySource Source = ETextShaderPropertySource::Parameter;
    FString ParameterNodeType;
    FString UEBuiltinFunctionName;
    TMap<FString, FString> UEBuiltinArguments;
    ETextShaderPropertyType Type = ETextShaderPropertyType::Scalar;
    ETextShaderTextureType TextureType = ETextShaderTextureType::Texture2D;
    bool bHasExplicitTextureType = false;
    int32 ComponentCount = 1;
    bool bConst = false;
    bool bHasDefaultValue = false;
    double ScalarDefaultValue = 0.0;
    FLinearColor VectorDefaultValue = FLinearColor::White;
    FString TextureDefaultObjectPath;
    FTextShaderMetadata Metadata;
};
MemberTypeDefaultMeaning
NameFString""Property / parameter name as written.
SourceETextShaderPropertySourceParameterParameter node vs. UE.* builtin.
ParameterNodeTypeFString""The explicit Unreal expression-class token when the declaration names one, e.g. ScalarParameter, TextureSampleParameter2D. Empty for a compact type token.
UEBuiltinFunctionNameFString""Builtin name when Source == UEBuiltin.
UEBuiltinArgumentsTMap<FString, FString>emptyNamed arguments for that builtin, as raw text.
TypeETextShaderPropertyTypeScalarScalar / vector / texture family.
TextureTypeETextShaderTextureTypeTexture2DTexture dimension. Meaningful only alongside bHasExplicitTextureType.
bHasExplicitTextureTypeboolfalsetrue only when the declared token names the dimension — Texture2D, TextureCube, Texture2DArray, VolumeTexture, or a TextureSampleParameter* variant.
ComponentCountint3211–4 for scalar and vector properties.
bConstboolfalseDeclared const — a constant node, not a parameter.
bHasDefaultValueboolfalseWhether the declaration carried = <value>.
ScalarDefaultValuedouble0.0Default for a scalar property.
VectorDefaultValueFLinearColorFLinearColor::WhiteDefault for a vector property.
TextureDefaultObjectPathFString""Resolved object path from Path(...).
MetadataFTextShaderMetadatadefault-constructedThe [ … ] block.

Tokens such as TextureObjectParameter map to a single Unreal node class that can hold any texture dimension. For those, bHasExplicitTextureType stayed false, TextureType stayed at its Texture2D default, and the 1.x generator inferred the real dimension from the assigned default asset rather than rejecting it. Since 2.0.0 the 1.x check of the class written in a texture default against its property is made on the source before binding: DSH1043 for a class that is not a texture, DSH1044 for a texture class of another dimension.

FTextShaderOutputBinding

One <target> = <variable>; statement inside an Outputs section.

struct FTextShaderOutputBinding
{
    enum class ETargetKind : uint8 { MaterialProperty, ExpressionInput };

    ETargetKind TargetKind = ETargetKind::MaterialProperty;
    FString MaterialProperty;
    FString ExpressionClass;
    TMap<FString, FString> ExpressionArguments;
    int32 ExpressionPinIndex = INDEX_NONE;
    FString TargetText;
    FString SourceText;
};
MemberTypeDefaultMeaning
TargetKindETargetKindMaterialPropertyWhich of the two target forms was written.
MaterialPropertyFString""The material property name, e.g. Base.BaseColor. Used when TargetKind == MaterialProperty.
ExpressionClassFString""Target expression class when TargetKind == ExpressionInput.
ExpressionArgumentsTMap<FString, FString>emptyConstructor arguments for that expression, as raw text.
ExpressionPinIndexint32INDEX_NONETarget input-pin index. 1.x rejected a negative or unparseable one at parse time.
TargetTextFString""Raw left-hand-side source text, which 1.x reproduced verbatim in diagnostics.
SourceTextFString""Raw right-hand-side source text — the expression the 1.x generator evaluated.

FTextShaderVariableDeclaration

An output-variable declaration in an Outputs section.

struct FTextShaderVariableDeclaration
{
    FString Type;
    FString Name;
    bool bHasDefaultValue = false;
    FString DefaultValueText;
};
MemberTypeDefaultMeaning
TypeFString""Type token, already run through the GLSL-alias normalization — vec3 arrives as float3.
NameFString""Variable name.
bHasDefaultValueboolfalseWhether the declaration carried an initializer. A Shader with at least one initialized output declaration may omit its Graph block.
DefaultValueTextFString""The initializer expression, as raw text.

FTextShaderGraphRegion

A #Region / #EndRegion span inside a Graph block.

struct FTextShaderGraphRegion
{
    FString Name;
    int32 StartLine = 1;
    int32 EndLine = MAX_int32;
};
MemberTypeDefaultMeaning
NameFString""Region label; becomes the comment-box title.
StartLineint3211-based, inclusive.
EndLineint32MAX_int321-based. An unterminated region therefore extends to the end of the graph.

FTextShaderLayoutNode

One Node(Var=…, X=…, Y=…) directive.

struct FTextShaderLayoutNode
{
    FString Var;
    int32 X = 0;
    int32 Y = 0;
};
MemberTypeDefaultMeaning
VarFString""The graph variable whose node is pinned.
Xint320Editor X coordinate.
Yint320Editor Y coordinate.

FTextShaderLayoutComment

One Comment(Name=…, X=…, Y=…, W=…, H=…) directive.

struct FTextShaderLayoutComment
{
    FString Name;
    int32 X = 0;
    int32 Y = 0;
    int32 W = 420;
    int32 H = 240;
    FLinearColor Color = FLinearColor(0.10f, 0.16f, 0.22f, 0.35f);
};
MemberTypeDefaultMeaning
NameFString""Comment-box text.
Xint320Editor X coordinate.
Yint320Editor Y coordinate.
Wint32420Box width.
Hint32240Box height.
ColorFLinearColor(0.10, 0.16, 0.22, 0.35)Box tint.

FTextShaderLayout

The whole Layout section.

struct FTextShaderLayout
{
    TArray<FTextShaderLayoutNode> Nodes;
    TArray<FTextShaderLayoutComment> Comments;
};
MemberTypeMeaning
NodesTArray<FTextShaderLayoutNode>Pinned node positions, in declaration order.
CommentsTArray<FTextShaderLayoutComment>Comment boxes, in declaration order.

A layout with neither nodes nor comments is treated as "no layout" and automatic placement runs instead. See Graph layout.

FTextShaderFunctionParameter

One entry of an Inputs, Outputs or Results section.

struct FTextShaderFunctionParameter
{
    FString Type;
    FString Name;
    bool bOptional = false;
    bool bHasDefaultValue = false;
    FString DefaultValueText;
    FTextShaderMetadata Metadata;
};
MemberTypeDefaultMeaning
TypeFString""Type token, GLSL aliases already rewritten.
NameFString""Parameter name. For a return-type-lowered Function, the synthetic result parameter is named __return.
bOptionalboolfalseDeclared opt.
bHasDefaultValueboolfalseWhether a preview/default value was given.
DefaultValueTextFString""That value, as raw text.
MetadataFTextShaderMetadatadefault-constructedThe [ … ] block.

FTextShaderFunctionDefinition

A Function or GraphFunction block — an HLSL helper, not an asset.

struct FTextShaderFunctionDefinition
{
    FString Name;
    bool bSelfContained = false;
    TArray<FTextShaderFunctionParameter> Inputs;
    TArray<FTextShaderFunctionParameter> Results;
    FString HLSL;
    TArray<FString> IncludePaths;
};
MemberTypeDefaultMeaning
NameFString""Function name. Qualified as Namespace::Function when declared inside a Namespace block.
bSelfContainedboolfalseSet by the SelfContained or Inline modifier keyword.
InputsTArray<FTextShaderFunctionParameter>emptyin parameters — including the ones whose qualifier was implicit.
ResultsTArray<FTextShaderFunctionParameter>emptyout parameters, plus the synthetic __return parameter when the declaration carried a return type.
HLSLFString""The normalized body text.
IncludePathsTArray<FString>emptyThe #include lines at the very top of the body, stripped from HLSL: hoisted to the top of the generated .ush for a plain Function, onto the Custom node's include list for an embedded body. Virtual shader paths, quotes removed.

FTextShaderMaterialFunctionDefinition

A ShaderFunction, ShaderLayer or ShaderLayerBlend block — each generates one asset.

struct FTextShaderMaterialFunctionDefinition
{
    FString Name;
    FString Root;
    ETextShaderMaterialFunctionKind Kind = ETextShaderMaterialFunctionKind::ShaderFunction;
    TArray<FTextShaderPropertyDefinition> Properties;
    TArray<FTextShaderFunctionParameter> Inputs;
    TArray<FTextShaderFunctionParameter> Outputs;
    TMap<FString, FString> Settings;
    FString Code;
    int32 CodeStartIndex = INDEX_NONE;
    TArray<FTextShaderGraphRegion> GraphRegions;
    FTextShaderLayout Layout;
    FString HLSL;
};
MemberTypeDefaultMeaning
NameFString""Asset path from the Name= attribute.
RootFString""Package root from the Root= attribute.
KindETextShaderMaterialFunctionKindShaderFunctionWhich of the three keywords was used.
PropertiesTArray<FTextShaderPropertyDefinition>emptyFunction-local property nodes.
InputsTArray<FTextShaderFunctionParameter>emptyThe Inputs section.
OutputsTArray<FTextShaderFunctionParameter>emptyThe Outputs section.
SettingsTMap<FString, FString>emptyThe Settings section. Keys are lower-cased by NormalizeSettingKey.
CodeFString""The Graph block body.
CodeStartIndexint32INDEX_NONECharacter offset of that body in the prepared source, from which 1.x worked out the line of a graph diagnostic. Nothing reads it since 2.0.0.
GraphRegionsTArray<FTextShaderGraphRegion>empty#Region spans.
LayoutFTextShaderLayoutdefault-constructedThe Layout section.
HLSLFString""Never populated by the 1.x parser.

FTextShaderVirtualFunctionDefinition

A VirtualFunction block — a declaration of an existing UMaterialFunction; generates nothing.

struct FTextShaderVirtualFunctionDefinition
{
    FString Name;
    FString Asset;
    TArray<FTextShaderFunctionParameter> Inputs;
    TArray<FTextShaderFunctionParameter> Outputs;
    TMap<FString, FString> Options;
};
MemberTypeDefaultMeaning
NameFString""The name callable from Graph. Required; without one the legacy front end reports DSH6311.
AssetFString""Resolved object path of the target UMaterialFunction. Required, from the Asset= attribute or Options.Asset; without one, DSH6312.
InputsTArray<FTextShaderFunctionParameter>emptyDeclared inputs. Properties is accepted as a synonym for this section.
OutputsTArray<FTextShaderFunctionParameter>emptyDeclared outputs. Must be non-empty; otherwise DSH6313.
OptionsTMap<FString, FString>emptyThe Options section. Keys are lower-cased by NormalizeSettingKey.

FTextShaderDefinition

The root of the parse result: one whole translation unit.

struct FTextShaderDefinition
{
    FString Name;
    FString Root;
    TArray<FTextShaderPropertyDefinition> Properties;
    TMap<FString, FString> Settings;
    TArray<FTextShaderVariableDeclaration> OutputDeclarations;
    TArray<FTextShaderOutputBinding> Outputs;
    FString Code;
    int32 CodeStartIndex = INDEX_NONE;
    TArray<FTextShaderGraphRegion> GraphRegions;
    FTextShaderLayout Layout;
    FString HLSL;
    TArray<FTextShaderFunctionDefinition> Functions;
    TArray<FTextShaderFunctionDefinition> GraphFunctions;
    TArray<FTextShaderMaterialFunctionDefinition> MaterialFunctions;
    TArray<FTextShaderVirtualFunctionDefinition> VirtualFunctions;
    TArray<FString> Warnings;

    DREAMSHADER_API bool TryGetSetting(const TCHAR* Key, FString& OutValue) const;
    DREAMSHADER_API FString GetSetting(const TCHAR* Key, const TCHAR* DefaultValue = TEXT("")) const;
};
MemberTypeDefaultMeaning
NameFString""The top-level Shader(Name="…"). Empty means the unit declares no material — the usual test for "is there a Shader here".
RootFString""Shader(Root="…").
PropertiesTArray<FTextShaderPropertyDefinition>emptyThe Shader's Properties section.
SettingsTMap<FString, FString>emptyThe Shader's Settings section. Keys are lower-cased.
OutputDeclarationsTArray<FTextShaderVariableDeclaration>emptyOutput-variable declarations.
OutputsTArray<FTextShaderOutputBinding>emptyOutput bindings. In 1.x an empty array produced a parse warning and a generation error; since 2.0.0 a Shader with no Outputs section is warning DSH2256.
CodeFString""The Graph block body.
CodeStartIndexint32INDEX_NONECharacter offset of that body in the prepared source, from which 1.x worked out the line of a graph diagnostic. Nothing reads it since 2.0.0.
GraphRegionsTArray<FTextShaderGraphRegion>empty#Region spans.
LayoutFTextShaderLayoutdefault-constructedThe Layout section.
HLSLFString""Never populated by the 1.x parser.
FunctionsTArray<FTextShaderFunctionDefinition>emptyFunction blocks.
GraphFunctionsTArray<FTextShaderFunctionDefinition>emptyGraphFunction blocks.
MaterialFunctionsTArray<FTextShaderMaterialFunctionDefinition>emptyShaderFunction / ShaderLayer / ShaderLayerBlend blocks, in declaration order.
VirtualFunctionsTArray<FTextShaderVirtualFunctionDefinition>emptyVirtualFunction blocks.
WarningsTArray<FString>emptyNon-fatal diagnostics the 1.x parse collected; they never made Parse return false. Never filled since 2.0.0.

TryGetSetting

bool TryGetSetting(const TCHAR* Key, FString& OutValue) const;
Parameter KeySetting key in any casing, with or without surrounding whitespace
Parameter OutValueReceives the stored value on a hit; left untouched on a miss
Returnstrue if Settings contains NormalizeSettingKey(Key)
Constnessconst, pure, any thread

GetSetting

FString GetSetting(const TCHAR* Key, const TCHAR* DefaultValue = TEXT("")) const;
Parameter KeyAs above
Parameter DefaultValueReturned on a miss. Defaults to the empty string
ReturnsThe stored value, or DefaultValue
Constnessconst, pure, any thread

Because both the stored keys and the query pass through NormalizeSettingKey, lookup is case-insensitive and whitespace-trimmed. It is not insensitive to interior spaces, underscores or hyphens: Two Sided and TwoSided remain distinct keys.

NormalizeSettingKey

DREAMSHADER_API FString NormalizeSettingKey(const FString& InKey);

Trims leading and trailing whitespace, then lower-cases. That is the whole operation.

InputResult
" ShadingModel ""shadingmodel"
"TWOSIDED""twosided"
"Two Sided""two sided"
"Two_Sided""two_sided"

[!WARNING] NormalizeSettingKey and UDreamShaderSettings::NormalizeMappingKey are not interchangeable. The latter additionally strips every space, _ and -, and applies to setting values (enum aliases), not keys. Using the wrong one turns Two Sided Foliage into a lookup miss. The four normalizing helpers are compared side by side in DreamShaderModule.h.

Every TMap<FString, FString> in this header that holds settings or options — FTextShaderDefinition::Settings, FTextShaderMaterialFunctionDefinition::Settings, FTextShaderVirtualFunctionDefinition::Options and FTextShaderMetadata::ReflectedProperties — has its keys normalized this way before storage. Read those maps directly only through a normalized key.

Notes

  • Most members are vestigial in 2.0. The compiler fills Name, Root and Settings of an FTextShaderDefinition (and the kind, name, root and settings of an FTextShaderMaterialFunctionDefinition) and nothing else: properties, outputs, graph code and layout travel as IR. Do not expect a definition obtained from the compiler to describe the source. Outside a definition, the Classic graph layout fills an FTextShaderLayout from the IR's layout hints, and the VirtualFunction tools fill FTextShaderVirtualFunctionDefinition / FTextShaderFunctionParameter from a declaration they parse with the legacy front end.
  • The structs have no reflection, no Serialize, and no operator==. They are not network-replicated, not saveable, and not comparable without writing a comparison yourself.
  • The 1.x parser normalized type tokens before anything landed in a Type field: vec3 became float3, mat4 became float4x4, and so on. Since 2.0.0 a GLSL spelling in 1.x text is read as its HLSL type with DSH5277. See Types.
  • Container order was source order, and 1.x generated MaterialFunctions front to back. Since 2.0.0 the assets of one file are built in call order — a function another one calls is built first — and functions that call each other in a cycle are DSH8299.
  • Every struct is copyable and movable with the compiler-generated operations. Copies are deep — the members are FString, TArray and TMap values, not pointers.

Example

Reading a definition:

#include "DreamShaderTypes.h"

using namespace UE::DreamShader;

void Describe(const FTextShaderDefinition& Definition)
{
    if (!Definition.Name.IsEmpty())
    {
        // Case-insensitive; "backend", "Backend" and " BACKEND " all hit.
        const FString Backend = Definition.GetSetting(TEXT("Backend"), TEXT("<project default>"));

        UE_LOG(LogDreamShader, Display, TEXT("Shader '%s' (Root='%s', Backend=%s): %d propert(ies), %d binding(s)"),
            *Definition.Name,
            *Definition.Root,
            *Backend,
            Definition.Properties.Num(),
            Definition.Outputs.Num());
    }

    for (const FTextShaderMaterialFunctionDefinition& Function : Definition.MaterialFunctions)
    {
        UE_LOG(LogDreamShader, Display, TEXT("  %s '%s'"), LexToString(Function.Kind), *Function.Name);
    }

    for (const FString& Warning : Definition.Warnings)
    {
        UE_LOG(LogDreamShader, Warning, TEXT("  %s"), *Warning);
    }
}

For the source in Generation, as the 1.x parser filled the definition, this printed:

LogDreamShader: Shader 'Materials/M_Emissive' (Root='', Backend=<project default>): 1 propert(ies), 1 binding(s)
LogDreamShader:   ShaderFunction 'Functions/F_Tint'

A definition the 2.0 compiler builds carries only Name, Root and Settings — and Settings never holds Backend, which the binder takes out onto the IR product — so it prints Backend=<project default>, both counts are 0 and nothing else is listed.

See also

On this page