About shader_builder XML
In its most basic form, a Matchbox or Lightbox is only a .glsl file that contains all the shader information. That single file is enough for the application to generate both the shading result and a rough UI for the end user to manipulate the shader parameters.
To create a useful UI, you need a sidecar .xml file. This file is generated by running the shader_builder
utility with the -x
switch. Once it's been created by shader_builder
, you can edit the xml to tweak the UI to your needs, such as substituting curves for numeric fields.
shader_builder
.XML Structure
<!DOCTYPE ShaderNodePreset [
<!ELEMENT ShaderNodePreset (Shader+, Page+)>
<!ELEMENT Shader (Uniform+)>
<!ELEMENT Uniform (SubUniform* | PopEntry* | Duplicate*)>
<!ELEMENT SubUniform EMPTY>
<!ELEMENT PopEntry EMPTY>
<!ELEMENT Duplicate EMPTY>
<!ELEMENT Page (Col+)>
<!ELEMENT Col EMPTY>
]>
<ShaderNodePreset>
Parent
- None. ShaderNodePreset is the root element.
Children
<Shader>
: At least one for a Matchbox. Only one for a Lightbox . See<Shader>
usage definition.<Page>
: At least one.
Usage
- Root element. Mandatory.
Attribute | Description | Allowed Values | Default |
---|---|---|---|
Description | A description of the Preset. The description appears in the Matchbox node Note available from the Schematic. | Character data | EMPTY |
Name | The name of the Preset. The name appears in the Name field of the Node interface. The Name attribute overrides the filename, so if the .xml file is present, even if the user loads the .glsl file, the Name attribute is displayed in the UI. | Character data | Name of the preset |
HelpLink (optional) | Allows you to specify an URL that can be used for external documentation (only valid XML characters are allowed in the URL). A Help button is added to the Matchbox interface when this token is detected. | Character data | EMPTY |
LimitInputsToTexture (optional) | Allows you to limit the number of Input Sockets on the Matchbox node to the number of textures required by your shader. |
| False |
MatteProvider | Matchbox only Specifies if the Matchbox shader provides a matte to its child node, or if it is a pass through, where the Matchbox's child node uses the matte from the Matchbox's parent. If the Matchbox operates on the alpha and you want that alpha to be passed on the child node, you must set MatteProvider = True. |
| False |
SupportsAction | Matchbox only Hints to the usage of the Matchbox, in this case as an Action node. Batch is always supported. |
| False |
SupportsTransition | Matchbox only Hints to the usage of the Matchbox, in this case as a transition in the timeline. Batch is always supported. |
| False |
SupportsAdaptiveDegradation | Matchbox only Defines if the Matchbox node supports Batch adaptive degradation. Use in combination with the adsk_degrade uniform to create a less costly data path, or even completely bypass the Matchbox to enhance Batch interactivity. Note that the Matchbox must be coded with alternate paths using the adsk_degrade for adaptive degradation to work: simply setting SupportsAdaptiveDegradation = True does not make the node turn off when adaptive degradation is turned on. |
| False |
CommercialUsePermitted | Indicates if the shader should be used for commercial purposes. This attribute is not enforced by the application. Set by the creator of the shader to indicate if the shader can be used for commercial purposes. The user of the shader is responsible for verifying this attribute and using the shader accordingly. |
| True |
AccumulatePass | Numeric value that allows the matchbox to accumulate an intermediate pass. ( ShaderIndex ) rather than the final result: One-based. | ||
AccumulationFromStartFrame | Bool that specifies if accumulation should proceed recursively. There is an Accumulate example provided in the EXAMPLE folder. |
| True |
ShaderType | Defined by shader_builder, determines the type of shader, Lightbox or Matchbox. | Matchbox / Lightbox | Value depends on the .glsl file used to create the XML. |
SoftwareVersion | Defined by shader_builder, indicates the version of the application used to build the .xml. | Character data | shader_builder defined |
TimelineUseBack | Matchbox only Defines if the Matchbox uses the background of the timeline (True), or not (False). Only used in context of the timeline. |
| True |
Version | Version of shader. Metadata which is user-defined and not processed by the application. | Character data | 1 |
<Shader>
Parent
<ShaderNodePreset>
Children
<Uniform>
: At least one.
Usage
- Mandatory.
- There is one
<Shader>
for each shader pass defined in the .glsl file: a Matchbox can have multiple shader passes, but a Lightbox can only ever have one.<Shader>
lists the uniforms required for the associated shader pass.
<Uniform>
Parent
<Shader>
Children
<SubUniform>
: As many as required by the uniform, as defined by theType
attribute, and ifValueType <> PopUp
.<PopupEntry>
: Only if attributeValueType = PopUp
, in which case there can be as many as required.<Duplicate>
: Only one, only if parent<Uniform>
is a duplicate. See<Duplicate>
definition.
Usage
- One for each uniform in the current pass.
Example files can be found in /opt/Autodesk/presets/<application_version>/matchbox/shaders/EXAMPLES/
.
The following attributes are only used to define a curve-based UI, when <Uniform ValueType = Curve>
. For an example in context, see /opt/Autodesk/presets/<application_version>/matchbox/shaders/EXAMPLES/Curves.glsl
.
<SubUniform>
Parent
<Uniform>
Child
- EMPTY
Usage
- There is one
<SubUniform>
element for each value required by the<Uniform>
parent, based on the Value attribute:vec3
requires 3<SubUniform>
,float
requires none. How this gets translated in the UI depends on theValueType
defined: Colour displays a colour pot, which means that the SubUniform defines the starting RGB values for that uniform, whereasPosition
with avec3
displays three numeric fields defined by the attributes of 3<SubUniform>
.
The following attributes are only used to define a curve-based UI, when <Uniform ValueType = Curve>
. These values override the more general values from the parent <Uniform>
.
<Duplicate>
Parent
<Uniform>
Children
- EMPTY
Usage
When a uniform is present in more than one shader pass, it is only shown once in the user interface. This is indicated by the
<Duplicate>
element.For example, if a two-pass preset uses a bool uniform named filtering, the XML file defines it in the first
<Shader>
element:<Uniform Row="0" Col="0" Page="0" Default="True" Tooltip="" DisplayName="Filtering" Type="bool" Name="filtering"> </Uniform>
In the second
<Shader>
element, it is defined as a duplicate.<Uniform Type="bool" Name="filtering"> <Duplicate> </Duplicate> </Uniform>
If the second uniform isn't defined as a duplicate, it appears twice in the node UI.
Attributes
- NONE
<PopupEntry>
Parent
<Uniform>
Children
- EMPTY
Usage
Only used if
<Uniform ValueType = Popup>
. Each<PopupEntry>
is an element of the drop-down list.<PopupEntry Title="ReplaceMe" Value="0"> </PopupEntry>
Refer to
/opt/Autodesk/presets/<application_version>/matchbox/shaders/EXAMPLES/BuildList.xml
for an example.
Attribute | Description | Allowed Values |
---|---|---|
Title | The entry displayed in the drop-down list. | Character data |
Value | The actual value passed to the uniform. | Character data |
<Page>
Parent
<ShaderNodePreset>
Children
<Col>
: Up to 6 children.
Usage
Defines the name of a page, and the index of that page. A page can have two states in the UI: expanded or collapsed, as decided by the user.
If a UI page is expanded, it displays all 6 children
<Col>
of this<Page>
element. In this case, the name displayed in the UI is defined by theName
property.If the UI page is collapsed, then the 6
<Col>
of this<Page>
element are automatically split over two UI pages. One page name is defined byColName0_2
and contains the first three<Col>
. The other page name is defined byColName3_5
and contains the last three<Col>
. First to last order defined by theIndex
property of each<Col>
.
Attribute | Description | Allowed Values | Default |
---|---|---|---|
Name | Name of the page in the UI. Used when all the columns are displayed at once in the Expanded UI. | Character data | Page 1 |
ColName0_2 | Name of the page in the UI, used for the page that contains the first 3 columns of the shader settings. For use in the collapsed UI. | Character data | Page 1 |
ColName3_5 | Name of the page in the UI, used for the page that contains the last 3 columns of the shader settings. For use in the collapsed UI. | Character data | Page 2 |
Page | Index of the page. | Indexed from 0, max value of 6. | 0 |
<Col>
Parent
<Page>
Children
- EMPTY
Usage
- Defines the name of a column within a page.
Attribute | Description | Allowed Values | Default |
---|---|---|---|
Name | Name of the column to be displayed in the UI. | Character data | Column 1 |
Col | Index of the column. | Indexed from 0, max value of 6. | 0 |
Page | Index of the <Page> where the column appears. | Indexed from 0, max value of 6. | 0 |