We should eventually port the CPU voxelization algorithm to the GPU if we want to update the densities in real-time. Right now CPU voxelization of 1.8M hair vertices takes around 15ms which I guess is "real-time", but it would be nice to do this on the GPU as well. As part of porting Dominik's HLSL shaders I've used the image2D, so allocating an read/write image3D shouldn't be too different. The only part I see as somewhat problematic is that we'll need to use imageAtomicAdd as part of the voxelization algorithm, which requires the underlying format to be r32i or r32u as shown here, and can't be used with r8i and r8ui as we'd have liked (there is talk about format conversion, so it might still be possible). I also don't know the cost of imageAtomicAdd, so I need to find out if its usable. Otherwise it should be quite straightforward, like this:
We should eventually port the CPU voxelization algorithm to the GPU if we want to update the densities in real-time. Right now CPU voxelization of 1.8M hair vertices takes around 15ms which I guess is "real-time", but it would be nice to do this on the GPU as well. As part of porting Dominik's HLSL shaders I've used the
image2D
, so allocating an read/writeimage3D
shouldn't be too different. The only part I see as somewhat problematic is that we'll need to useimageAtomicAdd
as part of the voxelization algorithm, which requires the underlying format to ber32i
orr32u
as shown here, and can't be used withr8i
andr8ui
as we'd have liked (there is talk about format conversion, so it might still be possible). I also don't know the cost ofimageAtomicAdd
, so I need to find out if its usable. Otherwise it should be quite straightforward, like this: