DreamShaderLang
HLSL / GLSL Background

GLSL Overview

GLSL syntax, vector types, and how they map to DreamShaderLang.

GLSL is common in shader examples online. DreamShaderLang accepts familiar GLSL-style vector aliases such as vec2, vec3, and vec4.

Basic Shape

float luma(vec3 color)
{
    return dot(color, vec3(0.2126, 0.7152, 0.0722));
}

Common Types

GLSLDreamShaderLang
floatfloat
intint
boolbool
vec2vec2 / float2
vec3vec3 / float3
vec4vec4 / float4

Constructors and Swizzle

vec3 color = vec3(1.0, 0.2, 0.1);
float r = color.r;
vec2 rg = color.rg;

DreamShaderLang supports these common shader-language patterns in Graph and helper code.

Common Functions

FunctionUse
dotDot product.
mix / lerpInterpolation, depending on available aliases.
clamp / saturateRange limiting.
sin, cosTrigonometry.
normalizeNormalize a vector.

Common Keywords

KeywordMeaning
returnReturn from a helper.
if, elseConditional flow.
for, whileLoop flow in helper code when supported.
in, out, inoutFunction parameter direction in shader languages.

Relation to DreamShaderLang

DreamShaderLang is not GLSL, but GLSL snippets are often easy to port into Function helpers. Keep Unreal node creation in Graph with UE.*, and keep reusable math in Function / GraphFunction.

On this page