Storing the skin palette in a texture
Pre-generating the skin matrix cuts the number of uniform slots that the skinned shader needs in half, but it's possible to reduce the number of uniform slots needed to just one. This can be done by encoding the pre-generated skin matrix in a texture and reading that texture in the vertex shader instead of in a uniform array.
So far in this book, you have only dealt with the RGB24
and RGBA32
textures. In these formats, the three or four components of a pixel are encoded using 8 bits per component. This can only hold 256 unique values. These textures do not provide the amount of precision needed to store floating-point numbers.
There is another texture format that can be useful here—a FLOAT32
texture. With this texture format, each component of a vector gets a full 32-bit floating-point number to back it, giving you full precision. This texture can be sampled with a special sampler function that doesn't normalize the data...