To say i have a value of 255 for rgba i don’t want to hold 4 floating point values per vertex for a color i just want to hold the 8 bit value and let the shader turn that into floats when it reads it in to save memory. I also have this problem for indexs and potentially weights.
Is and if it is possible to drop off the memory requirements like that how do you do it?
Ect… example would be great if its possible.
Specifically problem is the below is obese i want to trim it down.
/// <summary>
/// basically a wide spectrum vertice structure.
/// </summary>
public struct VertexPositionColorNormalTextureTangentWeights : IVertexType
{
public Vector3 Position;
public Vector4 Color;
public Vector2 TextureCoordinate;
public Vector3 Normal;
public Vector3 Tangent;
public Vector3 BiTangent;
public Vector4 BlendIndices;
public Vector4 BlendWeights;
public static VertexDeclaration VertexDeclaration = new VertexDeclaration
(
new VertexElement(VertexElementByteOffset.PositionStartOffset(), VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(VertexElementByteOffset.OffsetVector4(), VertexElementFormat.Vector4, VertexElementUsage.Color, 0),
new VertexElement(VertexElementByteOffset.OffsetVector2(), VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0),
new VertexElement(VertexElementByteOffset.OffsetVector3(), VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
new VertexElement(VertexElementByteOffset.OffsetVector3(), VertexElementFormat.Vector3, VertexElementUsage.Normal, 1),
new VertexElement(VertexElementByteOffset.OffsetVector3(), VertexElementFormat.Vector3, VertexElementUsage.Normal, 2),
new VertexElement(VertexElementByteOffset.OffsetVector4(), VertexElementFormat.Vector4, VertexElementUsage.BlendIndices, 0),
new VertexElement(VertexElementByteOffset.OffsetVector4(), VertexElementFormat.Vector4, VertexElementUsage.BlendWeight, 0)
);
VertexDeclaration IVertexType.VertexDeclaration { get { return VertexDeclaration; } }
}
To say for example blend indices only range to 128 or rather thats all i allow typically so by passing a byte per element i could on the gpu then just do this.
float indice = input.BlendIndices.x / 128f;
So basically i want to pass in a byte or assign to a ieee float8. To save memory per vertice so i pass only 32 bits for blendweights indices and color ect but i dunno how to do it.