Click or drag to resize
DigitalRuneMaterial Class
Defines the material (visual properties) of a mesh.
Inheritance Hierarchy
SystemObject
  DigitalRune.GraphicsMaterial

Namespace: DigitalRune.Graphics
Assembly: DigitalRune.Graphics (in DigitalRune.Graphics.dll) Version: 1.2.0.0 (1.2.1.14562)
Syntax
public class Material : IDictionary<string, EffectBinding>, 
	ICollection<KeyValuePair<string, EffectBinding>>, IEnumerable<KeyValuePair<string, EffectBinding>>, 
	IEnumerable, INamedObject

The Material type exposes the following members.

Constructors
  NameDescription
Public methodMaterial
Initializes a new binding of the Material class.
Top
Methods
  NameDescription
Public methodAdd
Adds an effect binding for the specified render pass to the material.
Public methodClear
Removes all render passes and effect bindings from the material.
Public methodClone
Creates a new Material that is a clone of the current instance.
Protected methodCloneCore
Makes the instance a clone (deep copy) of the specified Material.
Public methodContains
Determines whether the material contains an effect binding for the specified render pass.
Protected methodCreateInstanceCore
When implemented in a derived class, creates a new instance of the Material 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 methodGetEnumerator
Returns an enumerator that iterates through a collection.
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.)
Public methodRemove
Removes the effect binding for the specified render pass from the material.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTryGet
Gets the effect binding for the specified render pass
Top
Extension Methods
  NameDescription
Public Extension MethodAddRangeKeyValuePairString, EffectBinding (Defined by CollectionHelper.)
Public Extension MethodDoKeyValuePairString, EffectBinding(ActionKeyValuePairString, EffectBinding)Overloaded.
Performs the given action on each element in a sequence when it is enumerated.
(Defined by LinqHelper.)
Public Extension MethodDoKeyValuePairString, EffectBinding(ActionKeyValuePairString, EffectBinding, Int32)Overloaded.
Performs the given action on each element (incorporating its index) in a sequence when it is enumerated.
(Defined by LinqHelper.)
Public Extension MethodForEachKeyValuePairString, EffectBinding(ActionKeyValuePairString, EffectBinding)Overloaded.
Immediately performs the given action on each element in a sequence.
(Defined by LinqHelper.)
Public Extension MethodForEachKeyValuePairString, EffectBinding(ActionKeyValuePairString, EffectBinding, Int32)Overloaded.
Immediately performs the given action on each element (incorporating its index) in a sequence.
(Defined by LinqHelper.)
Public Extension MethodIndexOfKeyValuePairString, EffectBinding
Returns the index of the first element in a sequence that satisfies the specified condition.
(Defined by LinqHelper.)
Top
Properties
  NameDescription
Public propertyCount
Gets the number of render passes supported by this material.
Public propertyEffectBindings
Gets a collection of effect bindings used by this material.
Public propertyItem
Gets or sets the effect binding for the specified render pass.
Public propertyName
Gets the name of the material.
Public propertyPasses
Gets a collection of all the render passes supported by this material.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodICollectionKeyValuePairString, EffectBindingAdd
Explicit interface implementationPrivate methodICollectionKeyValuePairString, EffectBindingContains
Explicit interface implementationPrivate methodIDictionaryString, EffectBindingContainsKey
Explicit interface implementationPrivate methodICollectionKeyValuePairString, EffectBindingCopyTo
Explicit interface implementationPrivate methodIEnumerableKeyValuePairString, EffectBindingGetEnumerator
Returns an enumerator that iterates through the collection.
Explicit interface implementationPrivate methodIEnumerableGetEnumerator
Returns an enumerator that iterates through a collection.
Explicit interface implementationPrivate propertyICollectionKeyValuePairString, EffectBindingIsReadOnly
Explicit interface implementationPrivate propertyIDictionaryString, EffectBindingKeys
Explicit interface implementationPrivate methodICollectionKeyValuePairString, EffectBindingRemove
Explicit interface implementationPrivate methodIDictionaryString, EffectBindingTryGetValue
Gets the value associated with the specified key.
Explicit interface implementationPrivate propertyIDictionaryString, EffectBindingValues
Top
Remarks

A Mesh represents the geometry and materials of a 3D object that can be rendered. A mesh owns a collection of Materials and is divided into Submeshes. Each Submesh describes a batch of primitives (usually triangles) that use one material and can be rendered with a single draw call.

An effect binding (see class EffectBinding) provides the render states required for each draw call: An that defines the graphics device states. A technique binding selects the vertex and pixel shaders for rendering. And parameter bindings define static properties (color, diffuse texture, gloss map, normal map, etc.) as well as dynamic properties (world/view/projection matrices, light properties, etc.). But depending on the render pipeline that is used, multiple render passes may be required to draw a certain object. Therefore, a Material is a dictionary of effect bindings - one effect binding per render pass. The dictionary key is the name of the render pass (a case-sensitive string such as "Default", "ZPass", "ShadowMap", "GBuffer", "Material", etc.). The dictionary value is the EffectBinding that contains required settings for this render pass. The entries in a material depend on the type of renderer that is used.

Example: A forward renderer usually only requires a single render pass, in which the mesh is rendered into the back buffer. In this case the material contains one entry (Key = "Default", Value = EffectBinding).

Advanced example: A light pre-pass renderer usually requires several render passes per mesh: In the "ShadowMap" pass the mesh is rendered into the shadow-map texture, which is used later on. Then in the "GBuffer" pass the depth, the normals, and other properties of the mesh are rendered into multiple render targets. Next, the renderer computes the lighting information. Then in the "Material" pass, the mesh is rendered again - the lighting information is combined with the material settings. In this example the material contains 3 entries. The keys are "GBuffer", "Material", and "ShadowMap".

A Material is not bound to a certain Mesh. It can be shared by different Mesh objects.

Important: When an EffectBinding is used as part of a Material, then it can only contain parameter bindings with the sort hint Material (see EffectParameterHint).

Cloning:
Materials can be cloned. When Clone is called all EffectBinding are duplicated (deep copy).

See Also