I’m trying to port my real-time GPU voxelization from standalone DirectX11 application into Unity SRP. The approach I’m using is basically this The Basics of GPU Voxelization | NVIDIA Developer
I’m using ReadWrite 3d RenderTexture to write voxel data in pixel shader.
Everything is working fine except I have no idea how to clear my RenderTexture every frame before doing the voxelization pass.
I could not find any appropriate clear function, so I've tried iterating over all the layers, binding them as render targets and clearing:
for (int i = 0; i < voxelSpaceDimensions.z; i++) { CoreUtils.SetRenderTarget( voxelizationBuffer, // <- Command buffer. voxelSpace.colorBuffer, // <- RW 3d RenderTexture. ClearFlag.Color, Color.clear, 0, // <- Miplevel. CubemapFace.Unknown, i // <- 3d RenderTexture Layer. ); }
Frame debug shows everything as expected, but in reality the texture has not been cleared.