Click or drag to resize
Ab4d.SharpEngine logo

VertexColorMaterial Class

VertexColorMaterial can be used to render 3D objects with specifying color for each of its position.
Inheritance Hierarchy
SystemObject
  Ab4d.SharpEngine.CoreComponentBase
    Ab4d.SharpEngine.CoreInitializedSceneComponent
      Ab4d.SharpEngine.MaterialsMaterial
        Ab4d.SharpEngine.MaterialsVertexColorMaterial

Namespace: Ab4d.SharpEngine.Materials
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 4.0.9584+ba1aaa26d4181dd3fa8ed7b6398391d1affa36c8
Syntax
C#
public class VertexColorMaterial : Material, 
	ITransparentMaterial, IVertexColorMaterial, IDiffuseMaterial, IAlphaPreMultipliedMaterial, ITwoSidedMaterial, 
	ISpecularMaterial, ISolidColorMaterial

The VertexColorMaterial type exposes the following members.

Constructors
Properties
 NameDescription
Public propertyDiffuseColor Gets or sets a Color3 that specifies the color that is multiplied by the per-vertex colors. Default value is White that preserves the per-vertex colors.
Public propertyHasSpecularColor Gets a boolean that specifies if this material is using specular effect.
Public propertyHasTransparency Gets or sets a boolean that specifies if any color in PositionColors has alpha value less than 1 (is semi-transparent) so the mesh needs to be alpha blended to be rendered correctly.
Public propertyIsPreMultipliedAlphaColor When IsPreMultipliedAlphaColor is true (false by default), then the PositionColors array contains pre-multiplied colors (color components multiplied with alpha value). Default value is false.
Public propertyIsSolidColor When true (by default), then this material is rendered with colors that are specified in the PositionColors or in the Mesh's VertexColors without any shading produced by lights. When false, then the material is rendered with shading produced by lights in the scene and by using SpecularPower and SpecularColor properties.
Public propertyIsTwoSided Gets or sets a Boolean that specifies if the material should be rendered on both front and back side. Note that when rendering semi-transparent objects and when alpha clipping is not used, it is better to set BackMaterial to the same material as Material instead of setting IsTwoSided to true because this correctly rendered the back side before the front side.
Public propertyOpacity Gets or sets a float value that is multiplied by alpha values of the per-vertex colors. Default value is 1 that preserves the per-vertex alpha values.
Public propertyPositionColors Gets or sets the Color4 array that specifies the colors for each position of the object. When the values in this array are changed after the material has already been initialized, then the UpdatePositionColors method must be called to update the VertexColorsBuffer. By default, the colors are not alpha pre-multiplied. To use alpha pre-multiplied colors, set the IsPreMultipliedAlphaColor property to true.
Public propertySpecularColor Gets or sets the Color3 that specifies the color used to draw the specular highlight effect. Default value is Color3.White.
Public propertySpecularPower Gets or sets a float that specifies the power of the specular effect. Zero value (by default) means that the specular effect is turned off.
Public propertyVertexColorsBuffer Gets a GpuBuffer for an array of Color4 values where each value represents a color of one position (vertex).
Top
Methods
 NameDescription
Protected methodCreateClone
(Overrides MaterialCreateClone)
Protected methodDispose Dispose
(Overrides MaterialDispose(Boolean))
Protected methodOnEffectChanged OnEffectChanged is called after the effect is changed - overridden methods can return false to prevent the change of effect.
(Overrides MaterialOnEffectChanged(Effect, Effect))
Protected methodOnInitializeSceneResources Initializes resources with the specified Scene and GpuDevice. This method can be overriden and is called from InitializeSceneResources(Scene) method.
(Overrides MaterialOnInitializeSceneResources(Scene, VulkanDevice))
Public methodUpdatePositionColors UpdatePositionColors must be called when the values in the PositionColors array are changed.
Public methodUpdatePositionColorsTransparency UpdatePositionColorsTransparency method check if any color in the PositionColors has Alpha value less than 1 and sets HasTransparency accordingly.
Top
Remarks

VertexColorMaterial can be used to render 3D objects with specifying color for each of its position.

The colors of each position is specified in the PositionColors array.

When values in the PositionColors array are changed, you need to call UpdatePositionColors method to update the DirectX resources.

See Also