DreamShaderLang
Plugin referenceDreamShaderLang

Options

Options

Options

DreamShader » DreamShaderLang » Options

The section of a VirtualFunction block that names the existing UMaterialFunction asset the declaration stands for.

Declared in.dsh, .dsf, .dsm — inside a VirtualFunction block only
Kindsection
Generatesnothing — a VirtualFunction declares an asset, it does not create one
Since1.2.0

In 2.0 the same declaration is an extern prototype with /// @asset — see DreamShaderLang 2.0; dsc migrate rewrites a VirtualFunction that way.

Synopsis

{ Options | Settings } [=]
{
    Asset = <asset-reference> ;
    [ <key> = <value> ; ]…
}
asset-reference := Path( <root> , "<relative-path>" )
                 | Path( "<absolute-object-path>" )
                 | "<absolute-object-path>"
                 | <absolute-object-path>

Options and Settings are accepted interchangeably as the section keyword; both read into the same list. Section names are matched case-insensitively, the = before { … } is optional (since 1.5.0), and a repeated section merges into the same list.

Keys

KeyRequiredValueEffect
Assetyes, unless VirtualFunction(Asset="…") was givenasset referenceThe UMaterialFunction a Graph call to this name resolves to.
DescriptionnostringKept as the declaration's description.
any other key—anyRead and ignored, with no diagnostic.

[!NOTE] The VirtualFunction sync service writes a Description key alongside Asset when it generates or refreshes a declaration.

Precedence

The block attribute wins over the section:

VirtualFunction(Name="BufferWriter", Asset=Path(Game, "MaterialFunctions/F_BufferWriter"))
{
    Options = { Asset = Path(Game, "Ignored"); }   // not consulted — the attribute was present
    Outputs = { float3 Result; }
}

Options.Asset is read only when the Asset attribute is absent or empty after trimming.

Statement grammar

Identical to the Settings grammar.

RuleDetail
Statement form<Key> = <Value> ; — a key that is not a word, a missing = or a missing value is DSH3261
Valueevery token up to the ; outside brackets, so Asset = Path(Game, "A/B") is one value
Key matchingcase-insensitive; the key is kept as written
Value handlinga single quoted string is its text, escapes resolved; anything else is the text of its tokens
Duplicate keythe later statement wins, with the warning DSH3262 (since 2.0.0; 1.x overwrote silently)
Commentsallowed between any two tokens

The asset reference is trimmed before it is used, so Asset = " /Game/MF/F_X "; and Asset = /Game/MF/F_X; name the same asset.

String escapes recognized in a quoted value are \n, \r, \t, \", \\ and \0; any other \X is DSH2104 (since 2.0.0; 1.x yielded the literal X).

Asset reference resolution

The front end keeps the reference as written, and the compiler resolves it when a Graph call to the VirtualFunction is built, using the general asset-reference resolver — not the texture-default resolver. Accepted root spellings:

RootResolves to
Game/Game
Engine/Engine
Plugin.<Name>the plugin's mounted asset path
Plugins.<Name>the plugin's mounted asset path

A Path( … ) call takes either 1 argument (an absolute /… object path) or 2 arguments (root plus a relative path). A bare or quoted value that is not a Path( … ) call is used directly and must be an absolute object path. The full grammar, both resolvers and every root diagnostic are on Path(...).

[!WARNING] An unresolvable Asset is not diagnosed when the file is read or bound — only when a Graph call to the function is built: DSH8270 for a reference that does not resolve, DSH8219 for an asset that does not load. A VirtualFunction that nothing calls compiles with a broken Asset and produces no message.

Post-parse rules

RuleCode
a Name attribute is present, non-empty after trimming, and an identifierDSH6311
an asset is available from the attribute or from Options.AssetDSH6312
at least one output is declaredDSH6313

Sections accepted alongside Options

SectionInside a VirtualFunction
Optionsthis page
Settingsalias for Options
Inputstyped parameters — Inputs / Outputs / Results
Propertiesalias for Inputs
Outputstyped parameters
Resultsalias for Outputs
Grapherror — DSH2247
Codeerror — DSH2247
Layout, any other nameerror — DSH2245

Notes

  • A VirtualFunction's Inputs and Outputs describe the existing asset's interface. They are what a Graph call is checked against; they do not create pins. Getting them out of step with the asset produces errors where the call is built — DSH8220 for an input the asset does not have, DSH8221 for an output — not declaration errors.
  • .dsh files may contain VirtualFunction blocks and nothing else that generates assets. A .dsm or .dsf whose only blocks are VirtualFunctions builds no asset.

Diagnostics

Every diagnostic carries the line and column of the statement it is about.

CodeStageRaised when
DSH3261parsea statement that is not Key = Value
DSH3262parsewarning: a key written twice; the later value wins
DSH6311parseno Name, an empty one, or one that is not an identifier
DSH6312parseno asset from the attribute or from Options
DSH6313parseno output declared
DSH2247parsea Graph or Code section in the block
DSH2245parseany other unknown section name
DSH8270, DSH8219building a callthe Asset value does not resolve, or does not load
DSH8220, DSH8221building a callthe declared interface names an input or output the asset does not have

The complete list is in the diagnostics index.

Example

VirtualFunction(Name="BufferWriter")
{
    Options = {
        Asset = Path(Game, "MaterialFunctions/F_BufferWriter");
        Description = "Existing material function declared for Graph calls.";
    }

    Inputs = {
        float3 Color;
        float  Alpha;
    }

    Outputs = {
        float3 Result;
    }
}

Calling it from a Shader in the same file, or in a file that imports it:

Graph = {
    float3 Written = BufferWriter(Color = Tint, Alpha = A);
}

Resolved reference:

Asset  Path(Game, "MaterialFunctions/F_BufferWriter")
    -> /Game/MaterialFunctions/F_BufferWriter.F_BufferWriter

See also

On this page