DirectX9Effect

Description

abstract class Tinman.AddOns.DirectX9.Effects.DirectX9Effect
<TParameters : RenderEffectParameters>

Derived from

RenderEffectGeneric<TParameters> abstract

Extended by

Example_Demo_DX9_A sealed
Example_Demo_DX9_B sealed
Example_Demo_DX9_C sealed

Full source code is included in the Tinman 3D SDK download.

Abstract base class for Direct3D 9 IRenderEffect implementations.

An implementing class must perform the following steps in its constructor:

Because there are no render state blocks / objects that could be created in the constructor, the render state for each pass must be setup by subclasses, using the following methods:

If an implementation wants to use low-level parameter slots, the following steps must be performed in the constructor:

The RS_SRGBWRITEENABLE render state is set automatically according to the RenderTargetFormat.Srgb format flags of render targets that have been set via IGraphicsContext.SetRenderTarget.

The SAMP_SRGBTEXTURE sampler state is set automatically according to ITexture.IsSrgb when a texture is set via IRenderEffectParameters.ParameterTexture1 or IRenderEffectParameters.ParameterTexture2.

Public / Constants

PS


public constant PS → (0:int32)

Shader type index: Pixel Shader

VS


public constant VS → (1:int32)

Shader type index: Vertex Shader

Public / Methods

Render​State​Alpha​To​Coverage


public method RenderStateAlphaToCoverage → (1)

enable in : bool

true to enable alpha-to-coverage, false to disable it.

returns → bool

The resulting alpha-to-coverage state. Will always be false if not supported.

Enables or disables the vendor-specific alpha-to-coverage extension.

Render​State​Bool


public method RenderStateBool → (2)

state in : int32

The RS_* render state to set.

value in : bool

The render state value.

Sets a render state value.

Render​State​Default


public method RenderStateDefault → ()

Sets default render state values.

