Click or drag to resize
DigitalRuneEffectBinding Class
Provides the logic for rendering a specific Effect.
Inheritance Hierarchy

Namespace: DigitalRune.Graphics.Effects
Assembly: DigitalRune.Graphics (in DigitalRune.Graphics.dll) Version: 1.2.0.0 (1.2.1.14562)
Syntax
public class EffectBinding

The EffectBinding type exposes the following members.

Constructors
  NameDescription
Protected methodEffectBinding
Initializes a new instance of the EffectBinding class. (This constructor creates an uninitialized instance. Use this constructor only for cloning or other special cases!)
Public methodEffectBinding(IGraphicsService, Effect)
Initializes a new instance of the EffectBinding class which can store all kinds of effect parameters.
Public methodEffectBinding(IGraphicsService, Effect, IDictionaryString, Object)
Initializes a new instance of the EffectBinding class which can be used in a Material (only storing bindings for Material parameters).
Public methodEffectBinding(IGraphicsService, Effect, IDictionaryString, Object, EffectParameterHint)
Initializes a new instance of the EffectBinding class with the given settings.
Top
Methods
  NameDescription
Public methodClone
Creates a new EffectBinding that is a clone of the current instance.
Protected methodCloneCore
Makes the instance a clone (deep copy) of the specified EffectBinding.
Protected methodCreateInstanceCore
When implemented in a derived class, creates a new instance of the EffectBinding derived class.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnInitializeBindings
Called when the effect technique and parameter bindings should be initialized.
Public methodSetT(EffectParameter, ActionDelegateParameterArrayBindingT, RenderContext, T)
Public methodSetT(EffectParameter, FuncDelegateParameterBindingT, RenderContext, T)
Public methodSetT(EffectParameter, T)
Public methodSetT(EffectParameter, T)
Public methodSetT(String, ActionDelegateParameterArrayBindingT, RenderContext, T)
Public methodSetT(String, FuncDelegateParameterBindingT, RenderContext, T)
Public methodSetT(String, T)
Public methodSetT(String, T)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyEffect
Gets the effect.
Public propertyHints
Gets a value indicating which effect parameters are handled by this effect binding.
Public propertyStatic memberKeepOpaqueData
Gets or sets a value indicating whether OpaqueData should be kept for debugging.
Public propertyOpaqueData
Gets the opaque data (only used for debugging, only set if KeepOpaqueData is ).
Public propertyParameterBindings
Gets the bindings that resolve effect parameters.
Public propertyTechniqueBinding
Gets or sets the binding that resolves the effect technique.
Public propertyUserData
Gets or sets user-defined data.
Top
Remarks

An Effect defines the render states required to render an object. An EffectBinding provides the logic that is required for using an effect at runtime.

Multiple EffectBindings can share the same Effect. An EffectBinding can in theory be shared by different graphics objects. But in most cases an EffectBinding belongs to a single object, such as a Mesh.

Technique and Parameter Bindings:
An effect may define one or more effect techniques. When rendering a certain object the correct technique needs to be chosen. In addition, an effect defines a set of effect parameters. An effect file (.fx) can define default values for effect parameters. However, most effect parameters need to be set at runtime. Static parameters (such as colors, textures, etc.) can be set when assets are loaded. Dynamic parameters (such as world matrix, view matrix, projection matrix, etc.) need to be updated, typically once per frame, when the associated objects are rendered.

Effect parameters belong to different categories, defined by EffectParameterHint. An EffectBinding can be used to manage all kinds of effect parameters, or only parameters of a certain type, e.g. only Material parameters. See also Hints.

DigitalRune Graphics introduces the concept of effect technique bindings and effect parameter bindings: The technique binding (see property TechniqueBinding) provides the logic for selecting a technique at runtime. Parameter bindings (stored in ParameterBindings) links a effect parameters to a certain values. By using a ConstParameterBindingT a parameter can be bound to a static value. By using a DelegateParameterBindingT a parameter can be dynamically updated when needed. Effect technique and parameter bindings are evaluated when the associated object (e.g. a mesh) needs to be rendered. Evaluation consists of two phases:

  1. Update: The effect technique is selected; the new value of an effect parameter is calculated.
  2. Apply: An effect technique is selected for rendering; the new value is applied to the effect parameter in Effect.

Initialization: When an effect binding is created all technique and parameter bindings are created automatically. This initialization involves two steps:

  1. Interpretation: IEffectInterpreters are used to interpret the meaning of effect techniques and parameters. An IEffectInterpreter returns EffectTechniqueDescriptions and EffectParameterDescriptions which indicate how the effect should be used at runtime. This information is stored per effect and can also be queried using the methods GetTechniqueDescriptions(Effect) and GetParameterDescriptions(Effect).
  2. Binding of Effect Parameters: IEffectBinders read the information provided in the previous step and create an EffectTechniqueBinding for the effect and EffectParameterBindings for all effect parameters.
The IEffectInterpreters and the IEffectBinders are stored in the IGraphicsService. Custom interpreters/binders can be added to support new types of effects.

Cloning:
EffectBindings need to be cloneable. The method Clone calls CreateInstanceCore and CloneCore(EffectBinding) which are responsible for creating a clone of the current instance. Classes that derive from EffectBinding need to provide the implementation for CreateInstanceCore and override CloneCore(EffectBinding) if necessary.

By default, when an EffectBinding is cloned all technique and parameter bindings are duplicated (deep copy). Any optional object stored in UserData is copied per reference (shallow copy).

See Also