Passing Flood-Fill Voxel Lighting Data to Shader

I have done some research into voxel lighting and have found that the flood-fill method seems to be the best. I have also given some thought into how i would do it, but have run into some roadblocks before i have even started.

Note: I am using VAO’s to render chunks which hold vertices, indices and UV data.

I am wondering if i would be able to pass a 3d array containing light values(0 to 15 or whatever) to the shaders. Which given vertex position and normal(would i need to add), calculate the block position(3d array index) it is facing and take the light value from the array and calculate ‘vertexColor’ with it.

Will my idea work? How would i pass a 3d array(array would be 16 * 256 * 26)?

Thanks.

I’d only use a 3D data structure on the CPU/host for the light baking / traversal / flood-fill algorithm.
When rendering the scene you only need the lighting information on the surfaces/vertices and can discard most lighting values/voxels anyway. Therefore I’d use a simple additional vertex attribute for the vertex colors to keep memory “sparse.”
So, for each chunk that you have, you can compute the light environment using the same 3D data structure for the flood-fill algorithm on the CPU, and then when generating the buffer object for all the vertices of your chunk, lookup/include the lighting value from the 3d flood-fill’ed structure and use that as vertex color.
This however requires you to not render all cubes in a chunk as individual draw calls (which you should not do anyways) but build up a buffer object for all the vertices of the cubes in your chunk.
Together with a nice index/element buffer, this will give you the best possible performance with the least amount of required GPU memory.

Thanks that helps alot.