The following is a list of commands that can be included in your script fragment xml files. For more information regarding script fragments, see Write fragments and fragment graphs to render to the viewport.
Acquires a render target from the cache that is of the given size and format, and adds it to the local variables. This is similar to acquiring an MRenderTarget
.
XML Syntax:
<acquireTarget
name="beauty"
format="EFORMAT_R32G32B32A32_FLOAT"
size="@finalDesc.Size"
relSize="1.0,1.0"
msaa="@finalDesc.NumMSAASamples"
/>
Attributes
format – the name of the raster format that should be used when creating the target. The format specifies the number of channels in the target, and the size and ordering of channels.
See MHWRender::MRasterFormat
for available values; for example, EFORMAT_
Note that the format parameter accepts the @ notation. The @ notation gets the value from a parameter of the fragment referred to by the @. For example, format="@final” will find a parameter on the current fragment called “final”, ensure that “final” is a texture or target parameter, and then set the new target’s format to be the same as that of the texture or target in “final”. Format is a required attribute.
size – the size of the target to be created, represented as a list of integers, separated by commas; for example, “16,16”. Accepted sizes are hardware dependent. Note that the size parameter, like the format parameter, accepts the @ notation. The @ notation gets the value from a parameter of the fragment referred to by the @. For example, size ="@final” will find a parameter on the current fragment called “final”, ensure that “final” is a texture or target parameter, and then set the new target’s size to be the same as that of the texture or target in “final”. size is a required attribute.
Note:
final
denotes the buffer that results should be drawn into at the end of the operation.
To create a new offscreen buffer, you may want to obtain the properties from finalDesc
, which is a description of final
.
relSize – relative size is an optional attribute that multiples the values given in the size attribute to obtain the final size used for creating the target. It denotes the width (x) and height (y) scale, and is represented as a list of 2 floating point numbers, separated by commas; for example, “0.5,0.5”. The relative size attribute does not accept the @ notation, but if the size parameter is indirect, the indirect size will be scaled by the relative size.
Sets the given target to the given target slot on the device. The target should have been previously acquired or provided by a parameter prior to its use in setTarget.
XML Syntax:
<setTarget
index="0"
value="beauty"
/>
Attributes
index - the index of the target being set. 4 simultaneous targets are supported, named “0” through “3”. index is a required attribute, and must be an integer from 0 to 3.
value - the name of the target to be set to the device. This target should be in the local cache or provided by a referenced parameter. Note that the value parameter accepts the @ notation. The @ notation gets the value from a parameter of the fragment referred to by the @. For example, value ="@final” will find a parameter on the current fragment called “final”, ensure that “final” is a target parameter, and then set the target held by “final” to the device’s target at the given index. Value is a required attribute. The empty string “” is treated as NULL and de-references the target. This is done so that ReleaseTargets can function correctly.
Sets the given target to the depth stencil buffer for the device. The target should have been previously acquired or provided by a parameter prior to its use in setDepthStencil.
XML Syntax:
<setDepthStencil
value="myDepthStencil"
/>
Attributes:
This command releases one or more targets from the local cache back to the target cache and removes the associated parameters from the local cache.
XML Syntax:
<releaseTargets
value="beauty,temp0"
/>
Attributes:
This command releases all of the local parameters back to the caches.
XML Syntax:
<releaseAll/>
This command clears a combination of the color buffer, the depth buffer and the stencil buffer to the given values.
XML Syntax:
<clear
color="0,0,0,0"
depth="1.0"
stencil="0"
/>
Attributes:
color - a list of float values representing the clear color, separated by commas; for example: “0.63,0.32,0.77,0.0”. color is an optional attribute, and if it is not given or if it is set to an empty string ””, it is taken to mean “do not clear the color component”. Only float4 RGBA colors are accepted.
depth - a single float value representing the depth clear value; for example: “1.00”. depth is an optional attribute, and if it is not given or if it is set to an empty string ””, it is taken to mean “do not clear the z component”.
stencil - a single integer value representing the clear value for the stencil buffer; for example, “128”. For stencil buffers created with D24S8, the most common format, accepted values are between 0 and 255. stencil is an optional attribute, if it is not given or if it is set to an empty string ””, it is taken to mean “do not clear the stencil component”.
This command sets the current drawing camera to the given value.
XML Syntax:
<setCamera
value="camera0"
index="0"
/>
Attributes:
This command sets the current viewport to the given drawing region. All drawing, including quad draws and clears, are restricted to the active viewport.
XML Syntax:
<setViewport
value="0.0,0.0, 0.5,0.5"
/>
Attributes:
This command sets the current scissor rectangle to the given region. This command has no effect unless the render state is set to enable the scissor rectangle. If the rectangle is enabled, then drawing, including quad draws, are restricted to the scissor rectangle.
XML Syntax:
<setScissorRect
value="0.0,0.0, 0.5,0.5"
/>
Attributes:
This command sets the override effect to the given value. All drawing, including quad draws, use the override effect until it is reset.
An effect can only be set once, but can be reused several times.
XML Syntax:
<setEffect
name="DownSampleEffect"
path="downSample"
technique="Main"
macrolist=""
/>
Attributes:
path – the path for the effect file. Optional. If this value is not empty, the effect will be created with the file, and if the specified effect name is already used by another effect, that effect will be released. If this value is empty, the effect with the specified effect name is reused, and if the effect doesn’t exist, this command will fail.
It is not necessary to provide a file extension, as Maya will look up the appropriate extension based on the device being used; for example, .fx
for DX11, .ogsfx
for Core Profile and .cgfx
for non-core profile OpenGL.
The override effect is terminated by setting the value to "", the empty string.
technique – the name of the active technique. Optional. If the effect path is empty, this parameter will be ignored. If the technique is not found in the effect, the command will fail.
This command sets the value of a parameter on the current effect to the given value. All subsequent uses of this effect will have this value.
XML Syntax:
<setEffectParameter
effect="downSample"
name="scale"
value="0.0,1.0"
/>
Attributes:
name – name of the parameter that is being set. name is a required attribute.
value – value to set the parameter to. Exact syntax is dependent on the parameter type; for example, the above example will match a float2, but not a target. Note that the value parameter accepts the @ notation. The @ notation gets the actual value from a parameter of the fragment referred to by the @. For example, value ="@cameraIn” will find a parameter on the current fragment called “cameraIn”, ensure that “cameraIn” is of the same type as the parameter referred to by name, and then set the parameter to the value of cameraIn.
This command sets the value of the given texture slot on the device to the given sampler state and texture.
XML Syntax:
<SetTexture
effect="Main"
name="gDistanceTex"
value="PointClamp"
texture="@DistanceMap"
/>
Attributes:
This command sets a given state block to the device. The complete device state may be set (the “RenderState”); or, each of its three components, the blend state, rasterizer state and depth stencil state may be set separately.
XML Syntax:
<setState
name="DepthStencilState"
value="myDepthStencilState"
/>
This command sets a parameter on the given renderer. The parameter may hold an auxiliary world, or specify an object filter used to accept all objects with certain item flags set. Examples are “visible”, and “castsShadow”.
XML Syntax:
<setRenderParameter
renderer="opaqueRend"
name="filter"
value="visible"
/>
Attributes:
This command declares a new parameter of the given type and adds it to the local cache. It optionally sets the value of the parameter to the given value. The parameter may subsequently be set by the setParameter command.
XML Syntax:
<declare
name="light0Shadow"
type="target"
value="shadowBuf0"
/>
Attributes:
This command sets a given parameter to the given value, which may be another parameter.
XML Syntax:
<setParameter
name="@output"
value="1.0,0.25"
/>
Attributes:
This command tests a given parameter for NULL or false, and if it is NULL or false, all statements are skipped until “else” or “endIf”. The statement can be nested.
XML Syntax:
<if
value="@depthStencil"
/>
Attributes
This command tests a given parameter for NULL or false and if it is NULL or false, all statements are executed until else or endIf. If true or not NULL, no statements are executed until an else or endif is encountered. The statement can be nested.
XML Syntax:
<ifNot
value="@depthStencil"
/>
Attributes
This command ends the main section and begins the else section of an if or ifNot command. It reverses the state of statement inclusion produced by if or ifNot. If an if statement evaluates to true, statements are executed until an endIf or an else is encountered. If an else is encountered, no subsequent statements are executed until an endIf is encountered. The conditional statement can be nested. Must be contained between either an if / endIf pair, or between an ifNot / endIf pair.
XML Syntax:
<else/>
Attributes
This command ends an if or ifNot command and restores normal, unconditional processing. All statements after the endIf are executed normally. The conditional statement can be nested. This command must match the if command one to one, and must appear after the matching if command.
XML Syntax:
<endIf/>
Attributes
This command calls a user supplied callback object. If the callback object is not in the local cache, it is created for you and added to the local parameters, then called. The callback takes 2 optional arguments.
XML Syntax:
<call
name="myCallback "
arg0="doThisThing" arg1="0.125"
/>
Attributes
This command renders all the objects in the list named in the value attribute. Valid values include "opaqueList", which is the list of opaque objects that you want to draw, and “quad”, that draws a single full screen quad. Render does not set targets, cameras, state, override effects, or other rendering related values; it merely draws the geometry with the state currently set in the interpreter. Both quad draws and scene draws are restricted to the area of the viewport.
XML Syntax:
<render
name="@opaqueList"
/>
Attributes:
This command will use a state setter class to manage the render state or sampler state of the virtual device. This command includes the setting of the state changes, the committing of the state changes, and the restoring to old state.
XML Syntax:
<SetStateCommand
commandName="SetStateParameter"
name="localStateSetter_fsShadow"
parameter="SetBlendEnable"
value="true"
index="0"
/>
commandName - a string indicating the name of the command. Required.
Currently only four types of commands are allowed: “SetStateParameter”, “SetRenderState”, “CommitNewState” and “RestorePreviousState”.
name - a string indicating the name of the state setter. Required. The state setter must have been already declared in a previous script.