PageRenderTime 38ms CodeModel.GetById 19ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Utilities/Graphics/VertexElementType.cs

#
C# | 117 lines | 18 code | 11 blank | 88 comment | 0 complexity | e8b2a561923a70fcb7abedc31fac1fd2 MD5 | raw file
  1namespace Delta.Utilities.Graphics
  2{
  3	/// <summary>
  4	/// Vertex element. Currently used to dynamically create vertex data,
  5	/// flags are combined to create a specific format. Data is always aligned
  6	/// in the same order as specified here. Usage for channels (e.g. texture
  7	/// channel 0, 1, etc.) is defined by number of UVs used (TexturedUV is
  8	/// usually in channel 0, then whatever UV comes next is channel 1, etc.).
  9	/// Note: All the byte sizes should be kept in sync with the VertexFormat
 10	/// GetVertexDataLength helper method!
 11	/// </summary>
 12	public enum VertexElementType
 13	{
 14		/// <summary>
 15		/// 2D position data (Point, 2 floats = 8 bytes).
 16		/// If compressed form (2 shorts = 4 bytes, ranging from
 17		/// 0 to 16k instead of 0.0-1.0, this way we have enough values to go from
 18		/// -2.0 to +2.0, which is good enough for 2D UI).
 19		/// Note: The ScreenSpace.ViewProjection2DViaShorts must be scaled correctly to
 20		/// account for this scaling (1.0f/16384.0f) before rendering.
 21		/// </summary>
 22		Position2D,
 23
 24		/// <summary>
 25		/// 3D position data (Vector, 3 floats = 12 bytes). Note: Often used in
 26		/// combination with the other compressed data types because it is just
 27		/// easier to use and does not require handling in the vertex shader
 28		/// If compressed form (3 shorts = 6 bytes). Each short
 29		/// is ranging from -32k to +32k and needs to be scaled with the world
 30		/// matrix of the model to account for the scaling factor needed. This
 31		/// scaling is based on VertexData.Position3DCompressedMultiplier, which
 32		/// is 1/256.0f, which allows 3D positions from -128.0f to +128.0f.
 33		/// Note: After Position3DCompressed the offset is 6 bytes, which is NOT
 34		/// 4 byte aligned, thus the next data type should be short, not float,
 35		/// else our performance will be killed (just use only Compressed).
 36		/// </summary>
 37		Position3D,
 38
 39		/// <summary>
 40		/// Normal vector data for light calculation and normal mapping (Vector,
 41		/// 3 floats = 12 bytes). If compressed, then just 3 normalized bytes are
 42		/// used +1 byte padding (because it all has to be 4 byte aligned).
 43		/// </summary>
 44		Normal,
 45
 46		/// <summary>
 47		/// Tangent vector for normal mapping (Vector, 3 floats = 12 bytes).
 48		/// If compressed, then just 3 normalized bytes are used +1 byte padding
 49		/// (because it all has to be 4 byte aligned).
 50		/// </summary>
 51		Tangent,
 52
 53		/// <summary>
 54		/// Binormal vector for normal mapping (Vector, 3 floats = 12 bytes).
 55		/// If compressed, then just 3 normalized bytes are used +1 byte padding
 56		/// (because it all has to be 4 byte aligned).
 57		/// </summary>
 58		Binormal,
 59
 60		/// <summary>
 61		/// Color for this vertex (Color, 4 bytes).
 62		/// </summary>
 63		Color,
 64
 65		/// <summary>
 66		/// UV data (Point, 2 floats = 8 bytes)
 67		/// Compressed UV data as shorts (2 shorts = 4 bytes), while the data is
 68		/// very small, it needs to be converted from shorts to real UVs for use
 69		/// in the vertex shader (done automatically in OpenGL ES via normalize,
 70		/// 1/32k is the scaling, see VertexData.TextureUVCompressedMultiplier).
 71		/// </summary>
 72		TextureUV,
 73
 74		/// <summary>
 75		/// UVW 3D texture data for cube mapping or reflection cube maps
 76		/// (Vector, 3 floats = 12 bytes).
 77		/// UVW 3D texture data in compressed form for cube mapping or reflection
 78		/// cube maps (3 shorts = 6 bytes), same rules as for TextureUVCompressed
 79		/// apply here too (1/32k automatically performed in OpenGL ES).
 80		/// </summary>
 81		TextureUVW,
 82
 83		/// <summary>
 84		/// Optional light map UV channel (secondary texture channel). Please note
 85		/// that most texture channels all use the same TextureUV data (e.g.
 86		/// DiffuseMap, NormalMap and SpecularMap), but LightMap has extra UVs.
 87		/// Uses Point, 2 floats = 8 bytes.
 88		/// Optional light map UV channel in compressed form, same rules as for
 89		/// TextureUVCompressed apply here (2 shorts = 4 bytes, 1/32k scaling).
 90		/// </summary>
 91		LightMapUV,
 92
 93		/// <summary>
 94		/// Extra UV channel for crazy purposes :D (Point, 2 floats = 8 bytes).
 95		/// Compressed form, same rules as for
 96		/// TextureUVCompressed apply here (2 shorts = 4 bytes, 1/32k scaling).
 97		/// </summary>
 98		ExtraUV,
 99
100		/// <summary>
101		/// Skin indices as compressed data for the skin weights, just 2 shorts,
102		/// should be used together with SkinWeight for 4 byte alignment. This
103		/// could also be optimized to 2 bytes, but then our vertex data is not
104		/// longer 4 byte aligned (which is not allowed in DirectX/XNA and can
105		/// sometimes be bad for performance in OpenGL, but usually supported).
106		/// Note: Unlike most other vertex element flags this one has no
107		/// compressed counterpart and is not normalized, the format is fine.
108		/// </summary>
109		SkinIndices,
110
111		/// <summary>
112		/// Skin weight data for skinning (just 2 normalized shorts = 4 bytes).
113		/// Will be automatically normalized when passed to the vertex shader.
114		/// </summary>
115		SkinWeights,
116	}
117}