I am trying to implement Vertex Texture Fetching on SM3.0. My motivation is that I don't want to split up my 120 bone humanoid to get room for skinning matrices in the registers, and not complicating my vertices. I wish to Copy all 120 Bone Matrices into a texture and sample it in the vertex shader.
A DX10 sample uses this method:
// Read a matrix(3 texture reads) from a texture containing animation data
float4x4 loadBoneMatrix(uint3 animationData,float bone)
{
// Calculate a UV for the bone for this vertex
float4x4 rval = g_Identity;
// animationData.x and .y are linear offsets. Combine into a single linear offset.
uint baseIndex = animationData.x + animationData.y;
baseIndex += (4*bone); // 4*bone is since each bone is 4 texels to form a float4x4
// Now turn linear offset into 2D coords
uint baseU = baseIndex%g_InstanceMatricesWidth;
uint baseV = baseIndex/g_InstanceMatricesWidth;
// Note that we assume the width of the texture(and just add texels) is an even multiple of the # of texels per bone,
// otherwise we'd have to recalculate the V component per lookup
float4 mat1 = g_txAnimations.Load( uint3(baseU,baseV,0));
float4 mat2 = g_txAnimations.Load( uint3(baseU+1,baseV,0));
float4 mat3 = g_txAnimations.Load( uint3(baseU+2,baseV,0));
// only load 3 of the 4 values, and deocde the matrix from them.
rval = decodeMatrix(float3x4(mat1,mat2,mat3));
return rval;
}
How would this be implemented in SM3.0?
I have looked around and tex2D or tex2Dlod seems to do what I want, but I am not sure how I get Bone[59] when the UVs are between 0.0f and 1.0f. Would I have to make the UV value = 59/120? Would this sample the correct vector, POINT filtering ofc.






