DirectX9Effect
Description
- 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:
-
Create render effect passes with RenderEffect.PassCreate.
-
Create shader objects with RenderEffect.ShaderCreate and assign them to render effect passes with RenderEffect.ShaderAssign.
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:
-
The RenderStateSet must be implemented and will be called once to set the render state, which will then be captures in a Direct3D 9 state block.
-
Use the RenderStateDefault method to establish default render state.
-
Use the RenderStateApply method to set common render state values.
-
Use the RenderStateAlphaToCoverage, RenderStateBool, RenderStateInt and RenderStateFloat method for setting all other render state.
If an implementation wants to use low-level parameter slots, the following steps must be performed in the constructor:
-
Declare low-level parameter slots with IRenderEffectParameters.ParameterDeclare, for example by calling RenderEffectParameters.Declare.
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 / Methods
RenderStateApply
Helper method for applying default render states.
-
DirectX9State.RS_COLORWRITEENABLE = COLORWRITEENABLE_? …
-
DirectX9State.RS_ZWRITEENABLE =
false
-
DirectX9State.RS_DEPTHBIAS =
-839 / 16777215.0
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
RenderStateSet
Sets the render state for the given rendering stage.
As convenience for setting up further render state, the default implementation calls RenderStateDefault, then RenderStateApply and finally SamplerStateApply2 for all shader resources with automatic state setup (see RenderEffectParameters.EffectComponents).
- See also
-
IRenderEffectBase.PassCurrent
DirectX9Effect.RenderStateAlphaToCoverage
DirectX9Effect.RenderStateApply
DirectX9Effect.RenderStateBool
DirectX9Effect.RenderStateDefault
DirectX9Effect.RenderStateFloat
DirectX9Effect.RenderStateInt
DirectX9Effect.SamplerStateApply1
DirectX9Effect.SamplerStateApply2
DirectX9Effect.SamplerStateApply3
DirectX9Effect.SamplerStateFloat
DirectX9Effect.SamplerStateInt
DirectX9Effect.TextureStage
DirectX9Effect.TextureStages
SamplerStateApply
3 overloads
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.
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.
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.
SetParameters
Applies the current values of all changed effect parameters (see RenderEffectParameters.Has).
The default implementation calls RenderEffectParameters.Apply on IRenderEffect.Parameters.
SetPixelShaderConstantFloat
Sets a pixel shader constant.
This method writes to one or more constant float registers (c?).
SetTexture
2 overloads
Sets the texture of the given texture stage.
The SAMP_SRGBTEXTURE
sampler state is set automatically according to ITexture.IsSrgb
Sets the texture of the given texture stage.
The SAMP_SRGBTEXTURE
sampler state is set automatically according to ITexture.IsSrgb
SetVertexShaderConstantFloat
Sets a vertex shader constant.
This method writes to one or more constant float registers (c?).
TextureStage
Returns the texture stage that is associated with the given parameter slot in and the given render pass opt.
Protected / Constructors
DirectX9Effect
Creates a new instance of DirectX9Effect.
- RenderException
-
If an error has occurred while declaring low-level render effect parameter slots.