Skip to content

TypeDreamMoon/DreamShader

Repository files navigation

DreamShader banner

DreamShader

Text-first Unreal Engine material authoring with DreamShaderLang.

DreamShader turns .dsm, .dsf, and .dsh source files into Unreal UMaterial, UMaterialFunction, Material Layer, and Material Layer Blend assets.

Unreal Engine 5.7 Version 1.3.9 License MIT

中文文档 | Language Reference | Examples | Packages | VSCode | Changelog

Issues VSCode Extension Rider Plugin

QQ group: 466585194

DreamShader character

Tip

DreamShader is actively developed against Unreal Engine 5.7. Other Unreal versions have not been fully tested.

Keep all .dsm, .dsf, and .dsh source files in version control. The generated Unreal assets can always be rebuilt from source.

The decompiler is a migration helper. It handles many common materials and some large Lyra cases, but it is not intended to be a perfect round-trip system yet.

Overview

DreamShader workflow overview

Workflow Language Tooling
Generate UMaterial from Shader. Use Graph = { ... } as a node-oriented material DSL. Auto-compile on save in the Unreal Editor.
Generate UMaterialFunction from ShaderFunction. Write HLSL-style helpers with Function, GraphFunction, and Namespace. Open generated VSCode workspaces from the editor toolbar.
Generate native Material Layer and Layer Blend functions. Use typed Properties for scalars, vectors, textures, switches, MPC values, and reflected node settings. Export existing materials and material functions to starter .dsm and .dsf files.
Reference existing Unreal material functions with VirtualFunction. Pass Texture2D, Texture2DArray, VolumeTexture, and MaterialAttributes values through graph code. Use the VSCode extension or Rider plugin for highlighting, completion, navigation, diagnostics, and package tools.

Quick Start

  1. Copy this plugin into your Unreal project:

    MyProject/Plugins/DreamShader/
    
  2. Enable DreamShader in Unreal Editor and restart the editor.

  3. Create a source directory in the project root:

    MyProject/DShader/
    
  4. Add a material source file, for example:

    MyProject/DShader/Materials/M_Minimal.dsm
    
  5. Save the file. DreamShader parses the source and generates or updates the target Unreal asset.

Project settings are available under Project Settings > DreamPlugin > Dream Shader.

Recommended layout:

