DreamShaderLang
HLSL / GLSL 背景

关键字速查

DreamShaderLang、HLSL 与 GLSL 常见关键字对照。

这一页是速查表。DreamShaderLang 自己的关键字较少,复杂计算主要借用 HLSL 风格 helper;GLSL 关键字主要用于迁移时对照。

DreamShaderLang

分类关键字 / 标识
顶层声明Shader, ShaderFunction, Function, Namespace, import
函数模式SelfContained, Inline
SectionProperties, Inputs, Outputs, Settings, Graph
参数限定in, out
Graph 控制流if, else
Unreal 节点入口UE.*, UE.Expression(...)
资产路径 helperPath(...)
输出绑定Base.*, Expression(...).Pin[n]

DreamShaderLang 常用类型

类型族类型
标量float, float1, half, half1, int, uint, bool
向量float2, float3, float4, half2, half3, half4
整数向量int2, int3, int4, uint2, uint3, uint4
布尔向量bool2, bool3, bool4
GLSL 别名vec2, vec3, vec4, ivec2, uvec2, bvec2
纹理Texture2D, TextureCube, Texture2DArray, SamplerState

HLSL 常见关键字

分类关键字
类型void, bool, int, uint, half, float, double
控制流if, else, for, while, do, switch, case, default
跳转return, break, continue, discard
参数in, out, inout
修饰const, static, uniform, groupshared
纹理Texture2D, TextureCube, SamplerState, SamplerComparisonState

GLSL 常见关键字

分类关键字
类型void, bool, int, uint, float, double, vec2, vec3, vec4, mat3, mat4
控制流if, else, for, while, do, switch, case, default
跳转return, break, continue, discard
参数in, out, inout
修饰const, uniform, layout, centroid, flat, smooth
精度lowp, mediump, highp

迁移提醒

从 GLSL 来在 DreamShaderLang / HLSL 中
vec3可以继续写 vec3,也可以写 float3
mix(a, b, t)lerp(a, b, t)
fract(x)frac(x)
texture(sampler, uv)使用 HLSL 风格纹理采样 helper。
main()不需要;用 ShaderGraph 描述材质。

On this page