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.
| Aspect | Value |
|---|---|
| Produces | one UMaterialInstanceConstant, named after the file, where a .dss of the same place would put its product |
| Checked against | the parent's real parameters — names, types, static-ness |
| Since | since 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 parameter | Override |
|---|---|
| scalar | uniform float Gain = 2.0; — int and bool parameters are scalars too |
| vector | uniform 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 |
| Mistake | Code |
|---|---|
| a name the parent does not have | DSH7258 — DSH7264 when only the case differs, which the engine would silently ignore |
| another type than the parent's | DSH7259 |
| a value the compiler cannot fold to a constant | DSH7265 |
@group, @sort, @slider, @desc — they belong to the parent | DSH7262, a warning |
| a parameter that exists only on a material layer or blend | DSH7268 |
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
.dsibeside the parent's source. dsc decompile /Game/Materials/MI_Steel_Wornwrites a.dsiholding only what differs from the parent.- A generated instance that was edited by hand is an ordinary
divergence; Adopt Into Source rewrites the
.dsivalue by value, so comments and order survive.
Substrate sugar
Operators and lerp over Substrate values, legacy parameters on a slab, run-time branches, values built member by member, and one source for Substrate and non-Substrate projects.
Migrating from 1.x
dsc migrate rewrites .dsm, .dsf and .dsh sources as .dss — and proves, before it writes anything, that no comment is lost and the same graph comes out.