Click or drag to resize
AB4D logo

WpfMaterial Class

WpfMaterial is a class that gets a WPF Material and converts it into a material that can be used by Ab3d.DXEngine.
Inheritance Hierarchy
SystemObject
  Ab3d.DirectXDXResourceBase
    Ab3d.DirectXSharedDXResource
      Ab3d.DirectXSharedDXDeviceResource
        Ab3d.DirectXMaterial
          Ab3d.DirectX.MaterialsWpfMaterial

Namespace: Ab3d.DirectX.Materials
Assembly: Ab3d.DXEngine.Wpf (in Ab3d.DXEngine.Wpf.dll) Version: 7.0.8865.1045
Syntax
C#
public sealed class WpfMaterial : Material, 
	IDiffuseMaterial, ITransparentMaterial, IDiffuseTextureMaterial, ISpecularMaterial, IEmissiveMaterial, 
	ITwoSidedMaterial, IEnvironmentalMapMaterial, IConstantBuffersCache, IDXAttributeChangedHandler

The WpfMaterial type exposes the following members.

Constructors
Properties
 NameDescription
Public propertyAlpha Gets a float value that defines the alpha value for the material.
Public propertyAlphaClipThreshold Pixels with alpha color values below this value will be clipped (not rendered and their depth will not be written to depth buffer). Expected values are between 0 and 1. When 0 (by default) then alpha clipping is disabled - this means that also pixels with alpha value 0 are fully processed (they are not visible but its depth value is still written so objects that are rendered afterwards and are behind the pixel will not be visible).
Public propertyAmbientColor Gets a Color3 that specifies an color that defines how much ambient color is reflected by this material.
Public propertyCachedConstantBuffers Gets or sets an array of DirectX Constant buffers that can be created for this instance of Material. The buffers can be created in Effects and can be reused for multiple frames when the material is not changed.
Public propertyConstantBuffersVersion Gets or sets a version that was read from Material's Version at the time of creating the CachedConstantBuffers
Public propertyDiffuseColor Gets a Color3 that specifies the diffuse color of this material.
Public propertyDiffuseTextures Gets an array of ShaderResourceView that define the textures.
Public propertyEmissiveColor Gets a Color3 that that represents the emissive color - the color of the object regardless of the lights.
Public propertyEnvironmentalCubeMap Gets ShaderResourceView that defines the EnvironmentalCubeMap. ShaderResourceView should define a cube map with 6 textures for each side of the cube.
Public propertyHasImageInvertedYTransformation If true then the texture image has a transformation that flips the texture vertically. This property is used by DXEngine to optimize the rendering of a texture.
Public propertyHasOnlyEmissiveColor Gets a Boolean that specifies if this material has only emissive color. If false than other material properties are also defined.
Public propertyHasSpecularColor Gets a boolean that specifies if specular material is used by the WpfMaterial
Public propertyHasTransparency Gets a boolean that specifies if this material is semi-transparent and needs to be alpha blended with the scene.
Public propertyIsDirty Gets or sets a Boolean that specifies if the properties of the used WPF material have changed and we need to call UpdateMaterial method to update the properties of this material.
Public propertyIsPreMultipliedAlphaColor When IsPreMultipliedAlphaColor is true (false by default) and Alpha is less then 1, then the color components of the DiffuseColor are multiplied with alpha value to produce pre-multiplied alpha colors. When false, then non-pre-multiplied color is converted to pre-multiplied color when this is required by the shader.
Public propertyIsRenderToBitmapRequired Gets a Boolean that specifies if this material is a complex material (VisualBrush, Gradient, DrawingImage, etc.) and require calling RenderToBitmap method to get a bitmap that will be used as a texture. This property is false for solid color materials and materials with BitmapImages.
Public propertyIsTwoSided Gets a Boolean that specifies if the material should be rendered on both front and back side.
Public propertyMaterial Gets a WPF Material that is used by this WpfMaterial object instance.
Public propertyReflectionFactor Gets reflection factor from 0 to 1 that is used when ReflectionMap is null. Values 1 means full reflection (only enviromental map will be shown) and 0 means that only diffuse material without environmental map is shown.
Public propertyReflectionMap Gets ShaderResourceView that defines the reflection map where white colors mean fully reflective image and black colors mean no reflection (fully diffuse).
Public propertyRenderedBrushTextureHeight When set to a value bigger than 0, than this property defines the height of the RenderTargetBitmap that is created when a VisualBrush, GradientBrush (LinearGradientBrush or RadialGradientBrush) or DrawingImage is rendered into texture that is used in DXEngine. When value is 0 or less then the DefaultVisualBrushTextureSize or DefaultGradientBrushTextureSize is used (in case of rendering DrawingImage this value can be 0 and if RenderedBrushTextureWidth is set, the height will be calculate to preserve the aspect ratio). This value can be also set with using the SetDXAttribute(Material, DXAttributeType, Object) method on WPF's material with CachedBitmapSize attribute.
Public propertyRenderedBrushTextureWidth When set to a value bigger than 0, than this property defines the width of the RenderTargetBitmap that is created when a VisualBrush, GradientBrush (LinearGradientBrush or RadialGradientBrush) or DrawingImage is rendered into texture that is used in DXEngine. When value is 0 or less then the DefaultVisualBrushTextureSize or DefaultGradientBrushTextureSize is used (in case of rendering DrawingImage this value can be 0 and if RenderedBrushTextureHeight is set, the width will be calculate to preserve the aspect ratio). This value can be also set with using the SetDXAttribute(Material, DXAttributeType, Object) method on WPF's material with CachedBitmapSize attribute.
Public propertyRenderToBitmapOnEveryFrame Gets or sets a Boolean that can be specifies to true to render the material to bitmap on each rendered frame (used only in case of VisualBrush, GradientBrush or DrawingImage). This can be used to render animating VisualBrush. Use this property with caution because it can greatly decrease performance. In this case it is recommended to lower the resolution of the rendered bitmap with setting the RenderedBrushTextureWidth or RenderedBrushTextureHeight or using CachedBitmapSize DXAttribute.
Public propertySamplerStates Gets an array of SamplerState that define the state of the samplers.
Public propertySpecularColor Gets the Color3 that specifies the color used to draw the specular highlight effect.
Public propertySpecularPower Gets a float that specifies the power of the specular effect. Zero values means that the specular effect is turned off.
Public propertyTextureBlendState Gets a BlendState that is used to render the texture. If null a CommonStates.Opaque will be used.
Public propertyTextureCoordinatesBounds TextureCoordinatesBounds contains the bounding value of the mesh's texture coordinates - needed when drawing texture and texture coordinates size is not 1.
Public propertyTextureResourceName Gets a string that can be used to specify the name of the texture - this can be a the file name of the texture file.
Top
Methods
 NameDescription