MyProject/
|- DShader/
|  |- Materials/
|  |  `- M_Sample.dsm
|  |- Shared/
|  |  `- Common.dsh
|  `- Packages/
`- Plugins/
   `- DreamShader/

Minimal Material

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

    Settings = {
        Domain = "UI";
        ShadingModel = "Unlit";
    }

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

    Graph = {
        Color = Tint;
    }
}

Root is optional and defaults to Game. To generate into a project content plugin, use Root="Plugin.MyPlugin":

Shader(Name="DreamMaterials/M_Minimal", Root="Plugin.MyPlugin")
{
    // ...
}

This produces /MyPlugin/DreamMaterials/M_Minimal.M_Minimal and saves the asset under [Project]/Plugins/MyPlugin/Content/DreamMaterials/M_Minimal.uasset.

Language Model

DreamShader language model

Item Purpose
.dsm Material implementation file. Usually contains Shader, ShaderFunction, ShaderLayer, ShaderLayerBlend, or VirtualFunction blocks.
.dsf Dream Shader Function file. Generates reusable ShaderFunction, ShaderLayer, and ShaderLayerBlend assets that can be imported by .dsm files.
.dsh Shared header file. Usually contains import, Function, GraphFunction, Namespace, and VirtualFunction declarations.
Shader Generates an Unreal UMaterial.
ShaderFunction Generates an Unreal UMaterialFunction.
ShaderLayer Generates a native UMaterialFunctionMaterialLayer.
ShaderLayerBlend Generates a native UMaterialFunctionMaterialLayerBlend.
VirtualFunction Describes an existing Unreal UMaterialFunction so it can be called from Graph.
Graph Node-oriented DSL used inside generated materials and functions.
Function Reusable HLSL-style helper.
GraphFunction Reusable Custom-node helper that can pull UE.* material nodes into generated Custom inputs.
Namespace Groups helpers, for example Texture::Sample2DRGB(...).
Path(...) Declares Unreal asset paths for textures, object settings, or virtual functions.

Properties

Properties can use compact types such as float, float3, Texture2D, Texture2DArray, and VolumeTexture, or explicit Unreal parameter node types. Reflected Unreal expression properties can be written in a trailing [...] block.

Properties = {
    ScalarParameter Roughness = 0.35 [
        Group="Surface";
        SortPriority=10;
        Description="Material roughness";
    ];

    VectorParameter Tint = float4(1.0, 0.9, 0.8, 1.0) [
        Group="Surface";
        SortPriority=20;
    ];

    StaticSwitchParameter UseDetail = true [
        Group="Switches";
        SortPriority=30;
    ];

    TextureSampleParameter2D Albedo = Path(Game, "Textures/T_Albedo") [
        Group="Textures";
        SamplerType="Color";
    ];
}

Material Parameter Collections can be read directly from graph code:

Graph = {
    float wind = UE.CollectionParam(
        Collection=Path(Game, "MaterialParameterCollections/MPC_Global"),
        Parameter="WindStrength");
}

Graph And Helpers

Graph = { ... } is the material-node DSL. Use it for variable declarations, assignments, constructors, UE.* material nodes, DreamShader helper calls, generated or virtual material function calls, and simple graph branches.

Graph = {
    float2 uv = UE.TexCoord(Index=0);
    float pulse = UE.Expression(Class="Sine", OutputType="float1", Input=UE.Time());
    Color = vec3(pulse, pulse, pulse);
}

Function is HLSL-style reusable code. It is better for calculations, loops, and logic that should live inside a Custom node.

Namespace(Name="Color")
{
    Function ApplyTint(in vec3 color, in vec3 tint, out vec3 result) {
        result = color * tint;
    }
}

Then import and call it:

import "Shared/Color.dsh";

Graph = {
    Color::ApplyTint(BaseColor, Tint, Color);
}

GraphFunction is also generated as a Custom node, but it can reference UE.* calls in the body. DreamShader creates those Unreal material nodes and wires their outputs into the Custom node as generated inputs.

Material Workflows

MaterialAttributes

MaterialAttributes can be used as a graph value, a function output, a virtual function output, and a material output binding. When a Shader binds to Base.MaterialAttributes, DreamShader automatically enables Unreal's Use Material Attributes option on the generated material.

Outputs = {
    MaterialAttributes Attrs;
    Base.MaterialAttributes = Attrs;
}

Graph = {
    Attrs.BaseColor = Color;
    Attrs.Roughness = Roughness;
}

Substrate

Substrate can be used as a graph value, a .dsf / ShaderFunction / VirtualFunction input or output, and a material output binding through Base.FrontMaterial. Binding Base.FrontMaterial sets the generated material to the Substrate shading model unless ShadingModel="Substrate" / "Strata" is already set.

Outputs = {
    Substrate Surface;
    Base.FrontMaterial = Surface;
}

Graph = {
    Surface = Substrate.Unlit(EmissiveColor=Color);
}

Use Substrate.* wrappers for UE 5.7 Substrate nodes such as Unlit, Slab, ConvertMaterialAttributes, VerticalLayer, Add, Weight, Select, and utility nodes like ThinFilm. Generic UE.Expression(..., OutputType="Substrate") is also supported for non-Custom material expressions.

Material Layers

ShaderLayer and ShaderLayerBlend generate native Unreal Material Layer function assets.

ShaderLayer(Name="Layers/L_SimpleSurface")
{
    Outputs = {
        MaterialAttributes Attrs;
    }

    Graph = {
        Attrs.BaseColor = vec3(0.8, 0.2, 0.1);
        Attrs.Roughness = 0.5;
    }
}

Current rules:

  • ShaderLayer creates UMaterialFunctionMaterialLayer.
  • ShaderLayerBlend creates UMaterialFunctionMaterialLayerBlend.
  • Both reuse the ShaderFunction sections: Properties, Inputs, Outputs, Settings, and Graph.
  • ShaderLayer may declare at most one input, and that input must be MaterialAttributes; use Properties for layer controls.
  • Both must declare exactly one MaterialAttributes output.
  • ShaderLayerBlend must declare exactly two inputs, both MaterialAttributes; use Properties for blend controls.
  • Legacy MaterialLayer(...) and MaterialLayerBlend(...) syntax still parses, but emits deprecation warnings.

This is native layer-function generation. Full Material Layer Stack and Layer Instance workflow support is still on the roadmap.

VirtualFunction

Use VirtualFunction to expose an existing Unreal UMaterialFunction to DreamShader without generating, saving, or overwriting that asset.

VirtualFunction(Name="BufferWriter")
{
    Options = {
        Asset = Path(Plugins.MoonToon, "MaterialFunctions/Buffer/Writer");
    }

    Inputs = {
        float3 Color;
        float Alpha;
    }

    Outputs = {
        float3 Result;
    }
}

Graph = {
    Result = BufferWriter(Tint, 1.0, Output="Result");
}

The Unreal Material Function asset context menu and editor toolbar include DreamShader actions for copying virtual function definitions, creating .dsh declarations, opening existing declarations, and copying call examples.

Editor Tools

DreamShader editor tools

Decompiler Export

Right-click a Material or Material Function in the Content Browser and choose DreamShader > Export DSM/DSF. Exported files are written to DShader/Decompiled/Materials or DShader/Decompiled/Functions and opened in your preferred text editor.

The exporter is intended as a migration starting point: common parameters, constants, arithmetic, swizzles, texture samples, Custom nodes, and MaterialFunctionCall nodes are emitted as DreamShader graph text. Less common reflected nodes fall back to UE.Expression(...) so the graph structure remains regeneratable.

Packages

DreamShader packages are reusable .dsh libraries installed under:

DShader/Packages/@scope/package-name/

Import example:

import "@typedreammoon/dream-noise/Library/Noise.dsh";

See Docs/Packages.md for package structure, lock files, install commands, and package authoring.

Editor Language Plugins

DreamShaderLang editor support is available for both VSCode and JetBrains Rider.

Editor Repository Main features
VSCode TypeDreamMoon/dreamshader-language-support Syntax highlighting, snippets, completion, Go to Definition, Find References, Hover, Signature Help, local diagnostics, Unreal bridge diagnostics, package commands, and quick templates.
Rider tsdaer/dreamshader-language-support .dsm / .dsf / .dsh file types, grammar and PSI parsing, highlighting, completion, navigation, diagnostics, Unreal Bridge integration, semantic tokens, inlay hints, and package tools.

The Unreal editor menu Tools > DreamShader and the DreamShader toolbar can open the generated DShader/DreamShader.code-workspace in VSCode.

Extension releases are available from dreamshader-language-support.

Configuration

Setting Default Description
SourceDirectory DShader Root directory for DreamShader source files.
GeneratedShaderDirectory Intermediate/DreamShader/GeneratedShaders Output directory for generated .ush helper files.
AutoCompileOnSave true Rebuild affected assets when .dsm, .dsf, or .dsh files are saved.
SaveDebounceSeconds 0.25 File-save debounce time.
VerboseLogs false Print more detailed logs.
OpenInNewWindow true Open the generated VSCode workspace in a new window by default.

Release

The repository includes a GitHub Actions release workflow. Push a tag that matches VersionName in DreamShader.uplugin:

git tag v1.3.9
git push origin v1.3.9

The release archive is named DreamShader-<Version>.zip and contains the plugin source, resources, documentation, README, CHANGELOG, and LICENSE. It excludes Binaries and Intermediate. The release workflow also attaches the latest VSCode extension assets from TypeDreamMoon/dreamshader-language-support.

Project Info

Item Value
Version 1.3.9
Language DreamShaderLang
Unreal Engine 5.7
Author TypeDreamMoon
GitHub https://github.com/TypeDreamMoon
Docs https://lang.64hz.cn/
Web https://dev.64hz.cn
License MIT
Copyright Copyright (c) 2026 TypeDreamMoon. All rights reserved.

Roadmap

  • Custom full-screen render pass support.
  • More complete VSCode semantic diagnostics.
  • Deeper Material Layer workflow support.
  • Deeper Moon Engine integration. Reference: https://zhuanlan.zhihu.com/p/21979494450

License

DreamShader is released under the MIT license.

For bug reports and feature requests, open an issue.

About

Unreal Engine Material DSL. Use Dream Shader Lang Write Unreal Material. Simple · Fast · Full syntax · HLSL GLSL Lang Support

Topics

Resources

License

Stars

Watchers

Forks

Contributors