HLSL Unpack float into 4 bytes
I'm using instancing, so the float is passed as a component of a matrix in a 2nd vertex buffer.
Which version of D3D are you using? And you mentioned BitConverter, so I guess you're using C#, so which C# wrapper are you using too?
I'm using SM3 for the shader, and XNA 4 (so 4 bytes = 1 single/float). I just did a bit more digging through msdn and it looks like there is no support for a byte type equivalent. which probably means id have to do something mad like cast the float in HLSL as an integer then do some bit manipulation which I believe isn't available either.
You mentioned just passing the bytes on their own unpacked which may lead to a solution, though if it does convert each byte to a float then it'd remove the advantage by taking 4 times the space of just 4 plain old bytes which takes me back to the original problem.
Looks like i'll just have to suck it up, use the boolean packing example I found, and make the best of it.
Aimee
For your 4 byte values, you use an element with the VertexElementFormat.Byte4 format. They will exist as 4 (packed) bytes within the buffer, and are only expanded to 4 floats (by dividing them by 255.0f) the moment when the vertex shader is run.
If you were planning on using a single element from a matrix to store these values, then you'll have to replace one of the matrix's VertexElementFormat.Vector4 elements with a VertexElementFormat.Vector3 element and this VertexElementFormat.Byte4 element.