Public methodStatic memberClearUsedDXMaterial Clears a cached DXEngine's Material that is used for the WPF material. This means that next time the WPF material will be used a new instance of DXEngine's Material will be created.
Public methodClone Clones the current material with creating a shallow copy of this Material (properties are copied but referenced objects are preserved).
(Overrides MaterialClone)
Public methodCreateLineMaterial(Material, Color4, Single) CreateLineMaterial converts WPF's material into DXEngine's LineMaterial. Line's color is get from DiffuseMaterial or EmissiveMaterial if present (else default color is used).
Public methodCreateLineMaterial(Material, Color, Double) CreateLineMaterial converts WPF's material into DXEngine's LineMaterial. Line's color is get from DiffuseMaterial or EmissiveMaterial if present (else default color is used).
Public methodStatic memberCreateTexture2D(DXDevice, BitmapSource) CreateTexture2D creates a 2D Texture from the specified WPF BitmapSource and returns a ShaderResourceView for the texture. User must dispose the returned ShaderResourceView when it is not used any more to prevent memory leak.
Public methodStatic memberCreateTexture2D(DXDevice, BitmapSource, TextureInfo) CreateTexture2D creates a 2D Texture from the specified WPF BitmapSource and returns a ShaderResourceView for the texture. User must dispose the returned ShaderResourceView when it is not used any more to prevent memory leak.
Public methodGetDefaultRenderingQueue Returns the RenderingQueue that should be used to render this material. The method returns TransparentRenderingQueue or StandardGeometryRenderingQueue based on the HasTransparency value.
(Overrides MaterialGetDefaultRenderingQueue(DXScene))
Public methodStatic memberGetUsedDXMaterial GetUsedDXMaterial method returns a DXEngine's Material that was created from the WPF material (or null if no DXMaterial was created for the WPF material) parentDXDevice is requireed to check if the created DXMeshGeometry3D was created for the same device.
Public methodStatic memberLoadTexture2D(DXDevice, String) LoadTexture2D loads a 2D Texture from the specified fileName and returns a ShaderResourceView for the texture. User must dispose the returned ShaderResourceView when it is not used any more to prevent memory leak. This method uses WPF's image loader - to load the image directly into DirectX use the LoadShaderResourceView(Device, String, TextureInfo) or LoadShaderResourceView(Device, String, Boolean, Boolean, Boolean, TextureInfo) methods instead.
Public methodStatic memberLoadTexture2D(DXDevice, String, TextureInfo) LoadTexture2D loads a 2D Texture from the specified fileName and returns a ShaderResourceView for the texture. User must dispose the returned ShaderResourceView when it is not used any more to prevent memory leak. This method uses WPF's image loader - to load the image directly into DirectX use the LoadShaderResourceView(Device, String, TextureInfo) or LoadShaderResourceView(Device, String, Boolean, Boolean, Boolean, TextureInfo) methods instead.
Public methodRefresh Refresh method updates the values of the properties used by Ab3d.DXEngine with reading the values from the used WPF Material. The method also recreates any textures that were created from WPF Material.
(Overrides MaterialRefresh)
Public methodStatic memberSetUsedDXMaterial(Material, Material) Sets the specified DXEngine's Material (dxMaterial) to be used when rendering the specified WPF material (wpfMaterial). It will be used when the WPF material will be shown in DXEngine (must be set before the objects are initialized in DXEngine).
Public methodStatic memberSetUsedDXMaterial(Material, Material, DXDevice)Obsolete.
Sets the specified DXEngine's Material (dxMaterial) to be used when rendering the specified WPF material (wpfMaterial). It will be used when the WPF material will be shown in DXEngine (must be set before the objects are initialized in DXEngine).
Public methodToString Provides a formated text of this WpfMaterial
(Overrides MaterialToString)
Top
Fields
 NameDescription
Public fieldStatic memberDefaultGradientBrushTextureSize DefaultGradientBrushTextureSize static field defines the width and height of the RenderTargetBitmap that is created when a GradientBrush (LinearGradientBrush or RadialGradientBrush) is rendered into texture that is used in DXEngine. The value can be overridden by RenderedBrushTextureWidth and RenderedBrushTextureHeight properties.
Public fieldStatic memberDefaultVisualBrushTextureSize DefaultVisualBrushTextureSize static field defines the width and height of the RenderTargetBitmap that is created when a VisualBrush is rendered into texture that is used in DXEngine. The value can be overridden by RenderedBrushTextureWidth and RenderedBrushTextureHeight properties.
Public fieldStatic memberLoadDdsIfAvailable When LoadDdsIfAvailable is set to true (false by default) the texture loader will check if there is a dds file with the same name but dds file extension. If dds file exist, it is loaded instead of the specified file. This can greatly improve load performance and memory usage. The check is done only on BitmapImages that do not have CacheOption set to OnLoad - in this case the bitmap is already loaded into BitmapImage.
Top
See Also