I have volume (3D image) divided into blocks 16x16x16. Whole volume is 128x128x128. Data are stored in linear memory in my shader. For every block, i store start index within linear memory. Now, I need to recalculate index from 16x16x16 block to index of 128x128x128 data. Every block is iterated with index 0, 1, 2, 3, ....4096 and I need to change this to global linear index.
I am using this formula: [ii, jj, kk] is 1D index from 16x16x16 block converted to 3D index within this block and next line convert this 3D index to 1D index within 128x128x128 data.
uint ii = index / 256; //get depth uint tmp = index % 256; //convert from 3D to 2D uint jj = tmp / 16; //get width uint kk = tmp % 16; //get height return startBlockIndex + ((128 * 128) * ii + (128) * jj + kk);
However, result is incorrect. Data are filled only in 1/4 of original volume. There is 16 times repeated same pattern, which should be only 1 and stretched across the whole volume. I think that this solution should work, but not quite sure... at least it worked on paper
Thanks for any advice