Jump to content
  • Advertisement
Sign in to follow this  
KaiserJohan

Packing vertex attributes

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement


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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!