# Packing vertex attributes

This topic is 995 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

While looking at skinned mesh shaders one idea struck me. Bone indices and weights are sent per vertex as 4-byte floats, such as below:

struct VSIn
{
float3 mPosition : POSITION;
float3 mNormal : NORMAL;
// ...
float4 mBoneIndices : BONEINDICES;
float4 mBoneWeights : BONEWEIGHTS;
};


It seems awfully wasteful to send bone indices as full 4-byte floats when in reality each value is probably up for 4 and would thus all easily fit into one float.

Same (probably?) applies to weights which i don't *think* needs all the fractions provided by 4-byte float?

When looking at MSDN docs it seems the smallest scalar type is 4 bytes, there is a half-float but only for backwards compatability? Likewise there dosn't seem to be any bitwise operators in HLSL.

If bandwidth is such a precious resource is there some clever trick to pack the vertex attributes tighter and ultimately is it worth the effort?

##### Share on other sites

Sorry, I totally forgot about input layout and formats. :) Never mind the question!

##### Share on other sites

Likewise there dosn't seem to be any bitwise operators in HLSL
SM4+ has full integer support with bitwise operators, so you can do this kind of fancy stuff manually... but yeah, as above, even on SM2/3, you'd use the input assembler to store indices and weights inside bytes.

On the last game I shipped, the animators actually noticed annoying errors when using 8bit weights, so we actually went with 10bits though!

##### Share on other sites

On the last game I shipped, the animators actually noticed annoying errors when using 8bit weights, so we actually went with 10bits though!

I am assuming you calculated 4th weight implicitily?

##### Share on other sites
Wrong topic. Mods can delete this post.

1. 1
2. 2
3. 3
4. 4
Rutin
11
5. 5

• 12
• 19
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632666
• Total Posts
3007718
• ### Who's Online (See full list)

There are no registered users currently online

×