语言参考
材质设置
Settings 中可用的材质域、混合模式、ShadingModel 和通用 Unreal 属性绑定。
Settings 会写入生成的 UMaterial 或 UMaterialFunction。Shader 的设置分为三类:DreamShader 特殊设置、通用 Unreal 材质属性、材质函数元数据。
特殊设置
这些设置由 DreamShader 显式解析:
Settings = {
Domain = "Surface";
BlendMode = "Opaque";
ShadingModel = "DefaultLit";
}| 设置 | 别名 | 说明 |
|---|---|---|
Domain | MaterialDomain | 材质域。 |
BlendMode | RenderType | 混合模式。 |
ShadingModel | 无 | Shading Model。 |
Material Domain
默认映射:
| 值 | Unreal Domain |
|---|---|
Surface | Surface |
DeferredDecal / Decal | Deferred Decal |
LightFunction / Light Function | Light Function |
Volume | Volume |
PostProcess / Post Process | Post Process |
UI / UserInterface / User Interface | User Interface |
RuntimeVirtualTexture / VirtualTexture | Runtime Virtual Texture |
空格、下划线和连字符会被规范化,所以 "Post Process"、"PostProcess"、"post-process" 这类写法都能解析到同一类键。
Blend Mode
默认映射:
| 值 | Unreal Blend Mode |
|---|---|
Opaque | Opaque |
Masked / Cutout | Masked |
Translucent / Transparent | Translucent |
Additive | Additive |
Modulate | Modulate |
AlphaComposite / PremultipliedAlpha / Premultiplied | Alpha Composite |
AlphaHoldout | Alpha Holdout |
Shading Model
默认映射:
| 值 |
|---|
Unlit |
DefaultLit / Default Lit / Lit |
Subsurface |
PreintegratedSkin / Preintegrated Skin |
ClearCoat / Clear Coat |
SubsurfaceProfile / Subsurface Profile |
TwoSidedFoliage / Two Sided Foliage |
Hair |
Cloth |
Eye |
SingleLayerWater / Single Layer Water |
ThinTranslucent / Thin Translucent |
Substrate / Strata |
通用材质属性
除了特殊设置外,DreamShader 会尝试通过反射写入 UMaterial 上的属性。
Settings = {
TwoSided = true;
Wireframe = false;
OpacityMaskClipValue = 0.3333;
DitheredLODTransition = true;
NumCustomizedUVs = 2;
}常用属性:
| 设置 | 类型 | 说明 |
|---|---|---|
TwoSided | bool | 双面材质。 |
Wireframe | bool | 线框。 |
DitheredLODTransition | bool | Dither LOD。 |
DitherOpacityMask | bool | Dither Opacity Mask。 |
AllowNegativeEmissiveColor | bool | 允许负 Emissive。 |
CastDynamicShadowAsMasked | bool | 按 Masked 投射动态阴影。 |
ResponsiveAA | bool | bEnableResponsiveAA 的别名。 |
ScreenSpaceReflections | bool | 屏幕空间反射。 |
ContactShadows | bool | 接触阴影。 |
DisableDepthTest | bool | 禁用深度测试。 |
OutputTranslucentVelocity | bool | 输出半透明速度。 |
TangentSpaceNormal | bool | 切线空间法线。 |
FullyRough | bool | Fully Rough。 |
IsSky | bool | Sky 材质。 |
ThinSurface | bool | bIsThinSurface 的别名。 |
HasPixelAnimation | bool | Pixel Animation。 |
NumCustomizedUVs | int | Customized UV 数量。 |
OpacityMaskClipValue | number | Mask Clip 值。 |
属性查找会兼容:
| 写法 | 说明 |
|---|---|
| 忽略大小写 | twosided 可以匹配 TwoSided。 |
| 忽略空格、下划线、连字符 | opacity-mask-clip-value 可匹配。 |
| 自动处理布尔前缀 | ResponsiveAA 可匹配 bEnableResponsiveAA。 |
| DisplayName | 能匹配 UPROPERTY display name。 |
嵌套设置
通用属性支持点路径和数组索引:
Settings = {
LightmassSettings.EmissiveBoost = 2.0;
}如果目标属性是固定数组,需要显式索引:
Settings = {
SomeArraySetting[0] = 1.0;
}材质函数设置
ShaderFunction 常见设置:
Settings = {
Description = "Tint helper";
ExposeToLibrary = true;
LibraryCategories = "DreamShader,Color";
}| 设置 | 说明 |
|---|---|
Description | 材质函数说明。 |
ExposeToLibrary | 是否暴露到材质函数库。 |
LibraryCategories | 逗号分隔的库分类。 |
默认重置
生成前 DreamShader 会把材质重置到一组稳定默认值,然后再应用 Settings。这能避免删除某个 setting 后,旧资产上残留之前的值。