DreamShaderLang
HLSL / GLSL Background

HLSL Overview

HLSL syntax, types, and keywords for DreamShaderLang users.

HLSL is the shader language used by Unreal's material Custom nodes. DreamShaderLang borrows some HLSL-style types and helper-function syntax, but Graph code still generates Unreal material nodes.

Basic Shape

float Luma(float3 color)
{
    return dot(color, float3(0.2126, 0.7152, 0.0722));
}

Common Types

HLSLDreamShaderLang equivalent
floatfloat
float2float2 / vec2
float3float3 / vec3
float4float4 / vec4
Texture2DTexture2D

Variables and Expressions

float3 tinted = color * tint;
float y = saturate(tinted.r);

DreamShaderLang Function bodies use familiar HLSL-style expressions for helper logic.

Control Flow

if (x > 0.5)
{
    return 1.0;
}
return 0.0;

Complex control flow is best placed in Function, not directly in Graph.

Common Builtins

FunctionUse
dotDot product.
lerpLinear interpolation.
saturateClamp to 0..1.
sin, cosTrigonometry.
normalizeNormalize a vector.

Common Keywords

KeywordMeaning
returnReturn a function value.
if, elseConditional flow.
for, whileLoop constructs in helper code when supported.
outOutput parameter.
inoutInput/output parameter.

Relation to DreamShaderLang

HLSL areaDreamShaderLang usage
Helper functionsFunction and GraphFunction bodies.
Vector mathGraph expressions and helpers.
Raw node graphUse Graph and UE.*, not plain HLSL.
Material settingsUse Settings, not HLSL code.

On this page