DreamShaderLang
语言参考

材质设置

Settings 中可用的材质域、混合模式、ShadingModel 和通用 Unreal 属性绑定。

Settings 会写入生成的 UMaterialUMaterialFunctionShader 的设置分为三类:DreamShader 特殊设置、通用 Unreal 材质属性、材质函数元数据。

特殊设置

这些设置由 DreamShader 显式解析:

Settings = {
    Domain = "Surface";
    BlendMode = "Opaque";
    ShadingModel = "DefaultLit";
}
设置别名说明
DomainMaterialDomain材质域。
BlendModeRenderType混合模式。
ShadingModelShading Model。

Material Domain

默认映射:

Unreal Domain
SurfaceSurface
DeferredDecal / DecalDeferred Decal
LightFunction / Light FunctionLight Function
VolumeVolume
PostProcess / Post ProcessPost Process
UI / UserInterface / User InterfaceUser Interface
RuntimeVirtualTexture / VirtualTextureRuntime Virtual Texture

空格、下划线和连字符会被规范化,所以 "Post Process""PostProcess""post-process" 这类写法都能解析到同一类键。

Blend Mode

默认映射:

Unreal Blend Mode
OpaqueOpaque
Masked / CutoutMasked
Translucent / TransparentTranslucent
AdditiveAdditive
ModulateModulate
AlphaComposite / PremultipliedAlpha / PremultipliedAlpha Composite
AlphaHoldoutAlpha 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;
}

常用属性:

设置类型说明
TwoSidedbool双面材质。
Wireframebool线框。
DitheredLODTransitionboolDither LOD。
DitherOpacityMaskboolDither Opacity Mask。
AllowNegativeEmissiveColorbool允许负 Emissive。
CastDynamicShadowAsMaskedbool按 Masked 投射动态阴影。
ResponsiveAAboolbEnableResponsiveAA 的别名。
ScreenSpaceReflectionsbool屏幕空间反射。
ContactShadowsbool接触阴影。
DisableDepthTestbool禁用深度测试。
OutputTranslucentVelocitybool输出半透明速度。
TangentSpaceNormalbool切线空间法线。
FullyRoughboolFully Rough。
IsSkyboolSky 材质。
ThinSurfaceboolbIsThinSurface 的别名。
HasPixelAnimationboolPixel Animation。
NumCustomizedUVsintCustomized UV 数量。
OpacityMaskClipValuenumberMask 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 后,旧资产上残留之前的值。

On this page