Table of Contents

Struct VertexElement

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

A description of a single element for the input-assembler stage. This structure is related to SharpDX.Direct3D11.InputElement.

[DataContract]
[DataSerializer(typeof(VertexElement.Serializer))]
public struct VertexElement : IEquatable<VertexElement>
Implements
Extension Methods

Remarks

Because SharpDX.Direct3D11.InputElement requires to have the same VertexBufferLayout.SlotIndex, VertexBufferLayout.VertexClassification and VertexBufferLayout.instanceDataStepRate, the VertexBufferLayout structure encapsulates a set of VertexElement for a particular slot, classification and instance data step rate. Unlike the default SharpDX.Direct3D11.InputElement, this structure accepts a semantic name with a postfix number that will be automatically extracted to the semantic index.

Constructors

VertexElement(string, PixelFormat)

Initializes a new instance of the VertexElement structure.

public VertexElement(string semanticName, PixelFormat format)

Parameters

semanticName string

The semantic name associated with this element, such as "POSITION", "TEXCOORD", or "NORMAL".
If the semantic name contains a postfix number, this number will be used as a semantic index, such as "TEXCOORD1" or "COLOR0".

format PixelFormat

The data format of the element, such as R32G32B32_Float (equivalent to Vector3) or R8G8B8A8_UNorm (equivalent to a 32-bit, 8bpc RGBA color).

Exceptions

ArgumentException

semanticName is null or an empty string.

VertexElement(string, int, PixelFormat, int)

Initializes a new instance of the VertexElement structure.

public VertexElement(string semanticName, int semanticIndex, PixelFormat format, int alignedByteOffset = -1)

Parameters

semanticName string

The semantic name associated with this element, such as "POSITION", "TEXCOORD", or "NORMAL".

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name, such as the 1 in "TEXCOORD1" or the 0 in "COLOR0".

format PixelFormat

The data format of the element, such as R32G32B32_Float (equivalent to Vector3) or R8G8B8A8_UNorm (equivalent to a 32-bit, 8bpc RGBA color).

alignedByteOffset int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Exceptions

ArgumentException

semanticName is null or an empty string.

ArgumentException

Cannot specify a semantic index in the semanticName when using this constructor. Use the constructor with explicit semantic index instead (VertexElement(string, PixelFormat)).

Fields

AppendAligned

Returns a value that can be used for the offset parameter of an Vertex Element to indicate that the element should be aligned directly after the previous one, including any packing if neccessary.

public const int AppendAligned = -1

Field Value

int

Properties

AlignedByteOffset

The byte offset from the start of the vertex to this element.

public readonly int AlignedByteOffset { get; }

Property Value

int

Remarks

