Modified the texture packing code to be templated.