I'm making a voxel engine and I can render a chunk. I'm using instanced rendering, meaning that I can render all of the chunk with a single draw call. Every blocks of a chunk has a single int (From 0 to 4095) that defines his block type (0 for air, 1 for dirt, etc...). I wanna be able to render my block by applying the good texture in my fragment shader. My chunk contains a tri-dimensionnal array :
uint8_t blocks[16][16][16]
The problem is that I can't find a way to send my array of int to the shader. I tried using a VBO but it makes no-sense (I didn't get any result). I also tried to send my array with glUniform1iv() but I failed.
- Is it possible to send an array of int to a shader with glUniformX() ?
- In order to prevent storing big data, can I set a byte (uint8_t) instead of int with glUniformX() ?
- Is there a good way to send that much data to my shader ?
- Is instanced drawing a good way to draw the same model with different textures/types of blocks.