Script fragment commands

The following is a list of commands that you can include in your script fragment xml files. For more information regarding script fragments, see Write fragments and fragment graphs to render to the viewport.

AcquireTarget

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

SetTarget

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

SetDepthStencil

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:

ReleaseTargets

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:

ReleaseAll

This command releases all of the local parameters back to the caches.

XML Syntax:

<releaseAll/>

Clear

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:

SetCamera

This command sets the current drawing camera to the given value.

XML Syntax:

<setCamera 
    value="camera0" 
    index="0" 
/>

Attributes:

SetViewport

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:

SetScissorRect

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:

SetEffect

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:

SetEffectParameter

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:

SetTexture

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:

SetState

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" 
/>

SetRenderParameter

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:

Declare

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:

SetParameter

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:

If

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

IfNot

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

Else

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

EndIf

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

Call

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

Render

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:

SetStateCommand

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" 
/>