These are the default render state values; (!) means that the value differs from the standard value that is defined by Direct3D:
DirectX9State.RS_ALPHABLENDENABLE = false
DirectX9State.RS_ALPHAFUNC = DirectX9State.CMP_ALWAYS
DirectX9State.RS_ALPHAREF = 0
DirectX9State.RS_ALPHATESTENABLE = false
DirectX9State.RS_ANTIALIASEDLINEENABLE = false
DirectX9State.RS_BLENDFACTOR = ~0
DirectX9State.RS_BLENDOP = DirectX9State.BLENDOP_ADD
DirectX9State.RS_BLENDOPALPHA = DirectX9State.BLENDOP_ADD
DirectX9State.RS_CCW_STENCILFAIL = DirectX9State.STENCILOP_KEEP
DirectX9State.RS_CCW_STENCILFUNC = DirectX9State.CMP_ALWAYS
DirectX9State.RS_CCW_STENCILPASS = DirectX9State.STENCILOP_KEEP
DirectX9State.RS_CCW_STENCILZFAIL = DirectX9State.STENCILOP_KEEP
DirectX9State.RS_CLIPPLANEENABLE = 0
DirectX9State.RS_COLORWRITEENABLE = 0xF
DirectX9State.RS_COLORWRITEENABLE1 = 0xF
DirectX9State.RS_COLORWRITEENABLE2 = 0xF
DirectX9State.RS_COLORWRITEENABLE3 = 0xF
DirectX9State.RS_CULLMODE = DirectX9State.CULL_CCW
DirectX9State.RS_DEPTHBIAS = 0.0f
DirectX9State.RS_DESTBLEND = DirectX9State.BLEND_ZERO
DirectX9State.RS_DESTBLENDALPHA = DirectX9State.BLEND_ZERO
DirectX9State.RS_DITHERENABLE = false
DirectX9State.RS_FILLMODE = DirectX9State.FILL_SOLID
DirectX9State.RS_INDEXEDVERTEXBLENDENABLE = false
DirectX9State.RS_LASTPIXEL = false (!)
DirectX9State.RS_MULTISAMPLEANTIALIAS = true
DirectX9State.RS_MULTISAMPLEMASK = ~0
DirectX9State.RS_NORMALIZENORMALS = false
DirectX9State.RS_POINTSCALE_A = 1.0f
DirectX9State.RS_POINTSCALE_B = 0.0f
DirectX9State.RS_POINTSCALE_C = 0.0f
DirectX9State.RS_POINTSCALEENABLE = false
DirectX9State.RS_POINTSIZE_MAX = 64.0f
DirectX9State.RS_POINTSIZE_MIN = 1.0f
DirectX9State.RS_POINTSPRITEENABLE = false
DirectX9State.RS_SCISSORTESTENABLE = true (!)
DirectX9State.RS_SEPARATEALPHABLENDENABLE = false
DirectX9State.RS_SLOPESCALEDEPTHBIAS = 0.0f
DirectX9State.RS_SRCBLEND = DirectX9State.BLEND_ONE
DirectX9State.RS_SRCBLENDALPHA = DirectX9State.BLEND_ONE
DirectX9State.RS_STENCILENABLE = false
DirectX9State.RS_STENCILFAIL = DirectX9State.STENCILOP_KEEP
DirectX9State.RS_STENCILFUNC = DirectX9State.CMP_ALWAYS
DirectX9State.RS_STENCILMASK = ~0
DirectX9State.RS_STENCILPASS = DirectX9State.STENCILOP_KEEP
DirectX9State.RS_STENCILREF = 0
DirectX9State.RS_STENCILWRITEMASK = ~0
DirectX9State.RS_STENCILZFAIL = DirectX9State.STENCILOP_KEEP
DirectX9State.RS_TWEENFACTOR = 0.0f
DirectX9State.RS_TWOSIDEDSTENCILMODE = false
DirectX9State.RS_VERTEXBLEND = 0
DirectX9State.RS_ZENABLE = true
DirectX9State.RS_ZFUNC = DirectX9State.CMP_LESSEQUAL
DirectX9State.RS_ZWRITEENABLE = true
These are the default sampler state values:
DirectX9State.SAMP_ADDRESSU = DirectX9State.TADDRESS_WRAP
DirectX9State.SAMP_ADDRESSV = DirectX9State.TADDRESS_WRAP
DirectX9State.SAMP_ADDRESSW = DirectX9State.TADDRESS_WRAP
DirectX9State.SAMP_BORDERCOLOR = 0
DirectX9State.SAMP_MAGFILTER = DirectX9State.TEXF_POINT
DirectX9State.SAMP_MINFILTER = DirectX9State.TEXF_POINT
DirectX9State.SAMP_MIPFILTER = DirectX9State.TEXF_NONE
DirectX9State.SAMP_MIPMAPLODBIAS = 0.0f
DirectX9State.SAMP_MAXMIPLEVEL = 0
DirectX9State.SAMP_MAXANISOTROPY = 1
DirectX9State.SAMP_ELEMENTINDEX = 0
DirectX9State.SAMP_DMAPOFFSET = 0.0f
These are the default non-standard render state values:
RenderStateAlphaToCoverage = false

Render​State​Float


public method RenderStateFloat → (2)

state in : int32

The RS_* render state to set.

value in : float32

The render state value.

Sets a render state value.

Render​State​Int


public method RenderStateInt → (2)

state in : int32

The RS_* render state to set.

value in : int32

The render state value.

Sets a render state value.

Sampler​State​Apply

3 overloads


public method SamplerStateApply1 → (1)

name in : string

The parameter name that has been passed to IRenderEffectParameters.ParameterDeclare.

Applies the given common sampler state preset to all texture stages that are associated with a parameter slot.

This method first calls RenderEffectParameters.EffectSamplerState to get the common sampler state preset and then calls SamplerStateApply2.


public method SamplerStateApply2 → (2)

name in : string

The parameter name that has been passed to IRenderEffectParameters.ParameterDeclare.

preset in : SamplerStatePreset

The sampler state preset.

