4 ms·
Easy: I have an array with 256 elements. And I want to store the indexes of various elements of the array off in another data structure. So many of them, in fa
by drfuchs 4y ago
Easy: I have an array with 256 elements. And I want to store the indexes of various elements of the array off in another data structure. So many of them, in fact, that it’s important that the index values each fit into a byte. So, I want the index values to be 0..255, and not 1..256, since 256 doesn’t fit into a byte.
- _gabe_ 4y agoYou can still fit that information into one byte and convert it at compile time or runtime :) In a minecraft clone I made, each chunk consists of 16 subchunks so that I only need 12 bits to represent the block position in the shader. Technically, the block position ranges from INT32_MIN -> INT32_MAX, but since each subchunk only consists of 16x16x16 blocks I can get away with storing the position in 12 bits and then passing in the subchunk's world position once as a uniform.