Let’s say that I’m working on implementing cellular automata (like Conway’s Game of Life) on the GPU using compute shaders. (also, using DX11, not openGL, but that’s only half-relevant)
My question is more focused on data structures side of things. In particular, in order to do any sort of cellular automata, you need knowledge of your neighbouring cells.
Right now, I have a RWStructuredBuffer
in my compute shader, to which (from c# in unity) I upload a list of points (arranged in the shape of a 3D cube). I can access points via the SV_DispatchThreadID
index in the CS, and do shenanigans like apply velocities to each point etc.
But is this good practice when you want each cell to be able to know what its neighbours are? Doing index calculations to figure out what 1d index does a 3d-placed neighbour have, seems suboptimal.
Is there any way you could instead cast rays from each point and return its neighbour? That would be awesome because it would eliminate the need for a cubic “Grid” entirely, and save space (no more “empty”/unused points).
Cheers!
PS: I’m not very familiar with 3d textures, but they aren’t available in unity free; so I’d like to stay away from them if possible.