using UnityEngine; public static class Buffers { public static ComputeBuffer pointsBuffer; public static ComputeBuffer triangleBuffer; public static ComputeBuffer triCountBuffer; public static void Create(int numPointsPerAxis) { Release(); int numPoints = numPointsPerAxis * numPointsPerAxis * numPointsPerAxis; int numVoxelsPerAxis = numPointsPerAxis - 1; int numVoxels = numVoxelsPerAxis * numVoxelsPerAxis * numVoxelsPerAxis; int maxTriangleCount = numVoxels * 5; triangleBuffer = new ComputeBuffer (maxTriangleCount, sizeof (float) * 3 * 3, ComputeBufferType.Append); pointsBuffer = new ComputeBuffer (numPoints, sizeof (float) * 4); triCountBuffer = new ComputeBuffer (1, sizeof (int), ComputeBufferType.Raw); } public static void Release() { if (triangleBuffer != null) { triangleBuffer.Release(); pointsBuffer.Release(); triCountBuffer.Release(); } } }