Applies the given sampler state preset to all texture stages that are associated with a parameter slot.

This method first calls IRenderEffectParameters.ParameterIndex to get the low-level parameter slot index for name in and then calls SamplerStateApply3.


public method SamplerStateApply3 → (2)

slotOrIndex in : int32

If greater than or equal to 0, depicts the parameters slot whose texture stages to set sampler state for, see TextureStages. If less than -1, specifies the index N of the sampler which state to set, as -2-N. If equal to -1, the method returns silently without applying any sample state.

preset in : SamplerStatePreset

The sampler state preset.

Applies the given sampler state preset to a texture stage (i.e. a sampler index) or to all texture stages that are associated with a parameter slot.

Sampler​State​Float


public method SamplerStateFloat → (3)

index in : int32

The sampler index.

state in : int32

The SAMP_* render state to set.

value in : float32

The sampler state value.

Sets a sampler state value.

Sampler​State​Int


public method SamplerStateInt → (3)

index in : int32

The sampler index.

state in : int32

The SAMP_* render state to set.

value in : int32

The sampler state value.

Sets a sampler state value.

Set​Pixel​Shader​Constant​Float


public method SetPixelShaderConstantFloat → (4)

index in : int32

The constant register.

values in : float32 [ ]

The values to set.

first in : int32

Index into values in to first value.

tuples in : int32

Number of float4 tuples to read from values in.

Sets a pixel shader constant.

This method writes to one or more constant float registers (c?).

Set​Texture

2 overloads


public method SetTexture1 → (2)

stage in : int32

The texture stage index.

texture in : ITexture2D

The texture to set.

Sets the texture of the given texture stage.

The SAMP_SRGBTEXTURE sampler state is set automatically according to ITexture.IsSrgb


public method SetTexture2 → (2)

stage in : int32

The texture stage index.

texture in : ITextureCube

The texture to set.

Sets the texture of the given texture stage.

The SAMP_SRGBTEXTURE sampler state is set automatically according to ITexture.IsSrgb

Set​Texture​Null


public method SetTextureNull → (1)

stage in : int32

The texture stage index.

Sets the texture of the given texture stage to null.

Set​Vertex​Shader​Constant​Float


public method SetVertexShaderConstantFloat → (4)

index in : int32

The constant register.

values in : float32 [ ]

The values to set.

first in : int32

Index into values in to first value.

tuples in : int32

Number of float4 tuples to read from values in.

Sets a vertex shader constant.

This method writes to one or more constant float registers (c?).

Texture​Stage


public method TextureStage → (2)

slot in : int32

[0..IRenderEffectParameters.ParameterSlotCount-1]
The parameter slot.

pass opt : int32 = -1

[-1..IRenderEffectBase.PassCount-1]
The render pass index. If -1, IRenderEffectBase.PassCurrent will be used.

returns → int32

The associated texture stage or -1 if there are no associated stages or more than one associated stages.

Returns the texture stage that is associated with the given parameter slot in and the given render pass opt.

Texture​Stages


public method TextureStages → (2)

slot in : int32

[0..IRenderEffectParameters.ParameterSlotCount-1]
The parameter slot.

pass opt : int32 = -1

[-1..IRenderEffectBase.PassCount-1]
The render pass index. If -1, IRenderEffectBase.PassCurrent will be used.

returns → int32 [ ]

The associated texture stages.

Returns the texture stages that are associated with the given parameter slot in and the given render pass opt.

Protected / Constructors

Direct​X9​Effect


protected constructor DirectX9Effect → (4)

parameters in : TParameters

[not-null]
The render effect parameters object.

owner in : DirectX9Context

[not-null]
The owning context.

repositoryPrivate in : Path

[not-null]
The private GPU shader repository path or Path.Unknown if none.

parameterDeclareWithFlags opt : int32 = -1

The flags to use for calling RenderEffectParameters.Declare or -1 to not perform the call.

Creates a new instance of DirectX9Effect.

RenderException

If an error has occurred while declaring low-level render effect parameter slots.