Use -1 (or a constant like AppendAligned to automatically align the element after the previous one, including any packing if necessary.

Format

The data format of the element, such as R32G32B32_Float or R8G8B8A8_UNorm.

public readonly PixelFormat Format { get; }

Property Value

PixelFormat

Remarks

This must match the format expected by the Shader and the layout of the Vertex Buffer.

SemanticAsText

Gets the HLSL semantic name associated with this element, such as "POSITION", "TEXCOORD", or "NORMAL".
It can contain a postfix number, the SemanticIndex, such as "TEXCOORD1" or "COLOR0".

public readonly string SemanticAsText { get; }

Property Value

string

Remarks

This name must match the semantic used in the Vertex Shader input signature.

See Also

SemanticIndex

Gets the semantic index for the element, used when multiple elements share the same semantic name.

public readonly int SemanticIndex { get; }

Property Value

int

Remarks

For example, a 4x4 matrix might be passed as four "TEXCOORD" elements with indices 0 through 3.

SemanticName

Gets the HLSL semantic name associated with this element, such as "POSITION", "TEXCOORD", or "NORMAL".

public readonly string SemanticName { get; }

Property Value

string

Remarks

This name must match the semantic used in the Vertex Shader input signature.

Methods

BiTangent(PixelFormat, int)

Declares a VertexElement with the semantic "BITANGENT".

public static VertexElement BiTangent(PixelFormat format, int offsetInBytes = -1)

Parameters

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "BITANGENT" semantic.

BiTangent(int, PixelFormat, int)

Declares a VertexElement with the semantic "BITANGENT".

public static VertexElement BiTangent(int semanticIndex, PixelFormat format, int offsetInBytes = -1)

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "BITANGENT" semantic.

BiTangent<T>(int, int)

Declares a VertexElement with the semantic "BITANGENT".

public static VertexElement BiTangent<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "BITANGENT" semantic.

Type Parameters

T

The type of the bitangent element.

Exceptions

NotSupportedException

The specified T is not supported. It cannot be converted to a PixelFormat.

Color(PixelFormat, int)

Declares a VertexElement with the semantic "COLOR".

public static VertexElement Color(PixelFormat format, int offsetInBytes = -1)

Parameters

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "COLOR" semantic.

Color(int, PixelFormat, int)

Declares a VertexElement with the semantic "COLOR".

public static VertexElement Color(int semanticIndex, PixelFormat format, int offsetInBytes = -1)

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "COLOR" semantic.

Color<T>(int, int)

Declares a VertexElement with the semantic "COLOR".

public static VertexElement Color<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "COLOR" semantic.

Type Parameters

T

The type of the color element.

Exceptions

NotSupportedException

The specified T is not supported. It cannot be converted to a PixelFormat.

ConvertTypeToFormat<T>()

Converts a type T to its equivalent PixelFormat.

public static PixelFormat ConvertTypeToFormat<T>() where T : struct

Returns

PixelFormat

The equivalent PixelFormat to T.

Type Parameters

T

The type of the Vertex Element to convert.

Exceptions

NotSupportedException

The specified T is not supported. It cannot be converted to a PixelFormat.

Equals(VertexElement)

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(VertexElement other)

Parameters

other VertexElement

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

Normal(PixelFormat, int)

Declares a VertexElement with the semantic "NORMAL".

public static VertexElement Normal(PixelFormat format, int offsetInBytes = -1)

Parameters

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "NORMAL" semantic.

Normal(int, PixelFormat, int)

Declares a VertexElement with the semantic "NORMAL".

public static VertexElement Normal(int semanticIndex, PixelFormat format, int offsetInBytes = -1)

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "NORMAL" semantic.

Normal<T>(int, int)

Declares a VertexElement with the semantic "NORMAL".

public static VertexElement Normal<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "NORMAL" semantic.

Type Parameters

T

The type of the normal element.

Exceptions

NotSupportedException

The specified T is not supported. It cannot be converted to a PixelFormat.

Position(PixelFormat, int)

Declares a VertexElement with the semantic "POSITION".

public static VertexElement Position(PixelFormat format, int offsetInBytes = -1)

Parameters

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "POSITION" semantic.

Position(int, PixelFormat, int)

Declares a VertexElement with the semantic "POSITION".

public static VertexElement Position(int semanticIndex, PixelFormat format, int offsetInBytes = -1)

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "POSITION" semantic.

PositionTransformed(PixelFormat, int)

Declares a VertexElement with the semantic "SV_POSITION" (transformed position).

public static VertexElement PositionTransformed(PixelFormat format, int offsetInBytes = -1)

Parameters

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "SV_POSITION" semantic.

PositionTransformed(int, PixelFormat, int)

Declares a VertexElement with the semantic "SV_POSITION" (transformed position).

public static VertexElement PositionTransformed(int semanticIndex, PixelFormat format, int offsetInBytes = -1)

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "SV_POSITION" semantic.

PositionTransformed<T>(int, int)

Declares a VertexElement with the semantic "SV_POSITION" (transformed position).

public static VertexElement PositionTransformed<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "SV_POSITION" semantic.

Type Parameters

T

The type of the tranformed position element.

Exceptions

NotSupportedException

The specified T is not supported. It cannot be converted to a PixelFormat.

Position<T>(int, int)

Declares a VertexElement with the semantic "POSITION".

public static VertexElement Position<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "POSITION" semantic.

Type Parameters

T

The type of the position element.

Exceptions

NotSupportedException

The specified T is not supported. It cannot be converted to a PixelFormat.

Tangent(PixelFormat, int)

Declares a VertexElement with the semantic "TANGENT".

public static VertexElement Tangent(PixelFormat format, int offsetInBytes = -1)

Parameters

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "TANGENT" semantic.

Tangent(int, PixelFormat, int)

Declares a VertexElement with the semantic "TANGENT".

public static VertexElement Tangent(int semanticIndex, PixelFormat format, int offsetInBytes = -1)

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "TANGENT" semantic.

Tangent<T>(int, int)

Declares a VertexElement with the semantic "TANGENT".

public static VertexElement Tangent<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "TANGENT" semantic.

Type Parameters

T

The type of the tangent element.

Exceptions

NotSupportedException

The specified T is not supported. It cannot be converted to a PixelFormat.

TextureCoordinate(PixelFormat, int)

Declares a VertexElement with the semantic "TEXCOORD" (texture coordinates).

public static VertexElement TextureCoordinate(PixelFormat format, int offsetInBytes = -1)

Parameters

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "TEXCOORD" semantic.

TextureCoordinate(int, PixelFormat, int)

Declares a VertexElement with the semantic "TEXCOORD" (texture coordinates).

public static VertexElement TextureCoordinate(int semanticIndex, PixelFormat format, int offsetInBytes = -1)

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

format PixelFormat

The data format of the element.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "TEXCOORD" semantic.

TextureCoordinate<T>(int, int)

Declares a VertexElement with the semantic "TEXCOORD" (texture coordinates).

public static VertexElement TextureCoordinate<T>(int semanticIndex = 0, int offsetInBytes = -1) where T : struct

Parameters

semanticIndex int

The semantic index for the element, used when multiple elements share the same semantic name.

offsetInBytes int

The byte offset from the start of the vertex to this element. Use -1 (or a constant like AppendAligned to automatically align the element after the previous one.

Returns

VertexElement

A new Vertex Element that represents the "TEXCOORD" semantic.

Type Parameters

T

The type of the texture coordinates element.

Exceptions

NotSupportedException

The specified T is not supported. It cannot be converted to a PixelFormat.

ToString()

Returns the fully qualified type name of this instance.

public override readonly string ToString()

Returns

string

The fully qualified type name.

Operators

operator ==(VertexElement, VertexElement)

public static bool operator ==(VertexElement left, VertexElement right)

Parameters

left VertexElement
right VertexElement

Returns

bool

operator !=(VertexElement, VertexElement)

public static bool operator !=(VertexElement left, VertexElement right)

Parameters

left VertexElement
right VertexElement

Returns

bool