protected void OnDestroy() { if (velocity != null) { velocity.Dispose(); velocity = null; } if (color != null) { color.Dispose(); color = null; } }
protected void Start() { velocity = new PingPong3D(width, height, depth, RenderTextureFormat.ARGBFloat, FilterMode.Point, TextureWrapMode.Repeat); color = new PingPong3D(width, height, depth, RenderTextureFormat.ARGBHalf, FilterMode.Bilinear, TextureWrapMode.Repeat); block = new MaterialPropertyBlock(); renderer = GetComponent <Renderer>(); renderer.GetPropertyBlock(block); var mesh = Build(width, height, depth); GetComponent <MeshFilter>().sharedMesh = mesh; compute.SetInt("_Width", width); compute.SetInt("_Height", height); compute.SetInt("_Depth", depth); compute.SetVector("_InvSize", new Vector3(1f / width, 1f / height, 1f / depth)); compute.SetVector("_BoundsMin", mesh.bounds.min); compute.SetVector("_BoundsMax", mesh.bounds.max); Reset(); }