DreamShaderLang
DreamShaderLang 2.0

Material instances

.dsi — a material instance as source. A parent, the properties it overrides and the parameters it sets, checked against the parent's real parameters.

A .dsi file is one UMaterialInstanceConstant: a parent, a few overridden properties, and the parameters it sets. It has no graph, so it has no functions, no #include and no #pragma material — only one pragma and uniform lines.

AspectValue
Producesone UMaterialInstanceConstant, named after the file, where a .dss of the same place would put its product
Checked againstthe parent's real parameters — names, types, static-ness
Sincesince 2.0.0
// MI_HeroSkin.dsi
#pragma instance(Parent = "M_Skin", BlendMode = Masked, TwoSided = true)

uniform float Roughness = 0.35;
uniform float3 Tint = float3(1.0, 0.82, 0.76);

/// @static
uniform bool UseDetail = true;

/// @default /Game/Characters/Hero/T_Hero_Skin_D
uniform Texture2D Albedo;

/// @name Base Color Boost
uniform float BaseColorBoost = 1.2;

The parent

Parent is either a bare name — a material, or another instance, built by a DreamShader source under the same source root — or an object path (/Game/Materials/M_Skin) to any material or instance, DreamShader's or not.

A parent that comes from a source is compiled first when its asset is missing or older than that source, so building an instance never sees a stale parameter list. Instances of instances work; a chain that loops is refused.

Overrides

An override is a uniform declared the way the parent declares that parameter, with the value it is set to.

Parent parameterOverride
scalaruniform float Gain = 2.0; — int and bool parameters are scalars too
vectoruniform float3 Tint = float3(0, 1, 0); — a float3 keeps the parent's alpha, a float4 sets all four
static switch/// @static + uniform bool UseDetail = false;
static component mask/// @static + uniform bool4 Mask = bool4(true, false, false, false);
texture/// @default <asset> + uniform Texture2D Albedo; — no initializer; /// @default None clears it
font, runtime virtual texture, sparse volume texture, texture / parameter collection/// @default <asset> + a uniform of that type
MistakeCode
a name the parent does not haveDSH7258 — DSH7264 when only the case differs, which the engine would silently ignore
another type than the parent'sDSH7259
a value the compiler cannot fold to a constantDSH7265
@group, @sort, @slider, @desc — they belong to the parentDSH7262, a warning
a parameter that exists only on a material layer or blendDSH7268

A parameter whose name is not an identifier is declared under any identifier with /// @name <real name>. An override deleted from the file is deleted from the asset on the next build: the instance is rebuilt from the file, not patched.

From the editor, and back

  • New Instance in the Material Content Browser writes a .dsi beside the parent's source.
  • dsc decompile /Game/Materials/MI_Steel_Worn writes a .dsi holding only what differs from the parent.
  • A generated instance that was edited by hand is an ordinary divergence; Adopt Into Source rewrites the .dsi value by value, so comments and order survive.

On this page