private void RunBoundsPhase(Mesh mesh, out Vector3 minBounds, out Vector3 maxBounds) { int[] meshBounds = new int[6]; BoundsBuffer.SetData(meshBounds); MeshSampleComputeShader.Dispatch(ComputeBoundsKernel, Mathf.CeilToInt(mesh.triangles.Length / 64f), 1, 1); BoundsBuffer.GetData(meshBounds); const float packingMultiplier = 1000f; minBounds = new Vector3(meshBounds[0] / packingMultiplier, meshBounds[1] / packingMultiplier, meshBounds[2] / packingMultiplier); maxBounds = new Vector3(meshBounds[3] / packingMultiplier, meshBounds[4] / packingMultiplier, meshBounds[5] / packingMultiplier); minBounds -= m_padding * Vector3.one; maxBounds += m_padding * Vector3.one; }
public void Dispose() { BoundsBuffer?.Dispose(); SamplesBuffer?.Dispose(); PackedUVsBuffer?.Dispose(); InputVerticesBuffer?.Dispose(); InputTrianglesBuffer?.Dispose(); InputNormalsBuffer?.Dispose(); InputTangentsBuffer?.Dispose(); InputUVsBuffer?.Dispose(); OutputVerticesBuffer?.Dispose(); OutputTrianglesBuffer?.Dispose(); OutputNormalsBuffer?.Dispose(); OutputTangentsBuffer?.Dispose(); OutputUVsBuffer?.Dispose(); DestroyImmediate(MeshSampleComputeShader); DestroyImmediate(TessellationComputeShader); }